Received: by 10.192.165.148 with SMTP id m20csp2534393imm; Sun, 22 Apr 2018 09:02:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+4aDIigaC0cWsFS7+lo0vqQ7aNjlUAvsTgKNWQPBED5zdlE+eEFyB3aP57Kuxdl+K4Vf2Q X-Received: by 10.98.16.74 with SMTP id y71mr9526894pfi.188.1524412960955; Sun, 22 Apr 2018 09:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412960; cv=none; d=google.com; s=arc-20160816; b=RvI6C6qGlGp2V3SeXnlOAl2xLgYXZ3FL8mw7OgnR2nGyfAUQvbha4msQuEgWd7aEyg 1FdbnkcT253zyQsQjdXfDwoklrZotTrGo9EGDet/mETIsHncYehAF4TTHRYOWesVuIul SxNpw9H9zumhDLc3sXXJ6P548fpbgT+rLOGInYu1vH3QIEBsXsGkOjvedYaDmSDLyAtp 2vsqcNm6O4UPNCazEjr7kkwyEXeQDkgJeUaLrXecxw5kfNuBDPbNp3Ox3cS4uK25nbrJ e5PuLsUdvVVDQdCwC56BHcXHntlWa+aYGVNU1s8pM4E/44d43rsZY7tkXS3TTMXs+BNj vrtg== 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=LEl8P8sUqe22G8a80HgYz/zpCiDrIr8kL96L1HVyU50=; b=Px7juqdCb1+DZzxbFOQTECHo1goOo2Dh7r7JE7CuMpyWEJCxj3QcCM4rh7FMI9PoMs Yvef74vbsAtsSqdSlp+UsxhavmqbQ9kzLjKaQ1vV/5dbeVxzzK/NpKvqJhCteE3HUwKT u/rBpI00jqwLpSrUvQrSGq0Kidd56c2Yw2+IA3DkH2Eb3vtYTpAH9vvM16/Nmp8C98XY Z4/txu0HLmfFRuQs7xuxUlbXlgC93/xaFw+luQkYY36kQypz1Jf0elzWYLVN0jtijODz 2UV4YSrHkVzutuqSSwcxxI2ksmvmb20+2ivxiRZoPzEBE5Q/sHrCmf9OkXWX8aRdWJhO UOLQ== 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 l7-v6si10053930pls.93.2018.04.22.09.02.26; Sun, 22 Apr 2018 09:02:40 -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 S1754403AbeDVQBK (ORCPT + 99 others); Sun, 22 Apr 2018 12:01:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46246 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754163AbeDVN62 (ORCPT ); Sun, 22 Apr 2018 09:58:28 -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 95415CD5; Sun, 22 Apr 2018 13:58:27 +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.16 093/196] ext4: fail ext4_iget for root directory if unallocated Date: Sun, 22 Apr 2018 15:51:53 +0200 Message-Id: <20180422135109.102374209@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 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 @@ -4745,6 +4745,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 >