Skip to content

Commit 7d1756e

Browse files
heicarstpopcornmix
authored andcommitted
fs/compat: fix parameter handling for compat readv/writev syscalls
commit dfd948e upstream. We got a report that the pwritev syscall does not work correctly in compat mode on s390. It turned out that with commit 72ec351 ("switch compat readv/writev variants to COMPAT_SYSCALL_DEFINE") we lost the zero extension of a couple of syscall parameters because the some parameter types haven't been converted from unsigned long to compat_ulong_t. This is needed for architectures where the ABI requires that the caller of a function performed zero and/or sign extension to 64 bit of all parameters. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Ingo Molnar <mingo@kernel.org> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6927a11 commit 7d1756e

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

‎fs/read_write.c‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,9 @@ static size_t compat_readv(struct file *file,
947947
return ret;
948948
}
949949

950-
COMPAT_SYSCALL_DEFINE3(readv, unsigned long, fd,
950+
COMPAT_SYSCALL_DEFINE3(readv, compat_ulong_t, fd,
951951
const struct compat_iovec __user *,vec,
952-
unsigned long, vlen)
952+
compat_ulong_t, vlen)
953953
{
954954
struct fd f = fdget(fd);
955955
ssize_t ret;
@@ -983,9 +983,9 @@ COMPAT_SYSCALL_DEFINE4(preadv64, unsigned long, fd,
983983
return ret;
984984
}
985985

986-
COMPAT_SYSCALL_DEFINE5(preadv, unsigned long, fd,
986+
COMPAT_SYSCALL_DEFINE5(preadv, compat_ulong_t, fd,
987987
const struct compat_iovec __user *,vec,
988-
unsigned long, vlen, u32, pos_low, u32, pos_high)
988+
compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
989989
{
990990
loff_t pos = ((loff_t)pos_high << 32) | pos_low;
991991
return compat_sys_preadv64(fd, vec, vlen, pos);
@@ -1013,9 +1013,9 @@ static size_t compat_writev(struct file *file,
10131013
return ret;
10141014
}
10151015

1016-
COMPAT_SYSCALL_DEFINE3(writev, unsigned long, fd,
1016+
COMPAT_SYSCALL_DEFINE3(writev, compat_ulong_t, fd,
10171017
const struct compat_iovec __user *, vec,
1018-
unsigned long, vlen)
1018+
compat_ulong_t, vlen)
10191019
{
10201020
struct fd f = fdget(fd);
10211021
ssize_t ret;
@@ -1049,9 +1049,9 @@ COMPAT_SYSCALL_DEFINE4(pwritev64, unsigned long, fd,
10491049
return ret;
10501050
}
10511051

1052-
COMPAT_SYSCALL_DEFINE5(pwritev, unsigned long, fd,
1052+
COMPAT_SYSCALL_DEFINE5(pwritev, compat_ulong_t, fd,
10531053
const struct compat_iovec __user *,vec,
1054-
unsigned long, vlen, u32, pos_low, u32, pos_high)
1054+
compat_ulong_t, vlen, u32, pos_low, u32, pos_high)
10551055
{
10561056
loff_t pos = ((loff_t)pos_high << 32) | pos_low;
10571057
return compat_sys_pwritev64(fd, vec, vlen, pos);

‎include/linux/compat.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,16 @@ asmlinkage long compat_sys_keyctl(u32 option,
326326
u32 arg2, u32 arg3, u32 arg4, u32 arg5);
327327
asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
328328

329-
asmlinkage ssize_t compat_sys_readv(unsigned long fd,
330-
const struct compat_iovec __user *vec, unsigned long vlen);
331-
asmlinkage ssize_t compat_sys_writev(unsigned long fd,
332-
const struct compat_iovec __user *vec, unsigned long vlen);
333-
asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
329+
asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd,
330+
const struct compat_iovec __user *vec, compat_ulong_t vlen);
331+
asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd,
332+
const struct compat_iovec __user *vec, compat_ulong_t vlen);
333+
asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
334334
const struct compat_iovec __user *vec,
335-
unsigned long vlen, u32 pos_low, u32 pos_high);
336-
asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
335+
compat_ulong_t vlen, u32 pos_low, u32 pos_high);
336+
asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
337337
const struct compat_iovec __user *vec,
338-
unsigned long vlen, u32 pos_low, u32 pos_high);
338+
compat_ulong_t vlen, u32 pos_low, u32 pos_high);
339339
asmlinkage long comat_sys_lseek(unsigned int, compat_off_t, unsigned int);
340340

341341
asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,

0 commit comments

Comments
 (0)