Skip to content

Commit ed1f87f

Browse files
Jiri SlabyZhengShunQian
authored andcommitted
futex: futex_wake_op, fix sign_extend32 sign bits
commit d70ef22 upstream. sign_extend32 counts the sign bit parameter from 0, not from 1. So we have to use "11" for 12th bit, not "12". This mistake means we have not allowed negative op and cmp args since commit 30d6e0a ("futex: Remove duplicated code and fix undefined behaviour") till now. Fixes: 30d6e0a ("futex: Remove duplicated code and fix undefined behaviour") Signed-off-by: Jiri Slaby <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Darren Hart <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d5f1017 commit ed1f87f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/futex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,8 @@ static int futex_atomic_op_inuser(unsigned int encoded_op, u32 __user *uaddr)
14571457
{
14581458
unsigned int op = (encoded_op & 0x70000000) >> 28;
14591459
unsigned int cmp = (encoded_op & 0x0f000000) >> 24;
1460-
int oparg = sign_extend32((encoded_op & 0x00fff000) >> 12, 12);
1461-
int cmparg = sign_extend32(encoded_op & 0x00000fff, 12);
1460+
int oparg = sign_extend32((encoded_op & 0x00fff000) >> 12, 11);
1461+
int cmparg = sign_extend32(encoded_op & 0x00000fff, 11);
14621462
int oldval, ret;
14631463

14641464
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) {

0 commit comments

Comments
 (0)