From: pmeda@akamai.com
To: akpm@osdl.org
Cc: linux-mm@kvack.org, roland@redhat.com
Subject: [patch] ptrace: unlocked access to last_siginfo (resending)
Date: Tue, 11 Jan 2005 19:11:50 -0800 [thread overview]
Message-ID: <200501120311.TAA01315@allur.sanmateo.akamai.com> (raw)
Since Roland changed now to wakeup tracee with kill, I guess this needs to be fixed.
http://linus.bkbits.net:8080/linux-2.5/gnupatch@41e3fe5fIRH-W3aDnXZgfQ-qIvuXYg
ptrace_setsiginfo/ptrace_getsiginfo need to do locked access
to last_siginfo. ptrace_notify()/ptrace_stop() sets the
current->last_siginfo and sleeps on schedule(). It can be waked
up by kill signal from signal_wake_up before debugger wakes it up.
On return from schedule(), the current->last_siginfo is reset.
Signed-off-by: Prasanna Meda <pmeda@akamai.com>
--- a/kernel/ptrace.c Fri Nov 19 18:27:26 2004
+++ b/kernel/ptrace.c Fri Nov 19 18:52:52 2004
@@ -303,18 +303,33 @@
static int ptrace_getsiginfo(struct task_struct *child, siginfo_t __user * data)
{
- if (child->last_siginfo == NULL)
- return -EINVAL;
- return copy_siginfo_to_user(data, child->last_siginfo);
+ siginfo_t lastinfo;
+
+ spin_lock_irq(&child->sighand->siglock);
+ if (likely(child->last_siginfo != NULL)) {
+ memcpy(&lastinfo, child->last_siginfo, sizeof (siginfo_t));
+ spin_unlock_irq(&child->sighand->siglock);
+ return copy_siginfo_to_user(data, &lastinfo);
+ }
+ spin_unlock_irq(&child->sighand->siglock);
+ return -EINVAL;
}
static int ptrace_setsiginfo(struct task_struct *child, siginfo_t __user * data)
{
- if (child->last_siginfo == NULL)
- return -EINVAL;
- if (copy_from_user(child->last_siginfo, data, sizeof (siginfo_t)) != 0)
+ siginfo_t newinfo;
+
+ if (copy_from_user(&newinfo, data, sizeof (siginfo_t)) != 0)
return -EFAULT;
- return 0;
+
+ spin_lock_irq(&child->sighand->siglock);
+ if (likely(child->last_siginfo != NULL)) {
+ memcpy(child->last_siginfo, &newinfo, sizeof (siginfo_t));
+ spin_unlock_irq(&child->sighand->siglock);
+ return 0;
+ }
+ spin_unlock_irq(&child->sighand->siglock);
+ return -EINVAL;
}
int ptrace_request(struct task_struct *child, long request,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next reply other threads:[~2005-01-12 3:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-12 3:11 pmeda [this message]
2005-01-14 7:46 ` Roland McGrath
2005-01-27 3:36 ` Prasanna Meda
2005-01-27 3:40 ` Roland McGrath
2005-01-27 6:30 Meda, Prasanna
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=200501120311.TAA01315@allur.sanmateo.akamai.com \
--to=pmeda@akamai.com \
--cc=akpm@osdl.org \
--cc=linux-mm@kvack.org \
--cc=roland@redhat.com \
/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