From: FUJITA Tomonori Date: Sun, 27 Jun 2010 16:04:45 +0000 (+0900) Subject: [SCSI] scsi_debug: fix map_region and unmap_region oops X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9ab98f57b3e1d73cd0720d29c21b687ba609cde9;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [SCSI] scsi_debug: fix map_region and unmap_region oops map_region and unmap_region could access to invalid memory area since they don't check the size boundary. Signed-off-by: FUJITA Tomonori Acked-by: Douglas Gilbert Signed-off-by: James Bottomley --- diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 136329b4027b..b02bdc6c2cd1 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -1991,7 +1991,8 @@ static void map_region(sector_t lba, unsigned int len) block = lba + alignment; rem = do_div(block, granularity); - set_bit(block, map_storep); + if (block < map_size) + set_bit(block, map_storep); lba += granularity - rem; } @@ -2011,7 +2012,8 @@ static void unmap_region(sector_t lba, unsigned int len) block = lba + alignment; rem = do_div(block, granularity); - if (rem == 0 && lba + granularity <= end) + if (rem == 0 && lba + granularity <= end && + block < map_size) clear_bit(block, map_storep); lba += granularity - rem;