diff options
author | Peter Zijlstra <peterz@infradead.org> | 2024-09-09 12:50:09 +0200 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2024-09-10 11:57:27 +0200 |
commit | 1d7f856c2ca449f04a22d876e36b464b7a9d28b6 (patch) | |
tree | 36dfab1765b30922b40f7f49ce10fd45fa62e58b /kernel/livepatch/state.h | |
parent | fe513c2ef0a172a58f158e2e70465c4317f0a9a2 (diff) |
jump_label: Fix static_key_slow_dec() yet again
While commit 83ab38ef0a0b ("jump_label: Fix concurrency issues in
static_key_slow_dec()") fixed one problem, it created yet another,
notably the following is now possible:
slow_dec
if (try_dec) // dec_not_one-ish, false
// enabled == 1
slow_inc
if (inc_not_disabled) // inc_not_zero-ish
// enabled == 2
return
guard((mutex)(&jump_label_mutex);
if (atomic_cmpxchg(1,0)==1) // false, we're 2
slow_dec
if (try-dec) // dec_not_one, true
// enabled == 1
return
else
try_dec() // dec_not_one, false
WARN
Use dec_and_test instead of cmpxchg(), like it was prior to
83ab38ef0a0b. Add a few WARNs for the paranoid.
Fixes: 83ab38ef0a0b ("jump_label: Fix concurrency issues in static_key_slow_dec()")
Reported-by: "Darrick J. Wong" <djwong@kernel.org>
Tested-by: Klara Modin <klarasmodin@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'kernel/livepatch/state.h')
0 files changed, 0 insertions, 0 deletions