Skip to content

Commit 4a44bac

Browse files
author
Ingo Molnar
committed
symbols, stacktrace: look up init symbols after module symbols
Impact: fix incomplete stacktraces I noticed such weird stacktrace entries in lockdep dumps: [ 0.285956] {HARDIRQ-ON-W} state was registered at: [ 0.285956] [<ffffffff802bce90>] mark_irqflags+0xbe/0x125 [ 0.285956] [<ffffffff802bf2fd>] __lock_acquire+0x674/0x82d [ 0.285956] [<ffffffff802bf5b2>] lock_acquire+0xfc/0x128 [ 0.285956] [<ffffffff8135b636>] rt_spin_lock+0xc8/0xd0 [ 0.285956] [<ffffffffffffffff>] 0xffffffffffffffff The stacktrace entry is cut off after rt_spin_lock. After much debugging i found out that stacktrace entries that belong to init symbols dont get printed out, due to commit: a2da405: module: Don't report discarded init pages as kernel text. The reason is this check added to core_kernel_text(): - if (addr >= (unsigned long)_sinittext && + if (system_state == SYSTEM_BOOTING && + addr >= (unsigned long)_sinittext && addr <= (unsigned long)_einittext) return 1; This will discard inittext symbols even though their symbol table is still present and even though stacktraces done while the system was booting up might still be relevant. To not reintroduce the (not well-specified) bug addressed in that commit, first do a module symbols lookup, then a final init-symbols lookup. This will work fine on architectures that have separate address spaces for modules (such as x86) - and should not crash any other architectures either. Acked-by: Peter Zijlstra <peterz@infradead.org> Cc: Rusty Russell <rusty@rustcorp.com.au> LKML-Reference: <new-discussion> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 8144737 commit 4a44bac

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

‎kernel/extable.c‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ const struct exception_table_entry *search_exception_tables(unsigned long addr)
4141
return e;
4242
}
4343

44+
static inline int init_kernel_text(unsigned long addr)
45+
{
46+
if (addr >= (unsigned long)_sinittext &&
47+
addr <= (unsigned long)_einittext)
48+
return 1;
49+
return 0;
50+
}
51+
4452
__notrace_funcgraph int core_kernel_text(unsigned long addr)
4553
{
4654
if (addr >= (unsigned long)_stext &&
4755
addr <= (unsigned long)_etext)
4856
return 1;
4957

5058
if (system_state == SYSTEM_BOOTING &&
51-
addr >= (unsigned long)_sinittext &&
52-
addr <= (unsigned long)_einittext)
59+
init_kernel_text(addr))
5360
return 1;
5461
return 0;
5562
}
@@ -58,7 +65,19 @@ __notrace_funcgraph int __kernel_text_address(unsigned long addr)
5865
{
5966
if (core_kernel_text(addr))
6067
return 1;
61-
return __module_text_address(addr) != NULL;
68+
if (__module_text_address(addr))
69+
return 1;
70+
/*
71+
* There might be init symbols in saved stacktraces.
72+
* Give those symbols a chance to be printed in
73+
* backtraces (such as lockdep traces).
74+
*
75+
* Since we are after the module-symbols check, there's
76+
* no danger of address overlap:
77+
*/
78+
if (init_kernel_text(addr))
79+
return 1;
80+
return 0;
6281
}
6382

6483
int kernel_text_address(unsigned long addr)

0 commit comments

Comments
 (0)