aboutsummaryrefslogtreecommitdiffstats
path: root/net/sysctl_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sysctl_net.c')
-rw-r--r--net/sysctl_net.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/net/sysctl_net.c b/net/sysctl_net.c
index e3a6e37cd1c5..9bc6db04be3e 100644
--- a/net/sysctl_net.c
+++ b/net/sysctl_net.c
@@ -38,15 +38,24 @@ static int is_seen(struct ctl_table_set *set)
38} 38}
39 39
40/* Return standard mode bits for table entry. */ 40/* Return standard mode bits for table entry. */
41static int net_ctl_permissions(struct ctl_table_root *root, 41static int net_ctl_permissions(struct ctl_table_header *head,
42 struct nsproxy *nsproxy,
43 struct ctl_table *table) 42 struct ctl_table *table)
44{ 43{
44 struct net *net = container_of(head->set, struct net, sysctls);
45 kuid_t root_uid = make_kuid(net->user_ns, 0);
46 kgid_t root_gid = make_kgid(net->user_ns, 0);
47
45 /* Allow network administrator to have same access as root. */ 48 /* Allow network administrator to have same access as root. */
46 if (capable(CAP_NET_ADMIN)) { 49 if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
50 uid_eq(root_uid, current_uid())) {
47 int mode = (table->mode >> 6) & 7; 51 int mode = (table->mode >> 6) & 7;
48 return (mode << 6) | (mode << 3) | mode; 52 return (mode << 6) | (mode << 3) | mode;
49 } 53 }
54 /* Allow netns root group to have the same access as the root group */
55 if (gid_eq(root_gid, current_gid())) {
56 int mode = (table->mode >> 3) & 7;
57 return (mode << 3) | mode;
58 }
50 return table->mode; 59 return table->mode;
51} 60}
52 61