perf tools: Check '/tmp/perf-' symbol file ownership
PATCH 1/1 perf tools: Check '/tmp/perf-' symbol file ownership
The external symbol files are generated by JIT compilers, for example, but we need to make sure they're ours before injecting them to 'perf report'.
--- tools/perf/util/symbol.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
tools/perf/util/symbol.c +11 -0
@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) dso->adjust_symbols =0 ;if (strncmp (dso->name,"/tmp/perf-" ,10 ) ==0 ) { +struct stat st; + +if (stat (dso->name, &st) <0 ) +return -1 ; + +if (st.st_uid && (st.st_uid !=geteuid ())) { +pr_warning ("File %s not owned by current user or root, " +"ignoring it.\n" , dso->name); +return -1 ; + } + ret =dso__load_perf_map (dso, map, filter); dso->symtab_type = ret >0 ?SYMTAB__JAVA_JIT :SYMTAB__NOT_FOUND ;
Signature · 1 line
1.7.0.4
Quoted 7 lines · Pekka Enberg
The external symbol files are generated by JIT compilers, for example, but we need to make sure they're ours before injecting them to 'perf report'.
Cc Arnaldo Carvalho de Melo <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Pekka Enberg <[email protected]>
Doh - I forgot to CC Ingo who asked for this in the first place...
Quoted 35 lines
---
tools/perf/util/symbol.c | 11 +++++++++++1 files changed, 11 insertions(+), 0 deletions(-)tools/perf/util/symbol.c +11
-0@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) dso->adjust_symbols = 0; if (strncmp(dso->name, "/tmp/perf-", 10) == 0) { + struct stat st; + + if (stat(dso->name, &st) < 0) + return -1; + + if (st.st_uid && (st.st_uid != geteuid())) { + pr_warning("File %s not owned by current user or root, " + "ignoring it.\n", dso->name); + return -1; + } + ret = dso__load_perf_map(dso, map, filter);dso->symtab_type = ret > 0 ?
SYMTAB__JAVA_JIT:
SYMTAB__NOT_FOUND; --
1.7.0.4--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[tip:perf/urgent] perf symbols: Check '/tmp/perf-' symbol file ownership
In reply to Pekka EnbergCommit-ID: 981c1252691f4b855f2bb47ea93fb6052ea3aee2 Gitweb: http://git.kernel.org/tip/981c1252691f4b855f2bb47ea93fb6052ea3aee2 Author: Pekka Enberg <[email protected]> AuthorDate: Tue, 9 Aug 2011 22:54:18 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 9 Aug 2011 15:23:08 -0300
perf symbols: Check '/tmp/perf-' symbol file ownership
The external symbol files are generated by JIT compilers, for example, but we need to make sure they're ours before injecting them to 'perf report'.
--- tools/perf/util/symbol.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
tools/perf/util/symbol.c +11 -0
@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) dso->adjust_symbols =0 ;if (strncmp (dso->name,"/tmp/perf-" ,10 ) ==0 ) { +struct stat st; + +if (stat (dso->name, &st) <0 ) +return -1 ; + +if (st.st_uid && (st.st_uid !=geteuid ())) { +pr_warning ("File %s not owned by current user or root, " +"ignoring it.\n" , dso->name); +return -1 ; + } + ret =dso__load_perf_map (dso, map, filter); dso->symtab_type = ret >0 ?SYMTAB__JAVA_JIT :SYMTAB__NOT_FOUND ;
Re: [tip:perf/urgent] perf symbols: Check '/tmp/perf-' symbol file ownership
Quoted 30 lines · tip-bot for Pekka Enberg
Commit-ID: 981c1252691f4b855f2bb47ea93fb6052ea3aee2 Gitweb: http://git.kernel.org/tip/981c1252691f4b855f2bb47ea93fb6052ea3aee2 Author: Pekka Enberg <[email protected]> AuthorDate: Tue, 9 Aug 2011 22:54:18 +0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 9 Aug 2011 15:23:08 -0300perf symbols: Check '
/tmp/perf-' symbol file ownershipThe external symbol files are generated by JIT compilers, for example, but we need to make sure they're ours before injecting them to 'perf report'.
Requested-by Ingo Molnar <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Pekka Enberg <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/perf/util/symbol.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)tools/perf/util/symbol.c +0
-0@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) dso->adjust_symbols =0 ;if (strncmp (dso->name,"/tmp/perf-" ,10 ) ==0 ) {
tools/perf/util/symbol.c int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · line 1516
Quoted 10 lines
tools/perf/util/symbol.c +10
-0+struct stat st; + +if (stat (dso->name, &st) <0 ) +return -1 ; + +if (st.st_uid && (st.st_uid !=geteuid ())) { +pr_warning ("File %s not owned by current user or root, " +"ignoring it.\n" , dso->name); +return -1 ; + }
Is the force option relevant here -- similar to perf_session__open()?
David
Quoted 9 lines
tools/perf/util/symbol.c +1
-1+ ret =dso__load_perf_map (dso, map, filter); dso->symtab_type = ret >0 ?SYMTAB__JAVA_JIT :SYMTAB__NOT_FOUND ; --To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [tip:perf/urgent] perf symbols: Check '/tmp/perf-' symbol file ownership
Quoted 30 lines · David Ahern
Quoted 29 lines · tip-bot for Pekka Enberg
Commit-ID: 981c1252691f4b855f2bb47ea93fb6052ea3aee2
Gitweb: http://git.kernel.org/tip/981c1252691f4b855f2bb47ea93fb6052ea3aee2
Author: Pekka Enberg <[email protected]>
AuthorDate: Tue, 9 Aug 2011 22:54:18 +0300
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 9 Aug 2011 15:23:08 -0300perf symbols: Check '
/tmp/perf-' symbol file ownershipThe external symbol files are generated by JIT compilers, for example, but we need to make sure they're ours before injecting them to 'perf report'.
Requested-by Ingo Molnar <[email protected]>Cc Frederic Weisbecker <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Pekka Enberg <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>---
tools/perf/util/symbol.c | 11 +++++++++++1 files changed, 11 insertions(+), 0 deletions(-)tools/perf/util/symbol.c +0
-0@@ -1504,6 +1504,17 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) dso->adjust_symbols = 0;
Quoted 13 lines
tools/perf/util/symbol.c int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · line 1516
Quoted 11 lines
tools/perf/util/symbol.c +10
-0if (strncmp(dso->name, "/tmp/perf-", 10) == 0) { + struct stat st; + + if (stat(dso->name, &st) < 0) + return -1; + + if (st.st_uid && (st.st_uid != geteuid())) { + pr_warning("File %s not owned by current user or root, " + "ignoring it.\n", dso->name); + return -1; + }Is the force option relevant here -- similar to
perf_session__open()?
I don't know, I guess not. Ingo, Arnaldo?