From: Serge Hallyn <serue@us.ibm.com>
To: serue@us.ibm.com
Cc: Greg KH <greg@kroah.com>,
rsc@swtch.com, Ashwin Ganti <ashwin.ganti@gmail.com>,
ericvh@gmail.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, Ron Minnich <rminnich@gmail.com>
Subject: [PATCH 4/8] p9auth: add CAP_GRANT_ID to authorize use of /dev/caphash
Date: Tue, 16 Feb 2010 16:44:57 -0600 [thread overview]
Message-ID: <1266360301-30081-4-git-send-email-serue@us.ibm.com> (raw)
In-Reply-To: <1266360301-30081-1-git-send-email-serue@us.ibm.com>
From: Serge E. Hallyn <serue@us.ibm.com>
Granting userid capabilities to another task is a dangerous
privilege. Don't just let file permissions authorize it.
Define CAP_GRANT_ID as a new capability needed to write to
/dev/caphash.
For one thing this lets us start a factotum server early on
in init, then have init drop CAP_GRANT_ID from its bounding
set so the rest of the system cannot regain it.
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Greg KH <greg@kroah.com>
cc: rsc@swtch.com
Cc: Ashwin Ganti <ashwin.ganti@gmail.com>
Cc: ericvh@gmail.com
Cc: devel@linuxdriverproject.org
Cc: linux-kernel@vger.kernel.org
Cc: Ron Minnich <rminnich@gmail.com>
---
drivers/staging/p9auth/p9auth.c | 4 ++++
include/linux/capability.h | 6 +++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/p9auth/p9auth.c b/drivers/staging/p9auth/p9auth.c
index 8f70daa..fb27459 100644
--- a/drivers/staging/p9auth/p9auth.c
+++ b/drivers/staging/p9auth/p9auth.c
@@ -201,6 +201,10 @@ static ssize_t cap_write(struct file *filp, const char __user *buf,
retval = -EINVAL;
goto out;
}
+ if (!capable(CAP_GRANT_ID)) {
+ retval = -EPERM;
+ goto out;
+ }
printk(KERN_INFO "Capability being written to /dev/caphash : \n");
hexdump(user_buf, count);
memcpy(node_ptr->data, user_buf, count);
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 39e5ff5..ba2cbfe 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -355,7 +355,11 @@ struct cpu_vfs_cap_data {
#define CAP_MAC_ADMIN 33
-#define CAP_LAST_CAP CAP_MAC_ADMIN
+/* Allow granting setuid capabilities through p9auth /dev/caphash */
+
+#define CAP_GRANT_ID 34
+
+#define CAP_LAST_CAP CAP_GRANT_ID
#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
--
1.6.1
next prev parent reply other threads:[~2010-02-16 22:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 22:44 [PATCH 1/8] p9auth: set fsuid Serge Hallyn
2010-02-16 22:44 ` [PATCH 2/8] p9auth: split core function out of some set*{u,g}id functions Serge Hallyn
2010-02-16 22:44 ` [PATCH 3/8] p9auth: use setresuid Serge Hallyn
2010-02-16 22:44 ` Serge Hallyn [this message]
2010-02-16 22:44 ` [PATCH 5/8] p9auth cleanup Serge Hallyn
2010-02-16 22:44 ` [PATCH 6/8] p9auth: do groups Serge Hallyn
2010-02-16 22:45 ` [PATCH 7/8] p9auth: add cap_node timeout Serge Hallyn
2010-02-16 22:45 ` [PATCH 8/8] p9auth: don't trim entries on write-only open Serge Hallyn
2010-02-25 23:28 ` [PATCH 1/8] p9auth: set fsuid Greg KH
2010-02-26 4:05 ` Serge E. Hallyn
2010-02-26 5:06 ` Greg KH
2010-02-26 18:19 ` Serge E. Hallyn
2010-03-04 22:04 ` Ashwin Ganti
2010-03-05 20:07 ` Serge E. Hallyn
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=1266360301-30081-4-git-send-email-serue@us.ibm.com \
--to=serue@us.ibm.com \
--cc=ashwin.ganti@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=ericvh@gmail.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rminnich@gmail.com \
--cc=rsc@swtch.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
all inboxes | Powered by JetHome®