Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3005276imu; Sun, 9 Dec 2018 14:54:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/WXGQsP6J+jdC12Zq0v7A66a8OG6pwAjtuZvKI3m98A2pRoBXQGUJ0EdAx9xr45niljjMDt X-Received: by 2002:a17:902:3064:: with SMTP id u91mr9749123plb.325.1544396099058; Sun, 09 Dec 2018 14:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544396099; cv=none; d=google.com; s=arc-20160816; b=0EpiGRYk6vdBNoFju/ziBJZ9nGDvzoVAZi+1T4yLgpvXB6OHEtPrs8XCebbh7njnNA CztOBlKL7MYDRyTADswv1EU7MVUqC4bgInaL/nZ3u+gJfQFgLyB8JBs2qY+CjJCI1YOV eUmVK1p/5+g/bg70NvBzqk6bw1+AXN5aWYtp8J7gpTr/ajFDcfK9loZj9e1huhfE04lo I4PHYr/sN4RlTN9g179rft+QG8r9qPhSmAIewS4hVd4SsVfOpJELAGA6uXXZvd3rCKyJ W3ir4m+jx4TfQrmdNZS5xZ9m3DJQEnCrWbLIm2HQ8rsOaP4rxVoE4TulC0v0O5b4ycu/ PoVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=yjmIqWjInkrBYIauGfMeJS24xJ9tXGVSD4vXufkC3p4=; b=JFXwz8NcqYBEVfp3oT3w5CyOxDA2hUhygjNCjtbWBIeCCxyzyd6BJhQhZpiBCRWE6w 8UFUfZ/YjvrdQCv52AJUVsZsaQj1eiGaU+zB0bNarmsbGL/So68qLf/DDS7gHUtnvxBo GhyYyn5ekA7LPRcY/qxFwazvCatON8DtPV5yLQs2n7KqNzGTrLfAIdWBBTrvbLptb+Tz V1RLLpP86ssfRh+N/qRCM9h23typAIICjo6UlxVkV8hm2X1CtCUKjc3BuCPDh4hA1F3E 8ge69bflJ2YJkQyCty+nGe7du4Mk4JzamLdfyw33YWuFR4ETjLlS80K5kBneW5b4qvlE F3rg== ARC-Authentication-Results: i=1; mx.google.com; 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 ay4si8270777plb.235.2018.12.09.14.54.43; Sun, 09 Dec 2018 14:54:59 -0800 (PST) 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; 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 S1727659AbeLIWHp (ORCPT + 99 others); Sun, 9 Dec 2018 17:07:45 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:37236 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727295AbeLIWHm (ORCPT ); Sun, 9 Dec 2018 17:07:42 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW738-0002ij-8s; Sun, 09 Dec 2018 21:55:42 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72f-0003TO-Hn; Sun, 09 Dec 2018 21:55:13 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Theodore Ts'o" , "Maxim Malkov" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 188/328] ext4: prevent online resize with backup superblock In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 011fa99404bea3f5d897c4983f6bd51170e3b18f upstream. Prevent BUG or corrupted file systems after the following: mkfs.ext4 /dev/vdc 100M mount -t ext4 -o sb=40961 /dev/vdc /vdc resize2fs /dev/vdc We previously prevented online resizing using the old resize ioctl. Move the code to ext4_resize_begin(), so the check applies for all of the resize ioctl's. Reported-by: Maxim Malkov Signed-off-by: Theodore Ts'o Signed-off-by: Ben Hutchings --- fs/ext4/resize.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -24,6 +24,18 @@ int ext4_resize_begin(struct super_block return -EPERM; /* + * If we are not using the primary superblock/GDT copy don't resize, + * because the user tools have no way of handling this. Probably a + * bad time to do it anyways. + */ + if (EXT4_SB(sb)->s_sbh->b_blocknr != + le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { + ext4_warning(sb, "won't resize using backup superblock at %llu", + (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr); + return -EPERM; + } + + /* * We are not allowed to do online-resizing on a filesystem mounted * with error, because it can destroy the filesystem easily. */ @@ -758,18 +770,6 @@ static int add_new_gdb(handle_t *handle, "EXT4-fs: ext4_add_new_gdb: adding group block %lu\n", gdb_num); - /* - * If we are not using the primary superblock/GDT copy don't resize, - * because the user tools have no way of handling this. Probably a - * bad time to do it anyways. - */ - if (EXT4_SB(sb)->s_sbh->b_blocknr != - le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) { - ext4_warning(sb, "won't resize using backup superblock at %llu", - (unsigned long long)EXT4_SB(sb)->s_sbh->b_blocknr); - return -EPERM; - } - gdb_bh = sb_bread(sb, gdblock); if (!gdb_bh) return -EIO;