]> git.baikalelectronics.ru Git - kernel.git/commit
lockdep: Correct lock_classes index mapping
authorCheng Jui Wang <cheng-jui.wang@mediatek.com>
Thu, 10 Feb 2022 10:50:11 +0000 (18:50 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 11 Feb 2022 22:30:02 +0000 (23:30 +0100)
commit2f419ef9b65f5ead07b76ae06c81af8510f62392
treec62b1ea315955fe6c5b765e139fe89dad9a5f784
parentcdcfc33f146631371044f576fc7b64d7e71508a3
lockdep: Correct lock_classes index mapping

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 02771f570002 ("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: d3ac0644e08f ("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
kernel/locking/lockdep.c