From: Jianpeng Ma Date: Wed, 20 Jun 2018 12:22:38 +0000 (+0800) Subject: os/bluestore: fix length overflow. X-Git-Tag: v14.0.1~1043^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F22610%2Fhead;p=ceph.git os/bluestore: fix length overflow. In fact, length of 'struct interval_t' and 'struct bluestore_pextent_t' is uint32_t. But len of AllocatorLevel02::_mark_allocated is uint64_t. So it may cause data overflow which cause bug. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/bluestore/fastbmap_allocator_impl.h b/src/os/bluestore/fastbmap_allocator_impl.h index 179a22c80777..762f2d37bf49 100755 --- a/src/os/bluestore/fastbmap_allocator_impl.h +++ b/src/os/bluestore/fastbmap_allocator_impl.h @@ -390,10 +390,10 @@ protected: uint64_t* allocated, interval_vector_t* res); - uint64_t _mark_alloc_l1(const interval_t& r) + uint64_t _mark_alloc_l1(uint64_t offset, uint64_t length) { - uint64_t l0_pos_start = r.offset / l0_granularity; - uint64_t l0_pos_end = p2roundup(r.offset + r.length, l0_granularity) / l0_granularity; + uint64_t l0_pos_start = offset / l0_granularity; + uint64_t l0_pos_end = p2roundup(offset + length, l0_granularity) / l0_granularity; _mark_alloc_l1_l0(l0_pos_start, l0_pos_end); return l0_granularity * (l0_pos_end - l0_pos_start); } @@ -710,7 +710,7 @@ protected: uint64_t l2_pos_end = p2roundup(int64_t(o + len), int64_t(l2_granularity)) / l2_granularity; std::lock_guard l(lock); - auto allocated = l1._mark_alloc_l1(interval_t(o, len)); + auto allocated = l1._mark_alloc_l1(o, len); assert(available >= allocated); available -= allocated; _mark_l2_on_l1(l2_pos, l2_pos_end);