Linux Perf Users
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v3 4/4] perf test: Update PE file test for other locations
Date: Mon, 12 Oct 2026 23:25:36 -0700	[thread overview]
Message-ID: <as3O4IjPoB9v_Srl@z2> (raw)
In-Reply-To: <sashiko-outbox-168781@kernel.org>

On Tue, Oct 13, 2026 at 12:08:54AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] perf test: unconditional leak of get_argv_exec_path() and NULL deref
> --
> 
> commit 9107444f4267d3db60d0e4c357f3b28957bdb1bc
> Author: Namhyung Kim <namhyung@kernel.org>
> 
> perf test: Update PE file test for other locations
> 
> This commit updates the PE file parsing test to check multiple directory paths
> for the test data. The logic is modified to try other paths similar to the
> shell_tests__dir_fd() fallback mechanism.
> 
> > diff --git a/tools/perf/tests/pe-file-parsing.c b/tools/perf/tests/pe-file-parsing.c
> > index 3979f38bf127c..190520ffc3ad6 100644
> > --- a/tools/perf/tests/pe-file-parsing.c
> > +++ b/tools/perf/tests/pe-file-parsing.c
> > @@ -74,17 +74,20 @@ static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
> >  {
> >  	struct stat st;
> >  	char path_dir[PATH_MAX];
> > -
> > -	/* First try development tree tests. */
> > -	if (!lstat("./tests", &st))
> > -		return run_dir("./tests");
> > -
> > -	/* Then installed path. */
> > +	const char * const tests_dirs[] = {
> > +		"./tools/perf/tests",
> > +		"./tests",
> > +		"./source/tests",
> > +		path_dir,
> > +	};
> >  	snprintf(path_dir, PATH_MAX, "%s/tests", get_argv_exec_path());
> 
> [Severity: Low]
> Can this code in test__pe_file_parsing() lead to a memory leak and a potential
> NULL pointer dereference?
> 
> The get_argv_exec_path() function returns a dynamically allocated string that
> must be freed by the caller. Passing it directly to snprintf() inline causes
> the pointer to be permanently lost.
> 
> Additionally, since the patch moved this snprintf() call before the directory
> search loop, it now unconditionally allocates this string even if an earlier
> directory in the tests_dirs array would have succeeded.
> 
> Furthermore, if get_argv_exec_path() fails under memory pressure and returns
> NULL, snprintf("%s") could crash on strictly compliant libcs like musl.

These are pre-existing issues, will fix separately.

Thanks,
Namhyung

> 
> >  
> > -	if (!lstat(path_dir, &st))
> > -		return run_dir(path_dir);
> > +	for (size_t i = 0; i < ARRAY_SIZE(tests_dirs); ++i) {
> > +		if (!lstat(tests_dirs[i], &st))
> > +			return run_dir(tests_dirs[i]);
> > +	}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20261012235938.87912-1-namhyung@kernel.org?part=4

  reply	other threads:[~2026-10-13  6:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 23:59 [PATCH v3 1/4] perf symbol: Fix symbol loading from libbfd Namhyung Kim
2026-10-12 23:59 ` [PATCH v3 2/4] iperf symbol: Add missing symsrc__destroy() for libbfd Namhyung Kim
2026-10-13  0:04   ` sashiko-bot
2026-10-12 23:59 ` [PATCH v3 3/4] perf symbol: Set dso symtab type " Namhyung Kim
2026-10-13  0:08   ` sashiko-bot
2026-10-13  6:23     ` Namhyung Kim
2026-10-12 23:59 ` [PATCH v3 4/4] perf test: Update PE file test for other locations Namhyung Kim
2026-10-13  0:08   ` sashiko-bot
2026-10-13  6:25     ` Namhyung Kim [this message]
2026-10-13  0:08 ` [PATCH v3 1/4] perf symbol: Fix symbol loading from libbfd sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=as3O4IjPoB9v_Srl@z2 \
    --to=namhyung@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox