linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] userns: honour no_new_privs for cap_bset during user ns creation/switch
@ 2017-12-21 21:06 Maciej Żenczykowski
  2017-12-21 21:44 ` Eric W. Biederman
  0 siblings, 1 reply; 9+ messages in thread
From: Maciej Żenczykowski @ 2017-12-21 21:06 UTC (permalink / raw)
  To: Maciej Żenczykowski
  Cc: linux-security-module, Linux Kernel Mailing List,
	Eric W . Biederman, Mahesh Bandewar, Willem de Bruijn

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-01-03 11:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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-22  1:03   ` Maciej Żenczykowski
2017-12-22  1:18     ` Eric W. Biederman
2017-12-22  1:51       ` Maciej Żenczykowski
2017-12-22 14:08         ` Eric W. Biederman
2018-01-03 11:23           ` Christian Brauner
2017-12-22  2:17       ` Aleksa Sarai
2017-12-22 14:21         ` Eric W. Biederman

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).