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 414A93D6CD6; Fri, 24 Apr 2026 13:41:29 +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=1777038089; cv=none; b=gM+lwO6xZ4iLX2QTgF04gmekoLks9MfR4S17qgJ23mqzLTlTB+zbo8hVfmfDbo9gSdg0TNvv7Z0K9X4BIRybOxtys2eC4PGTHRtVHzOWm5vZNYjVt9exECpRUbBAoFTtqtnpZdfefFvTjPrm6fQkImej9m+gzKhqcTwe0mu6FVQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777038089; c=relaxed/simple; bh=StX0HdJe2qhXPKfn+VDUREWcDiq2o39uw+YM4ojL4eI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Upw/Tv5mXf2mOi2nrgUZEw5Zb8oESYIKOboZPej9sOUAFLZAusqJISipv8mR2YqcA0GNgp3juyr0hZP2HtginCe3RfYZJXcnMmmWcKa2nl1l8nzUb6D4cXrbMsc5XxdFxao7WgI3clKFxgNVfvZWt9PifO60nYJXKKsTAEb7QjY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hxEDrR45; 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="hxEDrR45" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB8D5C19425; Fri, 24 Apr 2026 13:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777038089; bh=StX0HdJe2qhXPKfn+VDUREWcDiq2o39uw+YM4ojL4eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hxEDrR45gwaVbz5DaOEDncciQjThlAMGoLY9hlI6NSjlmkhQxrWouNFOsn47I5SRc b3apih3E+qiF166uwT01LulUlIhTFrD+5dOnA6NX/XMZ+COW3pq2gSVjSncKfsEQvj dD6OgPSt7GCGrA2lIpDP5eNIl4zHf8+kOTZpQscs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Minhong He , Andrea Mayer , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 02/55] ipv6: add NULL checks for idev in SRv6 paths Date: Fri, 24 Apr 2026 15:30:41 +0200 Message-ID: <20260424132430.494029826@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424132430.006424517@linuxfoundation.org> References: <20260424132430.006424517@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.18-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: 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 310836a0cf17b..1d509b6d16bbd 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -379,6 +379,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 = min(READ_ONCE(net->ipv6.devconf_all->seg6_enabled), READ_ONCE(idev->cnf.seg6_enabled)); diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c index ee6bac0160ace..e6964c6b0d381 100644 --- 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); -- 2.53.0