Skip to contentSkip to conversation

ARM: unwind: Add missing "Call trace:" line

PATCH In review Kees Cook 4 participants 4 messages Jan 10, 2024 – Jan 11, 2024 Arm (32-bit)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 ARM: unwind: Add missing "Call trace:" line

Every other architecture in Linux includes the line "Call trace:" before backtraces. In some cases ARM would print "Backtrace:", but this was only via 1 specific call path, and wasn't included in CPU Oops nor things like KASAN, UBSAN, etc that called dump_stack(). Regularize this line so CI systems and other things (like LKDTM) that depend on parsing "Call trace:" out of dmesg will see it for ARM.

Before this patch:

	UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
	index 8 is out of range for type 'char [8]'
	CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
	Hardware name: Generic DT based system
	 dump_backtrace from show_stack+0x20/0x24
	 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
	 show_stack from dump_stack_lvl+0x88/0x98
	 dump_stack_lvl from dump_stack+0x18/0x1c
	 r7:00000042 r6:00000008 r5:00000008 r4:80fab118
	 dump_stack from ubsan_epilogue+0x10/0x3c
	 ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
	...

After this patch:

	UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
	index 8 is out of range for type 'char [8]'
	CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
	Hardware name: Generic DT based system
	Call trace:
	 dump_backtrace from show_stack+0x20/0x24
	 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
	 show_stack from dump_stack_lvl+0x88/0x98
	 dump_stack_lvl from dump_stack+0x18/0x1c
	 r7:00000042 r6:00000008 r5:00000008 r4:80fab118
	 dump_stack from ubsan_epilogue+0x10/0x3c
	 ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
	...
Cc Russell King <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Vladimir Murzin <[email protected]>
Cc Zhen Lei <[email protected]>
Cc Keith Packard <[email protected]>
Cc Haibo Li <[email protected]>
---
 arch/arm/kernel/traps.c  | 2 +-
 arch/arm/kernel/unwind.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/kernel/traps.c +1 -1
index 3bad79db5d6e..72c82a4d63ac 100644
@@ -220,7 +220,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
 	unsigned int fp, mode;
 	int ok = 1;
 
-	printk("%sBacktrace: ", loglvl);
+	printk("%sCall trace: ", loglvl);
 
 	if (!tsk)
 		tsk = current;
arch/arm/kernel/unwind.c +2 -0
index 9d2192156087..f60547dadc93 100644
@@ -524,6 +524,8 @@ void unwind_backtrace(struct pt_regs *regs, struct task_struct *tsk,
 {
 	struct stackframe frame;
 
+	printk("%sCall trace: ", loglvl);
+
 	pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
 
 	if (!tsk)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Kees Cook

Every other architecture in Linux includes the line "Call trace:" before backtraces. In some cases ARM would print "Backtrace:", but this was only via 1 specific call path, and wasn't included in CPU Oops nor things like KASAN, UBSAN, etc that called dump_stack(). Regularize this line so CI systems and other things (like LKDTM) that depend on parsing "Call trace:" out of dmesg will see it for ARM.

Before this patch:

        UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
        index 8 is out of range for type 'char [8]'
        CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
        Hardware name: Generic DT based system
         dump_backtrace from show_stack+0x20/0x24
         r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
         show_stack from dump_stack_lvl+0x88/0x98
         dump_stack_lvl from dump_stack+0x18/0x1c
         r7:00000042 r6:00000008 r5:00000008 r4:80fab118
         dump_stack from ubsan_epilogue+0x10/0x3c
         ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
        ...

After this patch:

        UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
        index 8 is out of range for type 'char [8]'
        CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
        Hardware name: Generic DT based system
        Call trace:
         dump_backtrace from show_stack+0x20/0x24
         r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
         show_stack from dump_stack_lvl+0x88/0x98
         dump_stack_lvl from dump_stack+0x18/0x1c
         r7:00000042 r6:00000008 r5:00000008 r4:80fab118
         dump_stack from ubsan_epilogue+0x10/0x3c
         ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
        ...
Quoted 11 lines
Cc Russell King <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Vladimir Murzin <[email protected]>
Cc Zhen Lei <[email protected]>
Cc Keith Packard <[email protected]>
Cc Haibo Li <[email protected]>

Makes sense.

Yours,
Linus Walleij

Reviewed-by on v1 1/1
#2 lore raw
In reply to Kees Cook

Il 10/01/24 22:56, Kees Cook ha scritto:

Quoted 38 lines

Every other architecture in Linux includes the line "Call trace:" before backtraces. In some cases ARM would print "Backtrace:", but this was only via 1 specific call path, and wasn't included in CPU Oops nor things like KASAN, UBSAN, etc that called dump_stack(). Regularize this line so CI systems and other things (like LKDTM) that depend on parsing "Call trace:" out of dmesg will see it for ARM.

Before this patch:

	UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
	index 8 is out of range for type 'char [8]'
	CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
	Hardware name: Generic DT based system
	 dump_backtrace from show_stack+0x20/0x24
	 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
	 show_stack from dump_stack_lvl+0x88/0x98
	 dump_stack_lvl from dump_stack+0x18/0x1c
	 r7:00000042 r6:00000008 r5:00000008 r4:80fab118
	 dump_stack from ubsan_epilogue+0x10/0x3c
	 ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
	...

After this patch:

	UBSAN: array-index-out-of-bounds in ../drivers/misc/lkdtm/bugs.c:376:16
	index 8 is out of range for type 'char [8]'
	CPU: 0 PID: 1402 Comm: cat Not tainted 6.7.0-rc2 #1
	Hardware name: Generic DT based system
	Call trace:
	 dump_backtrace from show_stack+0x20/0x24
	 r7:00000042 r6:00000000 r5:60070013 r4:80cf5d7c
	 show_stack from dump_stack_lvl+0x88/0x98
	 dump_stack_lvl from dump_stack+0x18/0x1c
	 r7:00000042 r6:00000008 r5:00000008 r4:80fab118
	 dump_stack from ubsan_epilogue+0x10/0x3c
	 ubsan_epilogue from __ubsan_handle_out_of_bounds+0x80/0x84
	...
Quoted 11 lines
Cc Russell King <[email protected]>
Cc Ard Biesheuvel <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Vladimir Murzin <[email protected]>
Cc Zhen Lei <[email protected]>
Cc Keith Packard <[email protected]>
Cc Haibo Li <[email protected]>
Reviewed-by on v1 1/1
#3 lore raw
In reply to Kees Cook
Quoted 6 lines · Kees Cook

Every other architecture in Linux includes the line "Call trace:" before backtraces. In some cases ARM would print "Backtrace:", but this was only via 1 specific call path, and wasn't included in CPU Oops nor things like KASAN, UBSAN, etc that called dump_stack(). Regularize this line so CI systems and other things (like LKDTM) that depend on parsing "Call trace:" out of dmesg will see it for ARM.