diff mbox series

[1/2] net: openvswitch: allow metering in non-initial user namespace

Message ID 20220911173825.167352-2-michael.weiss@aisec.fraunhofer.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: openvswitch: metering and conntrack in userns | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Weiß Sept. 11, 2022, 5:38 p.m. UTC
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 | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Paolo Abeni Sept. 20, 2022, 9:43 a.m. UTC | #1
On Sun, 2022-09-11 at 19:38 +0200, Michael Weiß wrote:
> 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 | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
> index 04a060ac7fdf..e9ef050a0dd5 100644
> --- a/net/openvswitch/meter.c
> +++ b/net/openvswitch/meter.c
> @@ -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
>  	},
>  };

It looks like the user namespace can allocate quite a bit of memory
with multiple meters, I think it's better additionally change
GFP_KERNEL to GFP_KERNEL_ACCOUNT in dp_meter_create().

Also plese add an explicit target tree in the subj when posting the
next revision, thanks!

Paolo
diff mbox series

Patch

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 04a060ac7fdf..e9ef050a0dd5 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -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
 	},
 };