From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CEF341FFC48; Mon, 23 Mar 2026 14:18:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774275515; cv=none; b=E+3UYxlV9Ophy7ICO3LXgyeJWAJi7bRoKqjBSDEQn8Jozu6v50CaCbrF/ZlvUlU9OEjFMioSh6r+i5vxBKqe8E5PA9z6dcyso2ePop5K3n5h5h9n9SfApuFS+dlDIEitQ1l+UV673oOBvonWwGYUsex0Hy4tXhuSLnktlR0JGcg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774275515; c=relaxed/simple; bh=PKHwGZWnVWkVhtSKSv1NPCNK1Jg4BgiZOLV5NFa9jF8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZyPk6o1I3dMaywdTi2MBqxeafFKKhc7HwfwGW6aSFoMcmapYEs6GTk06jCIm3ktLrsxwOoJuRXsAoEMd+T/d9cviIW6h/H+m0x1z/9CaDN6vbrS5oSlfbhRE6T3xtWrTmGP/uUTlQnYy0517fW++yY7B04hapZ8FrxxYk27R3q0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GpKIdxaV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GpKIdxaV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53FD1C4CEF7; Mon, 23 Mar 2026 14:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774275515; bh=PKHwGZWnVWkVhtSKSv1NPCNK1Jg4BgiZOLV5NFa9jF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GpKIdxaVsMSsTkV3SwhaoEb4bwXVZ9U7J1UbEAewOzSWdPMCGfmDFG/0VJzz5TaYE +LWcKORwL7CrP7ne0T9USh4j6/CSaKo1gfr28rLOsVVP9eAI8DLPoj07/aYEuX+lSf mn/RARziFGgMa6WQwDAT/8HFZH4dUROx4S8CxHoY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Raphael Zimmer , Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Subject: [PATCH 6.12 128/460] libceph: prevent potential out-of-bounds reads in process_message_header() Date: Mon, 23 Mar 2026 14:42:04 +0100 Message-ID: <20260323134529.758483684@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134526.647552166@linuxfoundation.org> References: <20260323134526.647552166@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Ilya Dryomov commit 69fb5d91bba44ecf7eb80530b85fa4fb028921d5 upstream. If the message frame is (maliciously) corrupted in a way that the length of the control segment ends up being less than the size of the message header or a different frame is made to look like a message frame, out-of-bounds reads may ensue in process_message_header(). Perform an explicit bounds check before decoding the message header. Cc: stable@vger.kernel.org Reported-by: Raphael Zimmer Signed-off-by: Ilya Dryomov Reviewed-by: Alex Markuze Reviewed-by: Viacheslav Dubeyko Signed-off-by: Greg Kroah-Hartman --- net/ceph/messenger_v2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -2864,12 +2864,15 @@ static int process_message_header(struct void *p, void *end) { struct ceph_frame_desc *desc = &con->v2.in_desc; - struct ceph_msg_header2 *hdr2 = p; + struct ceph_msg_header2 *hdr2; struct ceph_msg_header hdr; int skip; int ret; u64 seq; + ceph_decode_need(&p, end, sizeof(*hdr2), bad); + hdr2 = p; + /* verify seq# */ seq = le64_to_cpu(hdr2->seq); if ((s64)seq - (s64)con->in_seq < 1) { @@ -2900,6 +2903,10 @@ static int process_message_header(struct WARN_ON(!con->in_msg); WARN_ON(con->in_msg->con != con); return 1; + +bad: + pr_err("failed to decode message header\n"); + return -EINVAL; } static int process_message(struct ceph_connection *con)