Skip to content

Commit 3524b02

Browse files
sbashirochucklever
authored andcommitted
NFSD/blocklayout: Fix minlength check in proc_layoutget
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: 8650b8a ("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>
1 parent 566a414 commit 3524b02

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/nfsd/blocklayout.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
2323
{
2424
struct nfsd4_layout_seg *seg = &args->lg_seg;
2525
struct super_block *sb = inode->i_sb;
26+
u64 length;
2627
u32 block_size = i_blocksize(inode);
2728
struct pnfs_block_extent *bex;
2829
struct iomap iomap;
@@ -56,7 +57,8 @@ nfsd4_block_proc_layoutget(struct svc_rqst *rqstp, struct inode *inode,
5657
goto out_error;
5758
}
5859

59-
if (iomap.length < args->lg_minlength) {
60+
length = iomap.offset + iomap.length - seg->offset;
61+
if (length < args->lg_minlength) {
6062
dprintk("pnfsd: extent smaller than minlength\n");
6163
goto out_layoutunavailable;
6264
}

0 commit comments

Comments
 (0)