diff mbox

block: pass inclusive 'lend' parameter to truncate_inode_pages_range

Message ID 20180209141551.8927-1-ming.lei@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ming Lei Feb. 9, 2018, 2:15 p.m. UTC
The 'lend' parameter of truncate_inode_pages_range is required to be
inclusive, so follow the rule.

This patch fixes one memory corruption triggered by discard.

Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bart Van Assche Feb. 9, 2018, 3:12 p.m. UTC | #1
On Fri, 2018-02-09 at 22:15 +0800, Ming Lei wrote:
> The 'lend' parameter of truncate_inode_pages_range is required to be

> inclusive, so follow the rule.

> 

> This patch fixes one memory corruption triggered by discard.

> 

> Fixes: 351499a172c0 ("block: Invalidate cache on discard v2")


Since this bug got introduced in kernel v4.15 please add a "Cc: stable" tag.
Please also Cc: the author of the patch.

Thanks,

Bart.
diff mbox

Patch

diff --git a/block/ioctl.c b/block/ioctl.c
index 1668506d8ed8..3884d810efd2 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -225,7 +225,7 @@  static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
 
 	if (start + len > i_size_read(bdev->bd_inode))
 		return -EINVAL;
-	truncate_inode_pages_range(mapping, start, start + len);
+	truncate_inode_pages_range(mapping, start, start + len - 1);
 	return blkdev_issue_discard(bdev, start >> 9, len >> 9,
 				    GFP_KERNEL, flags);
 }