All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harsh Shandilya <harsh@prjkt.io>
To: stable@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>, Harsh Shandilya <harsh@prjkt.io>
Subject: [PATCH 2/3] ext4: fail ext4_iget for root directory if unallocated
Date: Sat, 21 Apr 2018 17:58:41 +0530	[thread overview]
Message-ID: <20180421122841.19735-1-harsh@prjkt.io> (raw)
In-Reply-To: <20180420222612.18881-3-harsh@prjkt.io>

From: Theodore Ts'o <tytso@mit.edu>

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 <wen.xu@gatech.edu>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
[harsh@prjkt.io: s/EFSCORRUPTED/EUCLEAN/ fs/ext4/inode.c]
Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
---
 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

  reply	other threads:[~2018-04-21 12:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 22:26 [PATCH 0/4] 4.17-rc1 stable tagged ext4 patches for 3.18.y Harsh Shandilya
2018-04-20 22:26 ` [PATCH 1/4] ext4: add validity checks for bitmap block numbers Harsh Shandilya
2018-04-21 12:28   ` [PATCH 1/3] " Harsh Shandilya
2018-04-20 22:26 ` [PATCH 2/4] ext4: fail ext4_iget for root directory if unallocated Harsh Shandilya
2018-04-21 12:28   ` Harsh Shandilya [this message]
2018-04-20 22:26 ` [PATCH 3/4] ext4: don't allow r/w mounts if metadata blocks overlap the superblock Harsh Shandilya
2018-04-21 12:29   ` [PATCH 3/3] " Harsh Shandilya
2018-04-21 20:07     ` Theodore Y. Ts'o
2018-04-22  2:30       ` Harsh Shandilya
2018-04-22  4:01         ` Theodore Y. Ts'o
2018-04-22  4:04           ` Harsh Shandilya
2018-04-20 22:26 ` [PATCH 4/4] ext4: force revalidation of directory pointer after seekdir(2) Harsh Shandilya
2018-04-20 23:23 ` [PATCH 0/4] 4.17-rc1 stable tagged ext4 patches for 3.18.y Harsh Shandilya
2018-04-21 12:21 ` [PATCH 0/3] " Harsh Shandilya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180421122841.19735-1-harsh@prjkt.io \
    --to=harsh@prjkt.io \
    --cc=stable@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.