linux/drivers/ufs/core
Steven Rostedt 535fcf4b8a ufs: core: tracing: Do not dereference pointers in TP_printk()
The trace events in drivers/ufs/core/ufs_trace.h were converted to take a
pointer to the hba structure as an argument for the tracepoint and then in
TP_printk() the printing of the dev_name from the ring buffer was
converted to using the dev dereferenced pointer from the hba saved
pointer.

This is not allowed as the TP_printk() is executed at the time the trace
event is read from /sys/kernel/tracing/trace file. That can happen
literally, seconds, minutes, hours, weeks, days, or even months later!
There is no guarantee that the hba pointer will still exist by the time it
is dereferenced when the "trace" file is read.

Instead, save the device name from the hba pointer at the time the
tracepoint is called and place it into the ring buffer event. Then the
TP_printk() can read the name directly from the ring buffer and remove the
possibility that it will read a freed pointer and crash the kernel.

This was detected when testing the trace event code that looks for
TP_printk() parameters doing illegal derferences[1]

[1] https://lore.kernel.org/all/20260630184836.74d477b6@gandalf.local.home/

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260630185412.283c26c5@gandalf.local.home
Fixes: 583e518e71 ("scsi: ufs: core: Add hba parameter to trace events")
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2026-07-07 10:42:28 -04:00
..
Kconfig scsi: ufs: core: Remove HPB support 2023-07-23 16:40:39 -04:00
Makefile scsi: ufs: core: Add support for TX Equalization 2026-03-27 17:20:29 -04:00
ufs_bsg.c scsi: ufs: core: Remove an unnecessary NULL pointer check 2025-11-12 20:58:28 -05:00
ufs_bsg.h
ufs_trace_types.h scsi: ufs: core: Remove UFS_DEV_COMP 2025-10-23 22:18:12 -04:00
ufs_trace.h ufs: core: tracing: Do not dereference pointers in TP_printk() 2026-07-07 10:42:28 -04:00
ufs-debugfs.c scsi: ufs: core: Add support to retrain TX Equalization via debugfs 2026-03-27 17:20:30 -04:00
ufs-debugfs.h scsi: ufs: core: Make the header files self-contained 2026-04-02 21:26:44 -04:00
ufs-fault-injection.c fault-inject: improve build for CONFIG_FAULT_INJECTION=n 2024-09-01 20:43:33 -07:00
ufs-fault-injection.h scsi: ufs: core: Make the header files self-contained 2026-04-02 21:26:44 -04:00
ufs-hwmon.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ufs-mcq.c scsi: ufs: core: Fix NULL pointer dereference in scsi_cmd_priv() calls 2026-06-01 21:57:52 -04:00
ufs-rpmb.c scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices 2025-11-10 12:49:43 -05:00
ufs-sysfs.c scsi: ufs: core: Introduce function ufshcd_query_attr_qword() 2026-05-05 03:27:42 -04:00
ufs-sysfs.h scsi: ufs: core: Revert "Make HID attributes visible" 2025-10-29 23:12:33 -04:00
ufs-txeq.c scsi: ufs: core: Add a quirk for extended TX EQTR Adapt L0L1L2L3 length 2026-05-22 21:14:59 -04:00
ufshcd-crypto.c blk-crypto: add basic hardware-wrapped key support 2025-02-10 09:54:19 -07:00
ufshcd-crypto.h scsi: ufs: core: Remove an include directive from ufshcd-crypto.h 2026-04-02 21:26:44 -04:00
ufshcd-priv.h scsi: ufs: Remove unnecessary return in void vops wrappers 2026-06-01 21:59:51 -04:00
ufshcd.c Merge branch 7.1/scsi-fixes into 7.2/scsi-staging 2026-06-15 21:01:30 -04:00