linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: unwind: Add missing "Call trace:" line
@ 2024-01-10 21:56 Kees Cook
  2024-01-10 23:46 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kees Cook @ 2024-01-10 21:56 UTC (permalink / raw)
  To: Russell King
  Cc: Kees Cook, Mark Brown, Ard Biesheuvel, Arnd Bergmann,
	Linus Walleij, Vladimir Murzin, Zhen Lei, Keith Packard,
	Haibo Li, linux-arm-kernel, Matthias Brugger,
	AngeloGioacchino Del Regno, Alexandre Mergnat, linux-kernel,
	linux-hardening

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
	...

Reported-by: Mark Brown <broonie@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Keith Packard <keithpac@amazon.com>
Cc: Haibo Li <haibo.li@mediatek.com>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/arm/kernel/traps.c  | 2 +-
 arch/arm/kernel/unwind.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 3bad79db5d6e..72c82a4d63ac 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -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;
diff --git a/arch/arm/kernel/unwind.c b/arch/arm/kernel/unwind.c
index 9d2192156087..f60547dadc93 100644
--- a/arch/arm/kernel/unwind.c
+++ b/arch/arm/kernel/unwind.c
@@ -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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ARM: unwind: Add missing "Call trace:" line
  2024-01-10 21:56 [PATCH] ARM: unwind: Add missing "Call trace:" line Kees Cook
@ 2024-01-10 23:46 ` Linus Walleij
  2024-01-11 12:12 ` AngeloGioacchino Del Regno
  2024-01-11 15:49 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2024-01-10 23:46 UTC (permalink / raw)
  To: Kees Cook
  Cc: Russell King, Mark Brown, Ard Biesheuvel, Arnd Bergmann,
	Vladimir Murzin, Zhen Lei, Keith Packard, Haibo Li,
	linux-arm-kernel, Matthias Brugger, AngeloGioacchino Del Regno,
	Alexandre Mergnat, linux-kernel, linux-hardening

On Wed, Jan 10, 2024 at 10:56 PM Kees Cook <keescook@chromium.org> wrote:

> 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
>         ...
>
> Reported-by: Mark Brown <broonie@kernel.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Vladimir Murzin <vladimir.murzin@arm.com>
> Cc: Zhen Lei <thunder.leizhen@huawei.com>
> Cc: Keith Packard <keithpac@amazon.com>
> Cc: Haibo Li <haibo.li@mediatek.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Makes sense.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ARM: unwind: Add missing "Call trace:" line
  2024-01-10 21:56 [PATCH] ARM: unwind: Add missing "Call trace:" line Kees Cook
  2024-01-10 23:46 ` Linus Walleij
@ 2024-01-11 12:12 ` AngeloGioacchino Del Regno
  2024-01-11 15:49 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-01-11 12:12 UTC (permalink / raw)
  To: Kees Cook, Russell King
  Cc: Mark Brown, Ard Biesheuvel, Arnd Bergmann, Linus Walleij,
	Vladimir Murzin, Zhen Lei, Keith Packard, Haibo Li,
	linux-arm-kernel, Matthias Brugger, Alexandre Mergnat,
	linux-kernel, linux-hardening

Il 10/01/24 22:56, Kees Cook ha scritto:
> 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
> 	...
> 
> Reported-by: Mark Brown <broonie@kernel.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Ard Biesheuvel <ardb@kernel.org>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Vladimir Murzin <vladimir.murzin@arm.com>
> Cc: Zhen Lei <thunder.leizhen@huawei.com>
> Cc: Keith Packard <keithpac@amazon.com>
> Cc: Haibo Li <haibo.li@mediatek.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ARM: unwind: Add missing "Call trace:" line
  2024-01-10 21:56 [PATCH] ARM: unwind: Add missing "Call trace:" line Kees Cook
  2024-01-10 23:46 ` Linus Walleij
  2024-01-11 12:12 ` AngeloGioacchino Del Regno
@ 2024-01-11 15:49 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-01-11 15:49 UTC (permalink / raw)
  To: Kees Cook
  Cc: Russell King, Ard Biesheuvel, Arnd Bergmann, Linus Walleij,
	Vladimir Murzin, Zhen Lei, Keith Packard, Haibo Li,
	linux-arm-kernel, Matthias Brugger, AngeloGioacchino Del Regno,
	Alexandre Mergnat, linux-kernel, linux-hardening

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

On Wed, Jan 10, 2024 at 01:56:01PM -0800, Kees Cook wrote:
> 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.

Reviewed-by: Mark Brown <broonie@kernel.org>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-11 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-10 21:56 [PATCH] ARM: unwind: Add missing "Call trace:" line Kees Cook
2024-01-10 23:46 ` Linus Walleij
2024-01-11 12:12 ` AngeloGioacchino Del Regno
2024-01-11 15:49 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).