linux-stable/kernel/locking
Cheng Jui Wang 6062d1267f lockdep: Correct lock_classes index mapping
commit 28df029d53 upstream.

A kernel exception was hit when trying to dump /proc/lockdep_chains after
lockdep report "BUG: MAX_LOCKDEP_CHAIN_HLOCKS too low!":

Unable to handle kernel paging request at virtual address 00054005450e05c3
...
00054005450e05c3] address between user and kernel address ranges
...
pc : [0xffffffece769b3a8] string+0x50/0x10c
lr : [0xffffffece769ac88] vsnprintf+0x468/0x69c
...
 Call trace:
  string+0x50/0x10c
  vsnprintf+0x468/0x69c
  seq_printf+0x8c/0xd8
  print_name+0x64/0xf4
  lc_show+0xb8/0x128
  seq_read_iter+0x3cc/0x5fc
  proc_reg_read_iter+0xdc/0x1d4

The cause of the problem is the function lock_chain_get_class() will
shift lock_classes index by 1, but the index don't need to be shifted
anymore since commit 01bb6f0af9 ("locking/lockdep: Change the range
of class_idx in held_lock struct") already change the index to start
from 0.

The lock_classes[-1] located at chain_hlocks array. When printing
lock_classes[-1] after the chain_hlocks entries are modified, the
exception happened.

The output of lockdep_chains are incorrect due to this problem too.

Fixes: f611e8cf98 ("lockdep: Take read/write status in consideration when generate chainkey")
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20220210105011.21712-1-cheng-jui.wang@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-23 12:01:08 +01:00
..
lock_events.c
lock_events.h
lock_events_list.h locking/rwsem: Adaptive disabling of reader optimistic spinning 2019-06-17 12:28:09 +02:00
lockdep.c lockdep: Correct lock_classes index mapping 2022-02-23 12:01:08 +01:00
lockdep_internals.h lockdep: Fix usage_traceoverflow 2020-10-09 08:53:08 +02:00
lockdep_proc.c locking/lockdep: Fix overflow in presentation of average lock-time 2020-07-25 21:47:42 +02:00
lockdep_states.h
locktorture.c locktorture: Make function torture_percpu_rwsem_init() static 2020-08-24 18:45:32 -07:00
Makefile kcsan: Make KCSAN compatible with lockdep 2020-03-21 09:41:16 +01:00
mcs_spinlock.h
mutex-debug.c locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal 2021-05-26 12:06:50 +02:00
mutex-debug.h locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal 2021-05-26 12:06:50 +02:00
mutex.c locking/mutex: Fix HANDOFF condition 2021-09-15 09:50:23 +02:00
mutex.h locking/mutex: clear MUTEX_FLAGS if wait_list is empty due to signal 2021-05-26 12:06:50 +02:00
osq_lock.c locking/osq_lock: Annotate a data race in osq_lock 2020-06-29 12:04:48 -07:00
percpu-rwsem.c locking/percpu-rwsem: Use this_cpu_{inc,dec}() for read_count 2020-09-16 16:26:56 +02:00
qrwlock.c locking/qrwlock: Fix ordering in queued_write_lock_slowpath() 2021-04-28 13:40:00 +02:00
qspinlock.c x86/kvm: Add "nopvspin" parameter to disable PV spinlocks 2020-07-08 16:21:57 -04:00
qspinlock_paravirt.h Revert "locking/pvqspinlock: Don't wait if vCPU is preempted" 2019-09-25 10:22:37 +02:00
qspinlock_stat.h
rtmutex-debug.c kernel: rename show_stack_loglvl() => show_stack() 2020-06-09 09:39:13 -07:00
rtmutex-debug.h
rtmutex.c kernel: delete repeated words in comments 2022-02-01 17:25:45 +01:00
rtmutex.h
rtmutex_common.h rtmutex: Remove unused argument from rt_mutex_proxy_unlock() 2021-01-30 13:55:17 +01:00
rwsem.c kernel: delete repeated words in comments 2022-02-01 17:25:45 +01:00
rwsem.h locking/percpu-rwsem: Remove the embedded rwsem 2020-02-11 13:10:56 +01:00
semaphore.c kernel: delete repeated words in comments 2022-02-01 17:25:45 +01:00
spinlock.c
spinlock_debug.c lockdep: Introduce wait-type checks 2020-03-21 16:00:24 +01:00
test-ww_mutex.c