From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C5E434F241; Tue, 16 Dec 2025 12:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765887673; cv=none; b=hUbVMeBOWNTbQ2ahsJi32+nBMG55TtZxGbCrw1HfparjWIk0fwCfAfQGv+GxQ+UieWzpUaxCtL4ejfxmdM8LQ8h23ei9ps/wsmCXNIaTEJxpWi+camuc7aIHsKrLAisoeRoqa5luWaySJBnIlaAMPiBdWyTASCs8NCpH2lU1zE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765887673; c=relaxed/simple; bh=0lt8nPQVfpRCEVP2VCLXC9zrrptl78NycX7ZCWXFXlQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sgYdrlORmaEg/n3HwSv/xET7u4AzMivO85mlJeDy2F++DkuNlZ5eFM8bcmMN+AuV12YosieGdKGX7CGs5DnDgg8RKpA3disTt446pJTu9OXSDYCh6p1F0ABi163l1oT9G8uX2w43Cl2tGBptjTpyCXvCxM4LaThHpEN/kBVeg4U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GVCaAEyE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GVCaAEyE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EFB2C4CEF1; Tue, 16 Dec 2025 12:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1765887672; bh=0lt8nPQVfpRCEVP2VCLXC9zrrptl78NycX7ZCWXFXlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVCaAEyE2dM608Jf+x9Dxy2YEKmGocPDqv5Uj6AHrE8bgZ/je5dUfsGnTQZl0lssz uxUoChmWahLWCfc/Ip4Xipg9ldueJJsAgfcwio7jhiLuwVh6q6dPAY9ImoHFvk780e lJ0N0L9H2CqjxTaIf8yZ4SEiPVkaEwBRFhjG4H1M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sergey Bashirov , Christoph Hellwig , Chuck Lever , Sasha Levin Subject: [PATCH 6.18 303/614] NFSD/blocklayout: Fix minlength check in proc_layoutget Date: Tue, 16 Dec 2025 12:11:10 +0100 Message-ID: <20251216111412.347028804@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251216111401.280873349@linuxfoundation.org> References: <20251216111401.280873349@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sergey Bashirov [ Upstream commit 3524b021b0ec620a76c89aee78e9d4b4130fb711 ] The extent returned by the file system may have a smaller offset than the segment offset requested by the client. In this case, the minimum segment length must be checked against the requested range. Otherwise, the client may not be able to continue the read/write operation. Fixes: 8650b8a05850 ("nfsd: pNFS block layout driver") Signed-off-by: Sergey Bashirov Reviewed-by: Christoph Hellwig Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/blocklayout.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c index fde5539cf6a69..425648565ab2d 100644 --- a/fs/nfsd/blocklayout.c +++ b/fs/nfsd/blocklayout.c @@ -23,6 +23,7 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode, { struct nfsd4_layout_seg *seg = &args->lg_seg; struct super_block *sb = inode->i_sb; + u64 length; u32 block_size = i_blocksize(inode); struct pnfs_block_extent *bex; struct iomap iomap; @@ -56,7 +57,8 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode, goto out_error; } - if (iomap.length < args->lg_minlength) { + length = iomap.offset + iomap.length - seg->offset; + if (length < args->lg_minlength) { dprintk("pnfsd: extent smaller than minlength\n"); goto out_layoutunavailable; } -- 2.51.0