]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nfs/localio: add refcounting for each iocb IO associated with NFS pgio header
authorMike Snitzer <snitzer@kernel.org>
Mon, 27 Oct 2025 13:08:32 +0000 (09:08 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 10 Nov 2025 15:32:28 +0000 (10:32 -0500)
commitf2060bdc21d70f3d8a4753a9fd3b0b02cb48c0bc
tree93446e27938f939f5d4ab42787d29f50c8d81e18
parent51a491f2708de79da76791523d40926921823b7e
nfs/localio: add refcounting for each iocb IO associated with NFS pgio header

Improve completion handling of as many as 3 IOs associated with each
misaligned DIO by using a atomic_t to track completion of each IO.

Update nfs_local_pgio_done() to use precise atomic_t accounting for
remaining iov_iter (up to 3) associated with each iocb, so that each
NFS LOCALIO pgio header is only released after all IOs have completed.
But also allow early return if/when a short read or write occurs.

Fixes reported BUG: KASAN: slab-use-after-free in nfs_local_call_read:
https://lore.kernel.org/linux-nfs/aPSvi5Yr2lGOh5Jh@dell-per750-06-vm-07.rhts.eng.pek2.redhat.com/

Reported-by: Yongcheng Yang <yoyang@redhat.com>
Fixes: c817248fc831 ("nfs/localio: add proper O_DIRECT support for READ and WRITE")
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/localio.c