[PATCH 3/3] signal(x86-64): alternative signal stack wraparound occurs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixing alternative signal stack wraparound.

If a process uses alternative signal stack by using sigaltstack()
and that stack overflow, stack wraparound occurs.
This patch checks whether the signal frame is on the alternative
stack. If the frame is not on there, kill a signal SIGSEGV to the process forcedly
then the process will be terminated.

This patch is for x86-64,version is 2.6.23-rc8.

Signed-off-by: Shi Weihua <[email protected]>

diff -pur linux-2.6.23-rc8.orig/arch/x86_64/ia32/ia32_signal.c linux-2.6.23-rc8/arch/x86_64/ia32/ia32_signal.c
--- linux-2.6.23-rc8.orig/arch/x86_64/ia32/ia32_signal.c	2007-07-09 08:32:17.000000000 +0900
+++ linux-2.6.23-rc8/arch/x86_64/ia32/ia32_signal.c	2007-09-26 12:09:07.000000000 +0900
@@ -428,6 +428,10 @@ int ia32_setup_frame(int sig, struct k_s

 	frame = get_sigframe(ka, regs, sizeof(*frame));

+	if ((ka->sa.sa_flags & SA_ONSTACK)
+		&& (sas_ss_flags((unsigned long) frame) == 0))
+		goto give_sigsegv;
+
 	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
 		goto give_sigsegv;

@@ -518,6 +522,10 @@ int ia32_setup_rt_frame(int sig, struct

 	frame = get_sigframe(ka, regs, sizeof(*frame));

+	if ((ka->sa.sa_flags & SA_ONSTACK)
+		&& (sas_ss_flags((unsigned long) frame) == 0))
+		goto give_sigsegv;
+
 	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
 		goto give_sigsegv;

diff -pur linux-2.6.23-rc8.orig/arch/x86_64/kernel/signal.c linux-2.6.23-rc8/arch/x86_64/kernel/signal.c
--- linux-2.6.23-rc8.orig/arch/x86_64/kernel/signal.c	2007-09-26 09:44:09.000000000 +0900
+++ linux-2.6.23-rc8/arch/x86_64/kernel/signal.c	2007-09-26 12:09:31.000000000 +0900
@@ -235,6 +235,10 @@ static int setup_rt_frame(int sig, struc
 	} else
 		frame = get_stack(ka, regs, sizeof(struct rt_sigframe)) - 8;

+	if ((ka->sa.sa_flags & SA_ONSTACK)
+		&& (sas_ss_flags((unsigned long) frame) == 0))
+		goto give_sigsegv;
+
 	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
 		goto give_sigsegv;


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux