Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2651054pxj; Mon, 31 May 2021 07:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwz1OnaDr6cl2ccvI73oTi+OiaS4HEl0BHphMr+Rknb0T5X8eY+zhT40wDfFj+x3/1+oYTy X-Received: by 2002:a05:6638:b84:: with SMTP id b4mr20413471jad.122.1622471086832; Mon, 31 May 2021 07:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471086; cv=none; d=google.com; s=arc-20160816; b=qYjOu7p0Okk1DHgW1ELtbwnrjmtWQFZWk7UjmUSNyKD17RZ3aRpma4UjNN1mHkrp0I CQf5cHzs02s0zGWKwc1wx/JtNn5uMTb34RlZo6RVFt2uli2Sy2OJ6UBAlJr0gxLrAFC0 qTExqgLoxNav4ZPdKce6iPg+BX1hWW9Po3qLnkA5x+uXzWUljizJ1aGh+5q3y+LDqeuR mdPBPO1pIcPBUgS364NtzyovBVRgU62AnxP7TWhYj9vQOiVaMhUOEge4cFywyPD1sOlH epHRx3J2kg7Erh5XkwE6jhSb4OS698Ajqg6UdRwmJg80EAyRr3eArCm7Th5CNL2sWJ4G LAAw== 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=et+iCehFJHT0o9+Fb/gJu+NGc70f+ZhzOOdyoPH/tbA=; b=B6a9y329DByLfsU+X4erOW1+Tjs3hBxwcCbL8onM2uhWF+maec41/+XpH79jLJkgIS GMqjrUgxgVuk3kIPHHBv3fCahHUwYogfGEL2NT9ZD+PD3tJy0nhHW3i4M2ltGPBB5UNL VSUzo9JScjMdjkiYzN9bqToE/Gmr2BEkMWT3E8iCYKKNngsoH33eXlh14xoAvNLDlHDn Q/fJpEpGrvoiV3XntYuvmEVmyWzREOaY0by+I8rdGIXqU8kZNZR9tS+Aq/tOeo9iAPE5 deNLDe+6iSyx+4ElAk/5zUlCTeRWHkrYqhWNzRorP5z4cr1/7DOFtlpulqOM4DI6J2Zn ktAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NiLc8vFR; 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 w13si6036143jao.90.2021.05.31.07.24.34; Mon, 31 May 2021 07:24:46 -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=NiLc8vFR; 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 S232666AbhEaOZi (ORCPT + 99 others); Mon, 31 May 2021 10:25:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232382AbhEaNvT (ORCPT ); Mon, 31 May 2021 09:51:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35EE66162D; Mon, 31 May 2021 13:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467940; bh=+AnYopkoo2JAvurKoTnNndHvZirtU9zs5Jxey1oteq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NiLc8vFR2FUcMJRu1uB7n1h5MNZeL/J69tAXpsnjdawEmSgWBbuAiHMbUD147wh6N lyjQ15NPt28jaXmDUtaz8/huVAyj5+42W5FvP38tWEGvd0gKp+FcE6HMqLAAe9+YQY /p3BmB+j8yHXYMb3dTExSxStX34zrvd45u4vXQZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.10 040/252] dm snapshot: properly fix a crash when an origin has no snapshots Date: Mon, 31 May 2021 15:11:45 +0200 Message-Id: <20210531130659.352408377@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 7e768532b2396bcb7fbf6f82384b85c0f1d2f197 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. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-snap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -854,7 +854,7 @@ 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)