mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
perf trace: Use zfree() to reduce chances of use after free
[ Upstream commit9997d5dd17] Do defensive programming by using zfree() to initialize freed pointers to NULL, so that eventual use after free result in a NULL pointer deref instead of more subtle behaviour. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Stable-dep-of:7962ef1365("perf trace: Really free the evsel->priv area") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
eb17c3d005
commit
e5dee8222d
@@ -2293,7 +2293,7 @@ static void syscall__exit(struct syscall *sc)
|
|||||||
if (!sc)
|
if (!sc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
free(sc->arg_fmt);
|
zfree(&sc->arg_fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
|
static int trace__sys_enter(struct trace *trace, struct evsel *evsel,
|
||||||
@@ -3129,7 +3129,7 @@ static void evlist__free_syscall_tp_fields(struct evlist *evlist)
|
|||||||
if (!et || !evsel->tp_format || strcmp(evsel->tp_format->system, "syscalls"))
|
if (!et || !evsel->tp_format || strcmp(evsel->tp_format->system, "syscalls"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
free(et->fmt);
|
zfree(&et->fmt);
|
||||||
free(et);
|
free(et);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4765,11 +4765,11 @@ static void trace__exit(struct trace *trace)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
strlist__delete(trace->ev_qualifier);
|
strlist__delete(trace->ev_qualifier);
|
||||||
free(trace->ev_qualifier_ids.entries);
|
zfree(&trace->ev_qualifier_ids.entries);
|
||||||
if (trace->syscalls.table) {
|
if (trace->syscalls.table) {
|
||||||
for (i = 0; i <= trace->sctbl->syscalls.max_id; i++)
|
for (i = 0; i <= trace->sctbl->syscalls.max_id; i++)
|
||||||
syscall__exit(&trace->syscalls.table[i]);
|
syscall__exit(&trace->syscalls.table[i]);
|
||||||
free(trace->syscalls.table);
|
zfree(&trace->syscalls.table);
|
||||||
}
|
}
|
||||||
syscalltbl__delete(trace->sctbl);
|
syscalltbl__delete(trace->sctbl);
|
||||||
zfree(&trace->perfconfig_events);
|
zfree(&trace->perfconfig_events);
|
||||||
|
|||||||
Reference in New Issue
Block a user