Netdev List
 help / color / mirror / Atom feed
From: Weiming Shi <bestswngs@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Alexander Aring <alex.aring@gmail.com>,
	netdev@vger.kernel.org, Xiang Mei <xmei5@asu.edu>,
	Weiming Shi <bestswngs@gmail.com>
Subject: [PATCH net] ipv6: rpl: add NULL check for idev in ipv6_rpl_srh_rcv()
Date: Fri, 15 May 2026 05:55:30 -0700	[thread overview]
Message-ID: <20260515125530.3396293-2-bestswngs@gmail.com> (raw)

ipv6_rpl_srh_rcv() calls __in6_dev_get(skb->dev) and dereferences the
result without a NULL check.  When addrconf_ifdown() concurrently clears
dev->ip6_ptr via RCU_INIT_POINTER(dev->ip6_ptr, NULL), __in6_dev_get()
returns NULL and the subsequent READ_ONCE(idev->cnf.rpl_seg_enabled)
triggers a NULL pointer dereference.

 BUG: kernel NULL pointer dereference, address: 0000000000000370
 Oops: Oops: 0000 [#1] SMP NOPTI
 RIP: 0010:ipv6_rthdr_rcv+0x3bf/0xe70
  ipv6_rpl_srh_rcv (net/ipv6/exthdrs.c:504)
  ipv6_rthdr_rcv (net/ipv6/exthdrs.c:691)
  ip6_protocol_deliver_rcu (net/ipv6/ip6_input.c:478)
  ip6_input_finish (net/ipv6/ip6_input.c:532)
  ip6_input (net/ipv6/ip6_input.c:540)

Add a NULL check for idev, dropping the packet when the device has no
IPv6 configuration.

Fixes: 8610c7c6e3bd ("net: ipv6: add support for rpl sr exthdr")
Reported-by: Xiang Mei <xmei5@asu.edu>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
---
 net/ipv6/exthdrs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 95558fd6f447..19002e551a03 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -498,6 +498,10 @@ static int ipv6_rpl_srh_rcv(struct sk_buff *skb)
 	u32 r;

 	idev = __in6_dev_get(skb->dev);
+	if (!idev) {
+		kfree_skb(skb);
+		return -1;
+	}

 	accept_rpl_seg = min(READ_ONCE(net->ipv6.devconf_all->rpl_seg_enabled),
 			     READ_ONCE(idev->cnf.rpl_seg_enabled));
--
2.43.0

             reply	other threads:[~2026-05-15 13:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 12:55 Weiming Shi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-28 22:48 [PATCH net] ipv6: rpl: add NULL check for idev in ipv6_rpl_srh_rcv() Andrea Mayer
2026-04-29  0:24 ` Eric Dumazet
2026-05-01 23:35   ` Andrea Mayer

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=20260515125530.3396293-2-bestswngs@gmail.com \
    --to=bestswngs@gmail.com \
    --cc=alex.aring@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xmei5@asu.edu \
    /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