diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2008-02-08 11:49:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:25:01 -0500 |
commit | 8811930dc74a503415b35c4a79d14fb0b408a361 (patch) | |
tree | 464a99a2be2f87b8e019fea231592ddf3ec38de7 | |
parent | 66191dc622f5ff0a541524c4e96fdacfacfda206 (diff) |
splice: missing user pointer access verification
vmsplice_to_user() must always check the user pointer and length
with access_ok() before copying. Likewise, for the slow path of
copy_from_user_mmap_sem() we need to check that we may read from
the user region.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Cc: Wojciech Purczynski <cliph@research.coseinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/splice.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/splice.c b/fs/splice.c index 4ee49e86edde..14e2262c0a04 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -1179,6 +1179,9 @@ static int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n) | |||
1179 | { | 1179 | { |
1180 | int partial; | 1180 | int partial; |
1181 | 1181 | ||
1182 | if (!access_ok(VERIFY_READ, src, n)) | ||
1183 | return -EFAULT; | ||
1184 | |||
1182 | pagefault_disable(); | 1185 | pagefault_disable(); |
1183 | partial = __copy_from_user_inatomic(dst, src, n); | 1186 | partial = __copy_from_user_inatomic(dst, src, n); |
1184 | pagefault_enable(); | 1187 | pagefault_enable(); |
@@ -1387,6 +1390,11 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *iov, | |||
1387 | break; | 1390 | break; |
1388 | } | 1391 | } |
1389 | 1392 | ||
1393 | if (unlikely(!access_ok(VERIFY_WRITE, base, len))) { | ||
1394 | error = -EFAULT; | ||
1395 | break; | ||
1396 | } | ||
1397 | |||
1390 | sd.len = 0; | 1398 | sd.len = 0; |
1391 | sd.total_len = len; | 1399 | sd.total_len = len; |
1392 | sd.flags = flags; | 1400 | sd.flags = flags; |