lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20241114171053.3112521-1-leo.yan@arm.com>
Date: Thu, 14 Nov 2024 17:10:52 +0000
From: Leo Yan <leo.yan@....com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	"Liang, Kan" <kan.liang@...ux.intel.com>,
	James Clark <james.clark@...aro.org>,
	linux-perf-users@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Leo Yan <leo.yan@....com>
Subject: [PATCH] perf: buildid: Print error for creating folder failure

The mkdir_p() function will fail to create a buildid cache folder if the
folder name is not an absolute path.  As a result, the cache folder is
empty after recording.

Print an error to remind users to use an absolute path name or check
permissions.  Update the documentation to reflect the requirement of
using an absolute path name.

After:

  # perf --buildid-dir debug_dir record -- test_program
    ...
    Failed to create build_id cache folder: debug_dir/[kernel.kallsyms]/5c81911cab18f69bab96f8a1fae64a9f1d83b104.
      Use an absolute path name or check permissions.

Signed-off-by: Leo Yan <leo.yan@....com>
---
 tools/perf/Documentation/perf-config.txt | 2 ++
 tools/perf/Documentation/perf.txt        | 4 ++--
 tools/perf/util/build-id.c               | 6 +++++-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/Documentation/perf-config.txt b/tools/perf/Documentation/perf-config.txt
index 379f9d7a8ab1..26d9b1dd2e8c 100644
--- a/tools/perf/Documentation/perf-config.txt
+++ b/tools/perf/Documentation/perf-config.txt
@@ -236,6 +236,8 @@ buildid.*::
 		cache location, or to disable it altogether. If you want to disable it,
 		set buildid.dir to /dev/null. The default is $HOME/.debug
 
+		This option must be an absolute path name.
+
 buildid-cache.*::
 	buildid-cache.debuginfod=URLs
 		Specify debuginfod URLs to be used when retrieving perf.data binaries,
diff --git a/tools/perf/Documentation/perf.txt b/tools/perf/Documentation/perf.txt
index cbcc2e4d557e..14c79bd7820a 100644
--- a/tools/perf/Documentation/perf.txt
+++ b/tools/perf/Documentation/perf.txt
@@ -37,8 +37,8 @@ OPTIONS
         Do not set pager.
 
 --buildid-dir::
-        Setup buildid cache directory. It has higher priority
-        than buildid.dir config file option.
+        Setup buildid cache directory with an absolute path name.
+        It has higher priority than buildid.dir config file option.
 
 --list-cmds::
         List the most commonly used perf commands.
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 8982f68e7230..a05d45ac1c87 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -637,8 +637,12 @@ build_id_cache__add(const char *sbuild_id, const char *name, const char *realnam
 		if (unlink(dir_name))
 			goto out_free;
 
-	if (mkdir_p(dir_name, 0755))
+	if (mkdir_p(dir_name, 0755)) {
+		pr_err("Failed to create build_id cache folder: %s.\n"
+		       "  Use an absolute path name or check permissions.\n",
+		       dir_name);
 		goto out_free;
+	}
 
 	/* Save the allocated buildid dirname */
 	if (asprintf(&filename, "%s/%s", dir_name,
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ