tools lib traceevent: Fix double free in event_read_fields()
PATCH 1/1 tools lib traceevent: Fix double free in event_read_fields()
There is a double free in event_read_fields(). After calling free_token() to free the token, if append() failed, then goto fail, which will call free_token() again. Triggered by compiling with perf and run "perf sched record". Fix the double free by goto fail_expect instead of fail while append() failed, which won't call redundant free_token().
BUG: double free
free(): double free detected in tcache 2
Aborted
--- tools/lib/traceevent/event-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
@@ -1594,7 +1594,7 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field ** ret =append (&brackets,"" ,"]" );if (ret <0 ) {free (brackets); - goto fail; + goto fail_expect; }/* add brackets to type */
Signature · 1 line
2.17.1
Quoted 6 lines · On Mon, 17 Oct 2022 16:59:37 +0800 Shang XiaoJing <[email protected]>…
There is a double free in
event_read_fields(). After callingfree_token()to free the token, ifappend()failed, then goto fail, which will callfree_token()again. Triggered by compiling with perf and run "perf sched record". Fix the double free by gotofail_expectinstead of fail whileappend()failed, which won't call redundantfree_token().
Quoted 8 lines
BUG: double free
free(): double free detected in tcache 2
AbortedFixes d286447f23cd ("tools lib traceevent: Handle realloc() failure path")Signed-off-by Shang XiaoJing <[email protected]>--- tools/lib/traceevent/event-parse.c | 2 +-
tool/lib/traceevent is deprecated.
Can you send this patch to [email protected] against
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Thanks!
-- Steve
Quoted 15 lines
1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/traceevent/event-parse.c +1
-1@@ -1594,7 +1594,7 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field ** ret =append (&brackets,"" ,"]" );if (ret <0 ) {free (brackets); - goto fail; + goto fail_expect; }/* add brackets to type */
Quoted 18 lines · Steven Rostedt
Quoted 6 lines · On Mon, 17 Oct 2022 16:59:37 +0800 Shang XiaoJing <[email protected]>…
There is a double free in
event_read_fields(). After callingfree_token()to free the token, ifappend()failed, then goto fail, which will callfree_token()again. Triggered by compiling with perf and run "perf sched record". Fix the double free by gotofail_expectinstead of fail whileappend()failed, which won't call redundantfree_token().Quoted 8 lines
BUG: double free
free(): double free detected in tcache 2
AbortedFixes d286447f23cd ("tools lib traceevent: Handle realloc() failure path")Signed-off-by Shang XiaoJing <[email protected]>--- tools/lib/traceevent/event-parse.c | 2 +-
Quoted 6 lines
tool/lib/traceevent is deprecated.
Can you send this patch to [email protected] against
https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
ok, thanks for the reminder.
Thanks,
Signature · 1 line
Shang XiaoJing