]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
NFSD/blocklayout: Fix minlength check in proc_layoutget
authorSergey Bashirov <sergeybashirov@gmail.com>
Fri, 3 Oct 2025 09:11:03 +0000 (12:11 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:30 +0000 (13:09 +0100)
[ 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 <sergeybashirov@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfsd/blocklayout.c

index ba8961e72feaaa7476be9ff9a9ab06bc3b0f4512..735fd1cdf4771623bf22eadac14cd1051e2abed3 100644 (file)
@@ -27,6 +27,7 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
 {
        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;
@@ -57,7 +58,8 @@ nfsd4_block_proc_layoutget(struct inode *inode, const struct svc_fh *fhp,
                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;
        }