* [PATCH v3 net-next 1/2] net: openvswitch: allow metering in non-initial user namespace
2022-09-23 13:38 [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns Michael Weiß
@ 2022-09-23 13:38 ` Michael Weiß
2022-09-23 13:38 ` [PATCH v3 net-next 2/2] net: openvswitch: allow conntrack " Michael Weiß
2022-09-27 9:50 ` [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Michael Weiß @ 2022-09-23 13:38 UTC (permalink / raw)
To: Paolo Abeni, Pravin B Shelar, David S . Miller, Jakub Kicinski
Cc: Joe Stringer, Andy Zhou, Michael Weiß,
Eric Dumazet, netdev, dev, linux-kernel
The Netlink interface for metering was restricted to global CAP_NET_ADMIN
by using GENL_ADMIN_PERM. To allow metring in a non-inital user namespace,
e.g., a container, this is changed to GENL_UNS_ADMIN_PERM.
Signed-off-by: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
---
net/openvswitch/meter.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 51111a9009bd..6e38f68f88c2 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -343,7 +343,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
return ERR_PTR(-EINVAL);
/* Allocate and set up the meter before locking anything. */
- meter = kzalloc(struct_size(meter, bands, n_bands), GFP_KERNEL);
+ meter = kzalloc(struct_size(meter, bands, n_bands), GFP_KERNEL_ACCOUNT);
if (!meter)
return ERR_PTR(-ENOMEM);
@@ -687,9 +687,9 @@ static const struct genl_small_ops dp_meter_genl_ops[] = {
},
{ .cmd = OVS_METER_CMD_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
- * privilege.
- */
+ .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+ * privilege.
+ */
.doit = ovs_meter_cmd_set,
},
{ .cmd = OVS_METER_CMD_GET,
@@ -699,9 +699,9 @@ static const struct genl_small_ops dp_meter_genl_ops[] = {
},
{ .cmd = OVS_METER_CMD_DEL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
- * privilege.
- */
+ .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+ * privilege.
+ */
.doit = ovs_meter_cmd_del
},
};
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH v3 net-next 2/2] net: openvswitch: allow conntrack in non-initial user namespace
2022-09-23 13:38 [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns Michael Weiß
2022-09-23 13:38 ` [PATCH v3 net-next 1/2] net: openvswitch: allow metering in non-initial user namespace Michael Weiß
@ 2022-09-23 13:38 ` Michael Weiß
2022-09-27 9:50 ` [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Michael Weiß @ 2022-09-23 13:38 UTC (permalink / raw)
To: Paolo Abeni, Pravin B Shelar, David S . Miller, Jakub Kicinski
Cc: Joe Stringer, Andy Zhou, Michael Weiß,
Eric Dumazet, netdev, dev, linux-kernel
Similar to the previous commit, the Netlink interface of the OVS
conntrack module was restricted to global CAP_NET_ADMIN by using
GENL_ADMIN_PERM. This is changed to GENL_UNS_ADMIN_PERM to support
unprivileged containers in non-initial user namespace.
Signed-off-by: Michael Weiß <michael.weiss@aisec.fraunhofer.de>
---
net/openvswitch/conntrack.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 48e8f5c29b67..cb255d8ed99a 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1982,7 +1982,8 @@ static int ovs_ct_limit_set_zone_limit(struct nlattr *nla_zone_limit,
} else {
struct ovs_ct_limit *ct_limit;
- ct_limit = kmalloc(sizeof(*ct_limit), GFP_KERNEL);
+ ct_limit = kmalloc(sizeof(*ct_limit),
+ GFP_KERNEL_ACCOUNT);
if (!ct_limit)
return -ENOMEM;
@@ -2252,14 +2253,16 @@ static int ovs_ct_limit_cmd_get(struct sk_buff *skb, struct genl_info *info)
static const struct genl_small_ops ct_limit_genl_ops[] = {
{ .cmd = OVS_CT_LIMIT_CMD_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
- * privilege. */
+ .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+ * privilege.
+ */
.doit = ovs_ct_limit_cmd_set,
},
{ .cmd = OVS_CT_LIMIT_CMD_DEL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
- .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN
- * privilege. */
+ .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN
+ * privilege.
+ */
.doit = ovs_ct_limit_cmd_del,
},
{ .cmd = OVS_CT_LIMIT_CMD_GET,
--
2.30.2
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns
2022-09-23 13:38 [PATCH v3 net-next 0/2] net: openvswitch: metering and conntrack in userns Michael Weiß
2022-09-23 13:38 ` [PATCH v3 net-next 1/2] net: openvswitch: allow metering in non-initial user namespace Michael Weiß
2022-09-23 13:38 ` [PATCH v3 net-next 2/2] net: openvswitch: allow conntrack " Michael Weiß
@ 2022-09-27 9:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-27 9:50 UTC (permalink / raw)
To: =?utf-8?q?Michael_Wei=C3=9F_=3Cmichael=2Eweiss=40aisec=2Efraunhofer=2Ede=3E?=
Cc: pabeni, pshelar, davem, kuba, joe, azhou, edumazet, netdev, dev,
linux-kernel
Hello:
This series was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:
On Fri, 23 Sep 2022 15:38:18 +0200 you wrote:
> Currently using openvswitch in a non-initial user namespace, e.g., an
> unprivileged container, is possible but without metering and conntrack
> support. This is due to the restriction of the corresponding Netlink
> interfaces to the global CAP_NET_ADMIN.
>
> This simple patches switch from GENL_ADMIN_PERM to GENL_UNS_ADMIN_PERM
> in several cases to allow this also for the unprivileged container
> use case.
>
> [...]
Here is the summary with links:
- [v3,net-next,1/2] net: openvswitch: allow metering in non-initial user namespace
https://git.kernel.org/netdev/net-next/c/803937184717
- [v3,net-next,2/2] net: openvswitch: allow conntrack in non-initial user namespace
https://git.kernel.org/netdev/net-next/c/59cd7377660a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread