Skip to contentSkip to conversation

perf script: avoid null dereference on symbol

PATCH Applied Ian Rogers 4 participants 5 messages Apr 21, 2020 – May 8, 2020 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf script: avoid null dereference on symbol

al->sym may be null given current if conditions and may cause a segv.

Fixes cd2bedb7863e9 (perf script: Allow --symbol to accept hexadecimal addresses)
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index dc0e11214ae1..f581550a3015 100644
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 			ret = strlist__has_entry(symbol_conf.sym_list,
 						al->sym->name);
 		}
-		if (!(ret && al->sym)) {
+		if (!ret && al->sym) {
 			snprintf(al_addr_str, sz, "0x%"PRIx64,
 				al->map->unmap_ip(al->map, al->sym->start));
 			ret = strlist__has_entry(symbol_conf.sym_list,
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Ian Rogers

al->sym may be null given current if conditions and may cause a segv.

Fixes cd2bedb7863e9 (perf script: Allow --symbol to accept hexadecimal addresses)

seems it's wrong commit number, I see it under d2bedb7863e9

Quoted 10 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +0 -0
index dc0e11214ae1..f581550a3015 100644

tools/perf/util/event.c int machine__resolve(struct machine *machine, struct addr_location *al, · line 629

Quoted 5 lines
tools/perf/util/event.c +1 -1
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 			ret = strlist__has_entry(symbol_conf.sym_list,
 						al->sym->name);
 		}
-		if (!(ret && al->sym)) {
+		if (!ret && al->sym) {

thanks,
jirka

Quoted 6 lines
tools/perf/util/event.c +0 -0
 			snprintf(al_addr_str, sz, "0x%"PRIx64,
 				al->map->unmap_ip(al->map, al->sym->start));
 			ret = strlist__has_entry(symbol_conf.sym_list,
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
#2 lore raw

Em Wed, Apr 22, 2020 at 10:20:16AM +0200, Jiri Olsa escreveu:

Quoted 6 lines · Ian Rogers
Quoted 3 lines

al->sym may be null given current if conditions and may cause a segv.

Fixes cd2bedb7863e9 (perf script: Allow --symbol to accept hexadecimal addresses)

seems it's wrong commit number, I see it under d2bedb7863e9

Thanks, added your Acked-by, I noticed the wrong commit number, fixed it up to the same you point above.

- Arnaldo

Quoted 29 lines
Quoted 11 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +0 -0
index dc0e11214ae1..f581550a3015 100644

tools/perf/util/event.c int machine__resolve(struct machine *machine, struct addr_location *al, · line 629

Quoted 5 lines
tools/perf/util/event.c +1 -1
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 			ret = strlist__has_entry(symbol_conf.sym_list,
 						al->sym->name);
 		}
-		if (!(ret && al->sym)) {
+		if (!ret && al->sym) {

thanks,
jirka

Quoted 6 lines
tools/perf/util/event.c +0 -0
 			snprintf(al_addr_str, sz, "0x%"PRIx64,
 				al->map->unmap_ip(al->map, al->sym->start));
 			ret = strlist__has_entry(symbol_conf.sym_list,
Signature · 1 line
2.26.1.301.g55bc3eb7cb9-goog
Signature · 1 line
- Arnaldo
author reviewer
#3 lore raw
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Wed, Apr 22, 2020 at 10:20:16AM +0200, Jiri Olsa escreveu:

Quoted 6 lines · Ian Rogers
Quoted 3 lines

al->sym may be null given current if conditions and may cause a segv.

Fixes cd2bedb7863e9 (perf script: Allow --symbol to accept hexadecimal addresses)

seems it's wrong commit number, I see it under d2bedb7863e9

Thanks, added your Acked-by, I noticed the wrong commit number, fixed it up to the same you point above.

Thanks for fixing the commit number, I'll try to figure out why I'm calculating these incorrectly.

Ian

Quoted 35 lines

- Arnaldo

Quoted 19 lines
Quoted 11 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +0 -0
index dc0e11214ae1..f581550a3015 100644

tools/perf/util/event.c int machine__resolve(struct machine *machine, struct addr_location *al, · line 629

Quoted 5 lines
tools/perf/util/event.c +1 -1
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
                    ret = strlist__has_entry(symbol_conf.sym_list,
                                            al->sym->name);
            }
-           if (!(ret && al->sym)) {
+           if (!ret && al->sym) {
Quoted 10 lines

thanks,
jirka

Quoted 6 lines
tools/perf/util/event.c +0 -1
                    snprintf(al_addr_str, sz, "0x%"PRIx64,
                            al->map->unmap_ip(al->map, al->sym->start));
                    ret = strlist__has_entry(symbol_conf.sym_list,
--

2.26.1.301.g55bc3eb7cb9-goog

--

- Arnaldo

merge bot Applied
#4 lore raw

[tip: perf/core] perf script: Avoid NULL dereference on symbol

In reply to Ian Rogers
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     1e76b171b71565b96117c2670c64ba54e36a9c2e
Gitweb:        https://git.kernel.org/tip/1e76b171b71565b96117c2670c64ba54e36a9c2e
Author:        Ian Rogers <[email protected]>
AuthorDate:    Mon, 20 Apr 2020 17:43:29 -07:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Wed, 22 Apr 2020 10:59:02 -03:00

perf script: Avoid NULL dereference on symbol

al->sym may be NULL given current if conditions and may cause a segv.

Fixes d2bedb7863e9 ("perf script: Allow --symbol to accept hexadecimal addresses")
Cc Alexander Shishkin <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index dc0e112..f581550 100644
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
 			ret = strlist__has_entry(symbol_conf.sym_list,
 						al->sym->name);
 		}
-		if (!(ret && al->sym)) {
+		if (!ret && al->sym) {
 			snprintf(al_addr_str, sz, "0x%"PRIx64,
 				al->map->unmap_ip(al->map, al->sym->start));
 			ret = strlist__has_entry(symbol_conf.sym_list,