libceph: make decode_pool() more resilient against corrupted osdmaps
authorIlya Dryomov <idryomov@gmail.com>
Tue, 2 Dec 2025 09:32:31 +0000 (10:32 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 10 Dec 2025 10:50:54 +0000 (11:50 +0100)
commit8c738512714e8c0aa18f8a10c072d5b01c83db39
tree4e0f6264afccf9ef11a88661475f247f1901b92e
parent04d8712b079327409b09dee628378f9583e2e035
libceph: make decode_pool() more resilient against corrupted osdmaps

If the osdmap is (maliciously) corrupted such that the encoded length
of ceph_pg_pool envelope is less than what is expected for a particular
encoding version, out-of-bounds reads may ensue because the only bounds
check that is there is based on that length value.

This patch adds explicit bounds checks for each field that is decoded
or skipped.

Cc: stable@vger.kernel.org
Reported-by: ziming zhang <ezrakiez@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Tested-by: ziming zhang <ezrakiez@gmail.com>
net/ceph/osdmap.c