diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2011-03-13 19:24:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-13 19:29:07 -0400 |
commit | c44ed965be7a84afaa07543c04eb97a5dfe93422 (patch) | |
tree | df96d439962f923eee668e46dbff574b3603ca3f /fs | |
parent | c9a816c0ecb8cef8e6573a8eab47fc48c765e0a1 (diff) |
compat breakage in preadv() and pwritev()
Fix for a dumb preadv()/pwritev() compat bug - unlike the native
variants, the compat_... ones forget to check FMODE_P{READ,WRITE}, so
e.g. on pipe the native preadv() will fail with -ESPIPE and compat one
will act as readv() and succeed.
Not critical, but it's a clear bug with trivial fix, so IMO it's OK for
-final.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/compat.c b/fs/compat.c index f6fd0a00e6cc..691c3fd8ce1d 100644 --- a/fs/compat.c +++ b/fs/compat.c | |||
@@ -1228,7 +1228,9 @@ compat_sys_preadv(unsigned long fd, const struct compat_iovec __user *vec, | |||
1228 | file = fget_light(fd, &fput_needed); | 1228 | file = fget_light(fd, &fput_needed); |
1229 | if (!file) | 1229 | if (!file) |
1230 | return -EBADF; | 1230 | return -EBADF; |
1231 | ret = compat_readv(file, vec, vlen, &pos); | 1231 | ret = -ESPIPE; |
1232 | if (file->f_mode & FMODE_PREAD) | ||
1233 | ret = compat_readv(file, vec, vlen, &pos); | ||
1232 | fput_light(file, fput_needed); | 1234 | fput_light(file, fput_needed); |
1233 | return ret; | 1235 | return ret; |
1234 | } | 1236 | } |
@@ -1285,7 +1287,9 @@ compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec, | |||
1285 | file = fget_light(fd, &fput_needed); | 1287 | file = fget_light(fd, &fput_needed); |
1286 | if (!file) | 1288 | if (!file) |
1287 | return -EBADF; | 1289 | return -EBADF; |
1288 | ret = compat_writev(file, vec, vlen, &pos); | 1290 | ret = -ESPIPE; |
1291 | if (file->f_mode & FMODE_PWRITE) | ||
1292 | ret = compat_writev(file, vec, vlen, &pos); | ||
1289 | fput_light(file, fput_needed); | 1293 | fput_light(file, fput_needed); |
1290 | return ret; | 1294 | return ret; |
1291 | } | 1295 | } |