]> www.infradead.org Git - users/jedix/linux-maple.git/commit
udf: Fix lock ordering in udf_evict_inode()
authorJan Kara <jack@suse.cz>
Mon, 20 May 2024 13:23:37 +0000 (15:23 +0200)
committerJan Kara <jack@suse.cz>
Wed, 5 Jun 2024 08:36:46 +0000 (10:36 +0200)
commit8832fc1e502687869606bb0a7b79848ed3bf036f
tree2395facf6bde8c42f55d5bc1821af6edee9c9de0
parentc1f1b25a6089eb93a11a147e8de766c0d6ad29ac
udf: Fix lock ordering in udf_evict_inode()

udf_evict_inode() calls udf_setsize() to truncate deleted inode.
However inode deletion through udf_evict_inode() can happen from inode
reclaim context and udf_setsize() grabs mapping->invalidate_lock which
isn't generally safe to acquire from fs reclaim context since we
allocate pages under mapping->invalidate_lock for example in a page
fault path.  This is however not a real deadlock possibility as by the
time udf_evict_inode() is called, nobody can be accessing the inode,
even less work with its page cache. So this is just a lockdep triggering
false positive. Fix the problem by moving mapping->invalidate_lock
locking outsize of udf_setsize() into udf_setattr() as grabbing
mapping->invalidate_lock from udf_evict_inode() is pointless.

Reported-by: syzbot+0333a6f4b88bcd68a62f@syzkaller.appspotmail.com
Fixes: b9a861fd527a ("udf: Protect truncate and file type conversion with invalidate_lock")
Signed-off-by: Jan Kara <jack@suse.cz>
fs/udf/file.c
fs/udf/inode.c