Skip to content

Commit

Permalink
[PATCH] futex: check and validate timevals
Browse files Browse the repository at this point in the history
The futex timeval is not checked for correctness.  The change does not
break existing applications as the timeval is supplied by glibc (and glibc
always passes a correct value), but the glibc-internal tests for this
functionality fail.

Signed-off-by: Thomas Gleixner <tglx@tglx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed Mar 31, 2006
1 parent d425b27 commit 9741ef9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion kernel/futex.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,11 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, int val,
unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
int val2 = 0;

if ((op == FUTEX_WAIT) && utime) {
if (utime && (op == FUTEX_WAIT)) {
if (copy_from_user(&t, utime, sizeof(t)) != 0)
return -EFAULT;
if (!timespec_valid(&t))
return -EINVAL;
timeout = timespec_to_jiffies(&t) + 1;
}
/*
Expand Down
4 changes: 3 additions & 1 deletion kernel/futex_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
int val2 = 0;

if ((op == FUTEX_WAIT) && utime) {
if (utime && (op == FUTEX_WAIT)) {
if (get_compat_timespec(&t, utime))
return -EFAULT;
if (!timespec_valid(&t))
return -EINVAL;
timeout = timespec_to_jiffies(&t) + 1;
}
if (op >= FUTEX_REQUEUE)
Expand Down

0 comments on commit 9741ef9

Please sign in to comment.