Skip to content

Commit 973c591

Browse files
committed
userns: Start out with a full set of capabilities.
Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent d0bd659 commit 973c591

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

kernel/user_namespace.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/user_namespace.h>
1212
#include <linux/highuid.h>
1313
#include <linux/cred.h>
14+
#include <linux/securebits.h>
1415

1516
static struct kmem_cache *user_ns_cachep __read_mostly;
1617

@@ -52,6 +53,14 @@ int create_user_ns(struct cred *new)
5253
new->gid = new->egid = new->sgid = new->fsgid = 0;
5354
put_group_info(new->group_info);
5455
new->group_info = get_group_info(&init_groups);
56+
/* Start with the same capabilities as init but useless for doing
57+
* anything as the capabilities are bound to the new user namespace.
58+
*/
59+
new->securebits = SECUREBITS_DEFAULT;
60+
new->cap_inheritable = CAP_EMPTY_SET;
61+
new->cap_permitted = CAP_FULL_SET;
62+
new->cap_effective = CAP_FULL_SET;
63+
new->cap_bset = CAP_FULL_SET;
5564
#ifdef CONFIG_KEYS
5665
key_put(new->request_key_auth);
5766
new->request_key_auth = NULL;

0 commit comments

Comments
 (0)