[PATCH v4 2/5] ima: use fs method to read integrity data [updated]
Jan Kara
jack at suse.cz
Wed Aug 2 08:01:08 UTC 2017
On Tue 01-08-17 16:24:30, Mimi Zohar wrote:
> From: Christoph Hellwig <hch at lst.de>
>
> Add a new ->integrity_read file operation to read data for integrity
> hash collection. This is defined to be equivalent to ->read_iter,
> except that it will be called with the i_rwsem held exclusively.
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> Cc: Matthew Garrett <matthew.garrett at nebula.com>
> Cc: Jan Kara <jack at suse.com>
> Cc: "Theodore Ts'o" <tytso at mit.edu>
> Cc: Andreas Dilger <adilger.kernel at dilger.ca>
> Cc: Jaegeuk Kim <jaegeuk at kernel.org>
> Cc: Chao Yu <yuchao0 at huawei.com>
> Cc: Steven Whitehouse <swhiteho at redhat.com>
> Cc: Bob Peterson <rpeterso at redhat.com>
> Cc: David Woodhouse <dwmw2 at infradead.org>
> Cc: Dave Kleikamp <shaggy at kernel.org>
> Cc: Ryusuke Konishi <konishi.ryusuke at lab.ntt.co.jp>
> Cc: Mark Fasheh <mfasheh at versity.com>
> Cc: Joel Becker <jlbec at evilplan.org>
> Cc: Richard Weinberger <richard at nod.at>
> Cc: "Darrick J. Wong" <darrick.wong at oracle.com>
> Cc: Hugh Dickins <hughd at google.com>
> Cc: Chris Mason <clm at fb.com>
> Signed-off-by: Mimi Zohar <zohar at linux.vnet.ibm.com>
...
> +static ssize_t ext4_file_integrity_read_iter(struct kiocb *iocb,
> + struct iov_iter *to)
> +{
> + struct inode *inode = file_inode(iocb->ki_filp);
> + int o_direct = iocb->ki_flags & IOCB_DIRECT;
> +
> + lockdep_assert_held(&inode->i_rwsem);
> + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
> + return -EIO;
> +
> + if (!iov_iter_count(to))
> + return 0; /* skip atime */
> +
> +#ifdef CONFIG_FS_DAX
> + if (IS_DAX(inode))
> + return dax_iomap_rw(iocb, to, &ext4_iomap_ops);
> +#endif
> + if (o_direct)
> + return -EINVAL;
> + return generic_file_read_iter(iocb, to);
> +}
I have noticed this o_direct check - why is it only in ext4 and shouldn't
rather higher layers make sure IOCB_DIRECT iocbs cannot reach
.integrity_read() methods?
Honza
--
Jan Kara <jack at suse.com>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the Linux-security-module-archive
mailing list