From: Oleg Nesterov <oleg@redhat.com>
To: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Cc: linux-tip-commits@vger.kernel.org, linux-kernel@vger.kernel.org,
hpa@zytor.com, mingo@redhat.com, roland@redhat.com,
tglx@linutronix.de, mingo@elte.hu
Subject: Re: [tip:x86/signal] x86: signal: check signal stack overflow properly
Date: Tue, 24 Mar 2009 23:00:08 +0100 [thread overview]
Message-ID: <20090324220008.GA23243@redhat.com> (raw)
In-Reply-To: <tip-14fc9fbc700dc95b4f46ebd588169324fe6deff8@git.kernel.org>
On 03/20, Hiroshi Shimamoto wrote:
>
> Commit-ID: 14fc9fbc700dc95b4f46ebd588169324fe6deff8
> Gitweb: http://git.kernel.org/tip/14fc9fbc700dc95b4f46ebd588169324fe6deff8
> Author: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
> AuthorDate: Thu, 19 Mar 2009 10:56:29 -0700
> Committer: Ingo Molnar <mingo@elte.hu>
> CommitDate: Fri, 20 Mar 2009 19:01:31 +0100
>
> x86: signal: check signal stack overflow properly
>
> Impact: cleanup
>
> Check alternate signal stack overflow with proper stack pointer.
> The stack pointer of the next signal frame is different if that
> task has i387 state.
I think the patch is correct but I have a minor question,
> No need to check SA_ONSTACK if we're already using alternate signal stack.
Yes, but this also mean that we don't need sas_ss_flags() under
"if (!onsigstack)",
> @@ -211,31 +211,27 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
> {
> /* Default to using normal stack */
> unsigned long sp = regs->sp;
> + int onsigstack = on_sig_stack(sp);
>
> #ifdef CONFIG_X86_64
> /* redzone */
> sp -= 128;
> #endif /* CONFIG_X86_64 */
>
> - /*
> - * If we are on the alternate signal stack and would overflow it, don't.
> - * Return an always-bogus address instead so we will die with SIGSEGV.
> - */
> - if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size)))
> - return (void __user *) -1L;
> -
> - /* This is the X/Open sanctioned signal stack switching. */
> - if (ka->sa.sa_flags & SA_ONSTACK) {
> - if (sas_ss_flags(sp) == 0)
> - sp = current->sas_ss_sp + current->sas_ss_size;
> - } else {
> + if (!onsigstack) {
> + /* This is the X/Open sanctioned signal stack switching. */
> + if (ka->sa.sa_flags & SA_ONSTACK) {
> + if (sas_ss_flags(sp) == 0)
> + sp = current->sas_ss_sp + current->sas_ss_size;
We can use "->sas_ss_size != 0" instead and avoid the unnecessary
sas_ss_flags()->on_sig_stack() check.
Please note that afaics sas_ss_flags()->on_sig_stack() is actually
wrong because we already adjusted "sp" above for redzone.
Suppose that on_sig_stack(regs->sp) = F, but "sp - 128" falls into
the altstack. In that case SA_ONSTACK won't switch the stack.
Of course, this is only theoretical, but still.
Oleg.
next prev parent reply other threads:[~2009-03-24 22:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-19 17:56 [PATCH] x86: signal: check signal stack overflow properly Hiroshi Shimamoto
2009-03-20 18:03 ` [tip:x86/signal] " Hiroshi Shimamoto
2009-03-24 22:00 ` Oleg Nesterov [this message]
2009-03-26 17:03 ` Hiroshi Shimamoto
2009-04-01 15:16 ` [tip:x86/urgent] x86: signal: check sas_ss_size instead of sas_ss_flags() Hiroshi Shimamoto
2009-04-09 12:22 ` [tip:x86/signal] x86: signal: check signal stack overflow properly Jaswinder Singh Rajput
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=20090324220008.GA23243@redhat.com \
--to=oleg@redhat.com \
--cc=h-shimamoto@ct.jp.nec.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=roland@redhat.com \
--cc=tglx@linutronix.de \
/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