Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1237161

[PATCH v1] perf report: Fix owner error when reading perf.data

From Taeung Song <treeze.taeung@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v1] perf report: Fix owner error when reading perf.data
Date 2015-10-01 11:10 +0200
Message-ID <qeI2e-7Z7-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


If perf.data file is owned by some user,
it can't be read even if current user is root.
A 'st_uid' from fstat() is user ID of the file owner.
Therefore use getuid() instead of st_uid to check if
user of the calling 'perf' process is root or not.

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
 tools/perf/util/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 1921942..91ebe4e 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -67,7 +67,7 @@ static int open_file_read(struct perf_data_file *file)
 	if (fstat(fd, &st) < 0)
 		goto out_close;
 
-	if (!file->force && st.st_uid && (st.st_uid != geteuid())) {
+	if (!file->force && getuid() && (st.st_uid != geteuid())) {
 		pr_err("File %s not owned by current user or root (use -f to override)\n",
 		       file->path);
 		goto out_close;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v1] perf report: Fix owner error when reading perf.data Taeung Song <treeze.taeung@gmail.com> - 2015-10-01 11:10 +0200
  Re: [PATCH v1] perf report: Fix owner error when reading perf.data Ingo Molnar <mingo@kernel.org> - 2015-10-01 11:20 +0200
    Re: [PATCH v1] perf report: Fix owner error when reading perf.data Taeung Song <treeze.taeung@gmail.com> - 2015-10-01 14:30 +0200
      Re: [PATCH v1] perf report: Fix owner error when reading perf.data Arnaldo Carvalho de Melo <acme@kernel.org> - 2015-10-01 15:00 +0200

csiph-web