Skip to content

Commit c9bd156

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
futex: Fix hardcoded flags
Xi reported that commit 5694289 ("futex: Flag conversion") broke glibc's robust futex tests. This was narrowed down to the change of FLAGS_SHARED from 0x01 to 0x10, at which point Florian noted that handle_futex_death() has a hardcoded flags argument of 1. Change this to: FLAGS_SIZE_32 | FLAGS_SHARED, matching how futex_to_flags() unconditionally sets FLAGS_SIZE_32 for all legacy futex ops. Reported-by: Xi Ruoyao <[email protected]> Reported-by: Florian Weimer <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Fixes: 5694289 ("futex: Flag conversion") Cc: <[email protected]>
1 parent b85ea95 commit c9bd156

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

kernel/futex/core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,8 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,
700700
owner = uval & FUTEX_TID_MASK;
701701

702702
if (pending_op && !pi && !owner) {
703-
futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
703+
futex_wake(uaddr, FLAGS_SIZE_32 | FLAGS_SHARED, 1,
704+
FUTEX_BITSET_MATCH_ANY);
704705
return 0;
705706
}
706707

@@ -752,8 +753,10 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr,
752753
* Wake robust non-PI futexes here. The wakeup of
753754
* PI futexes happens in exit_pi_state():
754755
*/
755-
if (!pi && (uval & FUTEX_WAITERS))
756-
futex_wake(uaddr, 1, 1, FUTEX_BITSET_MATCH_ANY);
756+
if (!pi && (uval & FUTEX_WAITERS)) {
757+
futex_wake(uaddr, FLAGS_SIZE_32 | FLAGS_SHARED, 1,
758+
FUTEX_BITSET_MATCH_ANY);
759+
}
757760

758761
return 0;
759762
}

0 commit comments

Comments
 (0)