[PATCHES v2 0/2] perf c2c hardening
Arnaldo Carvalho de Melo <[email protected]> Sun, 2 Aug 2026 22:11:38 -0300
| Newsgroups | org.kernel.vger.linux-perf-users,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Please consider merging,
Two hardening fixes for perf c2c found by the sashiko-bot AI reviewer.
Patch 1 fixes two silent failure modes in hpp_list__parse(): error masking
across successive PARSE_LIST invocations, and OOM from strdup() being
silently treated as empty input. The fix adds early exits, which exposed
a pre-existing problem: both callers of c2c_hists__reinit() had always
discarded its return value, so errors would now go undetected. Patch 1
also fixes the full caller chain: resort_cl_cb() now checks and propagates
the error, and perf_c2c__report() checks both c2c_hists__reinit() and
hists__iterate_cb() -- which already stops iteration on callback errors.
Patch 2 fixes a format list leak: when c2c_hists__init() fails partway
through, entries registered via perf_hpp_list__column_register() and
perf_hpp_list__register_sort_field() are left on the hpp_list.
perf_c2c_report() does not call perf_hpp__reset_output_field() on the
error path, so those entries leak. The fix moves cleanup into
c2c_hists__init() itself so all callers are protected.
Changes since v1 ([email protected]):
Patch 1:
- Addressed sashiko-bot [Medium] finding: the early exits added by v1
skip perf_hpp__setup_output_field(), making undetected errors in the
callers consequential. Fixed by propagating the error through
resort_cl_cb() and perf_c2c__report() (hists__iterate_cb() already
propagated callback return values).
- Dismissed sashiko-bot [Low] finding (missing string.h/stdlib.h):
strdup() and free() were already used in this function before this
patch; string2.h (included at the top of the file) pulls in string.h.
No new library calls were introduced.
- Subject updated to reflect the additional caller fixes.
This series was developed with AI assistance (Claude Sonnet 4.6).
- Arnaldo
Arnaldo Carvalho de Melo (2):
perf c2c: Fix error masking, OOM, and unchecked caller errors in
hpp_list__parse()
perf c2c: Clean up registered formats on c2c_hists__init() failure
tools/perf/builtin-c2c.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
--
2.55.0