Received: by 10.192.165.148 with SMTP id m20csp2464227imm; Sun, 22 Apr 2018 07:35:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/yUXYd7FuWCmgoVqCD/CtEi6LF1DUNf1PPouDMiqWqSfzRVZv1FJ0cizVoQQhd0cZSxgU7 X-Received: by 10.99.106.4 with SMTP id f4mr13745635pgc.225.1524407707812; Sun, 22 Apr 2018 07:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407707; cv=none; d=google.com; s=arc-20160816; b=Zjw/mlq3qOiZZVDVxd6GBURh5jNTYA0qtgK/HvLdr5ITbNMrgn+QW2gVanfa62eq8Q QnKiLyWav+/QCMfkykiDjXuZQ6p8Ax/Gcbm04GV63DJZLp0ctyTe16tvtI4c6nO02Bie f1Mq95PCimZE1wxBC7rXh/Wry4779mz2nqlqwRN756NgKrt7Fb3sJl+ck3RC3GnauHtd ER9PicFgSWxRd8lq2rKKaKBXNFMNZ1gdir52WMlnTG2CtcQMrvE+yvTF0G/GCIKuwv7v DZxERYWtZbahO4RHgWJbWCI6bW9WPEymmcpwDCYW3+QOEgsy7aarYPgQfV2hKVs+8C4f IVHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LothE92tO+Atq3UzzkUMNzspeA1nMmb1r6vOr7Q2ElA=; b=iLxSutkX5f1xkbMcgV3gs9iGFV+yKyMaewUbBHSS5wU+ZLc0W5+Nr3zGB7HnSC3FeP HwZq3JrhRl2uPAheisNBUAij0Ocy73SQkPg3kA5D9LbYu0sWHwOD5seXjopkqCKeK3rq 0yM4kjA9zKURomOJ7XRKPQanRDcHxbNAmORoPlNoHIGsw7BPaa/n+KfOLKyK0WWuveqm 3qkMuwRNCaFuuJX0Zlxcm5VT0S8nuiLyDQ9EkAFZZ3secgvJ7G+FaLPj4C/jPom5uUgF EcQfyowLUotliM5V7TpSrOV/QZ2fZLCvk8w3rfjxWG/wq8F2Z0DkP6QmgpgRhmP0NfzK 4oEA== 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 f9-v6si9337935plo.292.2018.04.22.07.34.53; Sun, 22 Apr 2018 07:35:07 -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; 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 S1757140AbeDVOdz (ORCPT + 99 others); Sun, 22 Apr 2018 10:33:55 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59820 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756785AbeDVOTh (ORCPT ); Sun, 22 Apr 2018 10:19:37 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9DF75B00; Sun, 22 Apr 2018 14:19:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso , Harsh Shandilya Subject: [PATCH 4.4 74/97] ext4: dont allow r/w mounts if metadata blocks overlap the superblock Date: Sun, 22 Apr 2018 15:53:52 +0200 Message-Id: <20180422135309.287086064@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Theodore Ts'o commit 18db4b4e6fc31eda838dd1c1296d67dbcb3dc957 upstream. If some metadata block, such as an allocation bitmap, overlaps the superblock, it's very likely that if the file system is mounted read/write, the results will not be pretty. So disallow r/w mounts for file systems corrupted in this particular way. Backport notes: 3.18.y is missing bc98a42c1f7d ("VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)") and e462ec50cb5f ("VFS: Differentiate mount flags (MS_*) from internal superblock flags") so we simply use the sb MS_RDONLY check from pre bc98a42c1f7d in place of the sb_rdonly function used in the upstream variant of the patch. Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org Signed-off-by: Harsh Shandilya Signed-off-by: Greg Kroah-Hartman --- fs/ext4/super.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2131,6 +2131,8 @@ static int ext4_check_descriptors(struct ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " "Block bitmap for group %u overlaps " "superblock", i); + if (!(sb->s_flags & MS_RDONLY)) + return 0; } if (block_bitmap < first_block || block_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2143,6 +2145,8 @@ static int ext4_check_descriptors(struct ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " "Inode bitmap for group %u overlaps " "superblock", i); + if (!(sb->s_flags & MS_RDONLY)) + return 0; } if (inode_bitmap < first_block || inode_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2155,6 +2159,8 @@ static int ext4_check_descriptors(struct ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " "Inode table for group %u overlaps " "superblock", i); + if (!(sb->s_flags & MS_RDONLY)) + return 0; } if (inode_table < first_block || inode_table + sbi->s_itb_per_group - 1 > last_block) {