lkml.org 
[lkml]   [2003]   [Jul]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 2.5.73] Signal stack fixes #2 i386-specific
Hi Linus!

This is the i386 specific part of the signal stack fixes. It sets the
flag, when switching to the signal stack and clears it, when switching
back. When the kernel tries to switch to the signal stack again,
without switching back, the process screwed up the signal stack, so we
kill it with a SIGSEGV.

Actually, the process doesn't get killed right away yet, so there is
room for improvement, but the general behaviour is the right one.

Please apply.

Jörn

--
There's nothing better for promoting creativity in a medium than
making an audience feel "Hmm ­ I could do better than that!"
-- Douglas Adams in a slashdot interview

--- linux-2.5.73/arch/i386/kernel/signal.c~ss_i386 2003-07-04 18:57:01.000000000 +0200
+++ linux-2.5.73/arch/i386/kernel/signal.c 2003-07-04 18:59:04.000000000 +0200
@@ -181,6 +181,9 @@
}
}

+ if (sas_ss_flags(regs->esp) == 0)
+ current->flags &= ~PF_SS_ACTIVE;
+
err |= __get_user(*peax, &sc->eax);
return err;

@@ -317,9 +320,22 @@
esp = regs->esp;

/* This is the X/Open sanctioned signal stack switching. */
- if (ka->sa.sa_flags & SA_ONSTACK) {
- if (sas_ss_flags(esp) == 0)
- esp = current->sas_ss_sp + current->sas_ss_size;
+ if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags(esp) == 0)) {
+ /* If we have switches to the signal stack before,
+ * something bad has happened to it, asking for a
+ * segmentation fault.
+ * If not, remember it for the next time
+ */
+ if (current->flags & PF_SS_ACTIVE) {
+ ka->sa.sa_handler = SIG_DFL;
+ force_sig(SIGSEGV, current);
+ /* XXX would it be simpler to return some broken
+ * value like NULL and have the calling function
+ * signal the segv?
+ */
+ }
+ current->flags |= PF_SS_ACTIVE;
+ esp = current->sas_ss_sp + current->sas_ss_size;
}

/* This is the legacy signal stack switching. */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.066 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site