Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3523322pxj; Mon, 24 May 2021 08:36:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUtMtMnyS/u0y69EyqpwYyA1uP0d1FYe/FKH3+GbaneqaLE3omv25rc7zNH6DaKbWqjQPW X-Received: by 2002:a05:6e02:1c25:: with SMTP id m5mr18332318ilh.295.1621870590257; Mon, 24 May 2021 08:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870590; cv=none; d=google.com; s=arc-20160816; b=1Ik9E5ZQ24nE9tJsSp9Xvo9U2Yt28MQiOv5GMYFaGIfPaNACZtiPFnCX4q8tZHrkoa SPw8kjbfxa/gb1rpsSTfBbxisB+q7tVyUhnrAoyCC2Yrf1O2zZEC+Y2dYxVwzNEmMbZ1 /w+wSbgsbCVoca8vA/A3NIolvTyXu4OvHUWXCQJ0U20Ne0BFujXsw8UeNM0YC/S5KUr4 baGS9MFKxRoNmHhmB5fX86Pq6EgD24aVkX2gcI0SMU4KxklfpfCVh8GYqhPxkqyE41Wy hm9AfMReTVWetgIZ3sdb2l6N1I5eFHh67do07JkTixCFBaJc3SQ7ycXbSlyJlIPpucuc Goqg== 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=lviI6zbiudU+Yq6KTtZYwCEa9wI6HNmuVBmMj67MRb0=; b=oIay7+72PLvsuZTEKVjvCdoc1KYZjol37/KkWvNs0nozbmwBbus3W6dtkdENSJxSAc svLAwwSOuaZ7Zu1WVaEFqkzV4iD/QKau/xOT5y/YV0JC+tlkOT3G2q2NEsabYVQrel/k 8QUdhhlwm502Xo6fSyfgFC3h9BsYL6Y8OCJ/KJppasElnYEca+OhQ3NW/J+wm+ezp+eW w81gOB/46B8Xw56D6umbuz9xYwgvgmnN5A3BDqnp+/5nemfssx20KucnjG/r2qMPRGvB YbTGLqZSwEhPCnCHuxXnnmM+wb6HTSdWwMX+YoKXJRnUwzuWFnKwZOre+5WFgPA6hv3k DgVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fg0VujFG; 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 g3si15799715jan.54.2021.05.24.08.36.17; Mon, 24 May 2021 08:36:30 -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=fg0VujFG; 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 S233192AbhEXPgV (ORCPT + 99 others); Mon, 24 May 2021 11:36:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:50522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233524AbhEXPdk (ORCPT ); Mon, 24 May 2021 11:33:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CA38E613F9; Mon, 24 May 2021 15:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870295; bh=PtR8MXR8hstar5fCiHpNWjS75+NhdGctlARPHuDvDHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fg0VujFGkj/ifSdc94rveqn6Tbb1YG9Np+JVExc5hz4U1sO7E4uC3ztAPa3rpy4oM yO8c9knsqqKOnUPIvrC1T656L0Bmn9dden4rUjHurb/oEbRRXUh13+dxe3NHKozQU6 ffeb1Z44SPUKqhAobXj5PMpdFq3q+Ufx7oL95jYQ= 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.4 09/31] dm snapshot: fix a crash when an origin has no snapshots Date: Mon, 24 May 2021 17:24:52 +0200 Message-Id: <20210524152323.230689914@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152322.919918360@linuxfoundation.org> References: <20210524152322.919918360@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 @@ -789,12 +789,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; }