]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
smb: client: require net admin for CIFS SWN netlink
authorMichael Bommarito <michael.bommarito@gmail.com>
Mon, 18 May 2026 00:11:50 +0000 (20:11 -0400)
committerSteve French <stfrench@microsoft.com>
Thu, 21 May 2026 16:15:17 +0000 (11:15 -0500)
CIFS_GENL_CMD_SWN_NOTIFY is the userspace witness-notify command.  The
intended sender is the cifs.witness helper, but the generic-netlink
operation currently has no capability flag, so any local process can send
RESOURCE_CHANGE or CLIENT_MOVE notifications to the in-kernel witness
handler.

The same family exposes CIFS_GENL_MCGRP_SWN without multicast-group
capability flags.  Register messages sent to that group include the witness
registration id and, for NTLM-authenticated mounts, the username, domain,
and password attributes copied from the CIFS session.  An unprivileged
local process should not be able to join that group and receive those
messages.

Require CAP_NET_ADMIN for incoming SWN_NOTIFY commands with
GENL_ADMIN_PERM, and require CAP_NET_ADMIN over the network namespace for
joining the SWN multicast group with GENL_MCAST_CAP_NET_ADMIN.  The
cifs.witness service runs with the privileges needed for both operations.

Fixes: fed979a7e082 ("cifs: Set witness notification handler for messages from userspace daemon")
Cc: stable@vger.kernel.org
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/netlink.c

index 147d9409252cd3b22bbd0e5436d97867b6309413..0dd10913c37a098aa376994ddd81c9c1e8444746 100644 (file)
@@ -33,13 +33,17 @@ static const struct nla_policy cifs_genl_policy[CIFS_GENL_ATTR_MAX + 1] = {
 static const struct genl_ops cifs_genl_ops[] = {
        {
                .cmd = CIFS_GENL_CMD_SWN_NOTIFY,
+               .flags = GENL_ADMIN_PERM,
                .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
                .doit = cifs_swn_notify,
        },
 };
 
 static const struct genl_multicast_group cifs_genl_mcgrps[] = {
-       [CIFS_GENL_MCGRP_SWN] = { .name = CIFS_GENL_MCGRP_SWN_NAME },
+       [CIFS_GENL_MCGRP_SWN] = {
+               .name = CIFS_GENL_MCGRP_SWN_NAME,
+               .flags = GENL_MCAST_CAP_NET_ADMIN,
+       },
 };
 
 struct genl_family cifs_genl_family = {