From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 35C002F8EB5; Sat, 30 May 2026 16:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780159251; cv=none; b=VjgQ07zSBYYFz82L25UELkc7etVcof6m/kHTcMNfcyX2xwDOa+AFmmDbufcXqnBUfHoAE1o5CZGNL0ozDLQ4QTUKWNa7AysAR3OuCNOrGnmP2hsywhROnxrGV6PXxBlfWlivLZN16YbzXbsEKLvXqK0PCEAcpoE+5S1DdrOwy2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780159251; c=relaxed/simple; bh=3VDeQMt/4aKDRK4oVqQ8kE+HEAGno3ms3v4le1zm+iQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J4O71SLbfL+qggIbHYIfRNbLCvo6eODd4a2fqVsteTIgprGVOiIg9iAoeHdnNWHvq2KvUmx26cPG7ZHrSSqbt9RGUEBjCPJV+5ACkf/a36mCNKqO2Qkza7YfFy6bKte4HAlvPcuGucrkXYW/mnvFnhgBzIOaHvTYnY4N3JY9rMU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zAMIg7Kb; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zAMIg7Kb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C6701F00893; Sat, 30 May 2026 16:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780159249; bh=sb4AsyBYQZjCR6J+MoOO8prIQWAldldBNCcWYmHcF2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zAMIg7KbCeiRSWN769ZoynyjXx9nzpUetGIZ9IZ8jLzWTeJK4c6wcX3Bt7yKzpdGj mLmvN71WgSC2FBqZ64PkzKi56LJ74tpRI6gYWH8YCRTWwkCjXk1X4PcB/hQISalFZG X2bsvXzR8Y8qZ7GrMAjPPm47ZJ7GAVsYnRuqFr0c= 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.1 112/969] ipv6: add NULL checks for idev in SRv6 paths Date: Sat, 30 May 2026 17:53:56 +0200 Message-ID: <20260530160303.406700136@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 61e0060185f4b..5fb97a87d2cb5 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -381,6 +381,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 b90c286d77ed4..e784f539194ad 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