ext4: check to make sure the rename(2)'s destination is not freed
authorTheodore Ts'o <tytso@mit.edu>
Mon, 27 Aug 2018 05:47:09 +0000 (01:47 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Sep 2018 10:06:06 +0000 (03:06 -0700)
commit31343d27f18f19ad1bb1c5b4475b86483598cd04
tree0178e1092b84188eea753af09c2a3c0d8110f8da
parent4334a6ae867aa12f01c1755368fd0de4c926ac75
ext4: check to make sure the rename(2)'s destination is not freed

commit b50282f3241acee880514212d88b6049fb5039c8 upstream.

If the destination of the rename(2) system call exists, the inode's
link count (i_nlinks) must be non-zero.  If it is, the inode can end
up on the orphan list prematurely, leading to all sorts of hilarity,
including a use-after-free.

https://bugzilla.kernel.org/show_bug.cgi?id=200931

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: Wen Xu <wen.xu@gatech.edu>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/namei.c