Received: by 10.192.165.148 with SMTP id m20csp2534276imm; Sun, 22 Apr 2018 09:02:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx49n1Z0QaOQKDBEYUW+6z2WTHxoXE43yBznOna44aKk1Y9LUgC8+t6AHT+ztiHOXRXKMPQnX X-Received: by 10.98.192.80 with SMTP id x77mr15689373pff.67.1524412954409; Sun, 22 Apr 2018 09:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412954; cv=none; d=google.com; s=arc-20160816; b=i6ZBeT9ULV35JDucEq3V68TEuIzKcqkfxcpzajqEzF5XGS5/nAX1VNkrOTXBQEbFQJ Jo5mT7lAWq/0/2ssoZM/eUyIr/YDp7ilXOvkAQdhSOlUaz+PdSCKsQU3EMqdm0uC/0a+ vDKrI1kVsOGe6TAIjmh7caRB896vQGwjRL6DmO/Adgd+r0Plxh1de/QHLuQgd8X58PQn CZ1NYTYBTkRm+d52ZGr7LiJsY5Bg2LC0cXrdDnXEmy7vdu40RKHEGUSC+3m4RlgdwmSF uJ3TrRkWsJni9MwI5xPsOor4BJAG/Woa0tpk4aAs9Dh9fUp4gHd/WQR3t9nGlSYAyGwx sKNw== 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=Idz60zM3ESyR+5p0vsN/bcdd/zasFzItA64mq320puw=; b=PkbkWBSW1xRFXSJ7K0/3wJw9exGUbV9r0AGKLc6nKCVjOV0Cgb2Y4hSjcBLsM1Qs2+ az/96L/UqokgOFVzmDkr0GaYOojQh55laN3VNvt84Syji2kbV8/Fer0GlyiVwyPzrhLp kNyt5yXCQTNrplFcD6kDTgMRJZrmD718lvSJPfwBz5UHmYV7VT9a6Bn9G4XTGdSp/AUD A66GJAQAbEM7xw/9tPF0RS5W9nPTlLy2+yhhYNoC0jpAxf+A3W1aIQMibrolZWOmif5H wJE4iDl/QrVSaONnzV0AqpCzKwLLz1JrvEg3pD1Wvzv3RFMrEf+MAEb2cxODK6W3zWFn qiBg== 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 h23-v6si9673326plr.576.2018.04.22.09.02.20; Sun, 22 Apr 2018 09:02:34 -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 S1754190AbeDVN6h (ORCPT + 99 others); Sun, 22 Apr 2018 09:58:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46282 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753506AbeDVN6d (ORCPT ); Sun, 22 Apr 2018 09:58:33 -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 E7458CD8; Sun, 22 Apr 2018 13:58:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Theodore Tso Subject: [PATCH 4.16 095/196] ext4: dont allow r/w mounts if metadata blocks overlap the superblock Date: Sun, 22 Apr 2018 15:51:55 +0200 Message-Id: <20180422135109.194594813@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-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. Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org 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 @@ -2333,6 +2333,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_rdonly(sb)) + return 0; } if (block_bitmap < first_block || block_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2345,6 +2347,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_rdonly(sb)) + return 0; } if (inode_bitmap < first_block || inode_bitmap > last_block) { ext4_msg(sb, KERN_ERR, "ext4_check_descriptors: " @@ -2357,6 +2361,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_rdonly(sb)) + return 0; } if (inode_table < first_block || inode_table + sbi->s_itb_per_group - 1 > last_block) {