From: Kuniyuki Iwashima <kuniyu@google.com>
To: y2k@desarrollaria.com
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
idosch@nvidia.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com
Subject: Re: ipv6: ip6mr: Call ip6mr_fib_lookup() under RCU in pim6_rcv() and reg_vif6_xmit()
Date: Fri, 8 May 2026 11:51:17 +0000 [thread overview]
Message-ID: <20260508115204.4068686-1-kuniyu@google.com> (raw)
In-Reply-To: <863d7892459fd7627388d8b0c1670292.y2k@desarrollaria.com>
From: y2k <y2k@desarrollaria.com>
Date: Fri, 08 May 2026 13:21:21 +0200
> Commit 019c892e4654 ("ipmr: Call ipmr_fib_lookup() under RCU.") fixed
> the same issue in IPv4's reg_vif_xmit(). The IPv6 counterpart has the
> same problem in two places.
No.
The change is just for rcu_dereference() added in the commit below
for ->exit_rtnl() conversion, but IP6MR is not yet converted.
---8<---
commit b3b6babf47517fde6b6de2493dea28e8831b9347
Author: Kuniyuki Iwashima <kuniyu@google.com>
Date: Thu Apr 23 05:34:54 2026
ipmr: Free mr_table after RCU grace period.
...
Note that IP6MR is not yet converted to ->exit_rtnl(), so this
change is not needed for now but will be.
---8<---
>
> In pim6_rcv() (net/ipv6/ip6mr.c:578) and reg_vif6_xmit()
> (net/ipv6/ip6mr.c:624), ip6mr_fib_lookup() is called without holding
> rcu_read_lock().
>
> When CONFIG_IP6_MROUTE_MULTIPLE_TABLES=n, ip6mr_fib_lookup() accesses
> net->ipv6.mrt6 directly without rcu_dereference(), while the IPv4
> equivalent correctly uses rcu_dereference(net->ipv4.mrt). This
> inconsistency means IPv6 multicast routing lacks proper RCU protection.
>
> In reg_vif6_xmit(), rcu_read_lock() is acquired at line 628 after the
> ip6mr_fib_lookup() call at line 624 — too late. In pim6_rcv(), there
> is no rcu_read_lock() before ip6mr_fib_lookup() at line 578 at all.
>
> Suggested fix for reg_vif6_xmit():
>
> + rcu_read_lock();
> if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0) {
> + rcu_read_unlock();
> goto tx_err;
> }
> DEV_STATS_ADD(dev, tx_bytes, skb->len);
> DEV_STATS_INC(dev, tx_packets);
> - rcu_read_lock();
> ip6mr_cache_report(mrt, skb, READ_ONCE(mrt->mroute_reg_vif_num),
> MRT6MSG_WHOLEPKT);
> rcu_read_unlock();
>
> Suggested fix for pim6_rcv():
>
> + rcu_read_lock();
> if (ip6mr_fib_lookup(net, &fl6, &mrt) < 0) {
> + rcu_read_unlock();
> goto drop;
> }
>
> Additionally, net->ipv6.mrt6 should be accessed via rcu_dereference()
> in ip6mr_fib_lookup() to match the IPv4 pattern in ipmr_fib_lookup().
next prev parent reply other threads:[~2026-05-08 11:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 11:21 ipv6: ip6mr: Call ip6mr_fib_lookup() under RCU in pim6_rcv() and reg_vif6_xmit() y2k
2026-05-08 11:51 ` Kuniyuki Iwashima [this message]
2026-05-08 12:02 ` y2k
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=20260508115204.4068686-1-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=y2k@desarrollaria.com \
/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