From: Jianpeng Ma Date: Wed, 20 Jun 2018 12:22:38 +0000 (+0800) Subject: os/bluestore: fix length overflow. X-Git-Tag: v13.2.6~61^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27366%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 (cherry picked from commit 40d13406b85ad1630e61296b0b4f2a85f228d2a4) --- diff --git a/src/os/bluestore/fastbmap_allocator_impl.h b/src/os/bluestore/fastbmap_allocator_impl.h index e490215a12d3..d53d031a52e6 100755 --- a/src/os/bluestore/fastbmap_allocator_impl.h +++ b/src/os/bluestore/fastbmap_allocator_impl.h @@ -405,10 +405,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); } @@ -725,7 +725,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);