Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3548154pxj; Mon, 24 May 2021 09:07:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfmK3VR+l71hic0Grq06CVpCIr0BX0PCVx3h8dL/LUUvbl+cMH4hDlinXawdViETVIJUPv X-Received: by 2002:a17:906:680d:: with SMTP id k13mr24283820ejr.371.1621872463238; Mon, 24 May 2021 09:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872463; cv=none; d=google.com; s=arc-20160816; b=ysbt31/wVXKV5wDA04WfIK/J8gRz41Ww7btYatWUsefVOMVI/rbFfBUlN/6X1SOYLC 4XAxTz+tM82RfR3ZHe7cJsomxQMi9MEF5gFUvBsu5vax2jywUP0lDKe5wDsnhrc0vZOk hUJE/884hFZoOdLl1FFfppJjUei4VaV/0RtuFVOkVI0lvG6OkFyi5CNqliMEYdKMnYdS MM8In7BGNAMg+UJvFwXibYyt1K6hoE3Kfgfj2eW5v/r2FStk9n5bEmS5Ya7/R5elziwA CJdzQ6E4ugrETdj7FtR/G8FPJmhool+3vVmzDCFIR52s0UU6hjCLeKjfS2z+7qTWB0RC uKWA== 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=P2EOvUAh+wdB87bsiLUze8W88hjT5mtbIrRzhG0Bp+rqM3z75dh49aZWoDuUiWwj/d qXb1Rxhe0CRB57C2Y8H5DX9OswNtGyFIwxw9V4RPZwyfa8iTwzjB1Z4FE3V5z+Gl9QGg 1w5slgIBEQA3mt1isptl7TZPBx0roRSYep+pvx2T/s1JiZ6B8RlWMYzApPHJW5xHilsI KMmgW45C6OStDwnZbf5AzjtksbNiJK/XTZFFeJqeM3Cr7bu9y99h6UHBMWAA/6dpKghK HlLeOIgh5qBNuDZVA+m6jbhlaTmQmQLZiTp0wJSJqIdZppqghdfA0SMgY2jyT6EdhCd1 ELVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SYZirnM5; 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 h2si13029271ejf.704.2021.05.24.09.07.20; Mon, 24 May 2021 09:07:43 -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=SYZirnM5; 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 S237170AbhEXQHj (ORCPT + 99 others); Mon, 24 May 2021 12:07:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:43814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235887AbhEXQAC (ORCPT ); Mon, 24 May 2021 12:00:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A03861984; Mon, 24 May 2021 15:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871146; bh=3tr2OMRnQcEEYAL6cEE519vtoioTcnPkV1HS//zF48Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SYZirnM5mDV+NiwuWJq34w2Uj3Ks9u7saTIX+bb+OuS0+ni7933lSt2l5iak+SY1w DKm8RqWUo2jAhdVaFX9urwg21RW0zdJRLtabJiR5rrBuPoUT1AZQ9OFl7d2vOXTqCx 1tyVysmk6BFts7CCKLULsHEF9wDc4NucDNRULQfI= 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.12 093/127] dm snapshot: fix a crash when an origin has no snapshots Date: Mon, 24 May 2021 17:26:50 +0200 Message-Id: <20210524152337.999170883@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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; }