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 4E63A49620; Mon, 13 Apr 2026 16:24:44 +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=1776097484; cv=none; b=LQyTv8V8leXHSNT0cEmr9gqm1s3UjNW3hpTE7nl7wJW3//4E364CJaktHbEXLZwIQldA0yDgZLuHBKKQowBPCNGEdBNwj0jG0Omd8StLNbUyEdF1xBQ3A/k25E8RCvxzHbkE1tpAwe3Ak+94VqXl25Jy6Cg5CoKb4yQ5IlFqw3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097484; c=relaxed/simple; bh=sWw79GL55Qdd/9OTxpLKP55tf7AOWQENE1oRdpivx0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gsKTflzWIq5WHjP6LHe2kZ9MtewC8npmqUkw0lh3tC9vRfJy/z4UJnzdld7aqX1j0objm0jN7zqaS80gKZvoXcSQyDldge4Db0BisbvvRvJLtlJ18G58DJAe72WgYoPegZ+FHgHKg/B9Cst1+HuNb+WTKIhmuVeYWclGVhsY2E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=p42IA5Ki; 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="p42IA5Ki" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1BE4C2BCAF; Mon, 13 Apr 2026 16:24:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776097484; bh=sWw79GL55Qdd/9OTxpLKP55tf7AOWQENE1oRdpivx0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p42IA5Kinu2dkEQOEDYcwwjq2/vq9s3ljx89YA6UjbIWQPq2S8hPJXwTE8NT9g64t 6EwEyzC74Ccn6HVbVguPvIQeo0t6ntlyGUXg+XEQvnvVYad8/Dz9nOHpWUj3nVUyHD dhrbUFZMg7pQvioNCQlWdFzTYFPUF2ABKp92RlRw= 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 5.15 153/570] libceph: prevent potential out-of-bounds reads in process_message_header() Date: Mon, 13 Apr 2026 17:54:44 +0200 Message-ID: <20260413155836.182143535@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@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 5.15-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 @@ -2527,12 +2527,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) { @@ -2563,6 +2566,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)