From: Shi Weihua <shiwh@cn.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: ak@suse.de, discuss@x86-64.org
Subject: [PATCH 3/3] signal(x86-64): alternative signal stack wraparound occurs
Date: Wed, 03 Oct 2007 17:06:28 +0900 [thread overview]
Message-ID: <47034D84.8050505@cn.fujitsu.com> (raw)
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 <shiwh@cn.fujitsu.com>
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;
reply other threads:[~2007-10-03 8:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47034D84.8050505@cn.fujitsu.com \
--to=shiwh@cn.fujitsu.com \
--cc=ak@suse.de \
--cc=discuss@x86-64.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox