Skip to content

Commit f1ba837

Browse files
V4belFlorian Westphal
authored andcommitted
netfilter: nfnetlink_queue: fix entry leak in bridge verdict error path
nfqnl_recv_verdict() calls find_dequeue_entry() to remove the queue entry from the queue data structures, taking ownership of the entry. For PF_BRIDGE packets, it then calls nfqa_parse_bridge() to parse VLAN attributes. If nfqa_parse_bridge() returns an error (e.g. NFQA_VLAN present but NFQA_VLAN_TCI missing), the function returns immediately without freeing the dequeued entry or its sk_buff. This leaks the nf_queue_entry, its associated sk_buff, and all held references (net_device refcounts, struct net refcount). Repeated triggering exhausts kernel memory. Fix this by dropping the entry via nfqnl_reinject() with NF_DROP verdict on the error path, consistent with other error handling in this file. Fixes: 8d45ff2 ("netfilter: bridge: nf queue verdict to use NFQA_VLAN and NFQA_L2HDR") Reviewed-by: David Dull <monderasdor@gmail.com> Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com> Signed-off-by: Florian Westphal <fw@strlen.de>
1 parent cfe7702 commit f1ba837

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net/netfilter/nfnetlink_queue.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,10 @@ static int nfqnl_recv_verdict(struct sk_buff *skb, const struct nfnl_info *info,
15461546

15471547
if (entry->state.pf == PF_BRIDGE) {
15481548
err = nfqa_parse_bridge(entry, nfqa);
1549-
if (err < 0)
1549+
if (err < 0) {
1550+
nfqnl_reinject(entry, NF_DROP);
15501551
return err;
1552+
}
15511553
}
15521554

15531555
if (nfqa[NFQA_PAYLOAD]) {

0 commit comments

Comments
 (0)