Commit 6e6abc03 authored by Al Viro's avatar Al Viro Committed by Ben Hutchings

vfs: missed source of ->f_pos races

commit 0e665d5d upstream.

compat_sys_{read,write}v() need the same "pass a copy of file->f_pos" thing
as sys_{read,write}{,v}().
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent a2810e54
...@@ -1174,11 +1174,14 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec, ...@@ -1174,11 +1174,14 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
struct file *file; struct file *file;
int fput_needed; int fput_needed;
ssize_t ret; ssize_t ret;
loff_t pos;
file = fget_light(fd, &fput_needed); file = fget_light(fd, &fput_needed);
if (!file) if (!file)
return -EBADF; return -EBADF;
ret = compat_readv(file, vec, vlen, &file->f_pos); pos = file->f_pos;
ret = compat_readv(file, vec, vlen, &pos);
file->f_pos = pos;
fput_light(file, fput_needed); fput_light(file, fput_needed);
return ret; return ret;
} }
...@@ -1233,11 +1236,14 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec, ...@@ -1233,11 +1236,14 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
struct file *file; struct file *file;
int fput_needed; int fput_needed;
ssize_t ret; ssize_t ret;
loff_t pos;
file = fget_light(fd, &fput_needed); file = fget_light(fd, &fput_needed);
if (!file) if (!file)
return -EBADF; return -EBADF;
ret = compat_writev(file, vec, vlen, &file->f_pos); pos = file->f_pos;
ret = compat_writev(file, vec, vlen, &pos);
file->f_pos = pos;
fput_light(file, fput_needed); fput_light(file, fput_needed);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment