From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:43801 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752480AbeDUM2u (ORCPT ); Sat, 21 Apr 2018 08:28:50 -0400 Received: by mail-pf0-f195.google.com with SMTP id j11so5590321pff.10 for ; Sat, 21 Apr 2018 05:28:50 -0700 (PDT) From: Harsh Shandilya To: stable@vger.kernel.org Cc: Theodore Ts'o , Harsh Shandilya Subject: [PATCH 2/3] ext4: fail ext4_iget for root directory if unallocated Date: Sat, 21 Apr 2018 17:58:41 +0530 Message-Id: <20180421122841.19735-1-harsh@prjkt.io> In-Reply-To: <20180420222612.18881-3-harsh@prjkt.io> References: <20180420222612.18881-3-harsh@prjkt.io> Sender: stable-owner@vger.kernel.org List-ID: From: Theodore Ts'o Commit 8e4b5eae5decd9dfe5a4ee369c22028f90ab4c44 upstream. If the root directory has an i_links_count of zero, then when the file system is mounted, then when ext4_fill_super() notices the problem and tries to call iput() the root directory in the error return path, ext4_evict_inode() will try to free the inode on disk, before all of the file system structures are set up, and this will result in an OOPS caused by a NULL pointer dereference. This issue has been assigned CVE-2018-1092. https://bugzilla.kernel.org/show_bug.cgi?id=199179 https://bugzilla.redhat.com/show_bug.cgi?id=1560777 Reported-by: Wen Xu Signed-off-by: Theodore Ts'o Cc: stable@vger.kernel.org [harsh@prjkt.io: s/EFSCORRUPTED/EUCLEAN/ fs/ext4/inode.c] Signed-off-by: Harsh Shandilya --- fs/ext4/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 77df898ed45b..d2ec9d2aa82b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4217,6 +4217,12 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino) goto bad_inode; raw_inode = ext4_raw_inode(&iloc); + if ((ino == EXT4_ROOT_INO) && (raw_inode->i_links_count == 0)) { + EXT4_ERROR_INODE(inode, "root inode unallocated"); + ret = -EUCLEAN; + goto bad_inode; + } + if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) { ei->i_extra_isize = le16_to_cpu(raw_inode->i_extra_isize); if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize > -- 2.15.0.2308.g658a28aa74af