linux/net/ceph
Raphael Zimmer 3660b98d12 libceph: Avoid using invalid osd indices from primary_temp
A corrupted osdmap received from a Ceph monitor or OSD may contain osd
indices in its pg_temp, primary_temp, pg_upmap, and pg_upmap_items parts
that don't exist, i.e., that are greater than max_osd or smaller than
CEPH_HOMELESS_OSD (-1). These indices are used to create the up and
acting set in ceph_pg_to_up_acting_osds(), called from calc_target().
While most of these osd indices are checked, the one from primary_temp
is not. Subsequently, this may lead to calc_target() returning this
(potentially invalid) index as target osd for a (linger) request.
Because the osd_state, osd_weight, and osd_addr arrays only contain
max_osd entries (with indices 0 to max_osd -1), this leads to
out-of-bounds accesses when trying to read values from these arrays.

This patch fixes the issue by adding a check to get_temp_osds(), so that
only valid osd indices from primary_temp are used, and it falls back to
using the primary from pg_temp or the up set if it is invalid.

[ idryomov: changelog ]

Cc: stable@vger.kernel.org
Fixes: 5e8d4d36bf ("libceph: add support for primary_temp mappings")
Signed-off-by: Raphael Zimmer <raphael.zimmer@tu-ilmenau.de>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2026-08-12 21:21:41 +02:00
..
crush libceph: Fix potential out-of-bounds access in crush_decode() 2026-05-11 10:39:21 +02:00
armor.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
auth_none.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
auth_none.h libceph: kill ceph_none_authorizer::reply_buf 2021-06-28 23:49:25 +02:00
auth_x_protocol.h libceph: add support for CEPH_CRYPTO_AES256KRB5 2026-02-09 12:29:22 +01:00
auth_x.c libceph: refresh auth->authorizer_buf{,_len} after authorizer update 2026-07-23 20:29:41 +02:00
auth_x.h ceph: fix whitespace 2018-08-02 21:33:21 +02:00
auth.c libceph: Fix slab-out-of-bounds access in auth message processing 2026-04-22 01:40:23 +02:00
buffer.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
ceph_common.c libceph: remove debugfs files before client teardown 2026-07-23 20:29:41 +02:00
ceph_hash.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ceph_strings.c libceph: introduce connection modes and ms_mode option 2020-12-14 23:21:50 +01:00
cls_lock_client.c libceph: fix multiple unsafe decodes in decode_locker() 2026-08-12 21:21:41 +02:00
crypto.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
crypto.h libceph: adapt ceph_x_challenge_blob hashing and msgr1 message signing 2026-02-09 12:29:22 +01:00
debugfs.c libceph: fix potential use-after-free in have_mon_and_osd_map() 2025-11-26 23:29:10 +01:00
decode.c libceph: tolerate addrvecs with multiple entries of the same type 2026-08-12 21:20:54 +02:00
Kconfig libceph: add support for CEPH_CRYPTO_AES256KRB5 2026-02-09 12:29:22 +01:00
Makefile libceph, ceph: implement msgr2.1 protocol (crc and secure modes) 2020-12-14 23:21:50 +01:00
messenger_v1.c libceph: add empty check to ceph_con_get_out_msg() 2025-10-08 23:30:47 +02:00
messenger_v2.c libceph: Remove obsolete session key alignment logic 2026-04-22 01:40:22 +02:00
messenger.c libceph: update outdated comment in ceph_sock_write_space() 2026-04-22 01:40:22 +02:00
mon_client.c libceph: bound get_version reply decode to front len 2026-07-23 20:29:41 +02:00
msgpool.c libceph: preallocate message data items 2018-10-22 10:28:22 +02:00
osd_client.c libceph: fix OOB read in decode_watchers() via missing bounds check 2026-08-12 21:21:41 +02:00
osdmap.c libceph: Avoid using invalid osd indices from primary_temp 2026-08-12 21:21:41 +02:00
pagelist.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
pagevec.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
snapshot.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 268 2019-06-05 17:30:29 +02:00
string_table.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
striper.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00