]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
libceph: Fix multiplication overflow in __decode_pg_upmap_items() testing
authorRaphael Zimmer <raphael.zimmer@tu-ilmenau.de>
Tue, 19 May 2026 11:01:30 +0000 (13:01 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 20 May 2026 00:20:20 +0000 (02:20 +0200)
commit19e63d1e35eded5b730072898bc112fe3f4853f7
tree244e4338e215d278668b6a789af1f20d589f07a7
parent2cf924db7f198404669ec589d6127b892b1ad8f2
libceph: Fix multiplication overflow in __decode_pg_upmap_items()

A message of type CEPH_MSG_OSD_MAP holds an OSD map, which typically
contains a pg_upmap part at its end. When decoding this part in
__decode_pg_upmap_items(), a len value is decoded from the message to
determine the number of items and the size of the allocation needed for
them. If the len value is greater than or equal to 2^31, an overflow
occurs in the multiplication that is performed to determine the needed
size of the incoming buffer to decode, as well as for the length of the
allocation for the ceph_pg_mapping struct. Subsequently, this results in
out-of-bounds writes (and reads) when decoding the incoming message
fields into the ceph_pg_mapping struct.

This patch fixes the issue by splitting the computation into multiple
parts and storing the results in local variables of type size_t. This
prevents the overflow by performing the multiplication in the
appropriate data type and ensures that the result is calculated only
once.

Signed-off-by: Raphael Zimmer <raphael.zimmer@tu-ilmenau.de>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
net/ceph/osdmap.c