Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756605Ab0BBP6C (ORCPT ); Tue, 2 Feb 2010 10:58:02 -0500 Received: from e35.co.us.ibm.com ([32.97.110.153]:40554 "EHLO e35.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756158Ab0BBP5e (ORCPT ); Tue, 2 Feb 2010 10:57:34 -0500 From: serue@us.ibm.com To: devel@driverdev.osuosl.org Cc: "Serge E. Hallyn" , Greg KH , rsc@swtch.com, Ashwin Ganti , ericvh@gmail.com, linux-kernel@vger.kernel.org, Ron Minnich Subject: [PATCH 4/6] p9auth: add CAP_GRANT_ID to authorize use of /dev/caphash Date: Tue, 2 Feb 2010 09:57:08 -0600 Message-Id: <1265126230-18731-4-git-send-email-serue@us.ibm.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1265126230-18731-1-git-send-email-serue@us.ibm.com> References: <1265126230-18731-1-git-send-email-serue@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2103 Lines: 64 From: Serge E. Hallyn 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 Cc: Greg KH cc: rsc@swtch.com Cc: Ashwin Ganti Cc: ericvh@gmail.com Cc: devel@linuxdriverproject.org Cc: linux-kernel@vger.kernel.org Cc: Ron Minnich --- 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 -- 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/