Commit d14976b5 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Yue Haibing
Browse files

tcp_metrics: validate source addr length

stable inclusion
from stable-v5.10.222
commit cdffc358717e436bb67122bb82c1a2a26e050f98
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IAGRRM
CVE: CVE-2024-42154

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=cdffc358717e436bb67122bb82c1a2a26e050f98



---------------------------

[ Upstream commit 66be40e622e177316ae81717aa30057ba9e61dff ]

I don't see anything checking that TCP_METRICS_ATTR_SADDR_IPV4
is at least 4 bytes long, and the policy doesn't have an entry
for this attribute at all (neither does it for IPv6 but v6 is
manually validated).

Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Fixes: 3e7013dd ("tcp: metrics: Allow selective get/del of tcp-metrics based on src IP")
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYue Haibing <yuehaibing@huawei.com>
parent 7b55c48f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -619,6 +619,7 @@ static const struct nla_policy tcp_metrics_nl_policy[TCP_METRICS_ATTR_MAX + 1] =
	[TCP_METRICS_ATTR_ADDR_IPV4]	= { .type = NLA_U32, },
	[TCP_METRICS_ATTR_ADDR_IPV6]	= { .type = NLA_BINARY,
					    .len = sizeof(struct in6_addr), },
	[TCP_METRICS_ATTR_SADDR_IPV4]	= { .type = NLA_U32, },
	/* Following attributes are not received for GET/DEL,
	 * we keep them for reference
	 */