From: Stanislav Fomichev <stfomichev@gmail.com>
To: Kery Qi <qikeyu2017@gmail.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
bjorn@kernel.org, hawk@kernel.org, pabeni@redhat.com,
magnus.karlsson@intel.com, daniel@iogearbox.net,
maciej.fijalkowski@intel.com, kuba@kernel.org,
edumazet@google.com, horms@kernel.org, ast@kernel.org,
sdf@fomichev.me, john.fastabend@gmail.com
Subject: Re: [PATCH bpf] xsk: fix init race causing NPD/UAF in xsk_create()
Date: Sun, 11 Jan 2026 12:24:21 -0800 [thread overview]
Message-ID: <aWQG9Xujon2RWeci@mini-arch> (raw)
In-Reply-To: <20260109104643.1988-2-qikeyu2017@gmail.com>
On 01/09, Kery Qi wrote:
> xsk_init() previously registered the PF_XDP socket family before the
> per-net subsystem and other prerequisites (netdevice notifier, caches)
> were fully initialized.
>
> This exposed .create = xsk_create() to user space while per-netns
> state (net->xdp.lock/list) was still uninitialized. A task with
> CAP_NET_RAW could trigger this during boot/module load by calling
> socket(PF_XDP, SOCK_RAW, 0) concurrently with xsk_init(), leading
> to a NULL pointer dereference or use-after-free in the list manipulation.
>
> To fix this, move sock_register() to the end of the initialization
> sequence, ensuring that all required kernel structures are ready before
> exposing the AF_XDP interface to userspace.
>
> Accordingly, reorder the error unwind path to ensure proper cleanup
> in reverse order of initialization. Also, explicitly add
> kmem_cache_destroy() in the error path to prevent leaking
> xsk_tx_generic_cache if the registration fails.
Is it something that you've hit in real life? xsk_init happens
so early during the init process (fs_init) that I don't understand
why the oder would matter.
next prev parent reply other threads:[~2026-01-11 20:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 10:46 [PATCH bpf] xsk: fix init race causing NPD/UAF in xsk_create() Kery Qi
2026-01-11 20:24 ` Stanislav Fomichev [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-01-09 10:04 Kery Qi
2026-01-09 10:22 ` bot+bpf-ci
2026-01-08 11:37 Kery Qi
2026-01-08 11:53 ` bot+bpf-ci
2026-01-08 10:53 Kery Qi
2026-01-08 11:21 ` bot+bpf-ci
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=aWQG9Xujon2RWeci@mini-arch \
--to=stfomichev@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=pabeni@redhat.com \
--cc=qikeyu2017@gmail.com \
--cc=sdf@fomichev.me \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox