|
@@ -42,26 +42,37 @@ static int net_ctl_permissions(struct ctl_table_header *head,
|
|
struct ctl_table *table)
|
|
struct ctl_table *table)
|
|
{
|
|
{
|
|
struct net *net = container_of(head->set, struct net, sysctls);
|
|
struct net *net = container_of(head->set, struct net, sysctls);
|
|
- kuid_t root_uid = make_kuid(net->user_ns, 0);
|
|
|
|
- kgid_t root_gid = make_kgid(net->user_ns, 0);
|
|
|
|
|
|
|
|
/* Allow network administrator to have same access as root. */
|
|
/* Allow network administrator to have same access as root. */
|
|
- if (ns_capable_noaudit(net->user_ns, CAP_NET_ADMIN) ||
|
|
|
|
- uid_eq(root_uid, current_euid())) {
|
|
|
|
|
|
+ if (ns_capable(net->user_ns, CAP_NET_ADMIN)) {
|
|
int mode = (table->mode >> 6) & 7;
|
|
int mode = (table->mode >> 6) & 7;
|
|
return (mode << 6) | (mode << 3) | mode;
|
|
return (mode << 6) | (mode << 3) | mode;
|
|
}
|
|
}
|
|
- /* Allow netns root group to have the same access as the root group */
|
|
|
|
- if (in_egroup_p(root_gid)) {
|
|
|
|
- int mode = (table->mode >> 3) & 7;
|
|
|
|
- return (mode << 3) | mode;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
return table->mode;
|
|
return table->mode;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void net_ctl_set_ownership(struct ctl_table_header *head,
|
|
|
|
+ struct ctl_table *table,
|
|
|
|
+ kuid_t *uid, kgid_t *gid)
|
|
|
|
+{
|
|
|
|
+ struct net *net = container_of(head->set, struct net, sysctls);
|
|
|
|
+ kuid_t ns_root_uid;
|
|
|
|
+ kgid_t ns_root_gid;
|
|
|
|
+
|
|
|
|
+ ns_root_uid = make_kuid(net->user_ns, 0);
|
|
|
|
+ if (uid_valid(ns_root_uid))
|
|
|
|
+ *uid = ns_root_uid;
|
|
|
|
+
|
|
|
|
+ ns_root_gid = make_kgid(net->user_ns, 0);
|
|
|
|
+ if (gid_valid(ns_root_gid))
|
|
|
|
+ *gid = ns_root_gid;
|
|
|
|
+}
|
|
|
|
+
|
|
static struct ctl_table_root net_sysctl_root = {
|
|
static struct ctl_table_root net_sysctl_root = {
|
|
.lookup = net_ctl_header_lookup,
|
|
.lookup = net_ctl_header_lookup,
|
|
.permissions = net_ctl_permissions,
|
|
.permissions = net_ctl_permissions,
|
|
|
|
+ .set_ownership = net_ctl_set_ownership,
|
|
};
|
|
};
|
|
|
|
|
|
static int __net_init sysctl_net_init(struct net *net)
|
|
static int __net_init sysctl_net_init(struct net *net)
|