Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2688280pxj; Mon, 31 May 2021 08:17:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6syIMdayCQuIsPZJZk+b6sTL/IUKE4p1lneVmrMhq8kgVPrjdfCW6bxLhTs+QuNPREdoH X-Received: by 2002:a5e:974d:: with SMTP id h13mr17255916ioq.150.1622474233946; Mon, 31 May 2021 08:17:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622474233; cv=none; d=google.com; s=arc-20160816; b=SezuRGpPDMSL+Yg1/ljgaG5lT9e1vOIQX+D6ElPyps7FGZJGE87HGbbGUrqF1reDlh vaoGXJchFshDh6SgZo61J3O7nN8fVGhsns9E1VmJObxfmaf85ws0s/ZhQ7ZjNBQIy3I3 YQK0DKba9ijBoUt7SwJE5Pps2bJAmXTzrbs+bSkvsM4tATw/af6PJc+xhGQ3icHZZrpf bYYQkp18QWq44se2hDhahpRStxhBp0rQfBMJ7SGqK+N5j12IHvCfc9FLetyK0MLP4ptC hC6KfCrAKILw4jBX2c/bdFSCR6U3eKlt2zV87hOnjLa83EL/fF92g8sQ0WtRblfFS4x7 tciQ== 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=et+iCehFJHT0o9+Fb/gJu+NGc70f+ZhzOOdyoPH/tbA=; b=rYwzqLCJjydf9eLaa2sFzPasSh2dp76ZEpuBmOk20MEldjfxpk4yY8S4aD0xet1xa5 aWNWo/Q7skTgf1HnQl31eFPUy3HT5AR/lhRYcne6VcRhPMR2nR9yEYvI1YppxS9NxmS6 oLYtsSpV1JtESkp7lE3Xc6TvVMhL5Q4sNjoTF5jRxQAfuesVyTpJMrwRyslBdSmOc5Zj LgnvKYo3Z6Rj+k6y1I5bO87fmd1vvszTrCRnoqyoBBC5w6Kxp3+QniPNvgKYOHFIffh8 3pz15TfQbqST/n272mqRlAOVyq4l5fdgdU6mhTSgUex0bqGPIb3GuiEQPDZedSHpRn5K 5qEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Im6CphXd; 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 t11si384751iog.32.2021.05.31.08.16.58; Mon, 31 May 2021 08:17:13 -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=Im6CphXd; 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 S233813AbhEaPSF (ORCPT + 99 others); Mon, 31 May 2021 11:18:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:43712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233537AbhEaOOH (ORCPT ); Mon, 31 May 2021 10:14:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 268F66199B; Mon, 31 May 2021 13:42:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468544; bh=+AnYopkoo2JAvurKoTnNndHvZirtU9zs5Jxey1oteq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Im6CphXdEjLmF75R//0+xUcbyUffMWFoQ0UdsQmyjGKcmd9e90XbBlQ9Onb+XiNxL jm4pbfAgYkxb/AHuKTCQwRvHO2ZWaSqbKg2POdvDeiWQC3Hz4+ePCL5AAqDUoCcmwZ IqRSBsuSDPWnKP33usCHOB4PZwokM0gN1wsQ/LEs= 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.4 030/177] dm snapshot: properly fix a crash when an origin has no snapshots Date: Mon, 31 May 2021 15:13:07 +0200 Message-Id: <20210531130648.958720109@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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: Mikulas Patocka commit 7e768532b2396bcb7fbf6f82384b85c0f1d2f197 upstream. If an origin target has no snapshots, o->split_boundary is set to 0. This causes BUG_ON(sectors <= 0) in block/bio.c:bio_split(). Fix this by initializing chunk_size, and in turn split_boundary, to rounddown_pow_of_two(UINT_MAX) -- the largest power of two that fits into "unsigned" type. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-snap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -854,7 +854,7 @@ static int dm_add_exception(void *contex static uint32_t __minimum_chunk_size(struct origin *o) { struct dm_snapshot *snap; - unsigned chunk_size = 0; + unsigned chunk_size = rounddown_pow_of_two(UINT_MAX); if (o) list_for_each_entry(snap, &o->snapshots, list)