Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2930402iog; Mon, 20 Jun 2022 07:43:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s0YlStGQpjI+LPG0Lsz6YsnP4uilX1qObRgl2yeR1tEiTQ60JaSGxn8vZWVAVxhCzeztz7 X-Received: by 2002:a17:90b:4ac9:b0:1ec:9bd1:92ff with SMTP id mh9-20020a17090b4ac900b001ec9bd192ffmr9061800pjb.178.1655736200345; Mon, 20 Jun 2022 07:43:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736200; cv=none; d=google.com; s=arc-20160816; b=U/xZuOqQ0zD4DP6Ko9qJoxdT5C23h1yzJSb5SfWVOvk6P5YkrUuSqMAz5jJmuZQ+Pl NgjOAAMqryuPdbvtlfVcxbSdOvEZiNLvjl7wdAA7SErfGojsotWSk5FCTRzlmL4M7JTV m3+dJy3XVWnEs51czg8vX05um0TeiJVHN4c+ez24NFp6f58toqN0mFhJv8DfLCMEq/1l R2vAM/xwy0bXQd1XDXvSt3nx2vcAQNPOzxef/RYXJBuuZJ8MG3akNfrsII/F0WRINbWP UuiMO61nra8g9gMtLG9wmE7pmAVaG00P48zfVMdkoJK9wYM8pcMINWhPUItCXj0bqkjP blgA== 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=LHIijReOYhWnsoYlrX5LaRtMJQTdTS9NqUExWppIL7iZA61PodDJ3+dlXjFwM7w+vI dh892WkGzSiNWJjt+6bOSstD3CydDLK0+dEL04/niDfjQwDOvnfb9052DznTppqHFgiD xsDEdvCvwugH/NMZT1ki+JTuenAWo7Spcb614FBUDWUzYJvntgRBebsFjNHyGmnrBUuo UaxLUxfDURY6K8Vce+DrA7mXlsyUnZYwBf1A5lgRD6RB7JhJpOaH6eye6rL/+zX6ElAC waH5PgchkG9rqRiZd6W4MlLU+BwAGnkPwtpXNY4AwN2yYBEfrqx01ZxilLEFowio2fs5 DkaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yWwrCNMh; 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 d9-20020a656209000000b00408b78ce298si16469335pgv.669.2022.06.20.07.43.08; Mon, 20 Jun 2022 07:43:20 -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=yWwrCNMh; 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 S244766AbiFTNHq (ORCPT + 99 others); Mon, 20 Jun 2022 09:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244023AbiFTNEd (ORCPT ); Mon, 20 Jun 2022 09:04:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FF05193DF; Mon, 20 Jun 2022 05:59:45 -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 3B02461535; Mon, 20 Jun 2022 12:59:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39599C3411B; Mon, 20 Jun 2022 12:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655729984; bh=QWVOvaoQcs9rJFN9ZErPqPmZV92C+J1OsaNkwQKcuwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yWwrCNMheFllQcwOVMHZ6q2dET4Wxbc1PtU+7cyhX/Ck+W8DnFv+HH7XK3jOcdEP8 3qcZUaipp2HBDokaZGJm+U2mkK/XPQNAlqyX6H7VV528WF88I8Z0aDNOXMjO00Um1d NlhOckT1blSXbHMPE92VXTyZq4kVKDc7gvJwWVyE= 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.18 120/141] dm mirror log: round up region bitmap size to BITS_PER_LONG Date: Mon, 20 Jun 2022 14:50:58 +0200 Message-Id: <20220620124733.098180033@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124729.509745706@linuxfoundation.org> References: <20220620124729.509745706@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);