Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp581077img; Fri, 22 Mar 2019 04:29:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuYXgVecP0u0C2GlvmDF2jn65VaX5hLRCMjy6kyhEe/WwBXNyHoqq/rphXEWTuy1NYvWzq X-Received: by 2002:a17:902:204:: with SMTP id 4mr9217191plc.180.1553254170555; Fri, 22 Mar 2019 04:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553254170; cv=none; d=google.com; s=arc-20160816; b=uVbZmABXwyXHndNkY2IgbX9aCu9nUBGxvVNMLdTcFr5qK+9DSOefaXNv6OB7Vf5+eD nWBQELO9J54jCdt5LBcKJgD7HKlEwWE+ZGBm++Oj/8gwNwXayKE2mnMplgDcRFcm3k+t BSB7790ICMMr0/kZGO+DkYyuPP1kz/z2j6PkyPDJ0La5xvUQTCrt9xZxhGINqFz1T0S+ x0cK9RR4KWUW5MTKdmNS1BUtYBC0hv5lhi8DL+6WsrfFctMu1eJfsWPB0vsZYSjkJ3cB dtee+nAD+qC4Gob52mCC/3mqF/0GqjSzjO+RRkKXe8/mtuKBsbB4Dhojf54Rh7wWwwm9 k32A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Jmu28WLn+YTPvULPdHsmZJN6pFza+iAgK5KJABGM3iY=; b=CBi0tWKnFV6gVcNrW27gE3Ll4E1UOClIGF/HR2ONWSzfjYbMN3sn/1le/8VPluJwCp Yp98K08AnkvPOlV3gS8tFfMyfRGO9/eE3UqGs641mJhXtVF/7WK9mXY7fZmnoBNpojo5 g3iptZDxx0CNrz2dO7RKeuNaxokjDQYJWhswLoLzv78lw3fPJnFkL3QE3XWM6QlxfFfR pf50NUW2ASCgTIa+sp3G1r5QwQV6WICd0A+r22vmVf8dJ5g6K6q61flmUbIzmLaWr6qB +tZiFa4iE/dBAgbGsVR++cXJF26bZEchhvuiW23XhKyvYp+78pSH+BJtWzqgoSk5qAa3 kY0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBIFfLOP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16si6943397ply.103.2019.03.22.04.29.15; Fri, 22 Mar 2019 04:29:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JBIFfLOP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729441AbfCVL0e (ORCPT + 99 others); Fri, 22 Mar 2019 07:26:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729437AbfCVL0b (ORCPT ); Fri, 22 Mar 2019 07:26:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 576A821925; Fri, 22 Mar 2019 11:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253990; bh=XjdCWV4t3XtFfQchKsPjv5NW4o99J19tKXNQeryG+9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBIFfLOPMfMlbhuyxFgVdd2ELQOnUgvwcx4SdKACwMKKJ9SOwJqQnPwXeAEn4etdp sOIwmxOKAm89oZbE0qNg+gXmd4BI4EboIQCEAY38Newz57u4n86xq2R5GcGOBs/b4T HlqZP/RXS1XWAWPraOwcswx0yOJb7zp+QyAbyBTE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Theodore Tso Subject: [PATCH 3.18 118/134] ext4: fix crash during online resizing Date: Fri, 22 Mar 2019 12:15:31 +0100 Message-Id: <20190322111218.900550642@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara commit f96c3ac8dfc24b4e38fc4c2eba5fea2107b929d1 upstream. When computing maximum size of filesystem possible with given number of group descriptor blocks, we forget to include s_first_data_block into the number of blocks. Thus for filesystems with non-zero s_first_data_block it can happen that computed maximum filesystem size is actually lower than current filesystem size which confuses the code and eventually leads to a BUG_ON in ext4_alloc_group_tables() hitting on flex_gd->count == 0. The problem can be reproduced like: truncate -s 100g /tmp/image mkfs.ext4 -b 1024 -E resize=262144 /tmp/image 32768 mount -t ext4 -o loop /tmp/image /mnt resize2fs /dev/loop0 262145 resize2fs /dev/loop0 300000 Fix the problem by properly including s_first_data_block into the computed number of filesystem blocks. Fixes: 1c6bd7173d66 "ext4: convert file system to meta_bg if needed..." Signed-off-by: Jan Kara Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/ext4/resize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -1930,7 +1930,8 @@ retry: le16_to_cpu(es->s_reserved_gdt_blocks); n_group = n_desc_blocks * EXT4_DESC_PER_BLOCK(sb); n_blocks_count = (ext4_fsblk_t)n_group * - EXT4_BLOCKS_PER_GROUP(sb); + EXT4_BLOCKS_PER_GROUP(sb) + + le32_to_cpu(es->s_first_data_block); n_group--; /* set to last group number */ }