]> git.ipfire.org Git - thirdparty/linux.git/commit
netfilter: x_tables: avoid leaking percpu counter pointers
authorKyle Zeng <kylebot@openai.com>
Sat, 6 Jun 2026 08:10:31 +0000 (01:10 -0700)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 10 Jun 2026 15:59:01 +0000 (17:59 +0200)
commitf7f2fbb0e893a0238dc464f8d8c0f5609bec584f
treee2886b33a6821900694c7e4fc017a6a89c360de1
parentc3009418f9fa1dcb3eb86f4d8c92583537b5faa3
netfilter: x_tables: avoid leaking percpu counter pointers

The native and compat get-entries paths copy the fixed rule entry header
from the kernelized rule blob to userspace before overwriting the entry's
counter fields with a sanitized counter snapshot.

On SMP kernels, entry->counters.pcnt contains the percpu allocation
address used by x_tables rule counters. A caller can provide a userspace
buffer that faults during the initial fixed-header copy after pcnt has
been copied but before the later sanitized counter copy runs. The syscall
then returns -EFAULT while leaving the raw percpu pointer in userspace.

Copy only the fixed entry prefix before counters from the kernelized rule
blob, then copy the sanitized counter snapshot into the counter field.
Apply this ordering to the IPv4, IPv6, and ARP native and compat
get-entries implementations so a fault cannot expose the internal percpu
counter pointer.

Fixes: 71ae0dff02d7 ("netfilter: xtables: use percpu rule counters")
Signed-off-by: Kyle Zeng <kylebot@openai.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv6/netfilter/ip6_tables.c