Skip to content

Commit

Permalink
parisc: sync compat getdents
Browse files Browse the repository at this point in the history
Add VERIFY_WRITE check in the beginning like compat_sys_getdents() EFAULT on
parisc if put_user() fails.

Signed-off-by: Alexandr Andreev <aandreev@openvz.org>
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Matthew Wilcox <willy@debian.org>
Cc: Grant Grundler <grundler@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
  • Loading branch information
Alexandr Andreev authored and Kyle McMartin committed May 23, 2007
1 parent 01da41b commit 2c8307f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/parisc/kernel/sys_parisc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 2c8307f

Please sign in to comment.