perf annotate-data: Fix a buffer overflow in TUI browser
A message that is not in the archive (sent off-list or not yet received): CA+JHD90ZChq4FFyrqVYE9RvK=K2sKoD6T5dyYknK=STST9_AEQ@mail.gmail.com
Namhyung Kim
maintainerPATCH 1/1 perf annotate-data: Fix a buffer overflow in TUI browser
In get_member_overhead(), k is updated when it has a entry in the histogram. But the entry->hists array is allocated with the number of evsel in the group. So the k should be reset when it iterates the event using for_each_group_evsel(), otherwise it'd crash due to a buffer overflow.
--- tools/perf/ui/browsers/annotate-data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/ui/browsers/annotate-data.c +2 -1
@@ -46,11 +46,12 @@ static int get_member_overhead(struct annotated_data_type *adt,struct annotated_member *member = entry->data;int i, k; -for (i =0 , k =0 ; i < member->size; i++) { +for (i =0 ; i < member->size; i++) {struct type_hist *h;struct evsel *evsel;int offset = member->offset + i; + k =0 ;for_each_group_evsel (evsel, leader) {if (symbol_conf.skip_empty &&evsel__hists (evsel)->stats.nr_samples ==0 )
Signature · 1 line
2.46.0.76.ge559c4bf1a-goog
Quoted 7 lines · Namhyung Kim
In
get_member_overhead(), k is updated when it has a entry in the histogram. But theentry->histsarray is allocated with the number of evsel in the group. So the k should be reset when it iterates the event usingfor_each_group_evsel(), otherwise it'd crash due to a buffer overflow.Fixes cb1898f58e0f ("perf annotate-data: Support --skip-empty option")
Thanks, applied to perf-tools-next,
- Arnaldo
Quoted 25 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/ui/browsers/annotate-data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/perf/ui/browsers/annotate-data.c +2
-1@@ -46,11 +46,12 @@ static int get_member_overhead(struct annotated_data_type *adt,struct annotated_member *member = entry->data;int i, k; -for (i =0 , k =0 ; i < member->size; i++) { +for (i =0 ; i < member->size; i++) {struct type_hist *h;struct evsel *evsel;int offset = member->offset + i; + k =0 ;for_each_group_evsel (evsel, leader) {if (symbol_conf.skip_empty &&evsel__hists (evsel)->stats.nr_samples ==0 )Signature · 1 line
2.46.0.76.ge559c4bf1a-goog