From: Paolo Abeni <pabeni@redhat.com>
To: zihanx@nebusec.ai
Cc: netdev@vger.kernel.org, dsahern@kernel.org, idosch@nvidia.com,
davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com,
horms@kernel.org, vega@nebusec.ai
Subject: Re: [PATCH net 1/1] ipv6: mcast: use resolved interface for source filters
Date: Thu, 19 Nov 2026 09:39:20 +0100 [thread overview]
Message-ID: <20261119083920.30482-1-pabeni@redhat.com> (raw)
In-Reply-To: <a5d3d0505baed01a213ea7953f0fe78cb025ee22.1794492711.git.zihanx@nebusec.ai>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://netdev-ai.bots.linux.dev/sashiko/
---
--- Patch [1]: [PATCH net 1/1] ipv6: mcast: use resolved interface for source filters ---
commit 65be18fe1d53e3d386a91fc23d1c7ba9cc2e7b28
Author: Zihan Xi <zihanx@nebusec.ai>
ipv6: mcast: use resolved interface for source filters
This patch makes ip6_mc_source() match socket memberships against the
ifindex of the device resolved by ip6_mc_find_idev(). Before, it treated
gsr_interface == 0 as a wildcard. The resolved ifindex is also passed to
ipv6_sock_mc_drop() when the last source is removed.
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index ecef55f261890..63770b3a7bb25 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
[ ... ]
> @@ -375,6 +376,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
> idev = ip6_mc_find_idev(net, group, pgsr->gsr_interface);
> if (!idev)
> return -ENODEV;
> + ifindex = idev->dev->ifindex;
>
> mutex_lock(&idev->mc_lock);
>
> @@ -386,7 +388,7 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
> err = -EADDRNOTAVAIL;
>
> for_each_pmc_socklock(inet6, sk, pmc) {
> - if (pgsr->gsr_interface && pmc->ifindex != pgsr->gsr_interface)
> + if (pmc->ifindex != ifindex)
> continue;
> if (ipv6_addr_equal(&pmc->addr, group))
> break;
[Severity: Medium]
[Finding: main-1-0]
[Sources: opus-5-5]
Does this break MCAST_JOIN_SOURCE_GROUP with gsr_interface == 0 when the
socket already has a membership for the group on another interface?
__ipv6_sock_mc_join() still treats ifindex 0 as "any interface". Its
duplicate check also runs before ip6_mc_find_dev() resolves the device:
net/ipv6/mcast.c:__ipv6_sock_mc_join() {
...
for_each_pmc_socklock(np, sk, mc_lst) {
if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
ipv6_addr_equal(&mc_lst->addr, addr))
return -EADDRINUSE;
}
...
dev = ip6_mc_find_dev(net, addr, ifindex);
...
}
The caller accepts -EADDRINUSE and goes on to call ip6_mc_source():
net/ipv6/ipv6_sockglue.c:do_ipv6_mcast_group_source() {
...
retv = ipv6_sock_mc_join_ssm(sk, greqs.gsr_interface,
&psin6->sin6_addr,
MCAST_INCLUDE);
/* prior join w/ different source is ok */
if (retv && retv != -EADDRINUSE)
return retv;
...
}
Suppose the socket joined group G on interface Y, and the route for G
resolves to interface X:
do_ipv6_mcast_group_source()
ipv6_sock_mc_join_ssm(sk, 0, G, MCAST_INCLUDE)
__ipv6_sock_mc_join()
returns -EADDRINUSE (matches Y, nothing created on X)
ip6_mc_source()
ip6_mc_find_idev() resolves to X
no pmc with ifindex == X
returns -EINVAL ("must have a prior join")
Before this patch the call returned 0, but it changed the socket filter
on Y while updating the interface filter on X. After this patch it fails.
In this state, a source-specific join with interface 0 can never join on
the resolved interface.
IPv4 does not have this gap. __ip_mc_join_group() calls ip_mc_find_dev()
first, which writes the resolved ifindex into imr. The duplicate check
then uses that ifindex.
MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE and MCAST_LEAVE_SOURCE_GROUP
with interface 0 also behave differently when the only membership is on
an interface the route does not resolve to, for example after a route
change.
One case that used to work now fails with -EINVAL: removing the last
INCLUDE source with MCAST_LEAVE_SOURCE_GROUP. Before this patch, that
path reached ipv6_sock_mc_drop(), which cleaned up using the pmc's own
ifindex.
Should __ipv6_sock_mc_join() resolve the device before its -EADDRINUSE
check, as IPv4 does? This is tagged for stable, so could the commit
message also say that these setsockopt() calls can now return -EINVAL?
--
This is an AI-generated review.
next prev parent reply other threads:[~2026-11-19 8:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 15:19 [PATCH net 0/1] ipv6: mcast: fix default-interface source filter selection Zihan Xi
2026-11-12 15:19 ` [PATCH net 1/1] ipv6: mcast: use resolved interface for source filters Zihan Xi
2026-11-19 8:39 ` Paolo Abeni [this message]
2026-11-19 8:43 ` Paolo Abeni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119083920.30482-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=vega@nebusec.ai \
--cc=zihanx@nebusec.ai \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox