perf llvm: don't access out-of-scope array
Subsystems (2)
Ian Rogers
reviewerPATCH 1/1 perf llvm: don't access out-of-scope array
test_dir is assigned to the release array which is out-of-scope 3 lines later. Extend the scope of the release array so that an out-of-scope array isn't accessed.
Bug detected by clang's address sanitizer.
--- tools/perf/util/llvm-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/llvm-utils.c +3 -3
@@ -233,14 +233,14 @@ static int detect_kbuild_dir(char **kbuild_dir)const char *prefix_dir ="" ;const char *suffix_dir ="" ; +/* _UTSNAME_LENGTH is 65 */ +char release[128 ]; +char *autoconf_path;int err;if (!test_dir) { -/* _UTSNAME_LENGTH is 65 */ -char release[128 ]; - err =fetch_kernel_version (NULL , release,sizeof (release));if (err)
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
Em Thu, Sep 26, 2019 at 03:00:18PM -0700, Ian Rogers escreveu:
Quoted 4 lines
test_diris assigned to the release array which is out-of-scope 3 lines later. Extend the scope of the release array so that an out-of-scope array isn't accessed.
Bug detected by clang's address sanitizer.
This one is really ironic, code to support using clang/llvm in perf is caught with a bug detected by clang's utilities ;-)
Please next time try to use 'git blame' so as to add this:
[root@quaco perf]# git tag --contains 07bc5c699a3d | grep ^v[[:digit:]] | sort --version-sort | head -1 v4.4
[root@quaco perf]#
And help get noticed by the various backport bots out there.
Thanks a lot, applied!
- Arnaldo
Quoted 29 lines
Signed-off-by Ian Rogers <[email protected]>--- tools/perf/util/llvm-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)tools/perf/util/llvm-utils.c +3
-3@@ -233,14 +233,14 @@ static int detect_kbuild_dir(char **kbuild_dir)const char *prefix_dir ="" ;const char *suffix_dir ="" ; +/* _UTSNAME_LENGTH is 65 */ +char release[128 ]; +char *autoconf_path;int err;if (!test_dir) { -/* _UTSNAME_LENGTH is 65 */ -char release[128 ]; - err =fetch_kernel_version (NULL , release,sizeof (release));if (err)Signature · 1 line
2.23.0.444.g18eeb5a265-goog
Signature · 1 line
- Arnaldo
[tip: perf/urgent] perf llvm: Don't access out-of-scope array
In reply to Ian RogersThe following commit has been merged into the perf/urgent branch of tip:
The following commit has been merged into the perf/urgent branch of tip:
Commit-ID: 7d4c85b7035eb2f9ab217ce649dcd1bfaf0cacd3 Gitweb: https://git.kernel.org/tip/7d4c85b7035eb2f9ab217ce649dcd1bfaf0cacd3 Author: Ian Rogers <[email protected]> AuthorDate: Thu, 26 Sep 2019 15:00:18 -07:00 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitterDate: Mon, 30 Sep 2019 17:29:35 -03:00
perf llvm: Don't access out-of-scope array
The 'test_dir' variable is assigned to the 'release' array which is out-of-scope 3 lines later.
Extend the scope of the 'release' array so that an out-of-scope array isn't accessed.
Bug detected by clang's address sanitizer.
--- tools/perf/util/llvm-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/llvm-utils.c +3 -3
@@ -233,14 +233,14 @@ static int detect_kbuild_dir(char **kbuild_dir)const char *prefix_dir ="" ;const char *suffix_dir ="" ; +/* _UTSNAME_LENGTH is 65 */ +char release[128 ]; +char *autoconf_path;int err;if (!test_dir) { -/* _UTSNAME_LENGTH is 65 */ -char release[128 ]; - err =fetch_kernel_version (NULL , release,sizeof (release));if (err)