]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dax: explain how read(2)/write(2) addresses are validated
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Wed, 6 Sep 2017 23:18:54 +0000 (16:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 7 Sep 2017 00:27:24 +0000 (17:27 -0700)
Add a comment explaining how the user addresses provided to read(2) and
write(2) are validated in the DAX I/O path.

We call dax_copy_from_iter() or copy_to_iter() on these without calling
access_ok() first in the DAX code, and there was a concern that the user
might be able to read/write to arbitrary kernel addresses with this
path.

Link: http://lkml.kernel.org/r/20170816173615.10098-1-ross.zwisler@linux.intel.com
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/dax.c

index c576f6181dc8958951669fd6f91d2d18177874c7..5b2eac3ef077db86c8e916abae92e14d084eefd1 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1004,6 +1004,11 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
                if (map_len > end - pos)
                        map_len = end - pos;
 
+               /*
+                * The userspace address for the memory copy has already been
+                * validated via access_ok() in either vfs_read() or
+                * vfs_write(), depending on which operation we are doing.
+                */
                if (iov_iter_rw(iter) == WRITE)
                        map_len = dax_copy_from_iter(dax_dev, pgoff, kaddr,
                                        map_len, iter);