netfilter: nfnetlink_queue: make hash table per queue
Subsystems (2)
Florian Westphal
maintainerPATCH 1/1 netfilter: nfnetlink_queue: make hash table per queue
Sharing a global hash table among all queues is tempting, but it can cause crash:
BUG: KASAN: slab-use-after-free in nfqnl_recv_verdict+0x11ac/0x15e0 [nfnetlink_queue] [..] nfqnl_recv_verdict+0x11ac/0x15e0 [nfnetlink_queue] nfnetlink_rcv_msg+0x46a/0x930 kmem_cache_alloc_node_noprof+0x11e/0x450
struct nf_queue_entry is freed via kfree, but parallel cpu can still encounter such an nf_queue_entry when walking the list.
Alternative fix is to free the nf_queue_entry via kfree_rcu() instead, but as we have to alloc/free for each skb this will cause more mem pressure.
Cc Scott Mitchell <[email protected]>
Fixes e19079adcd26 ("netfilter: nfnetlink_queue: optimize verdict lookup with hash table")
Signed-off-by Florian Westphal <[email protected]>
---
The 'Fixes' patch doesn't revert cleanly anymore; this patch isn't larger than the (mangled) revert.
So I would prefer this change in nf rather than going with my initial proposal to revert and followup in nf-next.
include/net/netfilter/nf_queue.h | 1 - net/netfilter/nfnetlink_queue.c | 139 +++++++++++-------------------- 2 files changed, 49 insertions(+), 91 deletions(-)
include/net/netfilter/nf_queue.h +0 -1
@@ -23,7 +23,6 @@ struct nf_queue_entry {struct nf_hook_state state;bool nf_ct_is_unconfirmed;u16 size;/* sizeof(entry) + saved route keys */ -u16 queue_num;/* extra space to store route keys */ };
net/netfilter/nfnetlink_queue.c +49 -90
248 lines not on this page · raw message
Signature · 1 line
2.52.0