Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp413632pxj; Thu, 20 May 2021 12:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRc70PkawL2Rm/gCNWNMnhBNcbY7+WQ3na7tNtAOHbl8Y7WHDIZ6Glle9xC8wgZZjG4Xjj X-Received: by 2002:a17:906:591:: with SMTP id 17mr6232911ejn.347.1621538094395; Thu, 20 May 2021 12:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538094; cv=none; d=google.com; s=arc-20160816; b=hHwgNWhrNjYuGhxuZnGFDa9kTDiuNgQTe8QfgkI8NvHV+QuuF16UZ8kYMZkgkCnEvQ 2IJH6pybElpTNE30ENzKt5k/Jouy72JrBCrhE4kh/M0Uf2obhehZIcDzQj4alHE8uajN hfZtfguxdPkqz+GY0EvlykYCqCU0yDITgLK5D70joufahaBzxKKAwoeK9nM4IHYwCLr4 JJTjAToJ/OHI94Go+MFIfDgMvimgnZR0iOnVwI/HPhbNQSldaNn8kqTH0S4ZliweMg/Q M9qZ62qSJ+S+GqwNsxRKXCrb/EINJJ9h5e/AL89JDpbkCjOWy9jF/lcAgIbTxMlI8h4A 1WUg== 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=K1n6gzPAZ7i6ZBOjtaEXwiT1dSwKIQdoqFajDPjtFDQ=; b=VpaRYV7xrD+CM6iGooa+EBOLTfzq0Zt/YJ0ey4/j2ipAEBX8ZlTvlecBgj1rCXI4RG FUR6F41qBsdhutxTzkDzor4VaGRtGb6WO8SjdQp4KCr/IxPEwY4SPifRKfFiiKm1jvX8 oLyPwRxm8YJwMR05YuyD0tSDmLn/F5pCo1RmzsY/2x0T+N0Iw2x+vyFxd5IwpvZcU5M+ oWHvp8HL6A57jsxbDDfM72G+eBEyaM7b0Ak2as3OGmKvzJr3Np35U/1XMOwMl4vwdkm8 6hL+hYdIHnRrXMI8i89zH9caxMm7id2JXS4nITaN10G+lcrXMCIizQ50fNM+Yg/aTgcC 5xaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nop3SSRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si3236695ejk.397.2021.05.20.12.14.31; Thu, 20 May 2021 12:14:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nop3SSRD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233685AbhETKgU (ORCPT + 99 others); Thu, 20 May 2021 06:36:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:51990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236333AbhETKXa (ORCPT ); Thu, 20 May 2021 06:23:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A47361469; Thu, 20 May 2021 09:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504118; bh=6qMJiWZ3pEETEodCSZjOD1Yryzg/jRm6fKQC5tedRcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nop3SSRDuzDalm87nocGYszLjTjc11jHY3bWmSdrItd9DRs7GI3sePAa1dvN+owUx dIc7RWDaWezhorWz38yCGfoTLfHyshPQs4zOBcM6l+QmeQZmAQZ4W3LNqDSa5v9pVc dTnjbIRrJbgJcpuSD/kNm8s+BqItyD6yFbhcukLk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joe Thornber , Ming-Hung Tsai , Mike Snitzer Subject: [PATCH 4.14 101/323] dm space map common: fix division bug in sm_ll_find_free_block() Date: Thu, 20 May 2021 11:19:53 +0200 Message-Id: <20210520092123.564416773@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joe Thornber commit 5208692e80a1f3c8ce2063a22b675dd5589d1d80 upstream. This division bug meant the search for free metadata space could skip the final allocation bitmap's worth of entries. Fix affects DM thinp, cache and era targets. Cc: stable@vger.kernel.org Signed-off-by: Joe Thornber Tested-by: Ming-Hung Tsai Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/persistent-data/dm-space-map-common.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/md/persistent-data/dm-space-map-common.c +++ b/drivers/md/persistent-data/dm-space-map-common.c @@ -337,6 +337,8 @@ int sm_ll_find_free_block(struct ll_disk */ begin = do_div(index_begin, ll->entries_per_block); end = do_div(end, ll->entries_per_block); + if (end == 0) + end = ll->entries_per_block; for (i = index_begin; i < index_end; i++, begin = 0) { struct dm_block *blk;