Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3529861pxj; Mon, 24 May 2021 08:45:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSY81zCTiQJRqaX4hjHHznOWr5d6cjXpi6LqlSzbvPNIkxtl9XrzpQ2ydDCJH0HhpQ7jpH X-Received: by 2002:a17:906:ca4f:: with SMTP id jx15mr11229310ejb.160.1621871132403; Mon, 24 May 2021 08:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871132; cv=none; d=google.com; s=arc-20160816; b=XEA5pshmYYIznidRBt12X2yfGyJElOCaUVM8lIL25VY7jqLcitOnbGe3zQlQyTqouC CuvP29Kk3CKpVsaqsfZP6JK7qax7SqmpxW53k46KT/+TFgVKheBrm4O4pNGmH5Zc4YJH IxJJYjATgbCOnVt1gTt/tOxV4uFLUcr0TBfozTv8RdOFMlPtyWg4qG8Kr5dyedQ2M/lO 5SSb0ZkqC6KDq8tAVTe1Huyh1lKEc4OA7cZqScXM5KGW4wHAuLmkilQTB8yIn4xTJuNI TomOsG8xvjW3tFmezr5djrTZ/BUUeMqfyGaeJgqbuZKVY5MqpRFaKdqVdIUWR6qAYkkN tXnQ== 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=rfhTs87ac0fHM5qs6QEvbpX+i1fi/p1r2OrpK1rd86M=; b=iU/8KmmM+6SifvhGl35YbIps/ZVEAOj8ChnjELIa6hYI99gBG6FM/4aU6/SnAZsrD6 0fgtaYDFYaDZrO5YsDffP6OiRyUCQCm5ydoaG76Kh3xR666x+VG1KGXHA2/Lj7046h5L XywkfHtIJnf3plHmwH7RewAZLxm8u+hnxaRALXo6u7eIUUChL7HCgZzYmXHG1Nz76InL hbSyG3VYlO0RZnqszoBFYmMYhkXcmoKOzoCBX3iinDYWGFdxWEoVQoXQ+ygnTeS/POMx SqT9qNdFQbL9GxtdR5hJBrkU6VmCo2GHeW7bykfiZAkuGJKIrzWrMX02FCoNSOBeyxss rcsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xzm0Zabp; 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 gn25si12924869ejc.434.2021.05.24.08.45.09; Mon, 24 May 2021 08:45:32 -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=xzm0Zabp; 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 S234584AbhEXPoZ (ORCPT + 99 others); Mon, 24 May 2021 11:44:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:58132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233805AbhEXPkU (ORCPT ); Mon, 24 May 2021 11:40:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64BB661434; Mon, 24 May 2021 15:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870453; bh=bkijXBVEuJerTV88teLlvM6UvUapCXn4lYlZn5veHJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xzm0ZabpWyx79tKi+UA0EtoFSobflTRk3yanXRAZfQGoNTb7S5UorAPVwRCYMQn9R of8jvo8HrQoseOCwj6ILTW7V9qUq1XEull3BXqCS3HyjqUtKzaMQyfa8xWAIbHFkc/ Dmh3qJvQNDuG6pOhpQLDKS9hIWhLP9Gseu7TCwUM= 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 4.14 14/37] dm snapshot: fix a crash when an origin has no snapshots Date: Mon, 24 May 2021 17:25:18 +0200 Message-Id: <20210524152324.676643600@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@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 @@ -793,12 +793,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; }