]>
git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
osd: fix UBSan shift overflow in pg_pool_t::calc_pg_masks
UBSan reports: shift exponent 32 is too large for 32-bit type 'int'
When pg_num or pgp_num is 0, pg_num-1 wraps to UINT_MAX (unsigned),
cbits() returns 32, and (1 << 32) on 32-bit int is undefined behavior
Use 1ULL for the shift and guard when cbits >= sizeof(unsigned)*CHAR_BIT
to avoid UB
- add unittest-crimson-pg-pool-shift to exercise the fix
Signed-off-by: Alexander Indenbaum <aindenba@redhat.com>