Received: by 10.192.165.148 with SMTP id m20csp2448349imm; Sun, 22 Apr 2018 07:16:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/KXD7vAqdf5c6E2PN+A1iOggttwSgQu7SXOl5UFJv+BJFGPcm0CLdN4l/LO779Cj80p3OF X-Received: by 2002:a17:902:3225:: with SMTP id y34-v6mr17862512plb.180.1524406602800; Sun, 22 Apr 2018 07:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406602; cv=none; d=google.com; s=arc-20160816; b=vRkOGWxK1wO3mgOeo5dA1kmo064vRFADR7NNbJtfrrGIul+gbVMshrNRwcAhfNcGkQ HW4amM4X8wiOGEwo+kzVaxq2eHQNwonfSzqhGsQN/FjhYkx8Q1MxABIBWAg1+gyA+oxy gGXjO5JEJgW9bSw1Rl5BRmsmuUr8c4YaL/aLrREzeUVAVcqNu/zBjFuIe8hhRoEnY300 jSkm5l6bEQBltLh/CFPaBwL0M08m9IhrFVwLK/msjQqU8EBUUjOv5Dm0//9SAuda5H7m D5pl2pkQsbAi1mwbEQP8eY2eP/UMjYHLXBQTcTPFOyAsNBrxOwI3+33vnGBtrHnv7gCS pFrw== 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=eoSEkcdEJJONseMU/zKWy19e7iRC6l9LjJINUJhaWO0=; b=seHHlogKfhksbu0F8BsEHoa+pDKtfyiuGIA14tuDoEporHsnbH4HOit9+k8v4LS1Wa 6vYeLyeinplqh3iw7lGJpKoulfTyIeVDOdCWdtQXSqFnmakdh+7DA8x74sQ3SLEqL49i cBoMLnQF89QNDRJ9JxixGGwnVmnvQGH8hbLXrlq5tVpXLlniOOgTyTaaPLKS5Bsa2PiP 3/l+FUcWQEhIZtFRDzmsU9YhPRbEfuqYYfs8Zi5b2JDwy4BVtaX0vnp9n03pX3uxXPhV S2ZDYpqjq+NfzfQIio8aUmUhOJVTkqE+faklAsXWFtb7XR1CEz5sooCJqGLi04dzH+0W 05QQ== 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 d2-v6si7420129plh.387.2018.04.22.07.16.28; Sun, 22 Apr 2018 07:16:42 -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 S932156AbeDVOPR (ORCPT + 99 others); Sun, 22 Apr 2018 10:15:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56760 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932094AbeDVOPO (ORCPT ); Sun, 22 Apr 2018 10:15:14 -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 682A084B; Sun, 22 Apr 2018 14:15:13 +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.9 65/95] ext4: dont allow r/w mounts if metadata blocks overlap the superblock Date: Sun, 22 Apr 2018 15:53:34 +0200 Message-Id: <20180422135213.085862274@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-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 @@ -2260,6 +2260,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: " @@ -2272,6 +2274,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: " @@ -2284,6 +2288,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) {