]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: fix use-after-free in -march=native (PR driver/89014)
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Jan 2019 16:36:46 +0000 (16:36 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 23 Jan 2019 16:36:46 +0000 (16:36 +0000)
commitefe18adc604368240be89967107165f5df1553fb
tree65813a8c2a946abae3bf6303f6306ddcd06d096f
parent8090d51ce27a5f35a643b0dbd7773a748c18aa3b
aarch64: fix use-after-free in -march=native (PR driver/89014)

Running:
  $ valgrind ./xgcc -B. -c test.c -march=native
on aarch64 shows a use-after-free in host_detect_local_cpu due
to the std::string result of aarch64_get_extension_string_for_isa_flags
only living until immediately after a c_str call.

This leads to corrupt "-march=" values being passed to cc1.

This patch fixes the use-after-free, though it appears to also need
Tamar's patch here:
  https://gcc.gnu.org/ml/gcc-patches/2018-12/msg01302.html
in order to generate valid values for cc1.  This may have worked by
accident in the past, if the corrupt "-march=" value happened to be
0-terminated in the "right" place; with this patch it now appears
to reliably break without Tamar's patch.

gcc/ChangeLog:
PR driver/89014
* config/aarch64/driver-aarch64.c (host_detect_local_cpu): Fix
use-after-free of the result of
aarch64_get_extension_string_for_isa_flags.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268189 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/aarch64/driver-aarch64.c