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 BE63934389F; Sat, 30 May 2026 17:41:31 +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=1780162892; cv=none; b=MDayH83agVSHoULx2kozQ7Kr4ycCz3uToKtKVfEFf9cVwGg6WD9qBVJFpMHaGPuE5hGFwF14TAPmy9YZYyGHYiELI+jw5CEJzbchAoaiu2KJMtknUgpTk1eFeGZf4edMK/fNvLC8sxynJYfE60Puge+7p1cMqLzW9KXWHO+7TOQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162892; c=relaxed/simple; bh=q3pld3kY0JnaNcEuujSsLVhGsgR/Mn/XQgmryBDg8Jo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G64RuGFEJczGkVb9DfHO6aiyE1nKp3B75Y6TYlTPg9WlXEGP4DYiY7dYCDzjcUZGSzcdzdDVrEIy2ePC6nDkcOkflbJf1mDcwyRMzdF5grwnUtGwgkLydfLG4EVOlKUTQZsYr7lsDRg7UiWSyew4oVpPC3lPcsB62mtnxsxgxfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U1lpKK/N; 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="U1lpKK/N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E1761F00893; Sat, 30 May 2026 17:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162891; bh=yMiSPgqFGoVMZXyWj63QajokchuSUQf3G6xC0NHns8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U1lpKK/NtqdJ3lwzQa4/81dsHISnoxHpAX4etcS40/AAlA4Fpm94K0jiJQT5I+IEn 9erxuGQL2LlyPGyAuEY10Hdg351v2air1Oe+ftHrITM74QdgCYdymOBb4FW/ZkpkcX LOAvDrAXKYH12orTPOCOebj/H6ogAlYzl47nuQXY= 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 5.15 094/776] ipv6: add NULL checks for idev in SRv6 paths Date: Sat, 30 May 2026 17:56:48 +0200 Message-ID: <20260530160242.766816818@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@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 5.15-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 10772dab66bbd..3d249c10e3e9b 100644 --- a/net/ipv6/exthdrs.c +++ b/net/ipv6/exthdrs.c @@ -373,6 +373,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 7e3a857699322..68acff337e414 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