From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795057668; b=DDbNoFUhsSBO+KWP/x17i2R/aDYeoShHBkMiXb44v0mK+hOP2xc0brpqCfNm9BphvEVX V1e9j8wgWyXLJBHShY0YEhc50D/T8WI9sjzHhYHpxGLqNGkcUideOIOOdvi+6k7eBqnjA f9fdEBktuTc/WRjQNYLxOcO+6P0lS1+oDIueTiDSzZTqF9wovNOBhPX/nVAoftALXtBc9 1VHzT9SWMbR1a6ZDmnbReKYbza0cli/BKBe/j/S4CClLfUphNoCdcFm42sHbcbxF+luCO /PsBe0itUugyOGz7p20IWRvoQnU4dHSG91WAxtc8h3378EVkqUsk8UnnWskg1/3DHnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795057668; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=PfjNgt9EsS6aeAxqlECrDRKmIc5sJTc4Hg2ptWpibJo=; b=3EVVW5LsFUTyzNKYsbJm5i9C0GqbRahGRF3kKLk05gTP4kiogqjBLZk1WjcCFiLZgdCR OlkizDhcYJXVH+XYGWHEJlLJqEROTDaW/7RsF7MPDtIRuZqvYScEjvvMI7s25ZqjWpU7U IzBbXwzzY5FUq5L3QqPsH3ADM7ZBmR77PdjG+fHxNFG/vEU3dO0u4pCmqMKY8PDwifYcD 0FkQBD0lkbgEewbyRcOSRqTnQcuKKqY4X/BG1GgR2u4VlADsVoHPapNA2254X5R8PKytm Rq5n9h5/iBPO9xqgCYHxfR7xbkwrTHv7nDhA3nP6j8hnXOqyJ6zk5hsL3vcA+aYMAVg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0UmxUxlk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D544B606A31C; Thu, 19 Nov 2026 03:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=0UmxUxlk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1251F000C4; Thu, 19 Nov 2026 03:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795057668; bh=PfjNgt9EsS6aeAxqlECrDRKmIc5sJTc4Hg2ptWpibJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=0UmxUxlkondvLoPwGbbzVPFYF0Y9l7LHWP+OJzOfXRYKRfToCYvn3B8hp/7nERp0f ef3tSV5YNYx5pneVOJXrB4ZfkKDNhP+teW1eUKjbb5xpxyU5exUJ5Sfgy4GiUc0szv TpeCC5P8hHpQ1IkJM9f23U1h8RTS6781vOszph9I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, co+25860fb17af97289@bugs.sh, Xiang Mei , Alex Markuze , Ilya Dryomov Subject: [PATCH 5.10 0211/1848] libceph: bound mon_command ack decode to front len Date: Wed, 18 Nov 2026 15:37:29 +0100 Message-ID: <20261118145920.864607631@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiang Mei commit 62b41a16d8603d4d809fda212f15c3e9c783a82b upstream. handle_command_ack() bounds the decode with msg->front_alloc_len, the size of the reply buffer, instead of msg->front.iov_len, the number of bytes the monitor sent. mon_alloc_msg() routes every CEPH_MSG_MON_COMMAND_ACK to get_generic_reply(), which returns the preallocated ->reply of whichever generic request carries the same tid, so the buffer keeps its fixed size however short the reply is. An ack with hdr.front_len below sizeof(struct ceph_mon_request_header) + sizeof(u32), including 0, still passes ceph_decode_need(), and ceph_decode_32() returns four bytes that were never received: uninitialized slab memory, stale bytes of an earlier message, or bytes the peer planted by sending a reply that lands in the same buffer and is then rejected. The read stays within the allocation, so KASAN does not flag it. req->result reaches userspace through ceph_monc_do_statfs(), ceph_monc_get_version() and ceph_monc_blocklist_add(); rbd hands it back from write() on /sys/bus/rbd/add_single_major, and rbd_get_client() passes it to ERR_PTR() unchecked, which faults: rbd: failed to get latest osdmap: -186318427 BUG: unable to handle page fault for address: fffffbfffe9ca034 Oops: Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:do_rbd_add (drivers/block/rbd.c:7105) Call Trace: ... kernfs_fop_write_iter (fs/kernfs/file.c:345) vfs_write (fs/read_write.c:595 fs/read_write.c:687) ksys_write (fs/read_write.c:739) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:84) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Kernel panic - not syncing: Fatal exception Use msg->front.iov_len, matching handle_subscribe_ack(), handle_statfs_reply(), handle_get_version_reply() and handle_auth_reply(). A well-formed ack has front.iov_len >= 22 and is unaffected; a short one takes the existing bad: path. This applies commit d3c32939fa0e ("libceph: bound get_version reply decode to front len") to the last decode-side use of front_alloc_len in this file. Cc: stable@vger.kernel.org Fixes: 6305a3b41515 ("libceph: support for blacklisting clients") Reported-by: co+25860fb17af97289@bugs.sh Assisted-by: Cursor Signed-off-by: Xiang Mei Reviewed-by: Alex Markuze Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- net/ceph/mon_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c @@ -870,7 +870,7 @@ static void handle_command_ack(struct ce { struct ceph_mon_generic_request *req; void *p = msg->front.iov_base; - void *const end = p + msg->front_alloc_len; + void *const end = p + msg->front.iov_len; u64 tid = le64_to_cpu(msg->hdr.tid); dout("%s msg %p tid %llu\n", __func__, msg, tid);