Re: [PATCH] tools lib traceevent: Fix double free in event_read_fields()

From: shangxiaojing
Date: Thu Oct 20 2022 - 21:01:40 EST




On 2022/10/21 5:23, Steven Rostedt wrote:
On Mon, 17 Oct 2022 16:59:37 +0800
Shang XiaoJing <shangxiaojing@xxxxxxxxxx> wrote:

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

Fixes: d286447f23cd ("tools lib traceevent: Handle realloc() failure path")
Signed-off-by: Shang XiaoJing <shangxiaojing@xxxxxxxxxx>
---
tools/lib/traceevent/event-parse.c | 2 +-

tool/lib/traceevent is deprecated.

Can you send this patch to linux-trace-devel@xxxxxxxxxxxxxxx against

https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/

ok, thanks for the reminder.

Thanks,
--
Shang XiaoJing