Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2931772iog; Mon, 20 Jun 2022 07:45:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1upuvnnTCcrT3tWcS+4Pm6B8A/R6DNc6bTgQzsMq7MMCTsmr8tfG3MqFlzhothWcPDwneUM X-Received: by 2002:a17:90a:1485:b0:1ec:788e:a053 with SMTP id k5-20020a17090a148500b001ec788ea053mr19390422pja.16.1655736302050; Mon, 20 Jun 2022 07:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736302; cv=none; d=google.com; s=arc-20160816; b=vr8d6CM3KZPhVIzHmF0ReTEraP3gZqxMC9U38mQ9eTDeoOu/aKVpOLTSHjuIekUW08 +fWFoFjPN/Q0DAsdoo6sye5THqCAEzX92ayzpei6+51oKwIc7MrfSEhxqbnqQGr1yxnx SQuxUd5xzAl7S4sNb+hKJHdwNe2utT3hGOwhxpgtht3Eypnm3LsSYV6gGCcPCHre7pTN sy9L4vk6cAzfSSh/273zSVpe6c/XPL/yzw7elAMRhK2LjUdV9eYhZG1KXO9I9e6Ud+Ec uVYL/ghvXadJJ8xnTaiJ1uD0tfo63jSj07QSeOko9NxxxeXu4a6q4SrNpkz8uoa+wSBK idEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sRgyeA8bTNtGnZC+08CDovJc/q7EuopG6HgfrYY2x0A=; b=GKsjAyo9DMKyC4xxvDMF9osGe9kV55Mw3T9Sbyf8eU3kjnqbz2Mn7QsZ2kp8SIMS1Y WC5r5Uy4lD3+77iIpAJ+/UuLPN7XZ7WZzWhxJY4fG4fdwu3jZSE+kr1qpTtmFSysOPvR WJ77k+PA96sZ7CnP4Ele4PN6qTWN2rQj9PmWyOiD/e5Q1j2QuBKe9g+ThnY0ugEfHx97 rgc49/os3cPJ55t6N4pJcMfUuVzEk/LjMtwOpG+a8PyDIhtmF5UhoNBo2xELY45qm2j3 TK5iGk6uKF6xXNhZN4wxuCBsOzJLw/Q/GAn8x08Bs6DGkpN7Hm5ZQ878K7RE+0vUqzNU 8qcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rIZISMgB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 188-20020a6304c5000000b003fc9b04edf6si16273090pge.423.2022.06.20.07.44.49; Mon, 20 Jun 2022 07:45:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rIZISMgB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346196AbiFTN2t (ORCPT + 99 others); Mon, 20 Jun 2022 09:28:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345010AbiFTN0K (ORCPT ); Mon, 20 Jun 2022 09:26:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18741C103; Mon, 20 Jun 2022 06:10:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C6A760C14; Mon, 20 Jun 2022 13:09:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43A4AC3411B; Mon, 20 Jun 2022 13:09:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655730570; bh=QWVOvaoQcs9rJFN9ZErPqPmZV92C+J1OsaNkwQKcuwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIZISMgBPgBhhKwzPHyb5+XxJfpvMUiEyX0T7/q19psL9iawUkwMkEEioA2jwF7XT Mp4x1SrrJ4TK1OW6FdiXEFc7bkTkzHNW2H18lywwc5vODb+WEwm9YmCBsKgh6C/qFJ KvVZYlDKOvcokzXiT9JhHt/8GP88R4jhPnt+QQ64= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.15 095/106] dm mirror log: round up region bitmap size to BITS_PER_LONG Date: Mon, 20 Jun 2022 14:51:54 +0200 Message-Id: <20220620124727.203157994@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124724.380838401@linuxfoundation.org> References: <20220620124724.380838401@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka commit 85e123c27d5cbc22cfdc01de1e2ca1d9003a02d0 upstream. The code in dm-log rounds up bitset_size to 32 bits. It then uses find_next_zero_bit_le on the allocated region. find_next_zero_bit_le accesses the bitmap using unsigned long pointers. So, on 64-bit architectures, it may access 4 bytes beyond the allocated size. Fix this bug by rounding up bitset_size to BITS_PER_LONG. This bug was found by running the lvm2 testsuite with kasan. Fixes: 29121bd0b00e ("[PATCH] dm mirror log: bitset_size fix") Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -415,8 +415,7 @@ static int create_log_context(struct dm_ /* * Work out how many "unsigned long"s we need to hold the bitset. */ - bitset_size = dm_round_up(region_count, - sizeof(*lc->clean_bits) << BYTE_SHIFT); + bitset_size = dm_round_up(region_count, BITS_PER_LONG); bitset_size >>= BYTE_SHIFT; lc->bitset_uint32_count = bitset_size / sizeof(*lc->clean_bits);