diff options
author | Andreas Schwab <schwab@suse.de> | 2020-01-20 17:01:50 +0100 |
---|---|---|
committer | Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com> | 2020-03-20 15:32:44 -0300 |
commit | 37db4539dd8b5c098d9235249c5d2aedaa67d7d1 (patch) | |
tree | f49c4c18712edfabd1d22a2cd8b8c1b0aeb16d8f | |
parent | 2dc2d678e91f3f093d0f4855ac086efb288a5e23 (diff) | |
download | glibc-37db4539dd8b5c098d9235249c5d2aedaa67d7d1.tar.gz glibc-37db4539dd8b5c098d9235249c5d2aedaa67d7d1.tar.xz glibc-37db4539dd8b5c098d9235249c5d2aedaa67d7d1.zip |
Fix array overflow in backtrace on PowerPC (bug 25423)
When unwinding through a signal frame the backtrace function on PowerPC didn't check array bounds when storing the frame address. Fixes commit d400dcac5e ("PowerPC: fix backtrace to handle signal trampolines"). (cherry picked from commit d93769405996dfc11d216ddbe415946617b5a494)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | debug/tst-backtrace5.c | 12 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/backtrace.c | 2 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/backtrace.c | 2 |
4 files changed, 17 insertions, 0 deletions
diff --git a/NEWS b/NEWS index 3ccaae3968..cb62587dbb 100644 --- a/NEWS +++ b/NEWS @@ -190,6 +190,7 @@ The following bugs are resolved with this release: [24155] x32 memcmp can treat positive length as 0 (if sign bit in RDX is set) (CVE-2019-7309) [25203] libio: Disable vtable validation for pre-2.1 interposed handles [25204] Ignore LD_PREFER_MAP_32BIT_EXEC for SUID programs + [25423] Array overflow in backtrace on powerpc Version 2.26 diff --git a/debug/tst-backtrace5.c b/debug/tst-backtrace5.c index 0b85e4482e..57b7dee0f6 100644 --- a/debug/tst-backtrace5.c +++ b/debug/tst-backtrace5.c @@ -88,6 +88,18 @@ handle_signal (int signum) } /* Symbol names are not available for static functions, so we do not check do_test. */ + + /* Check that backtrace does not return more than what fits in the array + (bug 25423). */ + for (int j = 0; j < NUM_FUNCTIONS; j++) + { + n = backtrace (addresses, j); + if (n > j) + { + FAIL (); + return; + } + } } NO_INLINE int diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c index 187c3b3349..f0a67008d9 100644 --- a/sysdeps/powerpc/powerpc32/backtrace.c +++ b/sysdeps/powerpc/powerpc32/backtrace.c @@ -114,6 +114,8 @@ __backtrace (void **array, int size) } if (gregset) { + if (count + 1 == size) + break; array[++count] = (void*)((*gregset)[PT_NIP]); current = (void*)((*gregset)[PT_R1]); } diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c index 919bf1cfd7..dd25b90bfc 100644 --- a/sysdeps/powerpc/powerpc64/backtrace.c +++ b/sysdeps/powerpc/powerpc64/backtrace.c @@ -87,6 +87,8 @@ __backtrace (void **array, int size) if (is_sigtramp_address (current->return_address)) { struct signal_frame_64 *sigframe = (struct signal_frame_64*) current; + if (count + 1 == size) + break; array[++count] = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_NIP]; current = (void*) sigframe->uc.uc_mcontext.gp_regs[PT_R1]; } |