Skip to contentSkip to conversation

Pass nr_wake2 to futex_wake_op

PATCH In review Andreas Schwab 2 participants 2 messages Jul 17, 2007 – Jul 18, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Pass nr_wake2 to futex_wake_op

The fourth argument of sys_futex is ignored when op == FUTEX_WAKE_OP, but futex_wake_op expects it as its nr_wake2 parameter.

The only user of this operation in glibc is always passing 1, so this bug had no consequences so far.

---
 kernel/futex.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/futex.c +3 -1
@@ -2061,8 +2061,10 @@ asmlinkage long sys_futex(u32 __user *ua
 	}
 	/*
 	 * requeue parameter in 'utime' if cmd == FUTEX_REQUEUE.
+	 * number of waiters to wake in 'utime' if cmd == FUTEX_WAKE_OP.
 	 */
-	if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE)
+	if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
+	    cmd == FUTEX_WAKE_OP)
 		val2 = (u32) (unsigned long) utime;
 
 	return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw
Quoted 17 lines · On Tue, 17 Jul 2007 13:31:29 +0200 Andreas Schwab <[email protected]> wrote:

The fourth argument of sys_futex is ignored when op == FUTEX_WAKE_OP, but futex_wake_op expects it as its nr_wake2 parameter.

The only user of this operation in glibc is always passing 1, so this bug had no consequences so far.

---
 kernel/futex.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/futex.c +0 -0
@@ -2061,8 +2061,10 @@ asmlinkage long sys_futex(u32 __user *ua
 	}

kernel/futex.c asmlinkage long sys_futex(u32 __user *ua · line 2070

Quoted 10 lines
kernel/futex.c +3 -1
 	/*
 	 * requeue parameter in 'utime' if cmd == FUTEX_REQUEUE.
+	 * number of waiters to wake in 'utime' if cmd == FUTEX_WAKE_OP.
 	 */
-	if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE)
+	if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
+	    cmd == FUTEX_WAKE_OP)
 		val2 = (u32) (unsigned long) utime;
 
 	return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);

So if an application or glibc _does_ start passing in non-1 values, it will malfunction on earlier kernels?

So that userspace code would need to have a test for the kernel version, I assume?

All a bit of a hassle. Still, I'd propose that this change (if the thus-far-silent cc'ees agree with it?) go into 2.6.22.x at least. If it gets accepted into 2.6.22.x then applications (or glibc) will need to test for kernels as far back as 2.6.22. Really they would need to test for the correct value of x in 2.6.22.x, but I don't know if glibc is set up for that.

Thoughts?