Skip to content

Commit

Permalink
[IA64] 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() (EINVAL vs
EFAULT).

Signed-off-by: Alexandr Andreev <aandreev@openvz.org>
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Alexandr Andreev authored and Tony Luck committed Mar 6, 2007
1 parent a27e5a1 commit 50157b0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arch/ia64/ia32/sys_ia32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 50157b0

Please sign in to comment.