Re: [PATCH v2] watch_queue: Fix note pool publication race in watch_queue_set_size()
From: Christian Brauner
Date: Mon Oct 12 2026 - 04:53:10 EST
On Fri, 09 Oct 2026 18:47:15 -0400, Cen Zhang (Microsoft) wrote:
> There is a race between watch_queue_set_size() and post_one_notification().
> watch_queue_set_size() publishes wqueue->notes, notes_bitmap, nr_pages and
> nr_notes with plain stores, and post_one_notification() reads them with
> plain loads under a different lock, so nothing orders the four stores
> against the poster's loads: depending on the build, notes can be stored
> last (gcc 14 on x86-64 does this). Since keyctl_watch_key() lets a watch
> attach to a queue before it is sized, post_one_notification() can already
> be running on another CPU at that moment: it reads nr_notes > 0, passes
> its bounds check, and then reads notes while it is still NULL,
> dereferencing notes[0].
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] watch_queue: Fix note pool publication race in watch_queue_set_size()
https://git.kernel.org/vfs/vfs/c/e184fdfd7ea0