Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2503537pxj; Mon, 10 May 2021 04:42:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrmqA7InjdEb4mtnCxByB6P6Sc732tAhe+Hq8H0uj/bw2F3NfgTLXOVTBu2f4bA/wPVEMl X-Received: by 2002:a17:906:c1c9:: with SMTP id bw9mr25575584ejb.239.1620646938627; Mon, 10 May 2021 04:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620646938; cv=none; d=google.com; s=arc-20160816; b=XL6a8lQFRrzhKOZ47mqwpA6Ou54D0M8ghwzSHZXtbHUmw6R9oMkLc7XokZmdjw8470 Ay4auJk1b80EwfZQ8DdINZVMXDzi1y1i6GvWihROsE/uBWOsthV7d/6VUtd2/ef8iwzr 8AQBmFANjso3M9dZ1mBVfvn3Tv0Bk/oL9P1Q4gDo3eFwu1TfGNZlbgllOv8fFM9/PONx zSD5NbOaVdzT5AdwPf0N8uZ4dTL72Znr6X8lLIF8EBld5Dt+7FH7x9/gZln31suWb258 4/Hth3o6KzwTFn7S8tvxxoG3ucO2EfSt9MU0hMxk/6tKDa5i5Q2RMY1sZfW4SX0BqC5t WtTA== 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=8WvRXSEGpSUDg3IGDbDU5C/I0KQ7VoBNfW56KR9/HXU=; b=A89UgXesmpy3FtcutOtpPKdtrz4NaQAPaBmkNa3zGAWJi7B3MJ3HWgv7B++GLfRHsL fKHrIbE/84Hh4Edp7Awmy7DmW62AIQkVaI5gg/F9hk4Iwq2jZya60Rrl2TrfyCqDAFQG ebNoFOcTgRiBbn2xJFouI14FsPahkmqXKMhdGa+XBMgBClTkddmub2ZKHqu7ttH2tF0R muHXc1FDQsuGq4NPpSbffsNxFRY3PfnjJDq3L606wpesFxjRuzbi+qTMY3HraH8q5R93 unKgKW7Vb9UoF4kx8u/phYTDju+zn5fR+WMr5e+TM/3qaL1cIJMXfxLLPui+MsmilREB 7DHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCBLQeJC; 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 z4si4727971ejp.321.2021.05.10.04.41.55; Mon, 10 May 2021 04:42:18 -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=JCBLQeJC; 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 S241295AbhEJLhw (ORCPT + 99 others); Mon, 10 May 2021 07:37:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:53030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233988AbhEJKzl (ORCPT ); Mon, 10 May 2021 06:55:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6152E61C2E; Mon, 10 May 2021 10:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643386; bh=NnXrD86QDaepdkZjCNN7ZgN4nfylby90UqM9E5K6xzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCBLQeJCyQgDr5bbTf3Gjn5CQWicMR7+xI5DnPbSqSoobaMP7Cc7Mg4ytQNBgKv8A jCaDJRELALcMJEe7V0spr3VhOJ56OEwYV41VZH0EMpF2pwq/W8eB5Nc+FFPrENC2ok LMO43LhNo17FIu9Q+FAPK73zhamLiG/eHwclrKIo= 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 5.10 294/299] dm space map common: fix division bug in sm_ll_find_free_block() Date: Mon, 10 May 2021 12:21:31 +0200 Message-Id: <20210510102014.640012135@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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 @@ -339,6 +339,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;