* [Qemu-devel] [PATCH] block migraton: check sectors before shift operation.
@ 2010-07-19 4:45 Yoshiaki Tamura
2010-07-19 9:23 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Yoshiaki Tamura @ 2010-07-19 4:45 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori, armbru, Yoshiaki Tamura
Commit d246673dcb9911218ff555bcdf28b250e38fa46c has expanded the types
of block drive that can be initialized for block migration. Although
bdrv_getlength() may return < 0, current code shifts it without
checking. This makes block migration initialization invalid and
results in abort() due to calling qemu_malloc() with 0 size at
bdrv_set_dirty_tracking(). This patch checks the return value of
bdrv_getlength() by masking with BDRV_SECTOR_MASK.
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
---
block-migration.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/block-migration.c b/block-migration.c
index 7db6f02..2e02a4a 100644
--- a/block-migration.c
+++ b/block-migration.c
@@ -237,10 +237,11 @@ static void init_blk_migration_it(void *opaque, BlockDriverState *bs)
int64_t sectors;
if (!bdrv_is_read_only(bs)) {
- sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS;
- if (sectors == 0) {
+ sectors = bdrv_getlength(bs) & BDRV_SECTOR_MASK;
+ if (sectors <= 0) {
return;
}
+ sectors >>= BDRV_SECTOR_BITS;
bmds = qemu_mallocz(sizeof(BlkMigDevState));
bmds->bs = bs;
--
1.7.1.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block migraton: check sectors before shift operation.
2010-07-19 4:45 [Qemu-devel] [PATCH] block migraton: check sectors before shift operation Yoshiaki Tamura
@ 2010-07-19 9:23 ` Kevin Wolf
2010-07-19 11:22 ` Yoshiaki Tamura
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2010-07-19 9:23 UTC (permalink / raw)
To: Yoshiaki Tamura; +Cc: aliguori, qemu-devel, armbru
Am 19.07.2010 06:45, schrieb Yoshiaki Tamura:
> Commit d246673dcb9911218ff555bcdf28b250e38fa46c has expanded the types
> of block drive that can be initialized for block migration. Although
> bdrv_getlength() may return < 0, current code shifts it without
> checking. This makes block migration initialization invalid and
> results in abort() due to calling qemu_malloc() with 0 size at
> bdrv_set_dirty_tracking(). This patch checks the return value of
> bdrv_getlength() by masking with BDRV_SECTOR_MASK.
>
> Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
I applied a similar patch by Shahar Havivi to the block branch a few
days ago.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block migraton: check sectors before shift operation.
2010-07-19 9:23 ` Kevin Wolf
@ 2010-07-19 11:22 ` Yoshiaki Tamura
0 siblings, 0 replies; 3+ messages in thread
From: Yoshiaki Tamura @ 2010-07-19 11:22 UTC (permalink / raw)
To: Kevin Wolf; +Cc: aliguori, qemu-devel, armbru
2010/7/19 Kevin Wolf <kwolf@redhat.com>:
> Am 19.07.2010 06:45, schrieb Yoshiaki Tamura:
>> Commit d246673dcb9911218ff555bcdf28b250e38fa46c has expanded the types
>> of block drive that can be initialized for block migration. Although
>> bdrv_getlength() may return < 0, current code shifts it without
>> checking. This makes block migration initialization invalid and
>> results in abort() due to calling qemu_malloc() with 0 size at
>> bdrv_set_dirty_tracking(). This patch checks the return value of
>> bdrv_getlength() by masking with BDRV_SECTOR_MASK.
>>
>> Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
>
> I applied a similar patch by Shahar Havivi to the block branch a few
> days ago.
Oops. Missed that discussion.
Yoshi
>
> Kevin
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-07-19 11:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-19 4:45 [Qemu-devel] [PATCH] block migraton: check sectors before shift operation Yoshiaki Tamura
2010-07-19 9:23 ` Kevin Wolf
2010-07-19 11:22 ` Yoshiaki Tamura
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.