perf/cgroup: correct indirection in perf_less_group_idx
Ian Rogers
reviewerPATCH 1/1 perf/cgroup: correct indirection in perf_less_group_idx
The void* in perf_less_group_idx is to a cell in the array which points at a perf_event*, as such it is a perf_event**.
Author: John Sperbeck <[email protected]>
--- kernel/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/events/core.c +2 -1
@@ -3503,7 +3503,8 @@ static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,static bool perf_less_group_idx (const void *l,const void *r) { -const struct perf_event *le = l, *re = r; +const struct perf_event *le = *(const struct perf_event **)l; +const struct perf_event *re = *(const struct perf_event **)r;return le->group_index < re->group_index; }
Signature · 1 line
2.25.1.696.g5e7596f4ac-goog
Peter Zijlstra
maintainerQuoted 5 lines · Ian Rogers
The void* in
perf_less_group_idxis to a cell in the array which points at a perf_event*, as such it is a perf_event**.Fixes 6eef8a7116de ("perf/core: Use min_heap in visit_groups_merge()")Author: John Sperbeck <[email protected]>
That doesn't make sense, did he write the patch? Then there needs to be a From: him and a SoB: him, If he reported the issue, it should be
Reported-by: him.
Quoted 10 lines
Signed-off-by Ian Rogers <[email protected]>--- kernel/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/events/core.c +0
-0
kernel/events/core.c static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx, · line 3507
Quoted 6 lines
kernel/events/core.c +2
-1@@ -3503,7 +3503,8 @@ static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,static bool perf_less_group_idx (const void *l,const void *r) { -const struct perf_event *le = l, *re = r; +const struct perf_event *le = *(const struct perf_event **)l; +const struct perf_event *re = *(const struct perf_event **)r;
How did this not insta explode?
Ian Rogers
reviewerQuoted 11 lines · Peter Zijlstra
Quoted 5 lines · Ian Rogers
The void* in
perf_less_group_idxis to a cell in the array which points at a perf_event*, as such it is a perf_event**.Fixes 6eef8a7116de ("perf/core: Use min_heap in visit_groups_merge()")Author: John Sperbeck <[email protected]>
That doesn't make sense, did he write the patch? Then there needs to be a From: him and a SoB: him, If he reported the issue, it should be
Reported-by: him.
Done.
https://lkml.org/lkml/2020/3/21/295
Quoted 11 lines
Quoted 11 lines
Signed-off-by Ian Rogers <[email protected]>--- kernel/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kernel/events/core.c +0
-0@@ -3503,7 +3503,8 @@ static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
Quoted 7 lines
kernel/events/core.c static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx, · line 3507
Quoted 5 lines
kernel/events/core.c +2
-1static bool perf_less_group_idx (const void *l,const void *r) { -const struct perf_event *le = l, *re = r; +const struct perf_event *le = *(const struct perf_event **)l; +const struct perf_event *re = *(const struct perf_event **)r;How did this not insta explode?
Agreed, a cgroup depth of at least 3 is needed for a heap allocation and we saw this with kasan. CONFIG_KASAN_STACK should have been able to catch this in the normal case.
Thanks,
Ian