Skip to contentSkip to conversation

tcp_metrics: validate source addr length

PATCH Superseded Jakub Kicinski 2 participants 2 messages Jun 26, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 tcp_metrics: validate source addr length

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).

Fixes 8a59359cb80f ("tcp: metrics: New netlink attribute for src IP and dumped in netlink reply")

---
In net-next we can make v6 use policy for validation, too. But it will conflict, so I'll send that on Thu.
---
CC: [email protected]
CC: [email protected]

---
 net/ipv4/tcp_metrics.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/tcp_metrics.c +1 -0
index e93df98de3f4..b01eb6d94413 100644
@@ -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
 	 */
Signature · 1 line
2.45.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jakub Kicinski

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).

Fixes 8a59359cb80f ("tcp: metrics: New netlink attribute for src IP and dumped in netlink reply")

This commit added dump only for these attributes.

It seems the bug was added in

commit 3e7013ddf55af7bc191792b8aea0c2b94fb0fef5

Author: Christoph Paasch <[email protected]>
Date:   Wed Jan 8 16:05:59 2014 +0100

tcp: metrics: Allow selective get/del of tcp-metrics based on src IP

Quoted 4 lines

---
In net-next we can make v6 use policy for validation, too. But it will conflict, so I'll send that on Thu.