From: Richard Henderson <rth@twiddle.net>
To: Michael Cree <mcree@orcon.net.nz>, linux-alpha@vger.kernel.org
Subject: Re: Bug: retry of clone() on Alpha can result in zeroed process thread pointer
Date: Tue, 29 Jul 2014 12:23:45 -1000 [thread overview]
Message-ID: <53D81EF1.5030306@twiddle.net> (raw)
In-Reply-To: <20140723085244.GB4799@omega>
[-- Attachment #1: Type: text/plain, Size: 182 bytes --]
I don't think this will help, but it's worth a test, prior to totally
re-writing entry.S. There's a chance of confusion of the value of regs->r0 if
there is in fact no error.
r~
[-- Attachment #2: z --]
[-- Type: text/plain, Size: 2145 bytes --]
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index 6cec288..5b855c8 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -452,30 +452,6 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
signal_setup_done(ret, ksig, 0);
}
-static inline void
-syscall_restart(unsigned long r0, unsigned long r19,
- struct pt_regs *regs, struct k_sigaction *ka)
-{
- switch (regs->r0) {
- case ERESTARTSYS:
- if (!(ka->sa.sa_flags & SA_RESTART)) {
- case ERESTARTNOHAND:
- regs->r0 = EINTR;
- break;
- }
- /* fallthrough */
- case ERESTARTNOINTR:
- regs->r0 = r0; /* reset v0 and a3 and replay syscall */
- regs->r19 = r19;
- regs->pc -= 4;
- break;
- case ERESTART_RESTARTBLOCK:
- regs->r0 = EINTR;
- break;
- }
-}
-
-
/*
* Note that 'init' is a special process: it doesn't get signals it doesn't
* want to handle. Thus you cannot kill init even with a SIGKILL even by
@@ -499,13 +475,35 @@ do_signal(struct pt_regs *regs, unsigned long r0, unsigned long r19)
if (get_signal(&ksig)) {
/* ... so re-check the single stepping. */
single_stepping |= ptrace_cancel_bpt(current);
+
+ /* Are we coming from a syscall error? */
+ if (r0 && regs->r19) {
+ switch (regs->r0) {
+ case ERESTARTSYS:
+ if (!(ksig.ka.sa.sa_flags & SA_RESTART)) {
+ case ERESTARTNOHAND:
+ case ERESTART_RESTARTBLOCK:
+ regs->r0 = EINTR;
+ regs->r19 = 1;
+ break;
+ }
+ /* fallthrough */
+ case ERESTARTNOINTR:
+ /* Reset v0 and a3 for syscall replay. */
+ regs->r0 = r0;
+ regs->r19 = r19;
+ regs->pc -= 4;
+ break;
+ }
+ }
+
/* Whee! Actually deliver the signal. */
- if (r0)
- syscall_restart(r0, r19, regs, &ksig.ka);
handle_signal(&ksig, regs);
} else {
single_stepping |= ptrace_cancel_bpt(current);
- if (r0) {
+
+ /* Are we coming from a syscall error? */
+ if (r0 && regs->r19) {
switch (regs->r0) {
case ERESTARTNOHAND:
case ERESTARTSYS:
@@ -522,6 +520,7 @@ do_signal(struct pt_regs *regs, unsigned long r0, unsigned long r19)
break;
}
}
+
restore_saved_sigmask();
}
if (single_stepping)
next prev parent reply other threads:[~2014-07-29 22:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 8:52 Bug: retry of clone() on Alpha can result in zeroed process thread pointer Michael Cree
2014-07-24 18:19 ` Richard Henderson
2014-07-24 19:30 ` Michael Cree
2014-07-29 22:23 ` Richard Henderson [this message]
2014-07-30 4:51 ` Michael Cree
2014-07-30 17:56 ` Richard Henderson
2014-07-30 19:30 ` Richard Henderson
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=53D81EF1.5030306@twiddle.net \
--to=rth@twiddle.net \
--cc=linux-alpha@vger.kernel.org \
--cc=mcree@orcon.net.nz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.