Re: [PATCH 5/5] perf dso: Replace assert with runtime check in dso__read_symbol()
Arnaldo Carvalho de Melo <[email protected]>
| Newsgroups | org.kernel.vger.linux-perf-users,dev.linux.lists.sashiko-reviews |
|---|---|
| Message-ID | <an8F4aeumUKOJN8x@x1> |
On Thu, Aug 13, 2026 at 03:26:29PM +0000, [email protected] wrote: > > +++ 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? Some other cases near here are returning this error as well, we need to add more errors and update the associated symbol__strerror_disassemble to print the more precise error messages, probably SYMBOL_ANNOTATE_ERRNO__BPF_INVALID_BTF. I will add this to a TODO file for a new patch series improving this situation. - Arnaldo