summary refs log tree commit diff
path: root/sysdeps/powerpc
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2020-01-20 17:01:50 +0100
committerAndreas Schwab <schwab@suse.de>2020-01-21 15:26:57 +0100
commitd93769405996dfc11d216ddbe415946617b5a494 (patch)
tree495421ac18939903f2514d2d658b038fcdc26f31 /sysdeps/powerpc
parent8b222fa38700422b4da6731806835f0bbf40920d (diff)
downloadglibc-d93769405996dfc11d216ddbe415946617b5a494.tar.gz
glibc-d93769405996dfc11d216ddbe415946617b5a494.tar.xz
glibc-d93769405996dfc11d216ddbe415946617b5a494.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").
Diffstat (limited to 'sysdeps/powerpc')
-rw-r--r--sysdeps/powerpc/powerpc32/backtrace.c2
-rw-r--r--sysdeps/powerpc/powerpc64/backtrace.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
index 7c2d4726f8..d1456c8ae4 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 65c260ab76..8a53a1088f 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];
 	}