glibc/scripts
Adhemerval Zanella 3a0588ae48 elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS with missing libraries (BZ #28868)
On _dl_map_object the underlying file is not opened in trace mode
(in other cases where the underlying file can't be opened,
_dl_map_object  quits with an error).  If there any missing libraries
being processed, they will not be considered on final nlist size
passed on _dl_sort_maps later in the function.  And it is then used by
_dl_sort_maps_dfs on the stack allocated working maps:

222   /* Array to hold RPO sorting results, before we copy back to  maps[].  */
223   struct link_map *rpo[nmaps];
224
225   /* The 'head' position during each DFS iteration. Note that we start at
226      one past the last element due to first-decrement-then-store (see the
227      bottom of above dfs_traversal() routine).  */
228   struct link_map **rpo_head = &rpo[nmaps];

However while transversing the 'l_initfini' on dfs_traversal it will
still consider the l_faked maps and thus update rpo more times than the
allocated working 'rpo', overflowing the stack object.

As suggested in bugzilla, one option would be to avoid sorting the maps
for trace mode.  However I think ignoring l_faked object does make
sense (there is one less constraint to call the sorting function), it
allows a slight less stack usage for trace, and it is slight simpler
solution.

The tests does trigger the stack overflow, however I tried to make
it more generic to check different scenarios or missing objects.

Checked on x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-04-27 08:36:09 -03:00
..
abi-versions.awk
abilist.awk Add GLIBC_ABI_DT_RELR for DT_RELR support 2022-04-26 10:16:11 -07:00
backport-support.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
build-many-glibcs.py Use Linux 5.17 in build-many-glibcs.py 2022-03-22 18:01:16 +00:00
check-c++-types.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-execstack.awk
check-initfini.awk Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-installed-headers.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-local-headers.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-localplt.awk
check-obsolete-constructs.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-textrel.awk
check-wrapper-headers.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
check-wx-segment.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
config-uname.sh
config.guess
config.sub
cpp
cross-test-ssh.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
documented.sh
dso-ordering-test.py scripts/dso-ordering-test.py: Fix C&P error in * callrefs processing 2022-03-18 18:18:45 +01:00
evaluate-test.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
firstversions.awk
gen-as-const.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
gen-libc-abis
gen-libc-modules.awk
gen-posix-conf-vars.awk
gen-rrtypes.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
gen-sorted.awk Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
gen-tunables.awk
glibc_shared_code.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
glibcelf.py elf: Define DT_RELR related macros and types 2022-04-26 10:16:11 -07:00
glibcextract.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
glibcsymbols.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
haveversions.awk
install-sh
lib-names.awk
list-fixed-bugs.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
list-sources.sh
localplt.awk
merge-test-results.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
mkinstalldirs
move-if-change Sync move-if-change from Gnulib, updating copyright 2022-01-01 11:42:26 -08:00
move-symbol-to-libc.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
pylint
pylintrc
rellns-sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
soversions.awk
sysd-rules.awk
test_printers_common.py Disable debuginfod in printer tests [BZ #28757] 2022-01-14 05:07:29 -08:00
test_printers_exceptions.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
test-installation.pl Update copyright dates not handled by scripts/update-copyrights. 2022-01-01 11:42:26 -08:00
tst-elf-edit.py elf: Replace tst-p_alignmod1-editX with a python script 2022-01-26 08:57:47 -03:00
tst-ld-trace.py elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS with missing libraries (BZ #28868) 2022-04-27 08:36:09 -03:00
update-abilist.sh Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
update-copyrights Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
vcstocl_quirks.py Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
versionlist.awk Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
versions.awk Add GLIBC_ABI_DT_RELR for DT_RELR support 2022-04-26 10:16:11 -07:00