[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH LVM2] Guarantee ah->area_multiple non-zero



Hi,

This patch guarantees ah->area_multiple being non-zero.

Since ah->area_multiple is used everywhere to calculate the length
of allocation, it's safer to set 1 if ah->area_count is zero.
Otherwise, zero division could occur.
For example, ah->area_count can be zero when the allocation request
is only for log device.

It should be reproducible by converting corelog mirror to disklog
mirror. But fortunately or unfortunately, this bug is hidden by
other bug.
(See "[PATCH LVM2] set stripes = 0 for the log device only allocation")

Patch applicable to LVM2 2.02.16.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
ah->area_count can be zero when the allocation request is only for
log device.
Since ah->area_multiple is used everywhere to calculate the length
of allocation, it's safer to set 1 if ah->area_count is zero.
Otherwise, zero division will occur.

It should be reproduced by converting corelog mirror to disklog
mirror. But fortunately, this bug is hidden by the other bug.

Patch applicable to LVM2 2.02.16.

---
 lib/metadata/lv_manip.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: LVM2.cvs/lib/metadata/lv_manip.c
===================================================================
--- LVM2.cvs.orig/lib/metadata/lv_manip.c	2006-12-13 00:08:32.000000000 -0500
+++ LVM2.cvs/lib/metadata/lv_manip.c	2006-12-13 00:08:42.000000000 -0500
@@ -476,7 +476,8 @@ static struct alloc_handle *_alloc_init(
 	ah->area_count = area_count;
 	ah->log_count = log_count;
 	ah->alloc = alloc;
-	ah->area_multiple = segtype_is_striped(segtype) ? ah->area_count : 1;
+	ah->area_multiple = segtype_is_striped(segtype) && ah->area_count
+				? ah->area_count : 1;
 
 	for (s = 0; s < ah->area_count; s++)
 		list_init(&ah->alloced_areas[s]);

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]