Re: [PATCH 5/5] perf dso: Replace assert with runtime check in dso__read_symbol()
| Newsgroups | org.kernel.vger.linux-perf-users |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Misleading error code used for bounds check failure. -- --- Patch [5]: [PATCH 5/5] perf dso: Replace assert with runtime check in dso__read_symbol() --- commit 99fef42823fa80b278999b8901d74d88e812bd2a Author: Arnaldo Carvalho de Melo <[email protected]> perf dso: Replace assert with runtime check in dso__read_symbol() This commit replaces an assert in dso__read_symbol() with a runtime bounds check to prevent out-of-bounds heap reads or assertion failures when processing untrusted perf.data files. > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c > index 4dd64069c4348..42bfe30a3b518 100644 > --- a/tools/perf/util/dso.c > +++ b/tools/perf/util/dso.c > @@ -2038,7 +2038,12 @@ const u8 *dso__read_symbol(struct dso *dso, const char *symfs_filename, > errno = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF; > return NULL; > } > - assert(len <= info_linear->info.jited_prog_len); > + if (len > info_linear->info.jited_prog_len) { > + pr_debug("BPF symbol length %zu exceeds jited_prog_len %u\n", > + len, info_linear->info.jited_prog_len); > + errno = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF; [Severity: Medium] Since this is a bounds check failure in dso__read_symbol() triggered by a corrupted perf.data file, reusing SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF might cause tools to incorrectly report that the BPF file is missing its BTF section instead of indicating a length mismatch. Could this regression result in a confusing message for the user? > + return NULL; > + } > *out_buf_len = len; > return (const u8 *)(uintptr_t)(info_linear->info.jited_prog_insns); > #else -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5