OSDN Git Service

ext4: avoid divide by zero fault when deleting corrupted inline directories
authorTheodore Ts'o <tytso@mit.edu>
Mon, 27 Aug 2018 13:22:45 +0000 (09:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Sep 2018 09:56:00 +0000 (02:56 -0700)
commit976eeff67a3ad52c8337e3e10d10ae0a93e7f1ec
tree8bebd3fa0f93d6286498657eba45228e482d95db
parentfdad4e17dc61310f9099d868ac6e528313b1ca9d
ext4: avoid divide by zero fault when deleting corrupted inline directories

commit 4d982e25d0bdc83d8c64e66fdeca0b89240b3b85 upstream.

A specially crafted file system can trick empty_inline_dir() into
reading past the last valid entry in a inline directory, and then run
into the end of xattr marker. This will trigger a divide by zero
fault.  Fix this by using the size of the inline directory instead of
dir->i_size.

Also clean up error reporting in __ext4_check_dir_entry so that the
message is clearer and more understandable --- and avoids the division
by zero trap if the size passed in is zero.  (I'm not sure why we
coded it that way in the first place; printing offset % size is
actually more confusing and less useful.)

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

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/dir.c
fs/ext4/inline.c