Skip to content

Commit 6f07048

Browse files
committed
powerpc: Define arch_is_kernel_initmem_freed() for lockdep
Under certain circumstances, we hit a warning in lockdep_register_key: if (WARN_ON_ONCE(static_obj(key))) return; This occurs when the key falls into initmem that has since been freed and can now be reused. This has been observed on boot, and under memory pressure. Define arch_is_kernel_initmem_freed(), which allows lockdep to correctly identify this memory as dynamic. This fixes a bug picked up by the powerpc64 syzkaller instance where we hit the WARN via alloc_netdev_mqs. Reported-by: Qian Cai <[email protected]> Reported-by: ppc syzbot c/o Andrew Donnellan <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Signed-off-by: Daniel Axtens <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 8dcd71b commit 6f07048

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

arch/powerpc/include/asm/sections.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@
55

66
#include <linux/elf.h>
77
#include <linux/uaccess.h>
8+
9+
#define arch_is_kernel_initmem_freed arch_is_kernel_initmem_freed
10+
811
#include <asm-generic/sections.h>
912

13+
extern bool init_mem_is_free;
14+
15+
static inline int arch_is_kernel_initmem_freed(unsigned long addr)
16+
{
17+
if (!init_mem_is_free)
18+
return 0;
19+
20+
return addr >= (unsigned long)__init_begin &&
21+
addr < (unsigned long)__init_end;
22+
}
23+
1024
extern char __head_end[];
1125

1226
#ifdef __powerpc64__

0 commit comments

Comments
 (0)