* [PATCH net 0/8] Netfilter fixes for net
@ 2022-03-01 21:53 Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant Pablo Neira Ayuso
` (7 more replies)
0 siblings, 8 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter fixes for net:
1) Use kfree_rcu(ptr, rcu) variant, using kfree_rcu(ptr) was not
intentional. From Eric Dumazet.
2) Use-after-free in netfilter hook core, from Eric Dumazet.
3) Missing rcu read lock side for netfilter egress hook,
from Florian Westphal.
4) nf_queue assume state->sk is full socket while it might not be.
Invoke sock_gen_put(), from Florian Westphal.
5) Add selftest to exercise the reported KASAN splat in 4)
6) Fix possible use-after-free in nf_queue in case sk_refcnt is 0.
Also from Florian.
7) Use input interface index only for hardware offload, not for
the software plane. This breaks tc ct action. Patch from Paul Blakey.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 277f2bb14361790a70e4b3c649e794b75a91a597:
ibmvnic: schedule failover only if vioctl fails (2022-02-22 17:06:27 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git HEAD
for you to fetch changes up to db6140e5e35a48405e669353bd54042c1d4c3841:
net/sched: act_ct: Fix flow table lookup failure with no originating ifindex (2022-03-01 22:08:31 +0100)
----------------------------------------------------------------
Eric Dumazet (2):
netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant
netfilter: fix use-after-free in __nf_register_net_hook()
Florian Westphal (5):
netfilter: egress: silence egress hook lockdep splats
netfilter: nf_queue: don't assume sk is full socket
selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test
netfilter: nf_queue: fix possible use-after-free
netfilter: nf_queue: handle socket prefetch
Paul Blakey (1):
net/sched: act_ct: Fix flow table lookup failure with no originating ifindex
include/linux/netfilter_netdev.h | 4 +
include/net/netfilter/nf_flow_table.h | 6 +-
include/net/netfilter/nf_queue.h | 2 +-
net/netfilter/core.c | 5 +-
net/netfilter/nf_flow_table_offload.c | 6 +-
net/netfilter/nf_queue.c | 36 +++++-
net/netfilter/nf_tables_api.c | 4 +-
net/netfilter/nfnetlink_queue.c | 12 +-
net/sched/act_ct.c | 13 ++-
tools/testing/selftests/netfilter/.gitignore | 1 +
tools/testing/selftests/netfilter/Makefile | 2 +-
tools/testing/selftests/netfilter/connect_close.c | 136 ++++++++++++++++++++++
tools/testing/selftests/netfilter/nft_queue.sh | 19 +++
13 files changed, 226 insertions(+), 20 deletions(-)
create mode 100644 tools/testing/selftests/netfilter/connect_close.c
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 23:30 ` patchwork-bot+netdevbpf
2022-03-01 21:53 ` [PATCH net 2/8] netfilter: fix use-after-free in __nf_register_net_hook() Pablo Neira Ayuso
` (6 subsequent siblings)
7 siblings, 1 reply; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Eric Dumazet <edumazet@google.com>
While kfree_rcu(ptr) _is_ supported, it has some limitations.
Given that 99.99% of kfree_rcu() users [1] use the legacy
two parameters variant, and @catchall objects do have an rcu head,
simply use it.
Choice of kfree_rcu(ptr) variant was probably not intentional.
[1] including calls from net/netfilter/nf_tables_api.c
Fixes: aaa31047a6d2 ("netfilter: nftables: add catch-all set element support")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 9cd1d7a62804..c86748b3873b 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4502,7 +4502,7 @@ static void nft_set_catchall_destroy(const struct nft_ctx *ctx,
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
list_del_rcu(&catchall->list);
nft_set_elem_destroy(set, catchall->elem, true);
- kfree_rcu(catchall);
+ kfree_rcu(catchall, rcu);
}
}
@@ -5669,7 +5669,7 @@ static void nft_setelem_catchall_remove(const struct net *net,
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
if (catchall->elem == elem->priv) {
list_del_rcu(&catchall->list);
- kfree_rcu(catchall);
+ kfree_rcu(catchall, rcu);
break;
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant
2022-03-01 21:53 ` [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant Pablo Neira Ayuso
@ 2022-03-01 23:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 19+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-01 23:30 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, davem, netdev, kuba
Hello:
This series was applied to netdev/net.git (master)
by Pablo Neira Ayuso <pablo@netfilter.org>:
On Tue, 1 Mar 2022 22:53:30 +0100 you wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> While kfree_rcu(ptr) _is_ supported, it has some limitations.
>
> Given that 99.99% of kfree_rcu() users [1] use the legacy
> two parameters variant, and @catchall objects do have an rcu head,
> simply use it.
>
> [...]
Here is the summary with links:
- [net,1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant
https://git.kernel.org/netdev/net/c/ae089831ff28
- [net,2/8] netfilter: fix use-after-free in __nf_register_net_hook()
https://git.kernel.org/netdev/net/c/56763f12b0f0
- [net,3/8] netfilter: egress: silence egress hook lockdep splats
https://git.kernel.org/netdev/net/c/17a8f31bba7b
- [net,4/8] netfilter: nf_queue: don't assume sk is full socket
https://git.kernel.org/netdev/net/c/747670fd9a2d
- [net,5/8] selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test
https://git.kernel.org/netdev/net/c/2e78855d311c
- [net,6/8] netfilter: nf_queue: fix possible use-after-free
https://git.kernel.org/netdev/net/c/c3873070247d
- [net,7/8] netfilter: nf_queue: handle socket prefetch
https://git.kernel.org/netdev/net/c/3b836da4081f
- [net,8/8] net/sched: act_ct: Fix flow table lookup failure with no originating ifindex
https://git.kernel.org/netdev/net/c/db6140e5e35a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 2/8] netfilter: fix use-after-free in __nf_register_net_hook()
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 3/8] netfilter: egress: silence egress hook lockdep splats Pablo Neira Ayuso
` (5 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Eric Dumazet <edumazet@google.com>
We must not dereference @new_hooks after nf_hook_mutex has been released,
because other threads might have freed our allocated hooks already.
BUG: KASAN: use-after-free in nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline]
BUG: KASAN: use-after-free in hooks_validate net/netfilter/core.c:171 [inline]
BUG: KASAN: use-after-free in __nf_register_net_hook+0x77a/0x820 net/netfilter/core.c:438
Read of size 2 at addr ffff88801c1a8000 by task syz-executor237/4430
CPU: 1 PID: 4430 Comm: syz-executor237 Not tainted 5.17.0-rc5-syzkaller-00306-g2293be58d6a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description.constprop.0.cold+0x8d/0x336 mm/kasan/report.c:255
__kasan_report mm/kasan/report.c:442 [inline]
kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
nf_hook_entries_get_hook_ops include/linux/netfilter.h:130 [inline]
hooks_validate net/netfilter/core.c:171 [inline]
__nf_register_net_hook+0x77a/0x820 net/netfilter/core.c:438
nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571
nf_register_net_hooks+0x59/0xc0 net/netfilter/core.c:587
nf_synproxy_ipv6_init+0x85/0xe0 net/netfilter/nf_synproxy_core.c:1218
synproxy_tg6_check+0x30d/0x560 net/ipv6/netfilter/ip6t_SYNPROXY.c:81
xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038
check_target net/ipv6/netfilter/ip6_tables.c:530 [inline]
find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:573
translate_table+0xc8b/0x1750 net/ipv6/netfilter/ip6_tables.c:735
do_replace net/ipv6/netfilter/ip6_tables.c:1153 [inline]
do_ip6t_set_ctl+0x56e/0xb90 net/ipv6/netfilter/ip6_tables.c:1639
nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
ipv6_setsockopt+0x122/0x180 net/ipv6/ipv6_sockglue.c:1024
rawv6_setsockopt+0xd3/0x6a0 net/ipv6/raw.c:1084
__sys_setsockopt+0x2db/0x610 net/socket.c:2180
__do_sys_setsockopt net/socket.c:2191 [inline]
__se_sys_setsockopt net/socket.c:2188 [inline]
__x64_sys_setsockopt+0xba/0x150 net/socket.c:2188
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f65a1ace7d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 71 15 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f65a1a7f308 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00007f65a1ace7d9
RDX: 0000000000000040 RSI: 0000000000000029 RDI: 0000000000000003
RBP: 00007f65a1b574c8 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000246 R12: 00007f65a1b55130
R13: 00007f65a1b574c0 R14: 00007f65a1b24090 R15: 0000000000022000
</TASK>
The buggy address belongs to the page:
page:ffffea0000706a00 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1c1a8
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 ffffea0001c1b108 ffffea000046dd08 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as freed
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x52dc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_ZERO), pid 4430, ts 1061781545818, free_ts 1061791488993
prep_new_page mm/page_alloc.c:2434 [inline]
get_page_from_freelist+0xa72/0x2f50 mm/page_alloc.c:4165
__alloc_pages+0x1b2/0x500 mm/page_alloc.c:5389
__alloc_pages_node include/linux/gfp.h:572 [inline]
alloc_pages_node include/linux/gfp.h:595 [inline]
kmalloc_large_node+0x62/0x130 mm/slub.c:4438
__kmalloc_node+0x35a/0x4a0 mm/slub.c:4454
kmalloc_node include/linux/slab.h:604 [inline]
kvmalloc_node+0x97/0x100 mm/util.c:580
kvmalloc include/linux/slab.h:731 [inline]
kvzalloc include/linux/slab.h:739 [inline]
allocate_hook_entries_size net/netfilter/core.c:61 [inline]
nf_hook_entries_grow+0x140/0x780 net/netfilter/core.c:128
__nf_register_net_hook+0x144/0x820 net/netfilter/core.c:429
nf_register_net_hook+0x114/0x170 net/netfilter/core.c:571
nf_register_net_hooks+0x59/0xc0 net/netfilter/core.c:587
nf_synproxy_ipv6_init+0x85/0xe0 net/netfilter/nf_synproxy_core.c:1218
synproxy_tg6_check+0x30d/0x560 net/ipv6/netfilter/ip6t_SYNPROXY.c:81
xt_check_target+0x26c/0x9e0 net/netfilter/x_tables.c:1038
check_target net/ipv6/netfilter/ip6_tables.c:530 [inline]
find_check_entry.constprop.0+0x7f1/0x9e0 net/ipv6/netfilter/ip6_tables.c:573
translate_table+0xc8b/0x1750 net/ipv6/netfilter/ip6_tables.c:735
do_replace net/ipv6/netfilter/ip6_tables.c:1153 [inline]
do_ip6t_set_ctl+0x56e/0xb90 net/ipv6/netfilter/ip6_tables.c:1639
nf_setsockopt+0x83/0xe0 net/netfilter/nf_sockopt.c:101
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1352 [inline]
free_pcp_prepare+0x374/0x870 mm/page_alloc.c:1404
free_unref_page_prepare mm/page_alloc.c:3325 [inline]
free_unref_page+0x19/0x690 mm/page_alloc.c:3404
kvfree+0x42/0x50 mm/util.c:613
rcu_do_batch kernel/rcu/tree.c:2527 [inline]
rcu_core+0x7b1/0x1820 kernel/rcu/tree.c:2778
__do_softirq+0x29b/0x9c2 kernel/softirq.c:558
Memory state around the buggy address:
ffff88801c1a7f00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88801c1a7f80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff88801c1a8000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88801c1a8080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88801c1a8100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Fixes: 2420b79f8c18 ("netfilter: debug: check for sorted array")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 354cb472f386..8a77a3fd69bc 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -428,14 +428,15 @@ static int __nf_register_net_hook(struct net *net, int pf,
p = nf_entry_dereference(*pp);
new_hooks = nf_hook_entries_grow(p, reg);
- if (!IS_ERR(new_hooks))
+ if (!IS_ERR(new_hooks)) {
+ hooks_validate(new_hooks);
rcu_assign_pointer(*pp, new_hooks);
+ }
mutex_unlock(&nf_hook_mutex);
if (IS_ERR(new_hooks))
return PTR_ERR(new_hooks);
- hooks_validate(new_hooks);
#ifdef CONFIG_NETFILTER_INGRESS
if (nf_ingress_hook(reg, pf))
net_inc_ingress_queue();
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 3/8] netfilter: egress: silence egress hook lockdep splats
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 2/8] netfilter: fix use-after-free in __nf_register_net_hook() Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 4/8] netfilter: nf_queue: don't assume sk is full socket Pablo Neira Ayuso
` (4 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
Netfilter assumes its called with rcu_read_lock held, but in egress
hook case it may be called with BH readlock.
This triggers lockdep splat.
In order to avoid to change all rcu_dereference() to
rcu_dereference_check(..., rcu_read_lock_bh_held()), wrap nf_hook_slow
with read lock/unlock pair.
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/linux/netfilter_netdev.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/netfilter_netdev.h b/include/linux/netfilter_netdev.h
index b4dd96e4dc8d..e6487a691136 100644
--- a/include/linux/netfilter_netdev.h
+++ b/include/linux/netfilter_netdev.h
@@ -101,7 +101,11 @@ static inline struct sk_buff *nf_hook_egress(struct sk_buff *skb, int *rc,
nf_hook_state_init(&state, NF_NETDEV_EGRESS,
NFPROTO_NETDEV, dev, NULL, NULL,
dev_net(dev), NULL);
+
+ /* nf assumes rcu_read_lock, not just read_lock_bh */
+ rcu_read_lock();
ret = nf_hook_slow(skb, &state, e, 0);
+ rcu_read_unlock();
if (ret == 1) {
return skb;
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 4/8] netfilter: nf_queue: don't assume sk is full socket
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
` (2 preceding siblings ...)
2022-03-01 21:53 ` [PATCH net 3/8] netfilter: egress: silence egress hook lockdep splats Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 5/8] selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test Pablo Neira Ayuso
` (3 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
There is no guarantee that state->sk refers to a full socket.
If refcount transitions to 0, sock_put calls sk_free which then ends up
with garbage fields.
I'd like to thank Oleksandr Natalenko and Jiri Benc for considerable
debug work and pointing out state->sk oddities.
Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener")
Tested-by: Oleksandr Natalenko <oleksandr@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nf_queue.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 6d12afabfe8a..5ab0680db445 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -46,6 +46,15 @@ void nf_unregister_queue_handler(void)
}
EXPORT_SYMBOL(nf_unregister_queue_handler);
+static void nf_queue_sock_put(struct sock *sk)
+{
+#ifdef CONFIG_INET
+ sock_gen_put(sk);
+#else
+ sock_put(sk);
+#endif
+}
+
static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
{
struct nf_hook_state *state = &entry->state;
@@ -54,7 +63,7 @@ static void nf_queue_entry_release_refs(struct nf_queue_entry *entry)
dev_put(state->in);
dev_put(state->out);
if (state->sk)
- sock_put(state->sk);
+ nf_queue_sock_put(state->sk);
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
dev_put(entry->physin);
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 5/8] selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
` (3 preceding siblings ...)
2022-03-01 21:53 ` [PATCH net 4/8] netfilter: nf_queue: don't assume sk is full socket Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 6/8] netfilter: nf_queue: fix possible use-after-free Pablo Neira Ayuso
` (2 subsequent siblings)
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
causes:
BUG: KASAN: slab-out-of-bounds in sk_free+0x25/0x80
Write of size 4 at addr ffff888106df0284 by task nf-queue/1459
sk_free+0x25/0x80
nf_queue_entry_release_refs+0x143/0x1a0
nf_reinject+0x233/0x770
... without 'netfilter: nf_queue: don't assume sk is full socket'.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tools/testing/selftests/netfilter/.gitignore | 1 +
tools/testing/selftests/netfilter/Makefile | 2 +-
.../selftests/netfilter/connect_close.c | 136 ++++++++++++++++++
.../testing/selftests/netfilter/nft_queue.sh | 19 +++
4 files changed, 157 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/netfilter/connect_close.c
diff --git a/tools/testing/selftests/netfilter/.gitignore b/tools/testing/selftests/netfilter/.gitignore
index 8448f74adfec..4cb887b57413 100644
--- a/tools/testing/selftests/netfilter/.gitignore
+++ b/tools/testing/selftests/netfilter/.gitignore
@@ -1,2 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
nf-queue
+connect_close
diff --git a/tools/testing/selftests/netfilter/Makefile b/tools/testing/selftests/netfilter/Makefile
index e4f845dd942b..7e81c9a7fff9 100644
--- a/tools/testing/selftests/netfilter/Makefile
+++ b/tools/testing/selftests/netfilter/Makefile
@@ -9,6 +9,6 @@ TEST_PROGS := nft_trans_stress.sh nft_fib.sh nft_nat.sh bridge_brouter.sh \
conntrack_vrf.sh nft_synproxy.sh
LDLIBS = -lmnl
-TEST_GEN_FILES = nf-queue
+TEST_GEN_FILES = nf-queue connect_close
include ../lib.mk
diff --git a/tools/testing/selftests/netfilter/connect_close.c b/tools/testing/selftests/netfilter/connect_close.c
new file mode 100644
index 000000000000..1c3b0add54c4
--- /dev/null
+++ b/tools/testing/selftests/netfilter/connect_close.c
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <signal.h>
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+
+#define PORT 12345
+#define RUNTIME 10
+
+static struct {
+ unsigned int timeout;
+ unsigned int port;
+} opts = {
+ .timeout = RUNTIME,
+ .port = PORT,
+};
+
+static void handler(int sig)
+{
+ _exit(sig == SIGALRM ? 0 : 1);
+}
+
+static void set_timeout(void)
+{
+ struct sigaction action = {
+ .sa_handler = handler,
+ };
+
+ sigaction(SIGALRM, &action, NULL);
+
+ alarm(opts.timeout);
+}
+
+static void do_connect(const struct sockaddr_in *dst)
+{
+ int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if (s >= 0)
+ fcntl(s, F_SETFL, O_NONBLOCK);
+
+ connect(s, (struct sockaddr *)dst, sizeof(*dst));
+ close(s);
+}
+
+static void do_accept(const struct sockaddr_in *src)
+{
+ int c, one = 1, s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+ if (s < 0)
+ return;
+
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one));
+
+ bind(s, (struct sockaddr *)src, sizeof(*src));
+
+ listen(s, 16);
+
+ c = accept(s, NULL, NULL);
+ if (c >= 0)
+ close(c);
+
+ close(s);
+}
+
+static int accept_loop(void)
+{
+ struct sockaddr_in src = {
+ .sin_family = AF_INET,
+ .sin_port = htons(opts.port),
+ };
+
+ inet_pton(AF_INET, "127.0.0.1", &src.sin_addr);
+
+ set_timeout();
+
+ for (;;)
+ do_accept(&src);
+
+ return 1;
+}
+
+static int connect_loop(void)
+{
+ struct sockaddr_in dst = {
+ .sin_family = AF_INET,
+ .sin_port = htons(opts.port),
+ };
+
+ inet_pton(AF_INET, "127.0.0.1", &dst.sin_addr);
+
+ set_timeout();
+
+ for (;;)
+ do_connect(&dst);
+
+ return 1;
+}
+
+static void parse_opts(int argc, char **argv)
+{
+ int c;
+
+ while ((c = getopt(argc, argv, "t:p:")) != -1) {
+ switch (c) {
+ case 't':
+ opts.timeout = atoi(optarg);
+ break;
+ case 'p':
+ opts.port = atoi(optarg);
+ break;
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ pid_t p;
+
+ parse_opts(argc, argv);
+
+ p = fork();
+ if (p < 0)
+ return 111;
+
+ if (p > 0)
+ return accept_loop();
+
+ return connect_loop();
+}
diff --git a/tools/testing/selftests/netfilter/nft_queue.sh b/tools/testing/selftests/netfilter/nft_queue.sh
index 7d27f1f3bc01..e12729753351 100755
--- a/tools/testing/selftests/netfilter/nft_queue.sh
+++ b/tools/testing/selftests/netfilter/nft_queue.sh
@@ -113,6 +113,7 @@ table inet $name {
chain output {
type filter hook output priority $prio; policy accept;
tcp dport 12345 queue num 3
+ tcp sport 23456 queue num 3
jump nfq
}
chain post {
@@ -296,6 +297,23 @@ test_tcp_localhost()
wait 2>/dev/null
}
+test_tcp_localhost_connectclose()
+{
+ tmpfile=$(mktemp) || exit 1
+
+ ip netns exec ${nsrouter} ./connect_close -p 23456 -t $timeout &
+
+ ip netns exec ${nsrouter} ./nf-queue -q 3 -t $timeout &
+ local nfqpid=$!
+
+ sleep 1
+ rm -f "$tmpfile"
+
+ wait $rpid
+ [ $? -eq 0 ] && echo "PASS: tcp via loopback with connect/close"
+ wait 2>/dev/null
+}
+
test_tcp_localhost_requeue()
{
ip netns exec ${nsrouter} nft -f /dev/stdin <<EOF
@@ -424,6 +442,7 @@ test_queue 20
test_tcp_forward
test_tcp_localhost
+test_tcp_localhost_connectclose
test_tcp_localhost_requeue
test_icmp_vrf
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 6/8] netfilter: nf_queue: fix possible use-after-free
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
` (4 preceding siblings ...)
2022-03-01 21:53 ` [PATCH net 5/8] selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 7/8] netfilter: nf_queue: handle socket prefetch Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 8/8] net/sched: act_ct: Fix flow table lookup failure with no originating ifindex Pablo Neira Ayuso
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
Eric Dumazet says:
The sock_hold() side seems suspect, because there is no guarantee
that sk_refcnt is not already 0.
On failure, we cannot queue the packet and need to indicate an
error. The packet will be dropped by the caller.
v2: split skb prefetch hunk into separate change
Fixes: 271b72c7fa82c ("udp: RCU handling for Unicast packets.")
Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/net/netfilter/nf_queue.h | 2 +-
net/netfilter/nf_queue.c | 13 +++++++++----
net/netfilter/nfnetlink_queue.c | 12 +++++++++---
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h
index 9eed51e920e8..980daa6e1e3a 100644
--- a/include/net/netfilter/nf_queue.h
+++ b/include/net/netfilter/nf_queue.h
@@ -37,7 +37,7 @@ void nf_register_queue_handler(const struct nf_queue_handler *qh);
void nf_unregister_queue_handler(void);
void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict);
-void nf_queue_entry_get_refs(struct nf_queue_entry *entry);
+bool nf_queue_entry_get_refs(struct nf_queue_entry *entry);
void nf_queue_entry_free(struct nf_queue_entry *entry);
static inline void init_hashrandom(u32 *jhash_initval)
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index 5ab0680db445..e39549c55945 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -96,19 +96,21 @@ static void __nf_queue_entry_init_physdevs(struct nf_queue_entry *entry)
}
/* Bump dev refs so they don't vanish while packet is out */
-void nf_queue_entry_get_refs(struct nf_queue_entry *entry)
+bool nf_queue_entry_get_refs(struct nf_queue_entry *entry)
{
struct nf_hook_state *state = &entry->state;
+ if (state->sk && !refcount_inc_not_zero(&state->sk->sk_refcnt))
+ return false;
+
dev_hold(state->in);
dev_hold(state->out);
- if (state->sk)
- sock_hold(state->sk);
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
dev_hold(entry->physin);
dev_hold(entry->physout);
#endif
+ return true;
}
EXPORT_SYMBOL_GPL(nf_queue_entry_get_refs);
@@ -196,7 +198,10 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
__nf_queue_entry_init_physdevs(entry);
- nf_queue_entry_get_refs(entry);
+ if (!nf_queue_entry_get_refs(entry)) {
+ kfree(entry);
+ return -ENOTCONN;
+ }
switch (entry->state.pf) {
case AF_INET:
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index ea2d9c2a44cf..64a6acb6aeae 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -710,9 +710,15 @@ static struct nf_queue_entry *
nf_queue_entry_dup(struct nf_queue_entry *e)
{
struct nf_queue_entry *entry = kmemdup(e, e->size, GFP_ATOMIC);
- if (entry)
- nf_queue_entry_get_refs(entry);
- return entry;
+
+ if (!entry)
+ return NULL;
+
+ if (nf_queue_entry_get_refs(entry))
+ return entry;
+
+ kfree(entry);
+ return NULL;
}
#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 7/8] netfilter: nf_queue: handle socket prefetch
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
` (5 preceding siblings ...)
2022-03-01 21:53 ` [PATCH net 6/8] netfilter: nf_queue: fix possible use-after-free Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 8/8] net/sched: act_ct: Fix flow table lookup failure with no originating ifindex Pablo Neira Ayuso
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
In case someone combines bpf socket assign and nf_queue, then we will
queue an skb who references a struct sock that did not have its
reference count incremented.
As we leave rcu protection, there is no guarantee that skb->sk is still
valid.
For refcount-less skb->sk case, try to increment the reference count
and then override the destructor.
In case of failure we have two choices: orphan the skb and 'delete'
preselect or let nf_queue() drop the packet.
Do the latter, it should not happen during normal operation.
Fixes: cf7fbe660f2d ("bpf: Add socket assign support")
Acked-by: Joe Stringer <joe@cilium.io>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nf_queue.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c
index e39549c55945..63d1516816b1 100644
--- a/net/netfilter/nf_queue.c
+++ b/net/netfilter/nf_queue.c
@@ -180,6 +180,18 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
break;
}
+ if (skb_sk_is_prefetched(skb)) {
+ struct sock *sk = skb->sk;
+
+ if (!sk_is_refcounted(sk)) {
+ if (!refcount_inc_not_zero(&sk->sk_refcnt))
+ return -ENOTCONN;
+
+ /* drop refcount on skb_orphan */
+ skb->destructor = sock_edemux;
+ }
+ }
+
entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
if (!entry)
return -ENOMEM;
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 8/8] net/sched: act_ct: Fix flow table lookup failure with no originating ifindex
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
` (6 preceding siblings ...)
2022-03-01 21:53 ` [PATCH net 7/8] netfilter: nf_queue: handle socket prefetch Pablo Neira Ayuso
@ 2022-03-01 21:53 ` Pablo Neira Ayuso
7 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-01 21:53 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Paul Blakey <paulb@nvidia.com>
After cited commit optimizted hw insertion, flow table entries are
populated with ifindex information which was intended to only be used
for HW offload. This tuple ifindex is hashed in the flow table key, so
it must be filled for lookup to be successful. But tuple ifindex is only
relevant for the netfilter flowtables (nft), so it's not filled in
act_ct flow table lookup, resulting in lookup failure, and no SW
offload and no offload teardown for TCP connection FIN/RST packets.
To fix this, add new tc ifindex field to tuple, which will
only be used for offloading, not for lookup, as it will not be
part of the tuple hash.
Fixes: 9795ded7f924 ("net/sched: act_ct: Fill offloading tuple iifidx")
Signed-off-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/net/netfilter/nf_flow_table.h | 6 +++++-
net/netfilter/nf_flow_table_offload.c | 6 +++++-
net/sched/act_ct.c | 13 +++++++++----
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h
index a3647fadf1cc..bd59e950f4d6 100644
--- a/include/net/netfilter/nf_flow_table.h
+++ b/include/net/netfilter/nf_flow_table.h
@@ -96,6 +96,7 @@ enum flow_offload_xmit_type {
FLOW_OFFLOAD_XMIT_NEIGH,
FLOW_OFFLOAD_XMIT_XFRM,
FLOW_OFFLOAD_XMIT_DIRECT,
+ FLOW_OFFLOAD_XMIT_TC,
};
#define NF_FLOW_TABLE_ENCAP_MAX 2
@@ -127,7 +128,7 @@ struct flow_offload_tuple {
struct { } __hash;
u8 dir:2,
- xmit_type:2,
+ xmit_type:3,
encap_num:2,
in_vlan_ingress:2;
u16 mtu;
@@ -142,6 +143,9 @@ struct flow_offload_tuple {
u8 h_source[ETH_ALEN];
u8 h_dest[ETH_ALEN];
} out;
+ struct {
+ u32 iifidx;
+ } tc;
};
};
diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
index b561e0a44a45..fc4265acd9c4 100644
--- a/net/netfilter/nf_flow_table_offload.c
+++ b/net/netfilter/nf_flow_table_offload.c
@@ -110,7 +110,11 @@ static int nf_flow_rule_match(struct nf_flow_match *match,
nf_flow_rule_lwt_match(match, tun_info);
}
- key->meta.ingress_ifindex = tuple->iifidx;
+ if (tuple->xmit_type == FLOW_OFFLOAD_XMIT_TC)
+ key->meta.ingress_ifindex = tuple->tc.iifidx;
+ else
+ key->meta.ingress_ifindex = tuple->iifidx;
+
mask->meta.ingress_ifindex = 0xffffffff;
if (tuple->encap_num > 0 && !(tuple->in_vlan_ingress & BIT(0)) &&
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 33e70d60f0bf..ec19f625863a 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -361,6 +361,13 @@ static void tcf_ct_flow_table_put(struct tcf_ct_params *params)
}
}
+static void tcf_ct_flow_tc_ifidx(struct flow_offload *entry,
+ struct nf_conn_act_ct_ext *act_ct_ext, u8 dir)
+{
+ entry->tuplehash[dir].tuple.xmit_type = FLOW_OFFLOAD_XMIT_TC;
+ entry->tuplehash[dir].tuple.tc.iifidx = act_ct_ext->ifindex[dir];
+}
+
static void tcf_ct_flow_table_add(struct tcf_ct_flow_table *ct_ft,
struct nf_conn *ct,
bool tcp)
@@ -385,10 +392,8 @@ static void tcf_ct_flow_table_add(struct tcf_ct_flow_table *ct_ft,
act_ct_ext = nf_conn_act_ct_ext_find(ct);
if (act_ct_ext) {
- entry->tuplehash[FLOW_OFFLOAD_DIR_ORIGINAL].tuple.iifidx =
- act_ct_ext->ifindex[IP_CT_DIR_ORIGINAL];
- entry->tuplehash[FLOW_OFFLOAD_DIR_REPLY].tuple.iifidx =
- act_ct_ext->ifindex[IP_CT_DIR_REPLY];
+ tcf_ct_flow_tc_ifidx(entry, act_ct_ext, FLOW_OFFLOAD_DIR_ORIGINAL);
+ tcf_ct_flow_tc_ifidx(entry, act_ct_ext, FLOW_OFFLOAD_DIR_REPLY);
}
err = flow_offload_add(&ct_ft->nf_ft, entry);
--
2.30.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH net 0/8] Netfilter fixes for net
@ 2024-08-14 22:20 Pablo Neira Ayuso
0 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2024-08-14 22:20 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw
Hi,
The following patchset contains Netfilter fixes for net:
1) Ignores ifindex for types other than mcast/linklocal in ipv6 frag
reasm, from Tom Hughes.
2) Initialize extack for begin/end netlink message marker in batch,
from Donald Hunter.
3) Initialize extack for flowtable offload support, also from Donald.
4) Dropped packets with cloned unconfirmed conntracks in nfqueue,
later it should be possible to explore lookup after reinject but
Florian prefers this approach at this stage. From Florian Westphal.
5) Add selftest for cloned unconfirmed conntracks in nfqueue for
previous update.
6) Audit after filling netlink header successfully in object dump,
from Phil Sutter.
7-8) Fix concurrent dump and reset which could result in underflow
counter / quota objects.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-24-08-15
Thanks.
----------------------------------------------------------------
The following changes since commit a2cbb1603943281a604f5adc48079a148db5cb0d:
tcp: Update window clamping condition (2024-08-14 10:50:49 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-24-08-15
for you to fetch changes up to bd662c4218f9648e888bebde9468146965f3f8a0:
netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests (2024-08-14 23:44:55 +0200)
----------------------------------------------------------------
netfilter pull request 24-08-15
----------------------------------------------------------------
Donald Hunter (2):
netfilter: nfnetlink: Initialise extack before use in ACKs
netfilter: flowtable: initialise extack before use
Florian Westphal (2):
netfilter: nf_queue: drop packets with cloned unconfirmed conntracks
selftests: netfilter: add test for br_netfilter+conntrack+queue combination
Phil Sutter (3):
netfilter: nf_tables: Audit log dump reset after the fact
netfilter: nf_tables: Introduce nf_tables_getobj_single
netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests
Tom Hughes (1):
netfilter: allow ipv6 fragments to arrive on different devices
net/bridge/br_netfilter_hooks.c | 6 +-
net/ipv6/netfilter/nf_conntrack_reasm.c | 4 +
net/netfilter/nf_flow_table_offload.c | 2 +-
net/netfilter/nf_tables_api.c | 147 ++++++++++++++-------
net/netfilter/nfnetlink.c | 5 +-
net/netfilter/nfnetlink_queue.c | 35 ++++-
tools/testing/selftests/net/netfilter/Makefile | 1 +
.../selftests/net/netfilter/br_netfilter_queue.sh | 78 +++++++++++
8 files changed, 228 insertions(+), 50 deletions(-)
create mode 100755 tools/testing/selftests/net/netfilter/br_netfilter_queue.sh
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 0/8] Netfilter fixes for net
@ 2022-08-09 22:05 Pablo Neira Ayuso
2022-08-10 4:27 ` Jakub Kicinski
0 siblings, 1 reply; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-08-09 22:05 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet
Hi,
The following patchset contains Netfilter fixes for net:
1) Harden set element field checks to avoid out-of-bound memory access,
this patch also fixes the type of issue described in 7e6bc1f6cabc
("netfilter: nf_tables: stricter validation of element data") in a
broader way.
2) Patches to restrict the chain, set, and rule id lookup in the
transaction to the corresponding top-level table, patches from
Thadeu Lima de Souza Cascardo.
3) Fix incorrect comment in ip6t_LOG.h
4) nft_data_init() performs upfront validation of the expected data.
struct nft_data_desc is used to describe the expected data to be
received from userspace. The .size field represents the maximum size
that can be stored, for bound checks. Then, .len is an input/output field
which stores the expected length as input (this is optional, to restrict
the checks), as output it stores the real length received from userspace
(if it was not specified as input). This patch comes in response to
7e6bc1f6cabc ("netfilter: nf_tables: stricter validation of element data")
to address this type of issue in a more generic way by avoid opencoded
data validation. Next patch requires this as a dependency.
5) Disallow jump to implicit chain from set element, this configuration
is invalid. Only allow jump to chain via immediate expression is
supported at this stage.
6) Fix possible null-pointer derefence in the error path of table updates,
if memory allocation of the transaction fails. From Florian Westphal.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit b8c3bf0ed2edf2deaedba5f0bf0bb54c76dee71d:
Merge tag 'for-net-2022-08-08' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth (2022-08-08 20:59:07 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 580077855a40741cf511766129702d97ff02f4d9:
netfilter: nf_tables: fix null deref due to zeroed list head (2022-08-09 20:13:30 +0200)
----------------------------------------------------------------
Christophe JAILLET (1):
netfilter: ip6t_LOG: Fix a typo in a comment
Florian Westphal (1):
netfilter: nf_tables: fix null deref due to zeroed list head
Pablo Neira Ayuso (3):
netfilter: nf_tables: validate variable length element extension
netfilter: nf_tables: upfront validation of data via nft_data_init()
netfilter: nf_tables: disallow jump to implicit chain from set element
Thadeu Lima de Souza Cascardo (3):
netfilter: nf_tables: do not allow SET_ID to refer to another table
netfilter: nf_tables: do not allow CHAIN_ID to refer to another table
netfilter: nf_tables: do not allow RULE_ID to refer to another chain
include/net/netfilter/nf_tables.h | 13 +-
include/uapi/linux/netfilter_ipv6/ip6t_LOG.h | 2 +-
net/netfilter/nf_tables_api.c | 184 ++++++++++++++++++---------
net/netfilter/nft_bitwise.c | 66 +++++-----
net/netfilter/nft_cmp.c | 44 +++----
net/netfilter/nft_dynset.c | 2 +-
net/netfilter/nft_immediate.c | 22 +++-
net/netfilter/nft_range.c | 27 ++--
8 files changed, 222 insertions(+), 138 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net 0/8] Netfilter fixes for net
2022-08-09 22:05 Pablo Neira Ayuso
@ 2022-08-10 4:27 ` Jakub Kicinski
2022-08-10 7:59 ` Pablo Neira Ayuso
0 siblings, 1 reply; 19+ messages in thread
From: Jakub Kicinski @ 2022-08-10 4:27 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, davem, netdev, pabeni, edumazet
On Wed, 10 Aug 2022 00:05:24 +0200 Pablo Neira Ayuso wrote:
> git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
That is not the tree you want me to pull from. Mumble, mumble.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net 0/8] Netfilter fixes for net
2022-08-10 4:27 ` Jakub Kicinski
@ 2022-08-10 7:59 ` Pablo Neira Ayuso
0 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-08-10 7:59 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: netfilter-devel, davem, netdev, pabeni, edumazet
On Tue, Aug 09, 2022 at 09:27:14PM -0700, Jakub Kicinski wrote:
> On Wed, 10 Aug 2022 00:05:24 +0200 Pablo Neira Ayuso wrote:
> > git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
>
> That is not the tree you want me to pull from. Mumble, mumble.
Right, one of my computers was running an old version of the script.
Sorry about this.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 0/8] Netfilter fixes for net
@ 2022-01-27 23:52 Pablo Neira Ayuso
0 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2022-01-27 23:52 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter fixes for net:
1) Remove leftovers from flowtable modules, from Geert Uytterhoeven.
2) Missing refcount increment of conntrack template in nft_ct,
from Florian Westphal.
3) Reduce nft_zone selftest time, also from Florian.
4) Add selftest to cover stateless NAT on fragments, from Florian Westphal.
5) Do not set net_device when for reject packets from the bridge path,
from Phil Sutter.
6) Cancel register tracking info on nft_byteorder operations.
7) Extend nft_concat_range selftest to cover set reload with no elements,
from Florian Westphal.
8) Remove useless update of pointer in chain blob builder, reported
by kbuild test robot.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 2f61353cd2f789a4229b6f5c1c24a40a613357bb:
net: hns3: handle empty unknown interrupt for VF (2022-01-25 13:08:05 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to b07f413732549e5a96e891411fbb5980f2d8e5a1:
netfilter: nf_tables: remove assignment with no effect in chain blob builder (2022-01-27 17:50:56 +0100)
----------------------------------------------------------------
Florian Westphal (4):
netfilter: nft_ct: fix use after free when attaching zone template
selftests: netfilter: reduce zone stress test running time
selftests: netfilter: check stateless nat udp checksum fixup
selftests: nft_concat_range: add test for reload with no element add/del
Geert Uytterhoeven (1):
netfilter: Remove flowtable relics
Pablo Neira Ayuso (2):
netfilter: nft_byteorder: track register operations
netfilter: nf_tables: remove assignment with no effect in chain blob builder
Phil Sutter (1):
netfilter: nft_reject_bridge: Fix for missing reply from prerouting
net/bridge/netfilter/nft_reject_bridge.c | 8 +-
net/ipv4/netfilter/Kconfig | 4 -
net/ipv6/netfilter/Kconfig | 4 -
net/ipv6/netfilter/Makefile | 3 -
net/ipv6/netfilter/nf_flow_table_ipv6.c | 0
net/netfilter/nf_tables_api.c | 1 -
net/netfilter/nft_byteorder.c | 12 ++
net/netfilter/nft_ct.c | 5 +-
.../selftests/netfilter/nft_concat_range.sh | 72 +++++++++-
tools/testing/selftests/netfilter/nft_nat.sh | 152 +++++++++++++++++++++
.../testing/selftests/netfilter/nft_zones_many.sh | 12 +-
11 files changed, 249 insertions(+), 24 deletions(-)
delete mode 100644 net/ipv6/netfilter/nf_flow_table_ipv6.c
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 0/8] Netfilter fixes for net
@ 2021-06-22 21:59 Pablo Neira Ayuso
2021-06-22 22:41 ` David Miller
0 siblings, 1 reply; 19+ messages in thread
From: Pablo Neira Ayuso @ 2021-06-22 21:59 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter fixes for net:
1) Nicolas Dichtel updates MAINTAINERS file to add Netfilter IRC channel.
2) Skip non-IPv6 packets in nft_exthdr.
3) Skip non-TCP packets in nft_osf.
4) Skip non-TCP/UDP packets in nft_tproxy.
5) Memleak in hardware offload infrastructure when counters are used
for first time in a rule.
6) The VLAN transfer routine must use FLOW_DISSECTOR_KEY_BASIC instead
of FLOW_DISSECTOR_KEY_CONTROL. Moreover, make a more robust check
for 802.1q and 802.1ad to restore simple matching on transport
protocols.
7) Fix bogus EPERM when listing a ruleset when table ownership flag
is set on.
8) Honor table ownership flag when table is referenced by handle.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thank you!
----------------------------------------------------------------
The following changes since commit a4f0377db1254373513b992ff31a351a7111f0fd:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf (2021-06-15 15:26:07 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to e31f072ffab0397a328b31a9589dcf9733dc9c72:
netfilter: nf_tables: do not allow to delete table with owner by handle (2021-06-22 12:15:05 +0200)
----------------------------------------------------------------
Nicolas Dichtel (1):
MAINTAINERS: netfilter: add irc channel
Pablo Neira Ayuso (7):
netfilter: nft_exthdr: check for IPv6 packet before further processing
netfilter: nft_osf: check for TCP packet before further processing
netfilter: nft_tproxy: restrict support to TCP and UDP transport protocols
netfilter: nf_tables: memleak in hw offload abort path
netfilter: nf_tables_offload: check FLOW_DISSECTOR_KEY_BASIC in VLAN transfer logic
netfilter: nf_tables: skip netlink portID validation if zero
netfilter: nf_tables: do not allow to delete table with owner by handle
MAINTAINERS | 1 +
net/netfilter/nf_tables_api.c | 65 ++++++++++++++++++++++++---------------
net/netfilter/nf_tables_offload.c | 34 +++++---------------
net/netfilter/nft_exthdr.c | 3 ++
net/netfilter/nft_osf.c | 5 +++
net/netfilter/nft_tproxy.c | 9 +++++-
6 files changed, 65 insertions(+), 52 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net 0/8] Netfilter fixes for net
2021-06-22 21:59 Pablo Neira Ayuso
@ 2021-06-22 22:41 ` David Miller
2021-06-22 23:06 ` Pablo Neira Ayuso
0 siblings, 1 reply; 19+ messages in thread
From: David Miller @ 2021-06-22 22:41 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel, netdev, kuba
[davem@localhost net]$ git pull --no-ff git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
From git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
* branch HEAD -> FETCH_HEAD
Already up to date.
[davem@localhost net]$
???
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH net 0/8] Netfilter fixes for net
2021-06-22 22:41 ` David Miller
@ 2021-06-22 23:06 ` Pablo Neira Ayuso
0 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2021-06-22 23:06 UTC (permalink / raw)
To: David Miller; +Cc: netfilter-devel, netdev, kuba
On Tue, Jun 22, 2021 at 03:41:12PM -0700, David Miller wrote:
>
> [davem@localhost net]$ git pull --no-ff git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
> From git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf
> * branch HEAD -> FETCH_HEAD
> Already up to date.
> [davem@localhost net]$
>
> ???
A robot got stuck here and it did not push out to origin for some
reason, sorry. Please retry, it should be there now.
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH net 0/8] Netfilter fixes for net
@ 2021-05-07 17:47 Pablo Neira Ayuso
0 siblings, 0 replies; 19+ messages in thread
From: Pablo Neira Ayuso @ 2021-05-07 17:47 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter fixes for your net tree:
1) Add SECMARK revision 1 to fix incorrect layout that prevents
from remove rule with this target, from Phil Sutter.
2) Fix pernet exit path spat in arptables, from Florian Westphal.
3) Missing rcu_read_unlock() for unknown nfnetlink callbacks,
reported by syzbot, from Eric Dumazet.
4) Missing check for skb_header_pointer() NULL pointer in
nfnetlink_osf.
5) Remove BUG_ON() after skb_header_pointer() from packet path
in several conntrack helper and the TCP tracker.
6) Fix memleak in the new object error path of userdata.
7) Avoid overflows in nft_hash_buckets(), reported by syzbot,
also from Eric.
8) Avoid overflows in 32bit arches, from Eric.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit bd1af6b5fffd36c12997bd48d61d39dc5796fa7b:
Documentation: ABI: sysfs-class-net-qmi: document pass-through file (2021-05-03 13:40:17 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 6c8774a94e6ad26f29ef103c8671f55c255c6201:
netfilter: nftables: avoid potential overflows on 32bit arches (2021-05-07 10:01:39 +0200)
----------------------------------------------------------------
Eric Dumazet (3):
netfilter: nfnetlink: add a missing rcu_read_unlock()
netfilter: nftables: avoid overflows in nft_hash_buckets()
netfilter: nftables: avoid potential overflows on 32bit arches
Florian Westphal (1):
netfilter: arptables: use pernet ops struct during unregister
Pablo Neira Ayuso (4):
netfilter: xt_SECMARK: add new revision to fix structure layout
netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check
netfilter: remove BUG_ON() after skb_header_pointer()
netfilter: nftables: Fix a memleak from userdata error path in new objects
include/linux/netfilter_arp/arp_tables.h | 3 +-
include/uapi/linux/netfilter/xt_SECMARK.h | 6 +++
net/ipv4/netfilter/arp_tables.c | 5 +-
net/ipv4/netfilter/arptable_filter.c | 2 +-
net/netfilter/nf_conntrack_ftp.c | 5 +-
net/netfilter/nf_conntrack_h323_main.c | 3 +-
net/netfilter/nf_conntrack_irc.c | 5 +-
net/netfilter/nf_conntrack_pptp.c | 4 +-
net/netfilter/nf_conntrack_proto_tcp.c | 6 ++-
net/netfilter/nf_conntrack_sane.c | 5 +-
net/netfilter/nf_tables_api.c | 11 ++--
net/netfilter/nfnetlink.c | 1 +
net/netfilter/nfnetlink_osf.c | 2 +
net/netfilter/nft_set_hash.c | 20 ++++---
net/netfilter/xt_SECMARK.c | 88 ++++++++++++++++++++++++-------
15 files changed, 124 insertions(+), 42 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2024-08-14 22:20 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-01 21:53 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 1/8] netfilter: nf_tables: prefer kfree_rcu(ptr, rcu) variant Pablo Neira Ayuso
2022-03-01 23:30 ` patchwork-bot+netdevbpf
2022-03-01 21:53 ` [PATCH net 2/8] netfilter: fix use-after-free in __nf_register_net_hook() Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 3/8] netfilter: egress: silence egress hook lockdep splats Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 4/8] netfilter: nf_queue: don't assume sk is full socket Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 5/8] selftests: netfilter: add nfqueue TCP_NEW_SYN_RECV socket race test Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 6/8] netfilter: nf_queue: fix possible use-after-free Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 7/8] netfilter: nf_queue: handle socket prefetch Pablo Neira Ayuso
2022-03-01 21:53 ` [PATCH net 8/8] net/sched: act_ct: Fix flow table lookup failure with no originating ifindex Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2024-08-14 22:20 [PATCH net 0/8] Netfilter fixes for net Pablo Neira Ayuso
2022-08-09 22:05 Pablo Neira Ayuso
2022-08-10 4:27 ` Jakub Kicinski
2022-08-10 7:59 ` Pablo Neira Ayuso
2022-01-27 23:52 Pablo Neira Ayuso
2021-06-22 21:59 Pablo Neira Ayuso
2021-06-22 22:41 ` David Miller
2021-06-22 23:06 ` Pablo Neira Ayuso
2021-05-07 17:47 Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).