Daniel Bristot de Oliveira
1389358bb0
tracing/timerlat: Move hrtimer_init to timerlat_fd open()
...
Currently, the timerlat's hrtimer is initialized at the first read of
timerlat_fd, and destroyed at close(). It works, but it causes an error
if the user program open() and close() the file without reading.
Here's an example:
# echo NO_OSNOISE_WORKLOAD > /sys/kernel/debug/tracing/osnoise/options
# echo timerlat > /sys/kernel/debug/tracing/current_tracer
# cat <<EOF > ./timerlat_load.py
# !/usr/bin/env python3
timerlat_fd = open("/sys/kernel/tracing/osnoise/per_cpu/cpu0/timerlat_fd", 'r')
timerlat_fd.close();
EOF
# ./taskset -c 0 ./timerlat_load.py
<BOOM>
BUG: kernel NULL pointer dereference, address: 0000000000000010
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1 ] PREEMPT SMP NOPTI
CPU: 1 PID: 2673 Comm: python3 Not tainted 6.6.13-200.fc39.x86_64 #1
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-1.fc39 04/01/2014
RIP: 0010:hrtimer_active+0xd/0x50
Code: 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 48 8b 57 30 <8b> 42 10 a8 01 74 09 f3 90 8b 42 10 a8 01 75 f7 80 7f 38 00 75 1d
RSP: 0018:ffffb031009b7e10 EFLAGS: 00010286
RAX: 000000000002db00 RBX: ffff9118f786db08 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff9117a0e64400 RDI: ffff9118f786db08
RBP: ffff9118f786db80 R08: ffff9117a0ddd420 R09: ffff9117804d4f70
R10: 0000000000000000 R11: 0000000000000000 R12: ffff9118f786db08
R13: ffff91178fdd5e20 R14: ffff9117840978c0 R15: 0000000000000000
FS: 00007f2ffbab1740(0000) GS:ffff9118f7840000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000010 CR3: 00000001b402e000 CR4: 0000000000750ee0
PKRU: 55555554
Call Trace:
<TASK>
? __die+0x23/0x70
? page_fault_oops+0x171/0x4e0
? srso_alias_return_thunk+0x5/0x7f
? avc_has_extended_perms+0x237/0x520
? exc_page_fault+0x7f/0x180
? asm_exc_page_fault+0x26/0x30
? hrtimer_active+0xd/0x50
hrtimer_cancel+0x15/0x40
timerlat_fd_release+0x48/0xe0
__fput+0xf5/0x290
__x64_sys_close+0x3d/0x80
do_syscall_64+0x60/0x90
? srso_alias_return_thunk+0x5/0x7f
? __x64_sys_ioctl+0x72/0xd0
? srso_alias_return_thunk+0x5/0x7f
? syscall_exit_to_user_mode+0x2b/0x40
? srso_alias_return_thunk+0x5/0x7f
? do_syscall_64+0x6c/0x90
? srso_alias_return_thunk+0x5/0x7f
? exit_to_user_mode_prepare+0x142/0x1f0
? srso_alias_return_thunk+0x5/0x7f
? syscall_exit_to_user_mode+0x2b/0x40
? srso_alias_return_thunk+0x5/0x7f
? do_syscall_64+0x6c/0x90
entry_SYSCALL_64_after_hwframe+0x6e/0xd8
RIP: 0033:0x7f2ffb321594
Code: 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 80 3d d5 cd 0d 00 00 74 13 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 3c c3 0f 1f 00 55 48 89 e5 48 83 ec 10 89 7d
RSP: 002b:00007ffe8d8eef18 EFLAGS: 00000202 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 00007f2ffba4e668 RCX: 00007f2ffb321594
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007ffe8d8eef40 R08: 0000000000000000 R09: 0000000000000000
R10: 55c926e3167eae79 R11: 0000000000000202 R12: 0000000000000003
R13: 00007ffe8d8ef030 R14: 0000000000000000 R15: 00007f2ffba4e668
</TASK>
CR2: 0000000000000010
---[ end trace 0000000000000000 ]---
Move hrtimer_init to timerlat_fd open() to avoid this problem.
Link: https://lore.kernel.org/linux-trace-kernel/7324dd3fc0035658c99b825204a66049389c56e3.1706798888.git.bristot@kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: stable@vger.kernel.org
Fixes: e88ed227f639 ("tracing/timerlat: Add user-space interface")
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2024-02-01 11:50:13 -05:00
..
2024-01-17 20:20:06 -08:00
2024-01-18 09:48:40 -08:00
2023-09-22 09:50:55 -07:00
2024-01-17 17:19:06 +00:00
2024-01-18 16:49:34 -08:00
2023-12-21 23:12:18 +01:00
2024-01-09 11:18:47 -08:00
2023-12-20 19:26:31 -05:00
2023-10-18 14:43:22 -07:00
2023-11-02 20:53:31 -10:00
2023-10-18 14:34:17 -07:00
2023-09-20 11:24:18 +02:00
2024-01-12 16:35:58 -08:00
2024-01-10 18:00:18 -08:00
2023-12-20 19:19:26 +01:00
2023-11-03 15:44:25 -10:00
2023-12-14 01:21:31 +05:30
2024-01-18 11:57:33 -08:00
2024-01-21 11:14:40 -08:00
2024-02-01 11:50:13 -05:00
2023-09-11 15:05:50 +02:00
2024-01-10 16:43:55 -08:00
2023-11-02 20:53:31 -10:00
2023-11-14 17:34:27 -05:00
2023-11-12 22:33:49 -05:00
2023-07-21 12:17:25 -04:00
2023-08-15 18:16:14 -04:00
2023-10-13 18:34:46 +02:00
2023-08-08 16:48:47 -04:00
2023-03-14 19:32:38 -07:00
2023-06-05 09:57:20 +02:00
2023-01-13 11:48:15 +01:00
2024-01-09 10:36:07 -08:00
2024-01-12 15:20:47 -08:00
2023-12-15 14:19:48 -08:00
2023-04-18 16:39:34 -07:00
2024-01-10 16:43:55 -08:00
2023-09-21 12:03:50 -06:00
2023-02-08 13:36:22 +01:00
2024-01-18 15:16:57 -08:00
2023-12-23 15:52:13 +01:00
2023-05-28 16:20:21 +09:00
2023-09-29 11:28:39 -07:00
2023-04-08 13:45:37 -07:00
2023-08-21 13:37:28 -07:00
2023-03-24 11:01:29 +01:00
2023-08-29 17:32:32 -07:00
2023-08-25 15:00:36 -07:00
2023-10-19 11:02:48 +02:00
2023-12-20 13:46:19 -08:00
2023-06-09 17:44:17 -07:00
2024-01-12 15:20:47 -08:00
2023-12-29 12:22:25 -08:00
2023-10-09 16:59:47 +10:00
2023-03-24 20:10:59 -07:00
2023-12-01 14:53:55 +09:00
2023-06-08 12:27:20 -07:00
2023-08-24 16:25:14 -07:00
2023-11-02 20:53:31 -10:00
2023-12-20 19:26:30 -05:00
2023-04-08 13:45:38 -07:00
2023-08-21 11:29:12 -07:00
2023-12-20 19:26:30 -05:00
2023-10-27 18:04:24 +08:00
2023-10-04 10:41:56 -07:00
2023-12-01 09:51:44 -08:00
2023-12-20 19:26:31 -05:00
2023-08-21 13:37:59 -07:00
2023-12-12 14:24:14 +01:00
2024-01-09 11:46:20 -08:00
2024-01-09 16:20:17 -08:00
2023-12-29 12:22:27 -08:00
2024-01-09 11:46:20 -08:00
2022-12-27 12:52:12 +01:00
2023-07-14 15:02:57 -07:00
2023-12-12 14:24:14 +01:00
2023-12-10 17:21:32 -08:00
2023-10-30 17:56:53 -10:00
2023-10-04 10:41:57 -07:00
2023-07-13 15:21:50 +02:00
2023-04-20 11:36:35 +02:00
2023-12-29 12:22:29 -08:00
2024-01-09 12:57:46 -08:00
2023-11-18 19:35:31 +01:00
2023-11-01 15:28:33 -10:00
2023-09-19 13:21:32 -07:00
2023-10-04 10:41:57 -07:00
2023-09-24 17:24:01 +02:00
2023-02-18 14:34:36 -05:00
2023-08-15 15:26:17 -07:00
2023-06-29 15:19:43 -07:00
2023-09-13 14:59:24 +02:00
2023-11-28 14:08:47 +01:00
2023-10-11 08:46:01 -07:00
2023-04-13 11:49:35 -07:00
2023-06-08 15:43:09 -04:00
2023-12-21 13:17:54 +01:00
2023-06-19 16:25:28 -07:00
2023-06-09 17:44:21 -07:00
2023-12-29 12:22:30 -08:00
2023-08-07 15:57:22 -10:00
2023-11-22 06:18:49 -10:00