diff mbox series

[RFC,v2,01/13] perf parse-events: Fix comparison of evsel and leader pmu name

Message ID 1587120084-18990-2-git-send-email-john.garry@huawei.com (mailing list archive)
State New, archived
Headers show
Series perf pmu-events: Support event aliasing for system PMUs | expand

Commit Message

John Garry April 17, 2020, 10:41 a.m. UTC
Since we now strdup() the pmu name for the event selector, use strcmp()
instead of pointer equality for comparison.

Fixes: d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c")
Signed-off-by: John Garry <john.garry@huawei.com>
---

I am not 100% sure that this is the right fix....

 tools/perf/util/parse-events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiri Olsa April 27, 2020, 8:16 a.m. UTC | #1
On Fri, Apr 17, 2020 at 06:41:12PM +0800, John Garry wrote:
> Since we now strdup() the pmu name for the event selector, use strcmp()
> instead of pointer equality for comparison.
> 
> Fixes: d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c")
> Signed-off-by: John Garry <john.garry@huawei.com>

I don't ee this change in your branch:
  private-topic-perf-5.6-sys-pmu-events-v2-upstream

do you have some updated tree?

thanks,
jirka

> ---
> 
> I am not 100% sure that this is the right fix....
> 
>  tools/perf/util/parse-events.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
> index 10107747b361..90ddade1ba23 100644
> --- a/tools/perf/util/parse-events.c
> +++ b/tools/perf/util/parse-events.c
> @@ -1629,7 +1629,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
>  		 * event. That can be used to distinguish the leader from
>  		 * other members, even they have the same event name.
>  		 */
> -		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
> +		if ((leader != evsel) && !strcmp(leader->pmu_name, evsel->pmu_name)) {
>  			is_leader = false;
>  			continue;
>  		}
> -- 
> 2.16.4
>
John Garry April 27, 2020, 9:03 a.m. UTC | #2
On 27/04/2020 09:16, Jiri Olsa wrote:
> On Fri, Apr 17, 2020 at 06:41:12PM +0800, John Garry wrote:
>> Since we now strdup() the pmu name for the event selector, use strcmp()
>> instead of pointer equality for comparison.
>>
>> Fixes: d4953f7ef1a2 ("perf parse-events: Fix 3 use after frees found with clang ASANutil/parse-events.c")
>> Signed-off-by: John Garry <john.garry@huawei.com>
> 
> I don't ee this change in your branch:
>    private-topic-perf-5.6-sys-pmu-events-v2-upstream
> 
> do you have some updated tree?

I have started rebase work here:

https://github.com/hisilicon/kernel-dev/commits/private-topic-perf-5.7-sys-pmu-events-v2

Without this patch, I get this spewed for metric events:

	assertion failed at util/parse-events.c:1637

However, if there was a problem on mainline, I would expect some other 
reports now.

Thanks,
John



> 
>> ---
>>
>> I am not 100% sure that this is the right fix....
>>
>>   tools/perf/util/parse-events.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
>> index 10107747b361..90ddade1ba23 100644
>> --- a/tools/perf/util/parse-events.c
>> +++ b/tools/perf/util/parse-events.c
>> @@ -1629,7 +1629,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
>>   		 * event. That can be used to distinguish the leader from
>>   		 * other members, even they have the same event name.
>>   		 */
>> -		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
>> +		if ((leader != evsel) && !strcmp(leader->pmu_name, evsel->pmu_name)) {
>>   			is_leader = false;
>>   			continue;
>>   		}
>> -- 
>> 2.16.4
>>
> 
> .
>
diff mbox series

Patch

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 10107747b361..90ddade1ba23 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1629,7 +1629,7 @@  parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,
 		 * event. That can be used to distinguish the leader from
 		 * other members, even they have the same event name.
 		 */
-		if ((leader != evsel) && (leader->pmu_name == evsel->pmu_name)) {
+		if ((leader != evsel) && !strcmp(leader->pmu_name, evsel->pmu_name)) {
 			is_leader = false;
 			continue;
 		}