Skip to content

Commit cb9391a

Browse files
author
Ming Lei
committed
block: fix overflow in blk_ioctl_discard()
JIRA: https://issues.redhat.com/browse/RHEL-39813 CVE: CVE-2024-36917 commit 22d24a5 Author: Li Nan <linan122@huawei.com> Date: Fri Mar 29 09:23:19 2024 +0800 block: fix overflow in blk_ioctl_discard() There is no check for overflow of 'start + len' in blk_ioctl_discard(). Hung task occurs if submit an discard ioctl with the following param: start = 0x80000000000ff000, len = 0x8000000000fff000; Add the overflow validation now. Signed-off-by: Li Nan <linan122@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20240329012319.2034550-1-linan666@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent 0e5b8cd commit cb9391a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

block/ioctl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
8989
unsigned long arg)
9090
{
9191
uint64_t range[2];
92-
uint64_t start, len;
92+
uint64_t start, len, end;
9393
struct inode *inode = bdev->bd_inode;
9494
int err;
9595

@@ -110,7 +110,8 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
110110
if (len & 511)
111111
return -EINVAL;
112112

113-
if (start + len > bdev_nr_bytes(bdev))
113+
if (check_add_overflow(start, len, &end) ||
114+
end > bdev_nr_bytes(bdev))
114115
return -EINVAL;
115116

116117
filemap_invalidate_lock(inode->i_mapping);

0 commit comments

Comments
 (0)