perf jevents: Fix suspicious code in fixregex()
Namhyung Kim
maintainerPATCH 1/1 perf jevents: Fix suspicious code in fixregex()
The new string should have enough space for the original string and the back slashes IMHO.
--- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/pmu-events/jevents.c +1 -1
@@ -137,7 +137,7 @@ static char *fixregex(char *s)return s;/* allocate space for a new string */ - fixed = (char *)malloc (len +1 ); + fixed = (char *)malloc (len + esc_count +1 );if (!fixed)return NULL ;
Signature · 1 line
2.28.0.402.g5ffc5be6b7-goog
Quoted 8 lines · Namhyung Kim
The new string should have enough space for the original string and the back slashes IMHO.
Cc John Garry <[email protected]>Cc Kajol Jain <[email protected]>Cc Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Definitely looks like the right fix. I'm surprised this hasn't shown up in sanitizer testing.
Thanks,
Ian
Quoted 20 lines
--- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/pmu-events/jevents.c +1
-2@@ -137,7 +137,7 @@ static char *fixregex(char *s)return s;/* allocate space for a new string */ - fixed = (char *)malloc (len +1 ); + fixed = (char *)malloc (len + esc_count +1 );if (!fixed)return NULL ; --2.28.0.402.g5ffc5be6b7-goog
Arnaldo Carvalho de Melo
maintainerEm Thu, Sep 03, 2020 at 10:47:39AM -0700, Ian Rogers escreveu:
Quoted 9 lines · Namhyung Kim
Quoted 7 lines
The new string should have enough space for the original string and the back slashes IMHO.
Cc John Garry <[email protected]>Cc Kajol Jain <[email protected]>Cc Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
Quoted 4 lines
Reviewed-by Ian Rogers <[email protected]>Definitely looks like the right fix. I'm surprised this hasn't shown up in sanitizer testing.
Yeap, good catch! Namyung you forgot to add the Fixes tag + Cc the patch author that introduced that bug, I did it:
Please consider doing it next time :-)
Thanks a lot!
- Arnaldo
Quoted 23 lines
Thanks,
IanQuoted 20 lines
--- tools/perf/pmu-events/jevents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/pmu-events/jevents.c +1
-2@@ -137,7 +137,7 @@ static char *fixregex(char *s)return s;/* allocate space for a new string */ - fixed = (char *)malloc (len +1 ); + fixed = (char *)malloc (len + esc_count +1 );if (!fixed)return NULL ; --2.28.0.402.g5ffc5be6b7-goog
Signature · 1 line
- Arnaldo
Namhyung Kim
maintainerHi Arnaldo and Ian,
Quoted 15 lines · Arnaldo Carvalho de Melo
Em Thu, Sep 03, 2020 at 10:47:39AM -0700, Ian Rogers escreveu:
Quoted 13 lines · Namhyung Kim
Quoted 7 lines
The new string should have enough space for the original string and the back slashes IMHO.
Cc John Garry <[email protected]>Cc Kajol Jain <[email protected]>Cc Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>Reviewed-by Ian Rogers <[email protected]>Definitely looks like the right fix. I'm surprised this hasn't shown up in sanitizer testing.
I guess the code didn't run on most arch (including x86) since they don't have backslashes.
Quoted 8 lines
Yeap, good catch! Namyung you forgot to add the Fixes tag + Cc the patch author that introduced that bug, I did it:
Cc William Cohen <[email protected]>Fixes fbc2844e84038ce3 ("perf vendor events: Use more flexible pattern matching for CPU identification for mapfile.csv"Please consider doing it next time :-)
Oh, right! Will do it later..
Thanks
Namhyung
Arnaldo Carvalho de Melo
maintainerEm Fri, Sep 04, 2020 at 10:38:35AM +0900, Namhyung Kim escreveu:
Quoted 19 lines · Arnaldo Carvalho de Melo
Quoted 11 lines
Em Thu, Sep 03, 2020 at 10:47:39AM -0700, Ian Rogers escreveu:
Quoted 10 lines · Namhyung Kim
Quoted 6 lines
The new string should have enough space for the original string and the back slashes IMHO.
Cc John Garry <[email protected]>Cc Kajol Jain <[email protected]>Cc Ian Rogers <[email protected]>Signed-off-by Namhyung Kim <[email protected]>Reviewed-by Ian Rogers <[email protected]>Definitely looks like the right fix. I'm surprised this hasn't shown up in sanitizer testing.
I guess the code didn't run on most arch (including x86) since they don't have backslashes.
Quoted 2 lines
Yeap, good catch! Namyung you forgot to add the Fixes tag + Cc the patch author that introduced that bug, I did it:
Quoted 6 lines
Quoted 4 lines
Cc William Cohen <[email protected]>Fixes fbc2844e84038ce3 ("perf vendor events: Use more flexible pattern matching for CPU identification for mapfile.csv"Please consider doing it next time :-)
Oh, right! Will do it later..
Thanks!
- Arnaldo