Skip to content

Commit 0226635

Browse files
Tetsuo Handatorvalds
authored andcommitted
fs/ntfs3: don't hold ni_lock when calling truncate_setsize()
syzbot is reporting hung task at do_user_addr_fault() [1], for there is a silent deadlock between PG_locked bit and ni_lock lock. Since filemap_update_page() calls filemap_read_folio() after calling folio_trylock() which will set PG_locked bit, ntfs_truncate() must not call truncate_setsize() which will wait for PG_locked bit to be cleared when holding ni_lock lock. Link: https://lore.kernel.org/all/[email protected]/ Link: https://syzkaller.appspot.com/bug?extid=bed15dbf10294aa4f2ae [1] Reported-by: syzbot <[email protected]> Debugged-by: Linus Torvalds <[email protected]> Co-developed-by: Hillf Danton <[email protected]> Signed-off-by: Hillf Danton <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Fixes: 4342306 ("fs/ntfs3: Add file operations and implementation") Signed-off-by: Linus Torvalds <[email protected]>
1 parent 88603b6 commit 0226635

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/ntfs3/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,10 @@ static int ntfs_truncate(struct inode *inode, loff_t new_size)
390390

391391
new_valid = ntfs_up_block(sb, min_t(u64, ni->i_valid, new_size));
392392

393-
ni_lock(ni);
394-
395393
truncate_setsize(inode, new_size);
396394

395+
ni_lock(ni);
396+
397397
down_write(&ni->file.run_lock);
398398
err = attr_set_size(ni, ATTR_DATA, NULL, 0, &ni->file.run, new_size,
399399
&new_valid, ni->mi.sbi->options->prealloc, NULL);

0 commit comments

Comments
 (0)