Re: [PATCH v9 5/7] coresight: tmc: Add support for reading crash data

From: James Clark
Date: Wed Jun 05 2024 - 06:31:06 EST




On 05/06/2024 09:17, Linu Cherian wrote:
> * Introduce a new mode CS_MODE_READ_CRASHDATA for reading trace
> captured in previous crash/watchdog reset.
>
> * Add special device files for reading ETR/ETF crash data.
>
> * User can read the crash data as below
>
> For example, for reading crash data from tmc_etf sink
>
> #dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
>

Hi Linu,

I think you are missing the removal of the new crash file when the
device is unloaded.

If you reload the module you get some errors:

# rmmod coresight_tmc
# modprobe coresight_tmc dyndbg=+p

kobject: kobject_add_internal failed for crash_tmc_etf0 with -EEXIST,
don't try to register things with the same name in the same
directory.
coresight tmc_etf0: Failed to setup user interface for crashdata
sysfs: cannot create duplicate filename '/devices/virtual
/misc/crash_tmc_etr0'

I'm not sure if it's related, but there are also some kasan errors at
the same time which I haven't seen before:

BUG: KASAN: slab-use-after-free in strcmp+0x94/0xd0
Read of size 1 at addr ffff00080b271be0 by task modprobe/570
CPU: 2 PID: 570 Comm: modprobe Not tainted 6.9.0-rc4+ #71
Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno
Development Platform, BIOS EDK II Oct 19 2019
Call trace:
dump_backtrace+0x100/0x158
show_stack+0x24/0x38
dump_stack_lvl+0x3c/0x98
print_report+0x178/0x508
kasan_report+0xc0/0x120
__asan_report_load1_noabort+0x20/0x30
strcmp+0x94/0xd0
cti_add_assoc_to_csdev+0x174/0x430 [coresight_cti]
coresight_register+0x414/0x500 [coresight]
__tmc_probe+0xd40/0x1340 [coresight_tmc]
tmc_probe+0x60/0x98 [coresight_tmc]
amba_probe+0x604/0x838
really_probe+0x318/0x780
__driver_probe_device+0x168/0x318
driver_probe_device+0x78/0x2a0
__driver_attach+0x22c/0x538
bus_for_each_dev+0x1bc/0x1f0
driver_attach+0x54/0x70
bus_add_driver+0x2a8/0x4c0
driver_register+0x168/0x2b8
amba_driver_register+0x74/0x98
coresight_init_driver+0x34/0xa8 [coresight]
init_module+0x34/0xfb8 [coresight_tmc]
do_one_initcall+0x1a0/0x8d0
do_init_module+0x1f8/0x588
load_module+0x3c20/0x44c0
__arm64_sys_finit_module+0x3c8/0x638
invoke_syscall+0x78/0x218
el0_svc_common+0x160/0x1d8
do_el0_svc+0x50/0x68
el0_svc+0x4c/0xc0
el0t_64_sync_handler+0x84/0x100
el0t_64_sync+0x190/0x198