提交 9ab98f57 编写于 作者: F FUJITA Tomonori 提交者: James Bottomley

[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: NFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: NDouglas Gilbert <dgilbert@interlog.com>
Signed-off-by: NJames Bottomley <James.Bottomley@suse.de>
上级 4289a086
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册