Steven Rostedt (VMware)
20c2f141b1
tracing / histogram: Fix NULL pointer dereference on strcmp() on NULL event name
...
[ Upstream commit 5acce0bff2a0420ce87d4591daeb867f47d552c2 ]
The following commands:
# echo 'read_max u64 size;' > synthetic_events
# echo 'hist:keys=common_pid:count=count:onmax($count).trace(read_max,count)' > events/syscalls/sys_enter_read/trigger
Causes:
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1 ] PREEMPT SMP
CPU: 4 PID: 1763 Comm: bash Not tainted 5.14.0-rc2-test+ #155
Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01
v03.03 07/14/2016
RIP: 0010:strcmp+0xc/0x20
Code: 75 f7 31 c0 0f b6 0c 06 88 0c 02 48 83 c0 01 84 c9 75 f1 4c 89 c0
c3 0f 1f 80 00 00 00 00 31 c0 eb 08 48 83 c0 01 84 d2 74 0f <0f> b6 14 07
3a 14 06 74 ef 19 c0 83 c8 01 c3 31 c0 c3 66 90 48 89
RSP: 0018:ffffb5fdc0963ca8 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffffffffb3a4e040 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff9714c0d0b640 RDI: 0000000000000000
RBP: 0000000000000000 R08: 00000022986b7cde R09: ffffffffb3a4dff8
R10: 0000000000000000 R11: 0000000000000000 R12: ffff9714c50603c8
R13: 0000000000000000 R14: ffff97143fdf9e48 R15: ffff9714c01a2210
FS: 00007f1fa6785740(0000) GS:ffff9714da400000(0000)
knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000002d863004 CR4: 00000000001706e0
Call Trace:
__find_event_file+0x4e/0x80
action_create+0x6b7/0xeb0
? kstrdup+0x44/0x60
event_hist_trigger_func+0x1a07/0x2130
trigger_process_regex+0xbd/0x110
event_trigger_write+0x71/0xd0
vfs_write+0xe9/0x310
ksys_write+0x68/0xe0
do_syscall_64+0x3b/0x90
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f1fa6879e87
The problem was the "trace(read_max,count)" where the "count" should be
"$count" as "onmax()" only handles variables (although it really should be
able to figure out that "count" is a field of sys_enter_read). But there's
a path that does not find the variable and ends up passing a NULL for the
event, which ends up getting passed to "strcmp()".
Add a check for NULL to return and error on the command with:
# cat error_log
hist:syscalls:sys_enter_read: error: Couldn't create or find variable
Command: hist:keys=common_pid:count=count:onmax($count).trace(read_max,count)
^
Link: https://lkml.kernel.org/r/20210808003011.4037f8d0@oasis.local.home
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: stable@vger.kernel.org
Fixes: 50450603ec9cb tracing: Add 'onmax' hist trigger action support
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-08-26 08:36:20 -04:00
..
2021-08-26 08:36:17 -04:00
2021-07-31 08:19:37 +02:00
2021-03-04 10:26:10 +01:00
2020-11-18 19:20:32 +01:00
2021-06-16 11:59:44 +02:00
2021-04-14 08:24:10 +02:00
2021-08-18 08:57:02 +02:00
2019-08-19 13:03:37 +02:00
2021-07-14 16:53:15 +02:00
2021-03-30 14:35:28 +02:00
2021-03-04 10:26:50 +01:00
2021-07-20 16:10:41 +02:00
2021-07-25 14:35:13 +02:00
2021-08-12 13:21:03 +02:00
2021-08-26 08:36:20 -04:00
2021-05-11 14:04:16 +02:00
2019-04-04 21:04:13 -04:00
2019-06-05 17:37:17 +02:00
2019-05-30 11:26:37 -07:00
2019-04-26 13:51:03 -04:00
2020-10-01 13:17:32 +02:00
2020-06-22 09:30:59 +02:00
2020-06-22 09:30:59 +02:00
2020-06-22 09:30:59 +02:00
2019-05-28 17:46:43 -04:00
2019-06-05 17:37:17 +02:00
2019-01-25 11:22:43 -08:00
2019-06-19 17:09:55 +02:00
2019-07-30 18:34:15 +02:00
2019-05-21 10:50:45 +02:00
2020-06-22 09:31:22 +02:00
2021-07-19 08:53:15 +02:00
2019-06-19 17:09:06 +02:00
2019-05-21 10:50:45 +02:00
2020-01-17 19:48:42 +01:00
2019-05-21 11:52:39 +02:00
2020-11-18 19:20:31 +01:00
2019-08-21 22:23:48 +10:00
2020-11-24 13:29:18 +01:00
2021-01-09 13:44:55 +01:00
2019-10-06 09:11:37 -06:00
2021-06-30 08:47:55 -04:00
2020-09-03 11:27:10 +02:00
2019-05-21 10:50:45 +02:00
2019-07-12 11:05:40 -07:00
2019-05-21 10:50:45 +02:00
2019-08-29 15:10:10 +01:00
2020-07-16 08:16:44 +02:00
2021-01-09 13:44:55 +01:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-05-21 10:50:46 +02:00
2019-07-22 18:05:11 +02:00
2019-03-07 18:32:02 -08:00
2021-02-03 23:25:56 +01:00
2019-09-06 23:58:44 +02:00
2021-05-19 10:08:28 +02:00
2019-08-19 21:54:15 -07:00
2019-05-24 20:16:01 +02:00
2020-04-17 10:50:22 +02:00
2021-02-13 13:52:54 +01:00
2019-05-30 11:26:39 -07:00
2021-07-14 16:53:19 +02:00
2019-06-05 17:37:17 +02:00
2021-05-11 14:04:16 +02:00
2021-04-07 14:47:38 +02:00
2021-04-07 14:47:38 +02:00
2019-05-24 17:27:11 +02:00
2021-06-30 08:47:42 -04:00
2020-10-01 13:17:23 +02:00
2019-06-05 17:37:17 +02:00
2020-06-17 16:40:22 +02:00
2019-10-07 15:47:19 -07:00
2019-08-19 21:54:16 -07:00
2019-07-18 17:08:07 -07:00
2019-07-16 19:23:24 -07:00
2019-05-21 10:50:45 +02:00
2021-05-26 12:05:15 +02:00
2020-11-18 19:20:30 +01:00
2020-08-26 10:40:51 +02:00
2020-06-24 17:50:35 +02:00
2019-05-27 09:36:28 -05:00
2021-03-04 10:26:45 +01:00
2020-11-10 12:37:24 +01:00
2021-05-14 09:44:33 +02:00
2021-02-07 15:35:49 +01:00
2019-07-08 11:01:13 -07:00
2018-12-05 19:31:44 -08:00
2019-11-04 21:19:25 +01:00
2019-10-17 12:47:12 +02:00
2019-06-21 01:54:53 +02:00
2020-10-01 13:17:23 +02:00
2019-01-04 13:13:47 -08:00
2020-10-01 13:17:10 +02:00
2021-03-17 17:03:45 +01:00
2020-01-09 10:19:54 +01:00
2019-05-21 11:52:39 +02:00
2019-08-01 14:30:22 -07:00
2021-07-14 16:53:08 +02:00
2019-05-30 11:26:37 -07:00
2019-07-18 17:08:07 -07:00
2020-10-14 10:32:58 +02:00
2021-05-14 09:44:33 +02:00
2019-07-08 19:36:47 -07:00
2019-05-21 10:50:45 +02:00
2019-07-08 19:36:47 -07:00
2019-06-05 17:37:17 +02:00
2019-06-05 17:37:17 +02:00
2019-04-19 09:46:05 -07:00
2020-02-24 08:36:52 +01:00
2019-04-16 16:55:15 +02:00
2021-07-31 08:19:37 +02:00