From: Florian Westphal <fw@strlen.de>
To: Junyoung Jang <graypanda.inzag@gmail.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Gwanhyun Lee <gwanhyunlee@gmail.com>, Phil Sutter <phil@nwl.cc>,
netfilter-devel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH nf] netfilter: nfnetlink_queue: drain cleanup work on netns exit
Date: Fri, 20 Nov 2026 14:32:31 +0100 [thread overview]
Message-ID: <awBLxqCPTWlGBWFx@strlen.de> (raw)
In-Reply-To: <20261120105718.866862-1-graypanda.inzag@gmail.com>
Junyoung Jang <graypanda.inzag@gmail.com> wrote:
> NETLINK_URELEASE unlinks an NFQUEUE instance and schedules its
> destruction through queue_rcu_work(). The RCU callback queues
> instance_destroy_work() on nfq_cleanup_wq. Queued entries retain
> entry->state.net, but nf_queue_entry_get_refs() pins only their
> sockets and network devices.
>
> A migratable device can return to init_net as the old namespace exits.
> cleanup_net() waits for the RCU callback but not the work it queued.
> It can free the namespace before instance_destroy_work() calls
> nfqnl_reinject(entry, NF_DROP), which dereferences the old state.net
> in nf_hook_entries_head().
A bit too verbose changelog for my taste but unfortunately with AI
it's becoming the new standard.
> A source review assisted by a coding agent identified this race. A
> 65,536-queue reproducer on unmodified mainline with
> KASAN and lockdep enabled reported:
The above is rendundant.
> BUG: KASAN: slab-use-after-free in nfqnl_reinject
> Workqueue: nfq_workqueue instance_destroy_work
>
> The free stack included cleanup_net(). The trigger used
> initial-namespace CAP_NET_ADMIN and a migratable virtio-net device;
> it required no kernel modification or fault injection.
This is useful, could also have added the trimmed backtrace
instead of the above.
> Drain NFQUEUE cleanup in the pernet exit batch. rcu_barrier() waits
> for pending RCU callbacks to enqueue their work; flush_workqueue()
> then completes that work before cleanup_net() frees the namespace.
> The batch hook avoids a barrier for each exiting namespace.
>
> The same mainline revision with this patch built without warnings and
> completed two 90-second reproducer runs in KVM with no KASAN or
> lockdep reports. No netfilter selftests were run.
This is redundant: its obvious from looking at the diff.
Reviewed-by: Florian Westphal <fw@strlen.de>
prev parent reply other threads:[~2026-11-20 13:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 10:57 [PATCH nf] netfilter: nfnetlink_queue: drain cleanup work on netns exit Junyoung Jang
2026-11-20 13:32 ` Florian Westphal [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awBLxqCPTWlGBWFx@strlen.de \
--to=fw@strlen.de \
--cc=graypanda.inzag@gmail.com \
--cc=gwanhyunlee@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=phil@nwl.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.