Skip to content

Commit f4ce24f

Browse files
committed
ext4: fix deadlock when converting an inline directory in nojournal mode
In no journal mode, ext4_finish_convert_inline_dir() can self-deadlock by calling ext4_handle_dirty_dirblock() when it already has taken the directory lock. There is a similar self-deadlock in ext4_incvert_inline_data_nolock() for data files which we'll fix at the same time. A simple reproducer demonstrating the problem: mke2fs -Fq -t ext2 -O inline_data -b 4k /dev/vdc 64 mount -t ext4 -o dirsync /dev/vdc /vdc cd /vdc mkdir file0 cd file0 touch file0 touch file1 attr -s BurnSpaceInEA -V abcde . touch supercalifragilisticexpialidocious Cc: stable@kernel.org Link: https://lore.kernel.org/r/20230507021608.1290720-1-tytso@mit.edu Reported-by: syzbot+91dccab7c64e2850a4e5@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=ba84cc80a9491d65416bc7877e1650c87530fe8a Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 4c0b481 commit f4ce24f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/ext4/inline.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ static int ext4_finish_convert_inline_dir(handle_t *handle,
11751175
ext4_initialize_dirent_tail(dir_block,
11761176
inode->i_sb->s_blocksize);
11771177
set_buffer_uptodate(dir_block);
1178+
unlock_buffer(dir_block);
11781179
err = ext4_handle_dirty_dirblock(handle, inode, dir_block);
11791180
if (err)
11801181
return err;
@@ -1249,14 +1250,14 @@ static int ext4_convert_inline_data_nolock(handle_t *handle,
12491250
if (!S_ISDIR(inode->i_mode)) {
12501251
memcpy(data_bh->b_data, buf, inline_size);
12511252
set_buffer_uptodate(data_bh);
1253+
unlock_buffer(data_bh);
12521254
error = ext4_handle_dirty_metadata(handle,
12531255
inode, data_bh);
12541256
} else {
12551257
error = ext4_finish_convert_inline_dir(handle, inode, data_bh,
12561258
buf, inline_size);
12571259
}
12581260

1259-
unlock_buffer(data_bh);
12601261
out_restore:
12611262
if (error)
12621263
ext4_restore_inline_data(handle, inode, iloc, buf, inline_size);

0 commit comments

Comments
 (0)