From 0c6dda7a1cbd587e48bcef1999875e29549c2b41 Mon Sep 17 00:00:00 2001
From: "Darrick J. Wong" <darrick.wong@oracle.com>
Date: Fri, 26 Jan 2018 11:11:20 -0800
Subject: [PATCH] iomap: warn on zero-length mappings
Git-commit: 0c6dda7a1cbd587e48bcef1999875e29549c2b41
Patch-mainline: v4.16-rc1
References: bsc#1127062
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>
Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
---
fs/iomap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/iomap.c b/fs/iomap.c
index e5de7725f18a..afd163586aa0 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -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,
--
2.16.4