Re: [PATCH 1/5] perf dso: Guard against errno==0 when dso__get_filename() returns NULL
| Newsgroups | org.kernel.vger.linux-perf-users |
|---|---|
| Message-ID | <[email protected]> |
> From: Arnaldo Carvalho de Melo <[email protected]> > > __open_dso() computes fd = -errno when dso__get_filename() returns NULL. > Some failure paths in dso__get_filename() (e.g. binary type mismatch) > return NULL without making a syscall, leaving errno at 0 from a prior > successful call. fd = -0 = 0, which is stdin — subsequent code treats > it as a valid file descriptor. > > Fall back to ENOENT when errno is 0, ensuring fd is always negative on > failure. > > The forced ENOENT stays in errno for the callers that check it after a > negative fd. It must not misdirect the try_to_open_dso() fallback > loop, though: dso__get_filename()'s chroot fallback used to accept a > stale ENOENT even when stat() succeeded on a non-regular file (e.g. a > directory). Re-stat() there and only take the chroot path when > stat() actually failed with ENOENT [sashiko-bot review of PATCH 1/5]. > > Fixes: eba5102d2f0b ("perf tools: Add global list of opened dso objects") > Reported-by: sashiko-bot <[email protected]> > Cc: Jiri Olsa <[email protected]> > Reviewed-by: Ian Rogers <[email protected]> > Assisted-by: Claude:claude-opus-4.6 > Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Sashiko has reviewed this patch and found no issues. It looks great! -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1