Received: by 10.192.165.148 with SMTP id m20csp2471002imm; Sun, 22 Apr 2018 07:44:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/vW8cL2qGxGevoytJbPFImHJnF8jrHpG653JZQl8B1mjMd5meXYREYNoL6P5Whi8UpKgpt X-Received: by 2002:a17:902:ac83:: with SMTP id h3-v6mr17887347plr.259.1524408241336; Sun, 22 Apr 2018 07:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408241; cv=none; d=google.com; s=arc-20160816; b=IsrbJdPbttamzlefSi3S7krbZ3ynTAkFSq5f8bF9Yryr+HylP1L2zBN9/aZly2vq1E xP4uVeib495+v8y6RAdkQyux8JpNw7rOSTDxMrWNbXCyAjTz6GJOjBW1g8o39vv4l34p 9fkF4Kf8MkeqIePEf3126AMz7wdP9tBZO744kHzdY15450dp0Fy1lvbU/JvJY73LcnAH IyR4GFGVhz+XqF4HbxDt1Psl8ktNGw6lyHJwpDWSV26clnkSMCYRrcotYk8gGgclOhej xlYSruzmudEWbCRnXiBOAQJmd6+wduW6NDSzIGCygM8hgyauJGm2BPLDAjdXtA2JfYZj 3RKw== 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=7D75LwFb1LASn4v9nThlD2GFnXNAwjQMiDIv/fxCnrw=; b=Bl8JZvxTigP31Xe+kQ6bKcUwHB5rZd5uVOLqVlqTbBJ5HloPVK/xDXLvhNblzQE905 BqSGBnT96OcpZQSFrHS5h66c7V9bNkY/L1L6DmcxZH+y0o3B3cqSmVtsMnG3j1Cux2/n 8T0W18dVutg53ZihDG8MQbeRwPPXz4NFcwXlWQIGih+oLbQC8rI4wzqMFmvI5wxObrHc W/8bl2F/aMWzYrqjutHmFUUGmG0KrcLRXr13zsrmu1ygcTs0F+NT425rlEb2W/x7BAtm 9WGn6DAQF9kfeyvu9zGLE9GbqNHu9BFga+iY3D0HGGXNnuoMlNXkP8iJZ7wD/KGxzhiM 42qg== 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 x12si9569034pfi.181.2018.04.22.07.43.46; Sun, 22 Apr 2018 07:44:01 -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 S932461AbeDVOR3 (ORCPT + 99 others); Sun, 22 Apr 2018 10:17:29 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58216 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932196AbeDVORW (ORCPT ); Sun, 22 Apr 2018 10:17:22 -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 212C1CCC; Sun, 22 Apr 2018 14:17:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Xu , Theodore Tso Subject: [PATCH 4.4 51/97] ext4: fail ext4_iget for root directory if unallocated Date: Sun, 22 Apr 2018 15:53:29 +0200 Message-Id: <20180422135308.136426210@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 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 Signed-off-by: Greg Kroah-Hartman --- fs/ext4/inode.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4231,6 +4231,12 @@ struct inode *ext4_iget(struct super_blo 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 = -EFSCORRUPTED; + 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 >