diff options
author | Tom de Vries <tdevries@suse.de> | 2024-02-05 11:04:06 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-02-05 11:04:06 +0100 |
commit | bae2a57f4c07f46093e7bf00fec2554868e77189 (patch) | |
tree | 15e1a59cd56c71061750961fb0950f256d8db823 /gdb/ada-lang.c | |
parent | d1abc689535000017f82243f8e863364dc756282 (diff) | |
download | binutils-bae2a57f4c07f46093e7bf00fec2554868e77189.zip binutils-bae2a57f4c07f46093e7bf00fec2554868e77189.tar.gz binutils-bae2a57f4c07f46093e7bf00fec2554868e77189.tar.bz2 |
[gdb/tdep] Fix use-after-free in arm_exidx_fill_cache
On arm-linux the linaro CI occasionally reports:
...
(gdb) up 10
#4 0x0001b864 in pthread_join ()
(gdb) FAIL: gdb.threads/staticthreads.exp: up 10
...
while this is expected:
...
(gdb) up 10
#3 0x00010568 in main (argc=1, argv=0xfffeede4) at staticthreads.c:76
76 pthread_join (thread, NULL);
(gdb) PASS: gdb.threads/staticthreads.exp: up 10
...
Thiago investigated the problem, and using valgrind found an invalid read in
arm_exidx_fill_cache.
The problem happens as follows:
- an objfile and corresponding per_bfd are allocated
- some memory is allocated in arm_exidx_new_objfile using
objfile->objfile_obstack, for the "exception table entry cache".
- a symbol reread is triggered, and the objfile, including the
objfile_obstack, is destroyed
- a new objfile is allocated, using the same per_bfd
- again arm_exidx_new_objfile is called, but since the same per_bfd is used,
it doesn't allocate any new memory for the "exception table entry cache".
- the "exception table entry cache" is accessed by arm_exidx_fill_cache,
and we have a use-after-free.
This is a regression since commit a2726d4ff80 ("[ARM] Store exception handling
information per-bfd instead of per-objfile"), which changed the "exception
table entry cache" from per-objfile to per-bfd, but failed to update the
obstack_alloc.
Fix this by using objfile->per_bfd->storage_obstack instead of
objfile->objfile_obstack.
I couldn't reproduce the FAIL myself, but Thiago confirmed that the patch
fixes it.
Tested on arm-linux.
Approved-By: Luis Machado <luis.machado@arm.com>
PR tdep/31254
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31254
Diffstat (limited to 'gdb/ada-lang.c')
0 files changed, 0 insertions, 0 deletions