From: Simon Horman <horms@kernel.org>
To: heminhong@kylinos.cn
Cc: Simon Horman <horms@kernel.org>,
davem@davemloft.net, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, dsahern@kernel.org,
andrea.mayer@uniroma2.it, kuba@kernel.org, edumazet@google.com,
david.lebrun@uclouvain.be, pabeni@redhat.com
Subject: Re: [net,v2] ipv6: sr: Add NULL check for idev in seg6_hmac_validate_skb
Date: Sun, 15 Mar 2026 16:01:59 +0000 [thread overview]
Message-ID: <20260315160159.1394504-1-horms@kernel.org> (raw)
In-Reply-To: <20260313022634.51885-1-heminhong@kylinos.cn>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
ipv6: sr: Add NULL check for idev in seg6_hmac_validate_skb
In seg6_hmac_validate_skb(), the pointer returned by __in6_dev_get()
can be NULL if the network device lacks proper IPv6 initialization
or is being torn down. Add a NULL check to avoid potential NULL pointer
dereference in subsequent code.
> diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
> --- a/net/ipv6/seg6_hmac.c
> +++ b/net/ipv6/seg6_hmac.c
> @@ -184,6 +184,8 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)
> int require_hmac;
>
> idev = __in6_dev_get(skb->dev);
> + if (!idev)
> + return false;
>
> srh = (struct ipv6_sr_hdr *)skb_transport_header(skb);
>
The patch adds a NULL check in seg6_hmac_validate_skb() to handle the
case when __in6_dev_get() returns NULL. However, does this fix the
complete issue?
Looking at ipv6_srh_rcv() in net/ipv6/exthdrs.c, there's an earlier use
of the same __in6_dev_get() call:
net/ipv6/exthdrs.c:ipv6_srh_rcv() {
...
idev = __in6_dev_get(skb->dev);
accept_seg6 = min(READ_ONCE(net->ipv6.devconf_all->seg6_enabled),
READ_ONCE(idev->cnf.seg6_enabled));
...
#ifdef CONFIG_IPV6_SEG6_HMAC
if (!seg6_hmac_validate_skb(skb)) {
...
}
The idev pointer is dereferenced on line 384 (idev->cnf.seg6_enabled)
before seg6_hmac_validate_skb() is called. If __in6_dev_get() can return
NULL as the commit message states, wouldn't this cause a NULL pointer
dereference before the new check in seg6_hmac_validate_skb() has a
chance to catch it?
Should ipv6_srh_rcv() also check for NULL after calling __in6_dev_get()?
next prev parent reply other threads:[~2026-03-15 16:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 7:23 [PATCH net] ipv6: sr: Add unlikely hint to idev NULL check in seg6_hmac_validate_skb Minhong He
2026-03-11 8:57 ` Eric Dumazet
2026-03-13 2:26 ` [PATCH net v2] ipv6: sr: Add NULL check for idev " Minhong He
2026-03-13 2:38 ` Jakub Kicinski
2026-03-14 22:49 ` Andrea Mayer
2026-03-15 16:01 ` Simon Horman [this message]
2026-03-16 7:33 ` [PATCH net v3] ipv6: add NULL checks for idev in SRv6 paths Minhong He
2026-03-18 0:51 ` Andrea Mayer
2026-03-19 0:44 ` patchwork-bot+netdevbpf
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=20260315160159.1394504-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=andrea.mayer@uniroma2.it \
--cc=davem@davemloft.net \
--cc=david.lebrun@uclouvain.be \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=heminhong@kylinos.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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