iomap: warn on zero-length mappings
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 26 Jan 2018 19:11:20 +0000 (11:11 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 29 Jan 2018 15:27:24 +0000 (07:27 -0800)
Don't let the iomap callback get away with feeding us a garbage zero
length mapping -- there was a bug in xfs that resulted in those leaking
out to hilarious effect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/iomap.c

index e5de7725f18a7358b2cff497c9babd0a7b65f8e7..afd163586aa079f25ea86e5f56f8d85f25f2af68 100644 (file)
@@ -65,6 +65,8 @@ iomap_apply(struct inode *inode, loff_t pos, loff_t length, unsigned flags,
                return ret;
        if (WARN_ON(iomap.offset > pos))
                return -EIO;
+       if (WARN_ON(iomap.length == 0))
+               return -EIO;
 
        /*
         * Cut down the length to the one actually provided by the filesystem,