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 335DF370D4F; Thu, 30 Jul 2026 16:10:23 +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=1785427824; cv=none; b=aQfOMocb7zwS69DbUEDwHVEA0lrQe6ZHMmC0K62lzu51GZzzwSrsNTLtmvMpmyWKxIIYPKBvDw/oubG9o9QGHrCO7irYWPI0SkzUyJlefWOcyrqDjDTTYpJ/CVIgslOcaxkDDBBPuaqEFboeblZUwaMlXsRP97th9EG0+li2x/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785427824; c=relaxed/simple; bh=vOJIOh1F5kA+V7iLEdbSKlKZiEqoAOYPuiH2dpzl2yU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QhjiUhc88guYVa+l6DYbMkI8YXZNt12oalz63uSa8HqrWVsCJT4aQhOQfogRgh6SY8QEimeSC3e1pU7PJUcnt+1I1BRCRJgMZTEKMTrjkP7DULLmoqGpilr0tUcLloVuyvPX6UD5R/tV6CXrxomA86N/oVJYze2CloACEFVyJuc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v23PBQwO; 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="v23PBQwO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ED021F000E9; Thu, 30 Jul 2026 16:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785427823; bh=tZhTzcPa0WTYyZsnWZ3OGWpR7/eixskNHaCyuGgcbVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=v23PBQwOd1DzhQHoZEr/nUqKqYP1oN2EeHXzuWpC3YvSrDS4cN4PvB73x4/3GLBYy TW7kLOiR7kOLQuxnhfQu3X2TWnhh30fDCLN46JIKHXv8nVcAzMbTv2AAipdaQpvzqT bjr269w2EUHbOC8Ui2NcP5nm8VgBDOBOmfVhpCo0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Raphael Zimmer , Viacheslav Dubeyko , Ilya Dryomov Subject: [PATCH 6.6 305/484] libceph: Fix multiplication overflow in decode_new_up_state_weight() Date: Thu, 30 Jul 2026 16:13:22 +0200 Message-ID: <20260730141430.115191087@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141423.392222816@linuxfoundation.org> References: <20260730141423.392222816@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Raphael Zimmer commit 98917a499ec7064c14fc56d180a4fd636fc2784c upstream. If a message of type CEPH_MSG_OSD_MAP contains a (maliciously) corrupted osdmap, out-of-bounds memory accesses may occur in decode_new_up_state_weight(). This happens because the bounds check for the new_state part is based on calculating its length depending on a len value read from the incoming message. This calculation may overflow leading to an incorrect bounds check. Subsequently, out-of-bounds reads may occur when decoding this part. This patch switches the multiplication to use check_mul_overflow() to abort processing the osdmap if an overflow occurred. Therefore, osdmaps/messages containing large values for len that result in a multiplication overflow are treated as invalid. [ idryomov: rename new_state_len -> new_state_item_size, formatting ] Cc: stable@vger.kernel.org Fixes: 930c53286977 ("libceph: apply new_state before new_up_client on incrementals") Signed-off-by: Raphael Zimmer Reviewed-by: Viacheslav Dubeyko Signed-off-by: Ilya Dryomov Signed-off-by: Greg Kroah-Hartman --- net/ceph/osdmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1844,6 +1844,8 @@ static int decode_new_up_state_weight(vo void *new_up_client; void *new_state; void *new_weight_end; + const u32 new_state_item_size = + sizeof(u32) + (struct_v >= 5 ? sizeof(u32) : sizeof(u8)); u32 len; int ret; int i; @@ -1864,7 +1866,8 @@ static int decode_new_up_state_weight(vo new_state = *p; ceph_decode_32_safe(p, end, len, e_inval); - len *= sizeof(u32) + (struct_v >= 5 ? sizeof(u32) : sizeof(u8)); + if (check_mul_overflow(len, new_state_item_size, &len)) + goto e_inval; ceph_decode_need(p, end, len, e_inval); *p += len;