Skip to contentSkip to conversation

netfilter: nfnetlink_queue: make hash table per queue

PATCH New Florian Westphal 1 participant 1 message Apr 7

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 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")

---
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
index 45eb26b2e95b..d17035d14d96 100644
@@ -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