Subject: Re: [PATCH net-next] genetlink: Use internal flags for multicast groups

From: Andy Shevchenko <[email-masked]>
Date: Mon, 18 Dec 2023 13:37:41 +0200

On Sun, Dec 17, 2023 at 09:53:48AM +0200, Ido Schimmel wrote:
> As explained in commit e03781879a0d ("drop_monitor: Require
> 'CAP_SYS_ADMIN' when joining "events" group"), the "flags" field in the
> multicast group structure reuses uAPI flags despite the field not being
> exposed to user space. This makes it impossible to extend its use
> without adding new uAPI flags, which is inappropriate for internal
> kernel checks.
> 
> Solve this by adding internal flags (i.e., "GENL_MCAST_*") and convert
> the existing users to use them instead of the uAPI flags.
> 
> Tested using the reproducers in commit 44ec98ea5ea9 ("psample: Require
> 'CAP_NET_ADMIN' when joining "packets" group") and commit e03781879a0d
> ("drop_monitor: Require 'CAP_SYS_ADMIN' when joining "events" group").
> 
> No functional changes intended.

...

> +#define GENL_MCAST_CAP_NET_ADMIN	BIT(0)
> +#define GENL_MCAST_CAP_SYS_ADMIN	BIT(1)
> +
>  /**
>   * struct genl_multicast_group - generic netlink multicast group
>   * @name: name of the multicast group, names are per-family
> - * @flags: GENL_* flags (%GENL_ADMIN_PERM or %GENL_UNS_ADMIN_PERM)
> - * @cap_sys_admin: whether %CAP_SYS_ADMIN is required for binding
> + * @flags: GENL_MCAST_* flags
>   */

No functional, but documentation changes...

So, I suggest to have these flags being described

/* ... */
#define FLAG1

/* ... */
#define FLAG2

-- 
With Best Regards,
Andy Shevchenko