Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796111757; b=Rvvy+HHbgn5qadLjcL2Lg280kMvXGbvWz58R0ThuiAJTNWf8r5Yq3CZK/ucA4MvJE+y9 eO/B2NcgxtKXjeYWec4sCA2oSuifprex9cIeG6En4+waq9B0dKJ4L+Peyc1r3Gn4TC60t M5/eqaqpgZo12j9KSZvhYZ3BMb/M7wrt3jXze6JEK3h/RXJtuSJNAl1mWfXdPrkOonXaY yAWpYaTUVoLSgBeRNxBxyBrZra2Xhasi/cDyxtn6bmLo92uRaP1v+oFmf2NZsXkOvwlcS MC+C3IylA56Nn7aZLNfXo1svEIS1uIl3RtLzKSsYwAgTvO1wsXSXE8G4o1aRzjl7aMw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796111757; 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=YmGGf8n+gnNM8Ew5ZnBcjBj/e7IDiwJ5EdfpqwKK60o=; b=YsQ7tnDa3BIoEFivBB3qKZQuXPwgWgOC6dzhzUpUoyBQLIZ9IXGXxcq9851QGGLiKRgP wdMZL/2q6VKYe8JUWYGjXrj2HABbXAV443Gu0tl6UmNCCj61aOV2B/QmzZHE/wgYVImTA 07vdA/x7QOkoTipcFZoiJU2tPOEK+NuHXrq5u0JuUwtA9wqiWPueX/xlIx/F6CAeohMkA 2S106cXo4DXOFdfXbi1G/UsE3W6T6TAXsCb9fAg88CJziHxoGPYCvHGE9ZYGi2q9BxXDK 1F24e8u6V9ihdOhMgFLdl/8O7IMsZcaobwVpDs1jT30j0KRlWclPR26g7Egjou3uEoQ== 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=alKp2rCF; arc=none smtp.remote-ip=209.85.214.172 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 39CA0606A320 for ; Tue, 1 Dec 2026 07:55:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 39CA0606A320 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=alKp2rCF Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2f05bc71e01so48318975ad.0 for ; Mon, 30 Nov 2026 23:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796111756; x=1796716556; 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=YmGGf8n+gnNM8Ew5ZnBcjBj/e7IDiwJ5EdfpqwKK60o=; b=alKp2rCFC7hdDXKcZYb7WoTYC9ONly6mODLd3hjqunvH+dadFdQ716f0E5SneteOQU qeP/8n+ZOWCJOn3v6pIVyIaente6xwTOX4jSY/rrfBbkvvGHr6y03/VQw1HhbAuKmB0Z /lSFY6ZloesYmNJ+5gGBKtapy2WgQMekQZJ+r7A6vJHoRcgUnDjMk1f1urEM4ale7BuV ui1PdiNqFHiMTJYLKMxyIT3eOzdoLgMkgHC2mnOuweyYI1OostTsXXv+b98T4JbDl1gV Q9AhluqEmmwkd0RFLBwBUB8n9/2DNQg0ot9wXUm7bNY4tOADFaRzbcXAheDs9/pyJPZ7 AOwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796111756; x=1796716556; 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=YmGGf8n+gnNM8Ew5ZnBcjBj/e7IDiwJ5EdfpqwKK60o=; b=b3GK/R7fwag5KJ0SMavp6m4SRrEavok0i29FPeJ/B9oSjvQ8i/7LBYEGP/EyxZTRKz hbeQg54fJP41JnUMPflCfEMi6vZXIYY9j4GH2B9DzPNwqiLai76WE6/HmlYpEj7hX033 FliabprbRkuzcSFo39/5J6HelA57GhDIp31myqVhRQRwhQ7k5RrKu81kw5HASbKs5xA5 C7DT9q6w48/7SUJLKTC0n+bwogpgaYOTfPkzaOP2t3lPsOCt365yh/s7bScBd7/+aAE9 SYRamWxRLg87O0ZgLbm3AYqBnlItGbunDeJ13obc/TWzY0CofMJWcwYulG7BrMLyFyvY Tabw== X-Gm-Message-State: APuU4Z/57Mr/F8N9/VTyZXH7NgdZBcykvcNe/5nf8g7DjWKIupvIE42E JZDNa7UN165mF/Urqbu1rYw7N7hhmFpF9iBhi9YFEwLQMtbT203an/AN X-Gm-Gg: AZFdTZd69xOBIfX/ke0gNWK41r2cmSqUinpQhWuhkJbVkNlM6lJ24yOiHy7iWFBDi9P UsnTrraNypxbk3Wm7o5G9klopBePF5+v+few9k5jwDYcngCyvpqNd1/3MF0SzdcSwWjw1z98ZE/ Y0Mb/YWdpF/Jqk7bsp6/9+d/v3K01pPAGiP/FUTlwBLzottlws0avKWjICRvV/rQtiacGzFMyxD R/DAqRfOsafJSPikZgN+o1VNvt+jYHDK13PPdEVXNDS2UuoTjRJI1+pPSv+ji5Toqk6cxgMdpk5 P4J1eA7vJ0otxZqsdVhCADCErxQwkN1UarczZvWfFHot1yYfv33uQTPQ5GewEP1gVpSc7reAgBf CDbZlEESBU6D1f1HLVnErE6sBAumKfestqUy5hxH2XsuU7hcAjhaKThqzNglDTTb0l6sGX0ijcT 97oZTcitmlih4mfWoYkVqrVs/HmeDVC7jZsQeDOIyMlrLehoFEINPRSaC57r0EbgCiwawLWpgpM wmhHsnp/2bvzSALjgNlfZpwoqGVB5UH7/8nrOB7ayUIaPe42EM2P0ynxIoa+hfWYNfdyWrHK+Ss i02zLtFzxnFyts+7+94I/1S0V/4N X-Received: by 2002:a17:902:f609:b0:2e9:cd03:b432 with SMTP id d9443c01a7336-2f03f1feec7mr340537095ad.60.1796111756472; Mon, 30 Nov 2026 23:55:56 -0800 (PST) Received: from Mac ([123.215.20.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f08d73dfe0sm142228235ad.69.2026.11.30.23.55.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 23:55:56 -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 v2 2/2] nfsd: reject LAYOUTCOMMIT on non-regular files Date: Tue, 1 Dec 2026 16:55:02 +0900 Message-ID: <20261201075502.22214-2-dwdnlzj@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20261201075502.22214-1-dwdnlzj@gmail.com> References: <20261130070511.65684-1-dwdnlzj@gmail.com> <20261201075502.22214-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. 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 --- 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)