All of lore.kernel.org
 help / color / mirror / Atom feed
From: zenczykowski@gmail.com (Maciej Żenczykowski)
To: linux-security-module@vger.kernel.org
Subject: [PATCH] userns: honour no_new_privs for cap_bset during user ns creation/switch
Date: Thu, 21 Dec 2017 13:06:05 -0800	[thread overview]
Message-ID: <20171221210605.181720-1-zenczykowski@gmail.com> (raw)

From: Maciej ?enczykowski <maze@google.com>

This allows locking down user namespaces tighter,
and it could even be considered a security fix.

Signed-off-by: Maciej ?enczykowski <maze@google.com>
---
 kernel/user_namespace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 246d4d4ce5c7..2354f7ade78a 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -50,11 +50,12 @@ static void set_cred_user_ns(struct cred *cred, struct user_namespace *user_ns)
 	 * anything as the capabilities are bound to the new user namespace.
 	 */
 	cred->securebits = SECUREBITS_DEFAULT;
+	cred->cap_bset = task_no_new_privs(current) ? current_cred()->cap_bset
+						    : CAP_FULL_SET;
 	cred->cap_inheritable = CAP_EMPTY_SET;
-	cred->cap_permitted = CAP_FULL_SET;
-	cred->cap_effective = CAP_FULL_SET;
+	cred->cap_permitted = cred->cap_bset;
+	cred->cap_effective = cred->cap_bset;
 	cred->cap_ambient = CAP_EMPTY_SET;
-	cred->cap_bset = CAP_FULL_SET;
 #ifdef CONFIG_KEYS
 	key_put(cred->request_key_auth);
 	cred->request_key_auth = NULL;
-- 
2.15.1.620.gb9897f4670-goog

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: "Maciej Żenczykowski" <zenczykowski@gmail.com>
To: "Maciej Żenczykowski" <maze@google.com>
Cc: linux-security-module@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"Eric W . Biederman" <ebiederm@xmission.com>,
	Mahesh Bandewar <maheshb@google.com>,
	Willem de Bruijn <willemb@google.com>
Subject: [PATCH] userns: honour no_new_privs for cap_bset during user ns creation/switch
Date: Thu, 21 Dec 2017 13:06:05 -0800	[thread overview]
Message-ID: <20171221210605.181720-1-zenczykowski@gmail.com> (raw)

From: Maciej Żenczykowski <maze@google.com>

This allows locking down user namespaces tighter,
and it could even be considered a security fix.

Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
 kernel/user_namespace.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 246d4d4ce5c7..2354f7ade78a 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -50,11 +50,12 @@ static void set_cred_user_ns(struct cred *cred, struct user_namespace *user_ns)
 	 * anything as the capabilities are bound to the new user namespace.
 	 */
 	cred->securebits = SECUREBITS_DEFAULT;
+	cred->cap_bset = task_no_new_privs(current) ? current_cred()->cap_bset
+						    : CAP_FULL_SET;
 	cred->cap_inheritable = CAP_EMPTY_SET;
-	cred->cap_permitted = CAP_FULL_SET;
-	cred->cap_effective = CAP_FULL_SET;
+	cred->cap_permitted = cred->cap_bset;
+	cred->cap_effective = cred->cap_bset;
 	cred->cap_ambient = CAP_EMPTY_SET;
-	cred->cap_bset = CAP_FULL_SET;
 #ifdef CONFIG_KEYS
 	key_put(cred->request_key_auth);
 	cred->request_key_auth = NULL;
-- 
2.15.1.620.gb9897f4670-goog

             reply	other threads:[~2017-12-21 21:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 21:06 Maciej Żenczykowski [this message]
2017-12-21 21:06 ` [PATCH] userns: honour no_new_privs for cap_bset during user ns creation/switch Maciej Żenczykowski
2017-12-21 21:44 ` Eric W. Biederman
2017-12-21 21:44   ` Eric W. Biederman
2017-12-22  1:03   ` Maciej Żenczykowski
2017-12-22  1:03     ` Maciej Żenczykowski
     [not found]     ` <CAHo-OoyrOr5jXwU-j4Z4qYdWo40+qAdAk0r+OpfMUZ6LgbS-RA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-22  1:18       ` Eric W. Biederman
2017-12-22  1:18         ` Eric W. Biederman
2017-12-22  1:18         ` Eric W. Biederman
2017-12-22  1:51         ` Maciej Żenczykowski
2017-12-22  1:51           ` Maciej Żenczykowski
     [not found]           ` <CAHo-OoxoTEZuQ0ZXa9a2BnjAv83y0UWC0eqn-ok9hS31LkiiSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-12-22 14:08             ` Eric W. Biederman
2017-12-22 14:08               ` Eric W. Biederman
2017-12-22 14:08               ` Eric W. Biederman
2018-01-03 11:23               ` Christian Brauner
2018-01-03 11:23                 ` Christian Brauner
     [not found]               ` <87o9mqhn3v.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2018-01-03 11:23                 ` Christian Brauner
     [not found]         ` <87fu83lfw5.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-12-22  1:51           ` Maciej Żenczykowski
2017-12-22  2:17           ` Aleksa Sarai
2017-12-22  2:17             ` Aleksa Sarai
2017-12-22 14:21             ` Eric W. Biederman
2017-12-22 14:21             ` Eric W. Biederman
2017-12-22 14:21               ` Eric W. Biederman
     [not found]   ` <87wp1foiwa.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-12-22  1:03     ` Maciej Żenczykowski
     [not found] ` <20171221210605.181720-1-zenczykowski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-12-21 21:44   ` Eric W. Biederman

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=20171221210605.181720-1-zenczykowski@gmail.com \
    --to=zenczykowski@gmail.com \
    --cc=linux-security-module@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.