nfsd4_layoutcommit() passes type 0 to fh_verify(). An NFSv4.1 client with a session and a writable directory filehandle on a pNFS-enabled export can send a reclaim LAYOUTCOMMIT during the server's grace period. The reclaim path skips layout stateid preprocessing, so a fabricated stateid and no prior layout or directory delegation still reach the layout provider. This is not a valid protocol reclaim. For XFS block and SCSI layouts, an empty extent list and a last-write offset in a mapped directory metadata block can inflate i_disk_size beyond the 32 GiB directory data section. A leaf directory can reach about 32 GiB, and a node directory can reach about 64 GiB. The bad size survives remount; later growth of a leaf directory can trigger XFS corruption detection and filesystem shutdown. Check d_is_reg() after fh_verify() and before invoking the layout provider. Return NFS4ERR_INVAL for non-regular files, an error permitted for LAYOUTCOMMIT. An arm64 QEMU server with Generic KASAN reproduced the directory size change from 4096 to 34359742464 bytes. A clean remount retained the bad size, and xfs_repair -n marked the root directory inode's size bad. A subsequent CREATE workload triggered XFS shutdown. A node directory's size also changed from 139264 to 68719480832 bytes. No KASAN report was observed in these runs. With this change on nfsd-testing 3c6328ce3297, the same LAYOUTCOMMIT returned NFS4ERR_INVAL, the directory size stayed at 4096 bytes, and 48 subsequent CREATE/REMOVE pairs completed without a KASAN or Oops report. The vulnerability research and validation were conducted by members of the Tobabz team as part of the Best of the Best 15th program. Fixes: 9cf514ccfacb ("nfsd: implement pNFS operations") Fixes: e0963ce53b00 ("NFSD: Allow layoutcommit during grace period") Link: https://lore.kernel.org/r/dded948f-dfdb-4919-aae1-bf84147bcd72@slotpi15m67/ Cc: stable@vger.kernel.org Signed-off-by: Jiwoong Wi --- Changes since v2: - Add the Tobabz team research and validation credit to the commit message. - No code changes. v2: https://lore.kernel.org/r/20261201075502.22214-2-dwdnlzj@gmail.com/ fs/nfsd/nfs4proc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 92a92b3e6d..6c5656e148 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -3161,6 +3161,10 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, NFSD_MAY_WRITE | NFSD_MAY_OWNER_OVERRIDE); if (nfserr) goto out; + if (!d_is_reg(current_fh->fh_dentry)) { + nfserr = nfserr_inval; + goto out; + } nfserr = nfserr_layoutunavailable; ops = nfsd4_layout_verify(current_fh->fh_export, lcp->lc_layout_type); -- 2.50.1 (Apple Git-155)