Skip to contentSkip to conversation

netfilter: xt_recent: fix (increase) ipv6 literal buffer length

PATCH In review Maciej Żenczykowski 2 participants 2 messages Nov 5, 2023 – Nov 7, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 netfilter: xt_recent: fix (increase) ipv6 literal buffer length

From: Maciej Żenczykowski <[email protected]>

in6_pton() supports 'low-32-bit dot-decimal representation' (this is useful with DNS64/NAT64 networks for example):

  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:1.2.3.4 > /proc/self/net/xt_recent/DEFAULT
  # cat /proc/self/net/xt_recent/DEFAULT
  src=aaaa:bbbb:cccc:dddd:eeee:ffff:0102:0304 ttl: 0 last_seen: 9733848829 oldest_pkt: 1 9733848829

but the provided buffer is too short:

  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:255.255.255.255 > /proc/self/net/xt_recent/DEFAULT
  -bash: echo: write error: Invalid argument
Cc Jan Engelhardt <[email protected]>
Cc Patrick McHardy <[email protected]>
Fixes 079aa88fe717 ("netfilter: xt_recent: IPv6 support")
---
 net/netfilter/xt_recent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_recent.c +1 -1
index 7ddb9a78e3fc..ef93e0d3bee0 100644
@@ -561,7 +561,7 @@ recent_mt_proc_write(struct file *file, const char __user *input,
 {
 	struct recent_table *t = pde_data(file_inode(file));
 	struct recent_entry *e;
-	char buf[sizeof("+b335:1d35:1e55:dead:c0de:1715:5afe:c0de")];
+	char buf[sizeof("+b335:1d35:1e55:dead:c0de:1715:255.255.255.255")];
 	const char *c = buf;
 	union nf_inet_addr addr = {};
 	u_int16_t family;
Signature · 1 line
2.42.0.869.gea05f2083d-goog
reviewer Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

in6_pton() supports 'low-32-bit dot-decimal representation' (this is useful with DNS64/NAT64 networks for example):

  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:1.2.3.4 > /proc/self/net/xt_recent/DEFAULT
  # cat /proc/self/net/xt_recent/DEFAULT
  src=aaaa:bbbb:cccc:dddd:eeee:ffff:0102:0304 ttl: 0 last_seen: 9733848829 oldest_pkt: 1 9733848829

but the provided buffer is too short:

Quoted 7 lines
  # echo +aaaa:bbbb:cccc:dddd:eeee:ffff:255.255.255.255 > /proc/self/net/xt_recent/DEFAULT
  -bash: echo: write error: Invalid argument
Cc Jan Engelhardt <[email protected]>
Cc Patrick McHardy <[email protected]>
Fixes 079aa88fe717 ("netfilter: xt_recent: IPv6 support")