From 445ebd01194510d69002bc9d0f5247b0fa1836c8 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 14 May 2008 14:58:29 +0000 Subject: [PATCH] Critical patch from anonymous. Fixes possible data corruption in BLOCKIO code. A pretty subtle bug. Can be triggered on very rare on practice combination of circumstances. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@370 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 46aba9ac8..a0fce19f5 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -2280,11 +2280,13 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, while(length > 0) { int len, bytes, off, thislen; uint8_t *addr; + u64 lba_start0; addr = address; off = offset_in_page(addr); len = length; thislen = 0; + lba_start0 = lba_start; while (len > 0) { int rc; @@ -2302,7 +2304,7 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, bios++; need_new_bio = 0; bio->bi_end_io = blockio_endio; - bio->bi_sector = lba_start << + bio->bi_sector = lba_start0 << (virt_dev->block_shift - 9); bio->bi_bdev = bdev; bio->bi_private = blockio_work; @@ -2321,7 +2323,7 @@ static void blockio_exec_rw(struct scst_cmd *cmd, struct scst_vdisk_thr *thr, if (rc < bytes) { sBUG_ON(rc != 0); need_new_bio = 1; - lba_start += thislen >> virt_dev->block_shift; + lba_start0 += thislen >> virt_dev->block_shift; thislen = 0; continue; }