From: David Howells <dhowells@redhat.com>
To: roland@redhat.com, jmorris@namei.org, chrisw@sous-sol.org,
oleg@redhat.com
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, eparis@redhat.com,
sds@tycho.nsa.gov, David Howells <dhowells@redhat.com>
Subject: [PATCH 2/2] CRED: Guard the setprocattr security hook against ptrace
Date: Fri, 08 May 2009 13:55:27 +0100 [thread overview]
Message-ID: <20090508125527.8488.82217.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20090508125522.8488.13637.stgit@warthog.procyon.org.uk>
Guard the setprocattr security hook against ptrace by taking the target task's
cred_guard_mutex around it. The problem is that setprocattr() may otherwise
note the lack of a debugger, and then perform an action on that basis whilst
letting a debugger attach between the two points. Holding cred_guard_mutex
across the test and the action prevents ptrace_attach() from doing that.
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/proc/base.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index fb45615..23342e1 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -2128,9 +2128,15 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
if (copy_from_user(page, buf, count))
goto out_free;
+ /* Guard against adverse ptrace interaction */
+ length = mutex_lock_interruptible(&task->cred_guard_mutex);
+ if (length < 0)
+ goto out_free;
+
length = security_setprocattr(task,
(char*)file->f_path.dentry->d_name.name,
(void*)page, count);
+ mutex_unlock(&task->cred_guard_mutex);
out_free:
free_page((unsigned long) page);
out:
next prev parent reply other threads:[~2009-05-08 12:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-08 12:55 [PATCH 1/2] CRED: Rename cred_exec_mutex to reflect that it's a guard " David Howells
2009-05-08 12:55 ` David Howells [this message]
2009-05-10 22:37 ` [PATCH 2/2] CRED: Guard the setprocattr security hook " James Morris
2009-05-09 18:59 ` [PATCH 1/2] CRED: Rename cred_exec_mutex to reflect that it's a guard " Oleg Nesterov
2009-05-10 23:29 ` Roland McGrath
2009-05-11 11:33 ` Ingo Molnar
2009-05-10 22:37 ` James Morris
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=20090508125527.8488.82217.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=chrisw@sous-sol.org \
--cc=eparis@redhat.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=sds@tycho.nsa.gov \
/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
all inboxes | Powered by JetHome®