]> www.infradead.org Git - users/jedix/linux-maple.git/commit
gfs2: Fix mmap + page fault deadlocks (part 1)
authorAndreas Gruenbacher <agruenba@redhat.com>
Mon, 3 May 2021 15:49:18 +0000 (17:49 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 2 Jun 2021 09:44:54 +0000 (11:44 +0200)
commit485805ef8389eb1caa484cbb66e815afac00879d
tree8b0bb0e1162151b441e9ba28890c38a529079f54
parent04264450d3cb6f54620b2884fa83882c13d4a8e7
gfs2: Fix mmap + page fault deadlocks (part 1)

When the buffer passed to a read or write system call is memory mapped to the
same file, a page fault can occur in gfs2_fault.  In that case, the task will
already be holding the inode glock, and trying to take it again will result in
a BUG in add_to_queue().  Fix that by recognizing the self-recursion case and
either skipping the lock taking (when the glock is held in a compatible way),
or failing the operation.

Likewise, gfs2_page_mkwrite can be called in similar situations, so
treat the locking there in the same way.

A future patch will handle this case more gracefully, along with addressing
more complex deadlock scenarios.

Reported-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/file.c