From: Will Drewry <redpig@dataspill.org>
To: linux-kernel@vger.kernel.org
Cc: James Morris <jmorris@namei.org>,
linux-security-module@vger.kernel.org, morgan@kernel.org
Subject: [RFC][PATCH 1/1] support optional non-VFS capability inheritance without disabling file caps
Date: Thu, 13 Aug 2009 23:15:11 -0500 [thread overview]
Message-ID: <2359eed20908132115t2f6cea3by2429d54914d5ac6f@mail.gmail.com> (raw)
Capabilities marked as inheritable (+i) are inaccessible when inherited
by a child process (after exec()) with CONFIG_SECURITY_FILE_CAPABILITIES
enabled unless the VFS entry of the child also provides the capability (or
cap_setpcap) in the permitted/effective sets.
This change adds a securebit, SECURE_INHERIT_CAPS, which enableѕ
inherited capabilities to be propagated to the permitted set of the
child process. If it doesn't conflict with VFS_CAP_FLAGS_EFFECTIVE, it
will also mark the capabilities effective. This bit and change only
take effect when SECURE_NOROOT is set.
The securebit guard is used because this change violates the following
constraint:
pP' = (X & fP) | (pI & fI)
With bit-6 enabled, the constraint becomes:
pP' = (X & fP) | (pI)
and pE' varying based on VFS bits and if there are any file-based capabilities.
This allows for a purely runtime capabilities-based environment without
requiring every file to be annotated with an extended attribute. This
also means that SECURE_NOROOT process trees using capabilities become
more accessible, especially for filesystems without extended attribute
support - or in mixed FS environments.
For example, a daemon like dhcpcd may be launched with cap_net_raw by a
more privileged daemon. Once dhcpcd drops the cap_net_raw privilege, it
will not be able to regain it. Even if a local user runs dhcpcd
manually, the capability will not be granted because the capability was
not derived from the filesystem. However, the calling capability
manager could either gain its permissions from init or by having a
file-based capability set.
Nb, I may be missing something obvious - any insights will be appreciated,
and there is a good bit of flexibility in what can be done here.
Signed-off-by: Will Drewry <redpig@dataspill.org>
---
include/linux/securebits.h | 12 +++++++++++-
security/commoncap.c | 7 +++++++
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/include/linux/securebits.h b/include/linux/securebits.h
index d2c5ed8..ed50b80 100644
--- a/include/linux/securebits.h
+++ b/include/linux/securebits.h
@@ -27,6 +27,15 @@
#define SECURE_KEEP_CAPS 4
#define SECURE_KEEP_CAPS_LOCKED 5 /* make bit-4 immutable */
+/* When set, any capabilities inherited from a parent process will
+ start in the permitted, and possibly effective, capability set
+ if SECURE_NOROOT is set.
+ pP' = (X & fP) | (pI & fI)
+ becomes
+ pP' = (X & fP) | (pI) */
+#define SECURE_INHERIT_CAPS 6
+#define SECURE_INHERIT_CAPS_LOCKED 7 /* make bit-6 immutable */
+
/* Each securesetting is implemented using two bits. One bit specifies
whether the setting is on or off. The other bit specify whether the
setting is locked or not. A setting which is locked cannot be
@@ -36,7 +45,8 @@
#define SECURE_ALL_BITS (issecure_mask(SECURE_NOROOT) | \
issecure_mask(SECURE_NO_SETUID_FIXUP) | \
- issecure_mask(SECURE_KEEP_CAPS))
+ issecure_mask(SECURE_KEEP_CAPS) | \
+ issecure_mask(SECURE_INHERIT_CAPS))
#define SECURE_ALL_LOCKS (SECURE_ALL_BITS << 1)
#endif /* !_LINUX_SECUREBITS_H */
diff --git a/security/commoncap.c b/security/commoncap.c
index 48b7e02..9b4590d 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -508,6 +508,13 @@ int cap_bprm_set_creds(struct linux_binprm *bprm)
}
if (new->euid == 0)
effective = true;
+ } else if (issecure(SECURE_INHERIT_CAPS)) {
+ /* Only enable permitted-to-effective inheritance if it doesn't
+ * override VFS_CAP_FLAGS_EFFECTIVE behavior. */
+ if (!effective && cap_isclear(new->cap_permitted))
+ effective = true;
+ new->cap_permitted = cap_combine(new->cap_permitted,
+ new->cap_inheritable);
}
skip:
next reply other threads:[~2009-08-14 4:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-14 4:15 Will Drewry [this message]
2009-08-14 13:32 ` Serge E. Hallyn
2009-08-14 15:40 ` Will Drewry
2009-08-15 17:22 ` Andrew G. Morgan
2009-08-16 4:24 ` Will Drewry
2009-08-17 4:50 ` Andrew G. Morgan
2009-08-17 14:38 ` Will Drewry
2009-08-17 15:26 ` Andrew G. Morgan
2009-08-17 16:48 ` Will Drewry
2009-08-18 0:30 ` Andrew G. Morgan
2009-08-18 14:07 ` David Howells
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=2359eed20908132115t2f6cea3by2429d54914d5ac6f@mail.gmail.com \
--to=redpig@dataspill.org \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=morgan@kernel.org \
/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®