Received: by 10.192.165.148 with SMTP id m20csp2459859imm; Sun, 22 Apr 2018 07:30:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+aNYkhJzvmoTRr3bLBQ87atl9umZsECyWqWOPFDV0SGQc1vy0LLKk4y6SQHeP94q3OUpsa X-Received: by 10.99.149.10 with SMTP id p10mr14228572pgd.217.1524407402299; Sun, 22 Apr 2018 07:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524407402; cv=none; d=google.com; s=arc-20160816; b=WscIj1pWN6r2HkoXtEhxkcuwreBxt7ue+QT2XToWttFJzvXIQk1O5HrptRkAjVTOnU VuU4dzCAj0iXUgJkVWIEfgw88gjZYqLHepCIDG04xGX4SMPvrvrm7oA6wm4eRQccU9yg DGIShKBrwkC29U0jrROIwQLg99cN4WonYTEd3MZ3ieeBCtyUra4xhku+Hg9DeIZZSZcF 8BoiS7ZYAcYYu/fOrwiXPKxu0If53et64XcTCD+s75hZLG928pg/CjW6pheCez68w2x1 SY+hikW0JYm/Di1aLrx5SH8GwV83aemEz9zpDF3lZlWbbsVA+lnXXKKzFp27Fok0J3LH hKAg== 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=A+1QO3qpxp+OYW4my3vIxJrAYCeqheujje87Ba7Fjn0=; b=NY7ZX9xEZvkryI18anGopuOB8Z7/4DERgTvqTSXHnEi5I5qEO78XRRFiCiiWwHlY6k 1vzsTqyTZSoiYpaRPrwA1Vjlgz4lLVsbrlINLX/0gDfKxq4ATlWmAVJZohkM1ciK98zE fPGmHzYLDoyFTTcpVAYrFlNLj9wAgRo8F/9COc9sGkRoRYjQAG9WdsbT9r/97eShdLsU iXNffXM/rMsmOmHQB4Ms47NlBhWOCvgJN9Gr04whAHLhIgCt8Jk7pWoLxtwQSgV6KZuU XL2VGsVyK7+PjqQlEWLMfs/i/paKcjz+XWQYH359ARjyUiGXadTLqmC4f78FMMbv3GFJ tt1Q== 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 f25si4894625pgv.47.2018.04.22.07.29.25; Sun, 22 Apr 2018 07:30:02 -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 S1757478AbeDVO1g (ORCPT + 99 others); Sun, 22 Apr 2018 10:27:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32846 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757340AbeDVOVX (ORCPT ); Sun, 22 Apr 2018 10:21:23 -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 BC710CB8; Sun, 22 Apr 2018 14:21:22 +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 3.18 39/52] ext4: dont allow r/w mounts if metadata blocks overlap the superblock Date: Sun, 22 Apr 2018 15:54:12 +0200 Message-Id: <20180422135317.199122697@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@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 3.18-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 @@ -2093,6 +2093,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: " @@ -2105,6 +2107,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: " @@ -2117,6 +2121,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) {