From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AF643D5643; Fri, 24 Apr 2026 13:38:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777037937; cv=none; b=gC88zKi8F6DRI+ccHD1+/KOgipg4tIGvodq60QKVVioP7tTfzHf3UdV4FJOXX4ao6Fd/jZxyjjevJYo1NQhz6WAExxDjFojlzcQR0J3ZiFyX1WoAn8ZxU5SpZOcnkpVpTGRfoBEMatRGYEvc4OsizkP1/b2u2Upzy9ZAJdCJA2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777037937; c=relaxed/simple; bh=p62pu+zVV5r+pjF16YzHdwa7CoM2udSjJorQdKccVzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n0IrOjJKH7lbSeul6KEPK9V2A17XOizzhBSMCHe0kHER39S7gJQ0gGvVmXpp5sTv4i/XDJfjAzrzoWS8KMjDRxe5b0QnTLTi3minYYXmn1qCMBPQTsEYd+gOAc56S1vyvTZm64w3EZhgTJTmLIsBLVrP6zIb4Xhcb1qUWvqA3D0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XQl9Mgoa; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XQl9Mgoa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3EEAC19425; Fri, 24 Apr 2026 13:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777037937; bh=p62pu+zVV5r+pjF16YzHdwa7CoM2udSjJorQdKccVzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQl9Mgoab6wZYeQnBPiOHOFKW0PNZ2ICoaBgUS+AJmasjUGklgijHgC/GzU2aE9F8 QM9JCLL+Lvi9GUOfCRSVlZNXFRHOwXMYh8OPu/HkvudXSPqdz0PN9+mcuY75ikd1VE i0py6KaxehKieYr9hXGY98EkeYV4v6vdG0xYqBv4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Minhong He , Andrea Mayer , Jakub Kicinski , Li hongliang <1468888505@139.com>, Sasha Levin Subject: [PATCH 6.6 128/166] ipv6: add NULL checks for idev in SRv6 paths Date: Fri, 24 Apr 2026 15:30:42 +0200 Message-ID: <20260424132559.719708310@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424132532.812258529@linuxfoundation.org> References: <20260424132532.812258529@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Minhong He [ Upstream commit 06413793526251870e20402c39930804f14d59c0 ] __in6_dev_get() can return NULL when the device has no IPv6 configuration (e.g. MTU < IPV6_MIN_MTU or after NETDEV_UNREGISTER). Add NULL checks for idev returned by __in6_dev_get() in both seg6_hmac_validate_skb() and ipv6_srh_rcv() to prevent potential NULL pointer dereferences. Fixes: 1ababeba4a21 ("ipv6: implement dataplane support for rthdr type 4 (Segment Routing Header)") Fixes: bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support") Signed-off-by: Minhong He Reviewed-by: Andrea Mayer Link: https://patch.msgid.link/20260316073301.106643-1-heminhong@kylinos.cn Signed-off-by: Jakub Kicinski Signed-off-by: Li hongliang <1468888505@139.com> Signed-off-by: Sasha Levin --- net/ipv6/exthdrs.c | 4 ++++ net/ipv6/seg6_hmac.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c index 676284b6efe8b..a8790163e8b6d 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -378,6 +378,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb) hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb); idev = __in6_dev_get(skb->dev); + if (!idev) { + kfree_skb(skb); + return -1; + } accept_seg6 = net->ipv6.devconf_all->seg6_enabled; if (accept_seg6 > idev->cnf.seg6_enabled) diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c index 6e15a65faeccd..bf97bf5ac1387 100644 --- a/net/ipv6/seg6_hmac.c +++ b/net/ipv6/seg6_hmac.c @@ -244,6 +244,8 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb) struct inet6_dev *idev; idev = __in6_dev_get(skb->dev); + if (!idev) + return false; srh = (struct ipv6_sr_hdr *)skb_transport_header(skb); -- 2.53.0