linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: chuck.lever@oracle.com
Subject: [PATCH][RFC] statd: drop all capabilities from the bounding set as well
Date: Tue,  8 May 2012 16:11:55 -0400	[thread overview]
Message-ID: <1336507915-2194-1-git-send-email-jlayton@redhat.com> (raw)

statd drops all capabilities except for CAP_NET_BIND when it starts. It's
possible though that if it ever had a compromise that an attacker would be
able to invoke a setuid process (or something with file capabilities) in
order to reinstate some caps.

In order to prevent that, have statd also prune the bounding set to nothing
prior to dropping capabilities.

Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 support/nsm/file.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/support/nsm/file.c b/support/nsm/file.c
index 5dd52c1..2d86f95 100644
--- a/support/nsm/file.c
+++ b/support/nsm/file.c
@@ -342,8 +342,20 @@ static _Bool
 nsm_clear_capabilities(void)
 {
 #ifdef HAVE_SYS_CAPABILITY_H
+	int ret;
+	unsigned long i;
 	cap_t caps;
 
+	/* prune the bounding set to nothing */
+	for (i = 0; i <= CAP_LAST_CAP; ++i) {
+		ret = prctl(PR_CAPBSET_DROP, i);
+		if (ret) {
+			xlog(L_ERROR, "Unable to prune capability %lu from "
+				      "bounding set: %m", i);
+			return false;
+		}
+	}
+
 	caps = cap_from_text("cap_net_bind_service=ep");
 	if (caps == NULL) {
 		xlog(L_ERROR, "Failed to allocate capability: %m");
-- 
1.7.7.6


                 reply	other threads:[~2012-05-08 20:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1336507915-2194-1-git-send-email-jlayton@redhat.com \
    --to=jlayton@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.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;
as well as URLs for NNTP newsgroup(s).