Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142814; b=yuXw5SlyC9/BQUkKx1JIDc8nrRZQJraj/di0CjaZePtKglDxLD2RVbAPy+Joe6ZNAOpk vgphidrW09WJitB2zJU1Qc/BMZFnlYKv69EpXHFYLxiVmXIQecoHNc+cx9DEK5HDHOO+g yOdtYPnsfK3hIxeR71wT+Ic4HlkLIgKAD4008LyOxXZh4lM2w9ptmOPZHV+9b0WJxYMY3 ZH9R6OwbB3dW6TNLIyiEQ1uWxS+uiWy8sofboB3C/b9QGBObbqKXWUbMA2JhttwYXF84C 7XEY7SVu4h0HmOmbreyi/EC7u7VkxGbLMKsxXd6/QYh72sAF7/P1Gq1gKQSrS9TcQtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142814; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=B7x4N3ghqMTfDQiF1dKfdQjQmh8M3e+PUXWcaFq739s=; b=2VRYh+JAriRcp+kVo0IZf98cAGFzxzhraw4bSnEnqRF+I+J+oy3uEdOlFeiqaw198EV9 APkIBaK3F1m16IpoMUp8KXhQ1NBYT/K1HwChyRAwDND6Pav/y534nSWM0ov7LZ7uC/LYo PrufWJ7trNTcMOCXwM1U7mZMA51xjBvWGg7DL86KGV9HroBSA8q1PNuVtY8yMOjUaGlqf YfwMb9VCtm5oKuPL75FxWcjfVtPL6rvWsYdHchu+PN1uQGS7YfPsx92AtT0PG0xCxWN3Q f7/nWJww06Ik4LoU2sBiKY3ZWAuoBDp/eEit+HaXmYHaX0FpdIlmrtpjaNyYc7Fcgmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=z04sdnGg; arc=none smtp.remote-ip=209.85.215.174 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 92DCD606A320 for ; Tue, 1 Dec 2026 16:33:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 92DCD606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=z04sdnGg Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-cde827b7b95so4289574a12.0 for ; Tue, 01 Dec 2026 08:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796142813; x=1796747613; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=B7x4N3ghqMTfDQiF1dKfdQjQmh8M3e+PUXWcaFq739s=; b=z04sdnGgbe9nBcn8DYH52Dh8P6wtnsBWWqjUs7YuD/rXs4JbOAOIhtafl/OxcSVQKY 0Y87KtVWLsGr+ndcAwFe0Q76j37xGubs0oT8U9nZog4k+QctYnL+Lg77xGDy3dO9Hn1j onOxIGBNds+EQtuOHmal4tka4W5SzGGxRnf16jokryUQ4Z1hm9AzpOrTmlr+i8S/JfOU tTJ7fXtvDMTe97Zrwc2afKwiV/PLzfWKsnAmgro705gzJbckIJcKdoGIlIGEO8YIH4J8 V5sPfl55excxKyifVvEaiDiLD/npYonqtHc0XoqosHNO4UN9Oh56f2U9GWHmRUXXoRjz 21/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796142813; x=1796747613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=B7x4N3ghqMTfDQiF1dKfdQjQmh8M3e+PUXWcaFq739s=; b=EWX/iRIsXYZ+pUC8OzbrFGC+MeQyLN6o+o4+AfCIH/fTHQRU4idnpB2va+avlA9AIV IE8UbOAOZMQvGJt7qWEiZbb1g6chZ+GATiyDTRZ+Snh9tpnAWFwlbAFA8bloiHmDGeHk NwjyIeLH4idSTdWQAnmFoTDlihDQF+umWSdq0GmIE5myxt97t0iaiCrTghOJ0kc42Anq AD7sLqeX2TPfFjWFRTJ5IxCqEvlLy1/4EHIjjwY37jj17b3UnpRV4cBGwwYFgvIrx4ao SMw2YHvO2sylcl/nmeCkqJgrwO3BBL0IB+Xl6lIf0ElgziHMg4xhSVlo865e3Qqjwv2x zqGQ== X-Gm-Message-State: APuU4Z8ATdd92fKFDWpPuWDpObm2aPMrrt1P4Z6mSH+P7VH47iSN9zLw Kp1mAwhye4eI1lC0Qsn9RiJpMxnP0RVct3dVksChhrlBWgP385L4QfB/ X-Gm-Gg: AZFdTZeFGqQgtrud3/AAaz/T06ycvr+yTmkS+8IYIdQ8O+v6rTnRHt5Fn8Xh5ZA60/O sg1A2tSb3dUDKUtN5jkSfGzvUXlM6Ep9/H2lRCV1OEsYOCwhkWESdAEoVTJvZ2DNDuOA4sbl2VG hvrYGY0TtdNkAPm5iC6rFz+MTMdY/taufA/p08+ILCarJI+9u5suNL/aksl7lkQIbScS71NI//C ZFxPixr87NN77cWXT2iiU14ql79+7JBZF6vXeHGwZAgUMWgHuHQurpu3ghzD7p707ApFgn5CIij cf/vstaQaM6GjX/T4kcZWFu/9zXZkdZSY0cRAKamrlAVayl7qzeGratQqkNJU/DVYp8H9lfQVji oY8V7ZohqQzYEfivGM9zvr+e9403tQBOtDol1N7oHINRevTDSHTtKaMZLL20YBT/sZ5EtbF4JdD nahH2Mzr9ddjaXU3CIJa9PBJ+I7yhwaT3XWI0R9USoylJ9PRXA1/tb5OHjW/dg2ilx5S7CUK5/q cSkyzH6up5hRfzbqJOqn4fzvjuNEpIYlol9vlYzOjH2glLHgjs5QHciXTSeUVp7N3m45KoE5vxf EFyol2RR4NQ/u4Ehw72Zi4gCbxMkeToPYtSe4sgz/mSWBubwMw== X-Received: by 2002:a17:90b:2c84:b0:3a5:c08:4c41 with SMTP id 98e67ed59e1d1-3b41c98a138mr32111909a91.50.1796142812581; Tue, 01 Dec 2026 08:33:32 -0800 (PST) Received: from Mac ([123.215.20.10]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b405d135e9sm61123762a91.4.2026.12.01.08.33.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 01 Dec 2026 08:33:32 -0800 (PST) From: Jiwoong Wi To: Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org, stable@vger.kernel.org, bobtobabz@gmail.com, Jiwoong Wi Subject: [PATCH v3 2/2] nfsd: reject LAYOUTCOMMIT on non-regular files Date: Wed, 2 Dec 2026 01:33:15 +0900 Message-ID: <20261201163315.15426-2-dwdnlzj@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261201163315.15426-1-dwdnlzj@gmail.com> References: <20261201075502.22214-1-dwdnlzj@gmail.com> <20261201163315.15426-1-dwdnlzj@gmail.com> X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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)