linux-stable/kernel/locking
Peter Zijlstra bca4104b00 lockdep: Fix block chain corruption
Kent reported an occasional KASAN splat in lockdep. Mark then noted:

> I suspect the dodgy access is to chain_block_buckets[-1], which hits the last 4
> bytes of the redzone and gets (incorrectly/misleadingly) attributed to
> nr_large_chain_blocks.

That would mean @size == 0, at which point size_to_bucket() returns -1
and the above happens.

alloc_chain_hlocks() has 'size - req', for the first with the
precondition 'size >= rq', which allows the 0.

This code is trying to split a block, del_chain_block() takes what we
need, and add_chain_block() puts back the remainder, except in the
above case the remainder is 0 sized and things go sideways.

Fixes: 810507fe6f ("locking/lockdep: Reuse freed chain_hlocks entries")
Reported-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Kent Overstreet <kent.overstreet@linux.dev>
Link: https://lkml.kernel.org/r/20231121114126.GH8262@noisy.programming.kicks-ass.net
2023-11-24 11:04:54 +01:00
..
irqflag-debug.c
lock_events.c locking/debug: Fix debugfs API return value checks to use IS_ERR() 2023-10-03 10:11:25 +02:00
lock_events.h locking: add lockevent_read() prototype 2023-06-09 17:44:15 -07:00
lock_events_list.h
lockdep.c lockdep: Fix block chain corruption 2023-11-24 11:04:54 +01:00
lockdep_internals.h
lockdep_proc.c locking/lockdep: Fix string sizing bug that triggers a format-truncation compiler-warning 2023-10-12 20:37:59 +02:00
lockdep_states.h
locktorture.c locktorture: Check the correct variable for allocation failure 2023-10-11 15:55:26 +02:00
Makefile
mcs_spinlock.h
mutex-debug.c
mutex.c locking: export contention tracepoints for bcachefs six locks 2023-10-19 14:47:33 -04:00
mutex.h
osq_lock.c
percpu-rwsem.c
qrwlock.c
qspinlock.c
qspinlock_paravirt.h x86/qspinlock-paravirt: Fix missing-prototype warning 2023-08-03 17:15:05 +02:00
qspinlock_stat.h
rtmutex.c locking/rtmutex: Add a lockdep assert to catch potential nested blocking 2023-09-20 09:31:14 +02:00
rtmutex_api.c locking/rtmutex: Fix task->pi_waiters integrity 2023-07-17 13:59:10 +02:00
rtmutex_common.h locking/rtmutex: Fix task->pi_waiters integrity 2023-07-17 13:59:10 +02:00
rwbase_rt.c locking/rtmutex: Add a lockdep assert to catch potential nested blocking 2023-09-20 09:31:14 +02:00
rwsem.c locking/rtmutex: Use rt_mutex specific scheduler helpers 2023-09-20 09:31:13 +02:00
semaphore.c
spinlock.c
spinlock_debug.c
spinlock_rt.c locking/rtmutex: Add a lockdep assert to catch potential nested blocking 2023-09-20 09:31:14 +02:00
test-ww_mutex.c locking/ww_mutex/test: Make sure we bail out instead of livelock 2023-09-22 09:43:41 +02:00
ww_mutex.h locking/rtmutex: Fix task->pi_waiters integrity 2023-07-17 13:59:10 +02:00
ww_rt_mutex.c locking/rtmutex: Avoid unconditional slowpath for DEBUG_RT_MUTEXES 2023-09-20 09:31:11 +02:00