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 8E4DF415F1C; Tue, 21 Jul 2026 21:45:22 +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=1784670323; cv=none; b=K673jNLryXzVcsjQC4hz0F7h2flaSq6kLWNYLmS2LJGeKmMBsWTlYx8QZYDSnOIkUyEYwmbRaN+b24kAhEcriwMC3M+Snm1s8Om5qVGG7BnNbHhK/C3CC+WAIqJDPoq0VQakf9onJRzDiAXGzwmh8geaI3f2m/dPJWwdflyB8FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670323; c=relaxed/simple; bh=V4oXvxKZqTVbrozPQCnZDFdPHeUGlP2wHpKAPTwc94s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ke7HNqO0/Vu9eMq0kHae41SNWBN8oPGRZXL0OLraiuuIS+kOzvpREaHCkSJnbZiuiMhlC2fy3rkuBzGOWHbLrhxNJFz1EAfx0cLvrXb6XcFrzCg6Ta3ypS4lNjlJclxkXhNmr2EU+kxGnRcR2KdDZo+a6Xlv5Q3i/ajlmBCobxc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=pKDI+VqC; 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="pKDI+VqC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 009C41F000E9; Tue, 21 Jul 2026 21:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670322; bh=bMlnVMy74jERL4fM5JEprFDuQDbaDfIvik7dwUQYfUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=pKDI+VqCahqxDO8FPqdq4fC8nPDyqzkIFBOGFgu0SKWrYXX4M7pT0vfnmnPPw3EoI 6Px4HmXlLclxVs2bqbZK6mmxc/SumlZXSpPjujRLu1KzDSDoefkrNX/l+bBAZAj0D9 iQoiOPjb4JxXh7KEpv2eTjBaYo8gZSFks4I5nSR8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Benjamin Marzinski , Mikulas Patocka Subject: [PATCH 6.1 0846/1067] dm-log: fix a bitset_size overflow on 32bit machines Date: Tue, 21 Jul 2026 17:24:07 +0200 Message-ID: <20260721152443.474042235@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Marzinski commit 9743132a41f4d9d0e54c5f2adcb821b04796bab1 upstream. Commit c20e36b7631d ("dm log: fix out-of-bounds write due to region_count overflow") made sure that region_count could fit in an unsigned int. But the bitmap memory isn't allocated based on region_count. It uses bitset_size (a size_t variable). The first step of calculating bitset_size is to set it to region_count, rounded up to a multiple of BITS_PER_LONG. If region_size is less than BITS_PER_LONG smaller than UINT_MAX, it will get rounded up to 2^32. On a 32bit architecture, this will make bitset_size wrap around to 0 and fail, despite region_count being valid. Since bitset_size gets divided by 8, it can hold any valid region_count. It just needs a special case to handle the rollover. If it is 0, the value rolled over, and bitset size should be set to the number of bytes needed to hold 2^32 bits. Signed-off-by: Benjamin Marzinski Signed-off-by: Mikulas Patocka Fixes: c20e36b7631d ("dm log: fix out-of-bounds write due to region_count overflow") Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-log.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -418,6 +418,9 @@ static int create_log_context(struct dm_ */ bitset_size = dm_round_up(region_count, BITS_PER_LONG); bitset_size >>= BYTE_SHIFT; + /* Handle dm_round_up rollover on 32-bit systems */ + if (!bitset_size) + bitset_size = 1UL << (BITS_PER_LONG - BYTE_SHIFT); lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits);