ext4: fix a potential fiemap/page fault deadlock w/ inline_data
authorTheodore Ts'o <tytso@mit.edu>
Tue, 25 Dec 2018 05:56:33 +0000 (00:56 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jan 2019 21:12:32 +0000 (22:12 +0100)
commiteb24a3b6bb4f11e7dec1000cb3c08d6371d23181
treeb18de2baed96200ba8e5683e3fac24f5bce74467
parentd1cfd9cba0cbc6638137b577ee09ee334701c827
ext4: fix a potential fiemap/page fault deadlock w/ inline_data

commit 2b08b1f12cd664dc7d5c84ead9ff25ae97ad5491 upstream.

The ext4_inline_data_fiemap() function calls fiemap_fill_next_extent()
while still holding the xattr semaphore.  This is not necessary and it
triggers a circular lockdep warning.  This is because
fiemap_fill_next_extent() could trigger a page fault when it writes
into page which triggers a page fault.  If that page is mmaped from
the inline file in question, this could very well result in a
deadlock.

This problem can be reproduced using generic/519 with a file system
configuration which has the inline_data feature enabled.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inline.c