linux-stable/kernel/locking
Peter Zijlstra 328854deec lockdep: Fix block chain corruption
[ Upstream commit bca4104b00 ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-03 07:33:06 +01:00
..
Makefile lockdep: allow instrumenting lockdep.c with KMSAN 2022-12-11 18:12:11 -08:00
irqflag-debug.c
lock_events.c
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-12-03 07:33:06 +01:00
lockdep_internals.h
lockdep_proc.c
lockdep_states.h
locktorture.c torture: Add lock_torture writer_fifo module parameter 2023-08-14 15:01:07 -07:00
mcs_spinlock.h
mutex-debug.c
mutex.c
mutex.h
osq_lock.c
percpu-rwsem.c locking/percpu-rwsem: Add percpu_is_write_locked() and percpu_is_read_locked() 2022-08-30 10:56:23 +02:00
qrwlock.c locking: Add __lockfunc to slow path functions 2022-08-19 19:47:51 +02:00
qspinlock.c locking/qspinlock: Micro-optimize pending state waiting for unlock 2023-01-05 11:01:50 +01:00
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: Fix task->pi_waiters integrity 2023-07-17 13:59:10 +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/rwbase: Mitigate indefinite writer starvation 2023-04-29 09:08:52 +02:00
rwsem.c locking/rwsem: Add __always_inline annotation to __down_read_common() and inlined callers 2023-05-08 10:58:24 +02:00
semaphore.c locking: Add __sched to semaphore functions 2022-09-15 16:14:03 +02:00
spinlock.c locking/spinlocks: Mark spinlocks noinline when inline spinlocks are disabled 2022-08-04 11:05:43 +02:00
spinlock_debug.c
spinlock_rt.c
test-ww_mutex.c locking/ww_mutex/test: Fix potential workqueue corruption 2023-11-28 17:19:35 +00:00
ww_mutex.h locking/rtmutex: Fix task->pi_waiters integrity 2023-07-17 13:59:10 +02:00
ww_rt_mutex.c