Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3537908pxj; Mon, 24 May 2021 08:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8nrQJyDK9L/Oij555zh7O7YZ1AzWfkX49Tpi0sVXFToTv8Q3++6UTvhJXKDQnNpIxe3JS X-Received: by 2002:a92:502:: with SMTP id q2mr16537330ile.203.1621871794644; Mon, 24 May 2021 08:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871794; cv=none; d=google.com; s=arc-20160816; b=F6shs9j9z/ekifR2w0m3cVE+VfOr177zB/kj9n5eRSya8+UJHiiHlfeIt6LRhxbwOJ VrescLeZ62wPLcCq0TeJMG4/E+Va3slWmS2pGmaRTirqQGnjMcLZ9you1VCIipmQBujK wmIfWjon2r+8JVBiORokKGOAp6BsqpA8G+ElbQn0GK7TFp7PwqWzQ0v27NUNwa4RbQRR R+HsPXXqxUWuvRrUQwFDJTDdNo9e5pwdgvuB9w459EL3r1mcHqwlMSrIRcJDoHWB5knP 3OvoXTyME6O/GAB2Q6srxnzd/wGexsM1mEPQwKXdtcVfHtMbv5OzeMyzb0Rlk0wzAdyW sjmw== 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=rxw76hJBy0HZOgkCRZGoIYH1i9w9qpp7RhUFD6JHVS0=; b=GFM0rYGyLrdWFfdJ5XLPho75odgJOglwpGMJURQ5hTOwoWh8UjxvftUlZOaiUxlLIn jBfRFWNTD6TEtdzYfbn/nVk8UCWrocUFRJsEmjWxVBFo4EFMIwY8uu1i4rwQY/VzAJh0 VLm2G7mhtucI9+Mhr3Z1dLMqK2t4+5KwqhARrFJIZ5FWcq2oPrcTyeYjRzYtBN+6XBpB jydQoRxqRFUMi5Wn9UCCOyK2OEKym53d3b2zLw/0jzZXe6XfGpD6AyK96o8K3OhCrMwm tLDz5phKsYwzMmGNNJM9h1NDribA4CuYCKqzXG+abVRYGELnm1uNJGSeCiykTAaKuBmD TNaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Wehs7P9; 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 g2si15278414jaj.107.2021.05.24.08.56.21; Mon, 24 May 2021 08:56:34 -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=2Wehs7P9; 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 S234971AbhEXP4L (ORCPT + 99 others); Mon, 24 May 2021 11:56:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:33936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234091AbhEXPs3 (ORCPT ); Mon, 24 May 2021 11:48:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 220606157F; Mon, 24 May 2021 15:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870649; bh=3tr2OMRnQcEEYAL6cEE519vtoioTcnPkV1HS//zF48Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Wehs7P9f1T00R5ylYFg3QEzxi9yyR+2HfcjnzL6cfk1snv4goanNYExZC0lCq9y4 mWGmVuRw7rIY/uP/5gLw/EF9a2vNxwAC3w/KttiIN7FvOzNgncflQg88I0IhHrbiHE en+FHtrNzswfXJJoEg8IfuWrocacflGfQxTrOPOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Tokarev , Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.4 42/71] dm snapshot: fix a crash when an origin has no snapshots Date: Mon, 24 May 2021 17:25:48 +0200 Message-Id: <20210524152327.835078212@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152326.447759938@linuxfoundation.org> References: <20210524152326.447759938@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 7ee06ddc4038f936b0d4459d37a7d4d844fb03db 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. Reported-by: Michael Tokarev Tested-by: Michael Tokarev Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-snap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -854,12 +854,11 @@ 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) - chunk_size = min_not_zero(chunk_size, - snap->store->chunk_size); + chunk_size = min(chunk_size, snap->store->chunk_size); return (uint32_t) chunk_size; }