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 CFB8935957; Mon, 23 Mar 2026 15:06:41 +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=1774278401; cv=none; b=nGbfN/HVEcmLKq+7P0NbIA/5eAhoWYrAtAgICQMqqxnk4r6qJR18ZPIbfnltbJv/gVEp4FxWKVD95RJM2a3aVk2k13Bbnl/AdGnFGMQz20wa2ICr2usKxL7ykGLtO5jTVXWvLsg6mUDA5RNThp+bRvZJI1YmYF8019lkxotNpYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774278401; c=relaxed/simple; bh=AsYCl94XjWITvmuEWBo0af/5PTDrThcaJOv0ajrV+GY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=swWopX8BvpI9pvFr3Bpbi2KC/3d4r2AdskFYURS54s3p6I0ChmTDRAGvWB353g9eGrt/EhSwOESEx83YCgN9v6JmJCd9KDBLzelR4QEAQxzD1C4TqF+yuT4xQdphR1MO2fSU9xtYuklwwRUGeji0ZRwEEQsDSKkW9CHuXihhIzw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Bas7H169; 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="Bas7H169" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 056FAC4CEF7; Mon, 23 Mar 2026 15:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774278401; bh=AsYCl94XjWITvmuEWBo0af/5PTDrThcaJOv0ajrV+GY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bas7H169JTDynsX7RhIGdMuzQtyG/TjABG45BlLNmE/01tXnL1IsrNYsevZzMY1Fo WIlu+6Q4rjPuRxLl6uTtbvoCvDgMCQOPKi48w/MQQGb/4ir6cCSkf9Dt+9tmJOgIbp WU8KQya0YjmlnO2AgHARRWdHEk3iCwPGyA6hfClc= 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.6 296/567] libceph: prevent potential out-of-bounds reads in process_message_header() Date: Mon, 23 Mar 2026 14:43:36 +0100 Message-ID: <20260323134541.143807327@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260323134533.749096647@linuxfoundation.org> References: <20260323134533.749096647@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.6-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 @@ -2868,12 +2868,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) { @@ -2904,6 +2907,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)