Netdev List
 help / color / mirror / Atom feed
From: Justin Iurman <justin.iurman@gmail.com>
To: Weiming Shi <bestswngs@gmail.com>,
	"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>,
	Andrea Mayer <andrea.mayer@uniroma2.it>
Subject: Re: [PATCH net] ipv6: rpl: add NULL check for idev in ipv6_rpl_srh_rcv()
Date: Sun, 17 May 2026 20:58:25 +0200	[thread overview]
Message-ID: <2e7d302f-a03e-4df3-8e6c-9339166a831e@gmail.com> (raw)
In-Reply-To: <20260515125530.3396293-2-bestswngs@gmail.com>

On 5/15/26 14:55, Weiming Shi wrote:
> 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

The fix is correct, but this is a duplicate of Andrea's patch (see [1]) 
where Eric suggested to use kfree_skb_reason() with 
SKB_DROP_REASON_IPV6DISABLED. Based on the above, I don't think this 
patch should be accepted.

  [1] 
https://lore.kernel.org/netdev/20260428224816.11223-1-andrea.mayer@uniroma2.it/

  reply	other threads:[~2026-05-17 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-15 12:55 [PATCH net] ipv6: rpl: add NULL check for idev in ipv6_rpl_srh_rcv() Weiming Shi
2026-05-17 18:58 ` Justin Iurman [this message]
2026-05-18  0:26   ` Andrea Mayer
  -- strict thread matches above, loose matches on Subject: below --
2026-04-28 22:48 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=2e7d302f-a03e-4df3-8e6c-9339166a831e@gmail.com \
    --to=justin.iurman@gmail.com \
    --cc=alex.aring@gmail.com \
    --cc=andrea.mayer@uniroma2.it \
    --cc=bestswngs@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