From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CC2248033E; Thu, 20 Aug 2026 17:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787246951; cv=none; b=sA/Zx7BW3hS2SFQaIc3Nld+KUiF5/sCxcr1X/o2u/2rPrRKy2TnFOKLVTN9n1CwI+cclhL9ntR2N2pVxucpx8BWuD41xQL9LeDCuBLnYWL0UzIPqzsVtjvkkQQcj8aW58u3k9Ti7kr8hvZcOcwmzhJAV1g1+0IlcQy/6ekMlHkM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787246951; c=relaxed/simple; bh=vvMCYd/Ic3/tSFuMUIkO31QNASPHE0He7NTmp7ic0jI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XzNWgZDcISzJb7/V8qt8Htr5TeWGqspNwFMSBqMvxTtk41mN5wh+gUGP4oFXwK/8aYc+BNXUlM7YspZ3bWyOjB7hcNNyTR9ZNi5/qhZJIbctsw7lISs4+r8WI1KeGgZxPZIONAE1wBtZaalX+qeKuz8wppHy3tao/Vd4xBDv9AE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XX8OT1cy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XX8OT1cy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EB8F1F000E9; Thu, 20 Aug 2026 17:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787246950; bh=vPb1BAZEbyzNg2e2e35ypZoKhLSTQqtU1tZWl2GmYWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XX8OT1cyyM2EX+Bh4Ol39ALkexArGzFrutteZlVM+ZJPgGmB+ReXVi0pOCwJvlFJ6 yNNuVMzpHBehBV4E8rhWwdF71+2zqTw73n5PdL7643qlfrcjCdYaFZw55yzGghNqdx s/NIl7dtAicXT0ecHudaRI1PtGZBlIpBuYveyWa0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Raphael Zimmer , Ilya Dryomov Subject: [PATCH 6.12 060/220] libceph: Avoid using invalid osd indices from primary_temp Date: Thu, 20 Aug 2026 16:54:10 +0200 Message-ID: <20260820145225.296033199@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145223.480031205@linuxfoundation.org> References: <20260820145223.480031205@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Raphael Zimmer commit 3660b98d1204b419f6a77e9a295f148dcf38d042 upstream. 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: 5e8d4d36bf23 ("libceph: add support for primary_temp mappings") Signed-off-by: Raphael Zimmer Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- net/ceph/osdmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -2811,9 +2811,10 @@ static void get_temp_osds(struct ceph_os } } - /* primary_temp? */ + /* primary_temp? (shouldn't ever be a nonexistent or down OSD) */ pg = lookup_pg_mapping(&osdmap->primary_temp, pgid); - if (pg) + if (pg && !WARN_ON_ONCE(ceph_osd_is_down(osdmap, + pg->primary_temp.osd))) temp->primary = pg->primary_temp.osd; }