From: Alexandr Andreev Date: Tue, 6 Mar 2007 10:44:13 +0000 (-0800) Subject: parisc: sync compat getdents X-Git-Tag: v2.6.22-rc5~36^2~28 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=2c8307f63dd5caaf7ff8ad5118951e559a9ed5c8;p=karo-tx-linux.git parisc: sync compat getdents Add VERIFY_WRITE check in the beginning like compat_sys_getdents() EFAULT on parisc if put_user() fails. Signed-off-by: Alexandr Andreev Signed-off-by: Alexey Dobriyan Cc: Kyle McMartin Cc: Matthew Wilcox Cc: Grant Grundler Signed-off-by: Andrew Morton Signed-off-by: Kyle McMartin --- diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c index ce3245f87fdd..a8ebac4fadec 100644 --- a/arch/parisc/kernel/sys_parisc32.c +++ b/arch/parisc/kernel/sys_parisc32.c @@ -350,6 +350,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count) struct getdents32_callback buf; int error; + error = -EFAULT; + if (!access_ok(VERIFY_WRITE, dirent, count)) + goto out; + error = -EBADF; file = fget(fd); if (!file) @@ -366,8 +370,10 @@ sys32_getdents (unsigned int fd, void __user * dirent, unsigned int count) error = buf.error; lastdirent = buf.previous; if (lastdirent) { - put_user(file->f_pos, &lastdirent->d_off); - error = count - buf.count; + if (put_user(file->f_pos, &lastdirent->d_off)) + error = -EFAULT; + else + error = count - buf.count; } out_putf: