Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3526662pxj; Mon, 24 May 2021 08:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywB5F2D/f/dWLW8JwxJ9hqhgx052SKoS4g1nqEPhX2GzMzQiPJE8RRq0/9oc/Dk8qhk07R X-Received: by 2002:aa7:d70e:: with SMTP id t14mr26454487edq.377.1621870848829; Mon, 24 May 2021 08:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870848; cv=none; d=google.com; s=arc-20160816; b=PTfOQ21QqP5TwU7l3hQicZA9hHsf/j8Dz2naJV/q5Cj+Db6A64b62Roa3m0MtoOtST Gf8Hj6t7KOAF1dMVZmMYmjCyUJCRTT8kEJhW78GCHLZzwIppZ80o3QZ3TH62/lMg0jkp /qmj3NTO2ChpN9in8FpUkXMpCiTCCYX/4vjIhzc46DGivewOqYmJfGf8eXq5S0irSySa yV1OhRwJTXjqphbmn+jLAnmzdF35dUTHKlBPTGFbT/f4V3/234p7MssAx4E6Ip4ZYGAV tqHDBJb1K2SDE2korHZTNT7UYkCofIOE2R+5b82I7o6JF0runFNL6U/x2ZRSBKWYEJFc xJ8A== 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=WIY+uDMAIoyCw2kzQddJcKZER6h5C7ASDx4Znri1fow=; b=g5Chqd6H41m+so4Ao52XboTFS9gL+m54JaSP05HSkC5wj9PiixbabyW9y7wscLd80u P54OcLJcDtE/nkumH6QCJT7iaE5UTg5vOdoQw8w+/FyAxqF39KrkuHRtwb5OAGPwjekw I4oMY5Pg9ioDwB4wNPpPXCYHUrvIwJ15oCUyDhgEFYGSPD4FG5CfBg7Fzs9pS4S6xXpK lmO59dK5rIHYaikON6Gj/A3UbY2YAXF4lZIiotHQ1Xtix0pXfyKurieVBAbSVLn3zNV5 wIsQBTwHHXPmG93xvwrAlmn1SFVPtFUUnt3wq0V/Huxfk06qb+lIJO3AXpMvICIg0o+5 hW8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jxMY+jA0; 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 n9si6079763edw.373.2021.05.24.08.40.25; Mon, 24 May 2021 08:40:48 -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=jxMY+jA0; 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 S233728AbhEXPic (ORCPT + 99 others); Mon, 24 May 2021 11:38:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:50498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232829AbhEXPe4 (ORCPT ); Mon, 24 May 2021 11:34:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3AC4613C8; Mon, 24 May 2021 15:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870340; bh=ZP1z6xfZ4sra0aSKN20GNNlBCH2m0BhCbrHOQLCUcJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jxMY+jA0ClVYNcwTusj/ogDimx19oPZf/2l8YrtYq+8R5Llm52EJIS8obkybWHyBa u0EqB9hc4w+8nrhZjASMIfzCVp1REa2Xf0HEUn0R5zCCjvw2BY/9R6qlhqlCHMtSTL LCu4W95LObOoqZRFmtg64ZP1H8vjzuXI6LOQBdw0= 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.9 13/36] dm snapshot: fix a crash when an origin has no snapshots Date: Mon, 24 May 2021 17:24:58 +0200 Message-Id: <20210524152324.601677945@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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 @@ -788,12 +788,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; }