]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
PR25415: fix debuginfod SEGV for empty search path list
authorFrank Ch. Eigler <fche@redhat.com>
Sat, 18 Jan 2020 20:32:40 +0000 (15:32 -0500)
committerFrank Ch. Eigler <fche@redhat.com>
Sat, 18 Jan 2020 20:32:40 +0000 (15:32 -0500)
Prevent triggering undefined behaviour of fts(3), which causes
a SEGV on fedora glibc 2.29.

debuginfod/ChangeLog
debuginfod/debuginfod.cxx
tests/ChangeLog
tests/run-debuginfod-find.sh

index 8a25e1f7a7805d7d9b3165699a395c274fc3dd82..35130b2a5d85d42b130b4f72cc326121640f6297 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-18  Frank Ch. Eigler  <fche@redhat.com>
+
+       * debuginfod.cxx (thread_main_scanner): Handle empty source_paths[].
+
 2020-01-11  Frank Ch. Eigler  <fche@redhat.com>
 
        * debuginfod.cxx (libarchive_fdcache): New class/facility to own a
index 9ca9bc61b097656989f2bb7fa34de6a534ac672f..bf680048d44d4d0f53513cd63c1bc75f58558dab 100644 (file)
@@ -2360,6 +2360,11 @@ thread_main_scanner (void* arg)
 static void
 scan_source_paths()
 {
+  // NB: fedora 31 glibc/fts(3) crashes inside fts_read() on empty
+  // path list.
+  if (source_paths.empty())
+    return;
+
   // Turn the source_paths into an fts(3)-compatible char**.  Since
   // source_paths[] does not change after argv processing, the
   // c_str()'s are safe to keep around awile.
index 3e1c367d7f9b98c3e4c1330beb098af0d0e9008b..8936e410b3d66a6b6a3cc6e045441f9f3d58f38b 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-18  Frank Ch. Eigler  <fche@redhat.com>
+
+       * run-debuginfod-find.sh: Test empty source_paths[].
+
 2020-01-08  Mark Wielaard  <mark@klomp.org>
 
        * asm-test?.c: include libebl.h.
index 6862db7252763bb1bbf0fc78c871f15eb9be724e..2a3d591b4e7725d48e5f22b2bf3e5fc892438453 100755 (executable)
@@ -28,11 +28,13 @@ export DEBUGINFOD_CACHE_PATH=${PWD}/.client_cache
 
 PID1=0
 PID2=0
+PID3=0
 
 cleanup()
 {
   if [ $PID1 -ne 0 ]; then kill $PID1; wait $PID1; fi
   if [ $PID2 -ne 0 ]; then kill $PID2; wait $PID2; fi
+  if [ $PID3 -ne 0 ]; then kill $PID3; wait $PID3; fi
 
   rm -rf F R D L ${PWD}/.client_cache*
   exit_cleanup
@@ -360,4 +362,14 @@ testrun ${abs_builddir}/debuginfod_build_id_find -e F/prog 1
 
 testrun ${abs_top_builddir}/debuginfod/debuginfod-find debuginfo $BUILDID2 && false || true
 
+# Test debuginfod without a path list; reuse $PORT1
+env LD_LIBRARY_PATH=$ldpath ${abs_builddir}/../debuginfod/debuginfod $VERBOSE -F -U -d :memory: -p $PORT1 -L -F &
+PID3=$!
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 1
+wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
+wait_ready $PORT1 'thread_busy{role="scan"}' 0
+kill -int $PID3
+wait $PID3
+PID3=0
+
 exit 0