From: Alexandr Andreev Date: Tue, 6 Mar 2007 10:34:24 +0000 (-0800) Subject: [IA64] sync compat getdents X-Git-Tag: Ubuntu-5.4-5.4.0-11.14~46989^2~2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=50157b09b33c2ec3637d3b317b06a7235c57c7f2;p=mirror_ubuntu-focal-kernel.git [IA64] sync compat getdents Add VERIFY_WRITE check in the beginning like compat_sys_getdents() (EINVAL vs EFAULT). Signed-off-by: Alexandr Andreev Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Tony Luck --- diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index d430d36ae49d..0afb4fe7c35b 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c @@ -1267,6 +1267,10 @@ sys32_getdents (unsigned int fd, struct compat_dirent __user *dirent, unsigned i struct getdents32_callback buf; int error; + error = -EFAULT; + if (!access_ok(VERIFY_WRITE, dirent, count)) + goto out; + error = -EBADF; file = fget(fd); if (!file) @@ -1283,10 +1287,10 @@ sys32_getdents (unsigned int fd, struct compat_dirent __user *dirent, unsigned i error = buf.error; lastdirent = buf.previous; if (lastdirent) { - error = -EINVAL; if (put_user(file->f_pos, &lastdirent->d_off)) - goto out_putf; - error = count - buf.count; + error = -EFAULT; + else + error = count - buf.count; } out_putf: