Steven Rostedt (Google)
6e36373aa5
tracing: Free error logs of tracing instances
commit 3357c6e429643231e60447b52ffbb7ac895aca22 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-20 12:10:23 +02:00
..
2023-04-05 11:23:35 +02:00
2022-12-14 11:31:57 +01:00
2020-04-07 10:43:42 -07:00
2022-05-30 09:33:22 +02:00
2022-10-05 10:38:40 +02:00
2023-01-04 11:39:22 +01:00
2023-04-20 12:10:23 +02:00
2023-01-14 10:15:20 +01:00
2023-01-14 10:16:24 +01:00
2023-03-17 08:45:08 +01:00
2023-04-05 11:23:44 +02:00
2022-10-26 13:25:14 +02:00
2022-08-21 15:15:33 +02:00
2023-03-11 16:39:51 +01:00
2022-04-08 14:40:08 +02:00
2023-03-11 16:39:49 +01:00
2023-04-05 11:23:45 +02:00
2023-03-11 16:39:50 +01:00
2023-04-20 12:10:23 +02:00
2021-05-11 14:47:37 +02:00
2023-01-14 10:16:14 +01:00
2022-02-23 12:01:00 +01:00
2022-08-31 17:15:13 +02:00
2021-09-03 10:09:31 +02:00
2020-12-30 11:54:18 +01:00
2022-02-08 18:30:34 +01:00
2022-04-08 14:40:00 +02:00
2020-08-23 17:36:59 -05:00
2022-04-08 14:40:00 +02:00
2020-07-30 11:15:58 -07:00
2020-10-13 09:17:34 -07:00
2023-04-05 11:23:45 +02:00
2020-06-11 15:14:36 +02:00
2021-09-15 09:50:40 +02:00
2023-01-14 10:15:20 +01:00
2021-06-23 14:42:52 +02:00
2020-04-15 11:21:54 +02:00
2021-09-08 08:49:00 +02:00
2023-02-01 08:23:21 +01:00
2020-04-07 10:43:42 -07:00
2023-03-11 16:40:18 +01:00
2023-03-17 08:45:06 +01:00
2021-04-07 15:00:14 +02:00
2020-06-06 23:42:01 +09:00
2020-10-13 09:17:34 -07:00
2020-11-02 12:14:19 -08:00
2020-05-28 10:54:15 +02:00
2021-07-20 16:05:58 +02:00
2020-10-25 14:51:49 -07:00
2021-01-09 13:46:24 +01:00
2020-08-12 10:58:02 -07:00
2021-02-03 23:28:37 +01:00
2022-07-21 21:20:11 +02:00
2020-10-05 13:37:03 +02:00
2020-08-12 10:58:01 -07:00
2023-03-11 16:39:59 +01:00
2021-09-03 10:09:31 +02:00
2020-04-27 02:07:40 -04:00
2023-01-14 10:15:20 +01:00
2021-03-25 09:04:11 +01:00
2021-03-25 09:04:11 +01:00
2023-02-01 08:23:22 +01:00
2020-09-01 09:58:03 +02:00
2020-07-08 11:14:22 +02:00
2023-01-14 10:15:51 +01:00
2023-02-01 08:23:21 +01:00
2020-10-29 17:22:59 -05:00
2023-03-11 16:39:19 +01:00
2021-01-09 13:46:24 +01:00
2022-08-21 15:16:05 +02:00
2022-06-09 10:20:49 +02:00
2020-10-16 11:11:19 -07:00
2020-11-14 11:26:03 -08:00
2020-07-27 14:31:12 -04:00
2023-01-14 10:15:22 +01:00
2023-03-11 16:40:04 +01:00
2022-04-08 14:40:03 +02:00
2022-06-09 10:21:01 +02:00
2020-08-07 11:33:25 -07:00
2021-08-18 08:59:06 +02:00
2023-01-04 11:39:23 +01:00
2022-04-20 09:23:29 +02:00
2021-07-14 16:55:50 +02:00
2020-09-16 15:18:56 +02:00
2022-02-23 12:01:00 +01:00
2020-09-18 14:24:16 +01:00
2021-09-08 08:49:00 +02:00
2020-10-26 12:12:27 +01:00
2022-08-31 17:15:13 +02:00
2023-01-24 07:19:58 +01:00
2023-02-01 08:23:18 +01:00
2023-01-04 11:39:23 +01:00
2020-10-02 19:11:12 -07:00
2020-06-29 12:01:45 -07:00
2021-09-03 10:09:30 +02:00
2022-01-27 10:54:33 +01:00
2021-09-08 08:49:00 +02:00
2020-10-06 10:31:52 -07:00
2021-05-14 09:50:46 +02:00
2021-09-08 08:49:00 +02:00
2020-06-04 19:06:24 -07:00
2021-03-30 14:32:03 +02:00
2020-04-27 02:07:40 -04:00
2020-05-09 13:57:12 +02:00
2023-03-17 08:45:13 +01:00
2022-08-25 11:38:20 +02:00
2022-09-28 11:10:40 +02:00