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-03-21 12:43:05 -07:00
2023-02-21 18:24:12 -08:00
2022-12-01 00:09:20 +01:00
2022-12-02 11:25:00 +01:00
2023-03-22 09:03:17 +01:00
2023-03-21 15:13:15 +01:00
2023-03-15 21:49:47 +01:00
2023-01-01 11:15:05 -08:00
2022-12-21 14:31:52 -08:00
2023-03-05 11:19:16 -08:00
2023-03-23 17:18:35 -07:00
2023-02-23 14:00:10 -08:00
2023-02-21 10:45:51 -08:00
2023-02-23 14:05:08 -08:00
2023-02-15 20:06:26 +01:00
2023-02-23 13:49:45 -08:00
2023-02-02 16:40:07 -08:00
2023-03-21 14:43:04 +01:00
2023-02-21 09:45:13 -08:00
2023-04-05 09:54:37 -04:00
2022-11-30 16:13:18 -08:00
2022-08-22 18:50:06 -04:00
2022-04-25 14:37:28 +02:00
2022-09-01 17:39:30 -04:00
2022-08-29 19:47:03 -04:00
2022-09-07 11:30:15 -04:00
2023-03-01 10:01:22 -08:00
2022-09-26 19:46:09 -07:00
2023-03-01 10:01:22 -08:00
2022-09-26 10:13:13 -07:00
2023-03-14 19:32:38 -07:00
2023-01-13 11:48:18 +01:00
2023-01-13 11:48:15 +01:00
2022-12-02 12:43:02 +01:00
2023-02-02 22:32:59 -08:00
2022-11-01 10:04:52 -07:00
2022-09-26 19:46:07 -07:00
2023-02-21 15:27:48 -08:00
2022-07-05 13:32:59 -07:00
2023-02-08 13:36:22 +01:00
2023-03-25 12:57:34 -07:00
2022-09-07 21:53:50 +02:00
2023-01-22 23:43:34 +09:00
2022-07-15 18:21:49 +00:00
2023-02-09 17:03:20 -08:00
2022-04-15 14:49:55 -07:00
2022-12-01 15:53:05 -08:00
2022-11-12 18:47:36 -08:00
2023-01-13 15:09:08 -08:00
2022-11-15 00:42:02 -08:00
2022-11-15 00:42:02 -08:00
2022-03-31 10:36:55 +02:00
2023-02-09 16:51:39 -08:00
2023-02-23 17:55:40 -08:00
2023-02-02 22:50:05 -08:00
2022-09-11 21:55:06 -07:00
2023-02-02 22:50:05 -08:00
2023-02-21 08:49:16 +09:00
2023-01-20 14:30:45 +01:00
2023-02-02 22:50:02 -08:00
2022-09-11 21:55:12 -07:00
2022-12-23 12:00:24 -08:00
2023-02-02 16:26:06 -08:00
2022-10-25 15:15:52 -07:00
2022-12-19 12:33:32 -06:00
2023-03-02 21:54:23 -08:00
2023-01-25 14:07:21 -08:00
2023-02-23 17:09:35 -08:00
2023-01-18 17:12:37 -08:00
2022-06-29 13:07:16 +02:00
2022-09-11 21:55:12 -07:00
2022-12-27 12:52:10 +01:00
2022-10-04 15:59:36 +02:00
2023-02-09 16:51:39 -08:00
2023-02-17 14:58:01 -08:00
2022-12-27 12:52:12 +01:00
2022-04-11 17:07:29 -07:00
2022-11-09 18:06:35 +00:00
2023-01-13 17:01:06 -08:00
2022-12-27 12:52:11 +01:00
2022-10-10 12:49:34 -07:00
2022-09-11 21:55:10 -07:00
2022-07-05 13:32:59 -07:00
2022-05-08 01:33:09 -07:00
2022-10-17 16:41:16 +02:00
2022-04-05 09:59:38 +02:00
2022-05-24 11:11:13 -07:00
2022-08-20 15:17:45 -07:00
2023-02-23 17:09:35 -08:00
2022-09-08 16:56:45 -07:00
2023-02-21 13:34:07 -08:00
2022-09-11 21:55:10 -07:00
2022-08-29 12:47:15 +01:00
2023-01-05 12:10:35 -08:00
2023-02-18 14:34:36 -05:00
2022-04-29 14:38:03 -07:00
2022-05-18 18:24:57 -05:00
2023-03-03 16:18:19 -08:00
2023-02-02 22:50:04 -08:00
2022-11-30 20:16:49 -04:00
2022-05-19 23:25:47 -04:00
2022-10-23 12:01:01 -07:00
2023-03-08 11:44:45 +01:00
2022-06-23 18:41:40 +02:00
2022-08-06 16:38:17 -07:00
2023-01-13 07:50:40 -10:00