[PATCH net] ipv6: annotate data-race in ndisc_router_discovery()

8 views
Skip to first unread message

Eric Dumazet

unread,
Jan 18, 2026, 10:29:44 AMJan 18
to David S . Miller, Jakub Kicinski, Paolo Abeni, David Ahern, Simon Horman, net...@vger.kernel.org, eric.d...@gmail.com, Eric Dumazet, syzbot, Rocco Yue
syzbot found that ndisc_router_discovery() could read and write
in6_dev->ra_mtu without holding a lock [1]

This looks fine, IFLA_INET6_RA_MTU is best effort.

Add READ_ONCE()/WRITE_ONCE() to document the race.

Note that we might also reject illegal MTU values
(mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) in a future patch.

[1]
BUG: KCSAN: data-race in ndisc_router_discovery / ndisc_router_discovery

read to 0xffff888119809c20 of 4 bytes by task 25817 on cpu 1:
ndisc_router_discovery+0x151d/0x1c90 net/ipv6/ndisc.c:1558
ndisc_rcv+0x2ad/0x3d0 net/ipv6/ndisc.c:1841
icmpv6_rcv+0xe5a/0x12f0 net/ipv6/icmp.c:989
ip6_protocol_deliver_rcu+0xb2a/0x10d0 net/ipv6/ip6_input.c:438
ip6_input_finish+0xf0/0x1d0 net/ipv6/ip6_input.c:489
NF_HOOK include/linux/netfilter.h:318 [inline]
ip6_input+0x5e/0x140 net/ipv6/ip6_input.c:500
ip6_mc_input+0x27c/0x470 net/ipv6/ip6_input.c:590
dst_input include/net/dst.h:474 [inline]
ip6_rcv_finish+0x336/0x340 net/ipv6/ip6_input.c:79
...

write to 0xffff888119809c20 of 4 bytes by task 25816 on cpu 0:
ndisc_router_discovery+0x155a/0x1c90 net/ipv6/ndisc.c:1559
ndisc_rcv+0x2ad/0x3d0 net/ipv6/ndisc.c:1841
icmpv6_rcv+0xe5a/0x12f0 net/ipv6/icmp.c:989
ip6_protocol_deliver_rcu+0xb2a/0x10d0 net/ipv6/ip6_input.c:438
ip6_input_finish+0xf0/0x1d0 net/ipv6/ip6_input.c:489
NF_HOOK include/linux/netfilter.h:318 [inline]
ip6_input+0x5e/0x140 net/ipv6/ip6_input.c:500
ip6_mc_input+0x27c/0x470 net/ipv6/ip6_input.c:590
dst_input include/net/dst.h:474 [inline]
ip6_rcv_finish+0x336/0x340 net/ipv6/ip6_input.c:79
...

value changed: 0x00000000 -> 0xe5400659

Fixes: 49b99da2c9ce ("ipv6: add IFLA_INET6_RA_MTU to expose mtu value")
Reported-by: syzbot <syzk...@googlegroups.com>
Signed-off-by: Eric Dumazet <edum...@google.com>
Cc: Rocco Yue <rocc...@mediatek.com>
---
net/ipv6/ndisc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 59d17b6f06bfd19f4a5e0457f4f20ce7185894c1..f6a5d8c73af9721741c11b543e5abeecdbf2079f 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1555,8 +1555,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)
memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
mtu = ntohl(n);

- if (in6_dev->ra_mtu != mtu) {
- in6_dev->ra_mtu = mtu;
+ if (READ_ONCE(in6_dev->ra_mtu) != mtu) {
+ WRITE_ONCE(in6_dev->ra_mtu, mtu);
send_ifinfo_notify = true;
}

--
2.52.0.457.g6b5491de43-goog

patchwork-b...@kernel.org

unread,
Jan 20, 2026, 9:50:13 PMJan 20
to Eric Dumazet, da...@davemloft.net, ku...@kernel.org, pab...@redhat.com, dsa...@kernel.org, ho...@kernel.org, net...@vger.kernel.org, eric.d...@gmail.com, syzk...@googlegroups.com, rocc...@mediatek.com
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <ku...@kernel.org>:

On Sun, 18 Jan 2026 15:29:41 +0000 you wrote:
> syzbot found that ndisc_router_discovery() could read and write
> in6_dev->ra_mtu without holding a lock [1]
>
> This looks fine, IFLA_INET6_RA_MTU is best effort.
>
> Add READ_ONCE()/WRITE_ONCE() to document the race.
>
> [...]

Here is the summary with links:
- [net] ipv6: annotate data-race in ndisc_router_discovery()
https://git.kernel.org/netdev/net/c/9a063f96d87e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


Greg Kroah-Hartman

unread,
Jan 28, 2026, 10:35:51 AM (10 days ago) Jan 28
to sta...@vger.kernel.org, Greg Kroah-Hartman, pat...@lists.linux.dev, syzbot, Eric Dumazet, Rocco Yue, Jakub Kicinski, Sasha Levin
6.6-stable review patch. If anyone has any objections, please let me know.

------------------

From: Eric Dumazet <edum...@google.com>

[ Upstream commit 9a063f96d87efc3a6cc667f8de096a3d38d74bb5 ]

syzbot found that ndisc_router_discovery() could read and write
in6_dev->ra_mtu without holding a lock [1]

This looks fine, IFLA_INET6_RA_MTU is best effort.

Add READ_ONCE()/WRITE_ONCE() to document the race.

Link: https://patch.msgid.link/20260118152941.2...@google.com
Signed-off-by: Jakub Kicinski <ku...@kernel.org>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
net/ipv6/ndisc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d8e5e2833eded..80ceb401ecf2d 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1574,8 +1574,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)
memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
mtu = ntohl(n);

- if (in6_dev->ra_mtu != mtu) {
- in6_dev->ra_mtu = mtu;
+ if (READ_ONCE(in6_dev->ra_mtu) != mtu) {
+ WRITE_ONCE(in6_dev->ra_mtu, mtu);
send_ifinfo_notify = true;
}

--
2.51.0



Greg Kroah-Hartman

unread,
Jan 28, 2026, 10:47:27 AM (10 days ago) Jan 28
to sta...@vger.kernel.org, Greg Kroah-Hartman, pat...@lists.linux.dev, syzbot, Eric Dumazet, Rocco Yue, Jakub Kicinski, Sasha Levin
6.12-stable review patch. If anyone has any objections, please let me know.
index d961e6c2d09d7..480c906cb374c 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1582,8 +1582,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)

Greg Kroah-Hartman

unread,
Jan 28, 2026, 10:56:39 AM (10 days ago) Jan 28
to sta...@vger.kernel.org, Greg Kroah-Hartman, pat...@lists.linux.dev, syzbot, Eric Dumazet, Rocco Yue, Jakub Kicinski, Sasha Levin
6.18-stable review patch. If anyone has any objections, please let me know.
index f427e41e9c49b..0fd3f53dbb52e 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1555,8 +1555,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)

Greg Kroah-Hartman

unread,
Feb 4, 2026, 9:58:45 AM (3 days ago) Feb 4
to sta...@vger.kernel.org, Greg Kroah-Hartman, pat...@lists.linux.dev, syzbot, Eric Dumazet, Rocco Yue, Jakub Kicinski, Sasha Levin
5.15-stable review patch. If anyone has any objections, please let me know.
index af584e879467e..1821c1aa97ad4 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1507,8 +1507,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)

Greg Kroah-Hartman

unread,
Feb 4, 2026, 10:11:12 AM (3 days ago) Feb 4
to sta...@vger.kernel.org, Greg Kroah-Hartman, pat...@lists.linux.dev, syzbot, Eric Dumazet, Rocco Yue, Jakub Kicinski, Sasha Levin
6.1-stable review patch. If anyone has any objections, please let me know.
index 1a6408a24d21c..affbf12d44f57 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1572,8 +1572,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
Reply all
Reply to author
Forward
0 new messages