Received: by 10.192.165.148 with SMTP id m20csp2486205imm; Sun, 22 Apr 2018 08:02:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/fQH3e3b0i0rdgqt92y4uLNmiSjWlbRSb/TvFOJET3I1DWO+Q7uP+0g6hN8IGOWdspUcGz X-Received: by 10.99.121.69 with SMTP id u66mr6076737pgc.376.1524409351954; Sun, 22 Apr 2018 08:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409351; cv=none; d=google.com; s=arc-20160816; b=bq6LgnLTnEP5bOePq8Gi9ZwbyyiYDltyX5L3M4j5urSO2UIB2Lg/Jo3ts1+aOJ5nxI fq1ZL4kN8bEapTGyd80J2Nw5R48JguU5HFzz5hBMUrZ99i3kHSUy9/DK6so0VHKOnwWT BXmMlThnTEXifqCuEBPT8oIDgp8c/8uwVvzpLj217T+0FYkYs0NPEk8pm5Z+0o1/8nC2 pvJO/Xa3tOo+M2cbCZs+MXkU1SnbUj2PNYXeP2H5y3jEzL+rquKC7iybPntvcuHJ8VPp TcZEphMHtgHTm6AOEczH8H7G8ijI4q7xH4EBJ/ISSMNIFn22iiGnDZEJU0y/rKG2aou+ QjgQ== 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=C97/RWm4/2ci6jyQZmlg4Wy1vyJ90FfImc+C/HfdGZM=; b=jC/m+5c8K18DV6wwGICxv7ZwX668gi5bQBJt6O0oDtq9mIcm5x3aRN2dvIsLsm+rvV tkw4HiqIvuE29DDWaeC3KR4Rpjlqfz9m9WuySG4QeLpJ6zuaWILevKX6ziuTQkWpMwhS Z3F2q0hcnBTKcDf73h0BT5cXwhbjkTAu7PqfZRL19NZb9Lldra9kUUqGvZgzfdhLgEUj zCti2IdhDoX2QUbkSbAwcVJ6NAMuve4qMf0Mau8LhZu1mxyYITC/m0rg4gpqdWW14A0a 4wTDILx/GMu5QYXfj9jseHwHAslZHC7Uj4U1qTedXz3Owm0nvfMjhnlV7HJmZc2hkKaf Es/A== 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 f1-v6si9680455pld.168.2018.04.22.08.02.17; Sun, 22 Apr 2018 08:02:31 -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 S1756282AbeDVOMk (ORCPT + 99 others); Sun, 22 Apr 2018 10:12:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55062 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232AbeDVOM0 (ORCPT ); Sun, 22 Apr 2018 10:12:26 -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 8D590CCE; Sun, 22 Apr 2018 14:12:25 +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.9 38/95] ext4: fail ext4_iget for root directory if unallocated Date: Sun, 22 Apr 2018 15:53:07 +0200 Message-Id: <20180422135211.979705732@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 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 @@ -4493,6 +4493,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 >