Skip to contentSkip to conversation

perf: fix temporary file ownership check

PATCH In review Vasiliy Kulikov 2 participants 3 messages Aug 11, 2011 – Aug 14, 2011 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: fix temporary file ownership check

A file in /tmp/ might be a symlink, so lstat() should be used instead of stat().

Cc Pekka Enberg <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 tools/perf/util/symbol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/symbol.c +1 -1
index a8b5371..5db39f6 100644
@@ -1506,7 +1506,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
 		struct stat st;
 
-		if (stat(dso->name, &st) < 0)
+		if (lstat(dso->name, &st) < 0)
 			return -1;
 
 		if (st.st_uid && (st.st_uid != geteuid())) {
Signature · 1 line
1.7.0.4
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Vasiliy Kulikov

A file in /tmp/ might be a symlink, so lstat() should be used instead of stat().

Cc Pekka Enberg <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Peter Zijlstra <[email protected]>
Quoted 17 lines
---
 tools/perf/util/symbol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/symbol.c +1 -1
index a8b5371..5db39f6 100644
@@ -1506,7 +1506,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
 		struct stat st;
 
-		if (stat(dso->name, &st) < 0)
+		if (lstat(dso->name, &st) < 0)
 			return -1;
 
 		if (st.st_uid && (st.st_uid != geteuid())) {
#2 lore raw
In reply to Vasiliy Kulikov
Commit-ID:  e9b52ef2228cd0bed7a4465c693a39489e2c338d
Gitweb:     http://git.kernel.org/tip/e9b52ef2228cd0bed7a4465c693a39489e2c338d
Author:     Vasiliy Kulikov <[email protected]>
AuthorDate: Fri, 12 Aug 2011 00:55:37 +0400
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 12 Aug 2011 08:28:17 -0300

perf: fix temporary file ownership check

A file in /tmp/ might be a symlink, so lstat() should be used instead of stat().

---
 tools/perf/util/symbol.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/symbol.c +1 -1
index e142c21..469c026 100644
@@ -1506,7 +1506,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
 	if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
 		struct stat st;
 
-		if (stat(dso->name, &st) < 0)
+		if (lstat(dso->name, &st) < 0)
 			return -1;
 
 		if (st.st_uid && (st.st_uid != geteuid())) {