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 8B5E64409; Mon, 23 Jun 2025 21:37:17 +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=1750714637; cv=none; b=hOoWvzmAv8sFy+ku5JQXejW9N7RdzIsdNzVknqby2hASQtLobk9QTKml8IAas3GsIbFIuamJATAo3k/uO+q3wqJQxPUHM96zRo0mjG5wTZC72HR0X+1jN14XfzwOo863pbqHjFnHK8mfawcClIejXQPVw0Fpo+0LYf/K4yh53zM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714637; c=relaxed/simple; bh=qRgSTkSRJi1Ce8/x6ZY9SXafpVUEdev6tAkoNJi2BkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fDpzAeo7301WJe2I9KJnChHssle6l0Wwt+29w8OJX29LAWfOS3/GiFarifONmj81dMakjW2K3eb9u2PCGgZk481vGVxWY5Vil57iQxLv1WB/jkO0PrMeZIh4SmblrFxz/0kcqwRWW3S5EsfWs2ZNrHX/OPB0GYFjzSgPyBLZDmw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KYHmDr3o; 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="KYHmDr3o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24E31C4CEED; Mon, 23 Jun 2025 21:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714637; bh=qRgSTkSRJi1Ce8/x6ZY9SXafpVUEdev6tAkoNJi2BkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYHmDr3oW0teNOeIbGgqiptZWysM0VQxSYCsLlQ5Y9RseIHgjq/zlUxg/Es7noPaw 7/JMP+LuWHs1X9TlNPeNnMcZWI/nVb210l/+tfOS+kNbnTWOk1R7dbqE46/zlU8Xln zxQJuL0dZ6ZMTruBFDM4YD6N6Gpdx2nTC+tFC0xM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Petr Machata , Ido Schimmel , David Ahern , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 186/508] seg6: Fix validation of nexthop addresses Date: Mon, 23 Jun 2025 15:03:51 +0200 Message-ID: <20250623130649.849204199@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130645.255320792@linuxfoundation.org> References: <20250623130645.255320792@linuxfoundation.org> User-Agent: quilt/0.68 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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ido Schimmel [ Upstream commit 7632fedb266d93ed0ed9f487133e6c6314a9b2d1 ] The kernel currently validates that the length of the provided nexthop address does not exceed the specified length. This can lead to the kernel reading uninitialized memory if user space provided a shorter length than the specified one. Fix by validating that the provided length exactly matches the specified one. Fixes: d1df6fd8a1d2 ("ipv6: sr: define core operations for seg6local lightweight tunnel") Reviewed-by: Petr Machata Signed-off-by: Ido Schimmel Reviewed-by: David Ahern Link: https://patch.msgid.link/20250604113252.371528-1-idosch@nvidia.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/seg6_local.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index 33cb0381b5749..b7d9a68a265d7 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -1250,10 +1250,8 @@ static const struct nla_policy seg6_local_policy[SEG6_LOCAL_MAX + 1] = { [SEG6_LOCAL_SRH] = { .type = NLA_BINARY }, [SEG6_LOCAL_TABLE] = { .type = NLA_U32 }, [SEG6_LOCAL_VRFTABLE] = { .type = NLA_U32 }, - [SEG6_LOCAL_NH4] = { .type = NLA_BINARY, - .len = sizeof(struct in_addr) }, - [SEG6_LOCAL_NH6] = { .type = NLA_BINARY, - .len = sizeof(struct in6_addr) }, + [SEG6_LOCAL_NH4] = NLA_POLICY_EXACT_LEN(sizeof(struct in_addr)), + [SEG6_LOCAL_NH6] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), [SEG6_LOCAL_IIF] = { .type = NLA_U32 }, [SEG6_LOCAL_OIF] = { .type = NLA_U32 }, [SEG6_LOCAL_BPF] = { .type = NLA_NESTED }, -- 2.39.5