Skip to content

Commit

Permalink
[SCSI] scsi_debug: fix map_region and unmap_region oops
Browse files Browse the repository at this point in the history
map_region and unmap_region could access to invalid memory area since
they don't check the size boundary.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed Jul 27, 2010
1 parent 4289a08 commit 9ab98f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/scsi/scsi_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 9ab98f5

Please sign in to comment.