Patch "block: fix overflow in blk_ioctl_discard()" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    block: fix overflow in blk_ioctl_discard()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-fix-overflow-in-blk_ioctl_discard.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 7aacccd1badd5e88eb0ac9a6c160eb9f77d3bf2e
Author: Li Nan <linan122@xxxxxxxxxx>
Date:   Fri Mar 29 09:23:19 2024 +0800

    block: fix overflow in blk_ioctl_discard()
    
    [ Upstream commit 22d24a544b0d49bbcbd61c8c0eaf77d3c9297155 ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Link: https://lore.kernel.org/r/20240329012319.2034550-1-linan666@xxxxxxxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/ioctl.c b/block/ioctl.c
index 47567ba1185a6..99b8e2e448729 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -89,7 +89,7 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
 		unsigned long arg)
 {
 	uint64_t range[2];
-	uint64_t start, len;
+	uint64_t start, len, end;
 	struct inode *inode = bdev->bd_inode;
 	int err;
 
@@ -110,7 +110,8 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
 	if (len & 511)
 		return -EINVAL;
 
-	if (start + len > bdev_nr_bytes(bdev))
+	if (check_add_overflow(start, len, &end) ||
+	    end > bdev_nr_bytes(bdev))
 		return -EINVAL;
 
 	filemap_invalidate_lock(inode->i_mapping);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux