Steven Rostedt (Google)
3357c6e429
tracing: Free error logs of tracing instances
When a tracing instance is removed, the error messages that hold errors
that occurred in the instance needs to be freed. The following reports a
memory leak:
# cd /sys/kernel/tracing
# mkdir instances/foo
# echo 'hist:keys=x' > instances/foo/events/sched/sched_switch/trigger
# cat instances/foo/error_log
[ 117.404795] hist:sched:sched_switch: error: Couldn't find field
Command: hist:keys=x
^
# rmdir instances/foo
Then check for memory leaks:
# echo scan > /sys/kernel/debug/kmemleak
# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff88810d8ec700 (size 192):
comm "bash", pid 869, jiffies 4294950577 (age 215.752s)
hex dump (first 32 bytes):
60 dd 68 61 81 88 ff ff 60 dd 68 61 81 88 ff ff `.ha....`.ha....
a0 30 8c 83 ff ff ff ff 26 00 0a 00 00 00 00 00 .0......&.......
backtrace:
[<00000000dae26536>] kmalloc_trace+0x2a/0xa0
[<00000000b2938940>] tracing_log_err+0x277/0x2e0
[<000000004a0e1b07>] parse_atom+0x966/0xb40
[<0000000023b24337>] parse_expr+0x5f3/0xdb0
[<00000000594ad074>] event_hist_trigger_parse+0x27f8/0x3560
[<00000000293a9645>] trigger_process_regex+0x135/0x1a0
[<000000005c22b4f2>] event_trigger_write+0x87/0xf0
[<000000002cadc509>] vfs_write+0x162/0x670
[<0000000059c3b9be>] ksys_write+0xca/0x170
[<00000000f1cddc00>] do_syscall_64+0x3e/0xc0
[<00000000868ac68c>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
unreferenced object 0xffff888170c35a00 (size 32):
comm "bash", pid 869, jiffies 4294950577 (age 215.752s)
hex dump (first 32 bytes):
0a 20 20 43 6f 6d 6d 61 6e 64 3a 20 68 69 73 74 . Command: hist
3a 6b 65 79 73 3d 78 0a 00 00 00 00 00 00 00 00 :keys=x.........
backtrace:
[<000000006a747de5>] __kmalloc+0x4d/0x160
[<000000000039df5f>] tracing_log_err+0x29b/0x2e0
[<000000004a0e1b07>] parse_atom+0x966/0xb40
[<0000000023b24337>] parse_expr+0x5f3/0xdb0
[<00000000594ad074>] event_hist_trigger_parse+0x27f8/0x3560
[<00000000293a9645>] trigger_process_regex+0x135/0x1a0
[<000000005c22b4f2>] event_trigger_write+0x87/0xf0
[<000000002cadc509>] vfs_write+0x162/0x670
[<0000000059c3b9be>] ksys_write+0xca/0x170
[<00000000f1cddc00>] do_syscall_64+0x3e/0xc0
[<00000000868ac68c>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
The problem is that the error log needs to be freed when the instance is
removed.
Link: https://lore.kernel.org/lkml/76134d9f-a5ba-6a0d-37b3-28310b4a1e91@alu.unizg.hr/
Link: https://lore.kernel.org/linux-trace-kernel/20230404194504.5790b95f@gandalf.local.home
Cc: stable@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Thorsten Leemhuis <regressions@leemhuis.info>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Eric Biggers <ebiggers@kernel.org>
Fixes: 2f754e771b ("tracing: Have the error logs show up in the proper instances")
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Tested-by: Mirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
2023-04-05 09:54:37 -04:00
..
2023-01-25 10:31:02 -05:00
2023-02-21 09:23:22 -07:00
2023-02-21 18:24:12 -08:00
2022-06-03 14:05:34 -07:00
2022-11-04 08:50:07 +09:00
2023-03-19 10:46:02 -07:00
2023-02-23 10:20:49 -08:00
2023-03-19 12:20:48 -04:00
2022-07-30 14:01:28 -04:00
2022-04-26 17:58:50 -04:00
2021-10-05 17:38:45 -04:00
2022-11-18 10:15:34 +09:00
2022-11-23 19:08:30 -05:00
2023-04-03 11:51:38 -04:00
2023-02-18 14:34:09 -05:00
2022-09-26 13:01:09 -04:00
2022-09-26 13:01:09 -04:00
2022-05-26 21:13:00 -04:00
2022-11-23 19:07:12 -05:00
2021-08-18 18:10:32 -04:00
2023-02-24 10:04:13 +09:00
2022-11-23 19:08:31 -05:00
2023-01-25 10:31:11 -05:00
2023-03-09 22:17:06 -05:00
2021-12-06 15:37:21 -05:00
2023-04-03 11:51:12 -04:00
2022-12-14 08:50:56 -05:00
2022-12-15 18:01:16 -08:00
2023-02-23 10:20:49 -08:00
2023-02-12 10:23:39 -05:00
2021-10-13 18:19:41 -04:00
2021-10-27 11:21:49 -04:00
2023-03-19 13:23:22 -04:00
2021-07-27 17:05:06 +01:00
2023-02-24 10:04:13 +09:00
2023-04-03 11:52:46 -04:00
2023-01-24 11:27:29 -05:00
2023-01-31 15:01:46 +01:00
2021-10-08 18:08:43 -04:00
2023-02-24 09:44:27 +09:00
2023-02-24 10:04:13 +09:00
2023-02-24 09:44:15 +09:00
2023-02-24 09:44:15 +09:00
2022-05-26 21:12:52 -04:00
2022-05-12 00:37:11 +02:00
2022-05-12 00:37:11 +02:00
2022-10-17 16:41:19 +02:00
2023-02-07 12:42:54 -05:00
2021-10-08 18:08:43 -04:00
2021-10-08 18:08:43 -04:00
2023-01-25 10:31:24 -05:00
2022-11-17 20:21:06 -05:00
2023-02-24 10:04:13 +09:00
2023-04-05 09:54:37 -04:00
2023-02-25 12:49:29 -08:00
2022-10-03 12:20:31 -04:00