Skip to contentSkip to conversation

kernel BUG in ext4_write_inline_data_end

BUG REPORT Jun Nie 2 participants 3 messages Nov 17, 2022 – Dec 7, 2022

lore
Share & tools
lore

Jun Nie

author
#0 lore raw

Hi,

syzbot find a bug[0] in ext4 on android13-5.15-lts as below and it can be reproduced on mailine v6.1-rc5(094226ad94f4) too The log from mainline can be found in URL [1]. The bisect test shows below commit[2] is the first commit that reproduce the bug. With reverting the commit, there is no bug reproduced[3].

Is reverting the commit 21175ca434c5 a acceptable solution? Any fix work is in progress?

[0] https://syzkaller.appspot.com/bug?id=5bafe4554067100b70f58a81268aa06ea3f9c345
[1] https://syzkaller.appspot.com/text?tag=CrashLog&x=118359c1880000
[2] 21175ca434c5 ext4: make prefetch_block_bitmaps default
[3] https://groups.google.com/g/syzkaller-android-bugs/c/HKLNVJQICMM/m/YcHNpH_iBAAJ

kernel BUG at fs/ext4/inline.c:227!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN

Call Trace:
 <TASK>
 ext4_write_end+0x1af/0x9d0 fs/ext4/inode.c:1307
 ext4_da_write_end+0x92/0xa70 fs/ext4/inode.c:3067
 generic_perform_write+0x3c7/0x5d0 mm/filemap.c:3836
 ext4_buffered_write_iter+0x49b/0x630 fs/ext4/file.c:271
 ext4_file_write_iter+0x456/0x1dc0
 do_iter_readv_writev+0x52a/0x720
 do_iter_write+0x1f4/0x760 fs/read_write.c:855
 vfs_iter_write+0x7c/0xa0 fs/read_write.c:896
 iter_file_splice_write+0x810/0xfd0 fs/splice.c:689
 do_splice_from fs/splice.c:767 [inline]
 direct_splice_actor+0xfe/0x130 fs/splice.c:934
 splice_direct_to_actor+0x4d4/0xbd0 fs/splice.c:889
 do_splice_direct+0x2a0/0x3f0 fs/splice.c:977
 do_sendfile+0x63b/0xfd0 fs/read_write.c:1249
 __do_sys_sendfile64 fs/read_write.c:1317 [inline]
 __se_sys_sendfile64 fs/read_write.c:1303 [inline]
 __x64_sys_sendfile64+0x1ce/0x230 fs/read_write.c:1303
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Regards,
Jun

author
#1 lore raw

[BUG REPORT] kernel BUG in ext4_write_inline_data_end or ext4_writepages

Hi,
syzbot find a new bug[1] in ext4 that's similar with bug[0], that leads to reboot.
While the bug[0] can be fixed with patch[2] from Bin. This new bug is still triggered with the patch[2], and log[3] is collected. Both log[1] and log[3] are
collected when testing bug[4] on the mainline.

[0] https://syzkaller.appspot.com/bug?id=5bafe4554067100b70f58a81268aa06ea3f9c345
[1] https://syzkaller.appspot.com/text?tag=CrashLog&x=16325fc3880000
[2] https://lore.kernel.org/lkml/CABymUCN+NSzkunRqFs8LgqjT6vXz-gyyZYn0hQWf8V9kmcO0Hw@mail.gmail.com/T/
[3] https://syzkaller.appspot.com/text?tag=CrashLog&x=155abe7b880000
[4] https://syzkaller.appspot.com/bug?id=899b37f20ce4072bcdfecfe1647b39602e956e36

[   38.932317][  T494] Call Trace:
[   38.935437][  T494]  <TASK>
[   38.938393][  T494]  ext4_write_inline_data_end+0xa39/0xdf0
[   38.943946][  T494]  ? put_page+0xa0/0xa0
[   38.947936][  T494]  ? ext4_da_write_begin+0x6f0/0x8d0
[   38.953055][  T494]  ? pipe_zero+0x240/0x240
[   38.957308][  T494]  ext4_da_write_end+0x1e2/0x950
[   38.962082][  T494]  ? ext4_da_write_begin+0x8d0/0x8d0
[   38.967204][  T494]  generic_perform_write+0x401/0x5f0
[   38.972326][  T494]  ? generic_file_direct_write+0x6c0/0x6c0
[   38.977994][  T494]  ? generic_write_checks_count+0x4b0/0x4b0
[   38.983694][  T494]  ext4_buffered_write_iter+0x35f/0x640
[   38.989074][  T494]  ext4_file_write_iter+0x198/0x1cd0
[   38.994194][  T494]  ? futex_unqueue+0x156/0x180
[   38.998795][  T494]  ? futex_wait+0x4c5/0x5c0
[   39.003307][  T494]  ? futex_wait_setup+0x320/0x320
[   39.008168][  T494]  ? avc_policy_seqno+0x1b/0x70
[   39.012862][  T494]  ? ext4_file_read_iter+0x470/0x470
[   39.017976][  T494]  vfs_write+0x8b5/0xef0
[   39.022056][  T494]  ? file_end_write+0x1b0/0x1b0
[   39.026739][  T494]  ? mutex_lock+0xb6/0x130
[   39.030994][  T494]  ? bit_wait_io_timeout+0x110/0x110
[   39.036117][  T494]  ? __fget_files+0x2d9/0x330
[   39.040630][  T494]  ? __fdget_pos+0x268/0x300
[   39.045054][  T494]  ? ksys_write+0x77/0x2c0
[   39.049307][  T494]  ksys_write+0x198/0x2c0
[   39.053472][  T494]  ? save_fpregs_to_fpstate+0x210/0x210
[   39.058855][  T494]  ? __ia32_sys_read+0x90/0x90
[   39.063465][  T494]  ? __kasan_check_write+0x14/0x20
[   39.068403][  T494]  ? switch_fpu_return+0x129/0x270
[   39.073348][  T494]  __x64_sys_write+0x7b/0x90
[   39.077783][  T494]  do_syscall_64+0x2f/0x50
[   39.082030][  T494]  entry_SYSCALL_64_after_hwframe+0x63/0xcd

Regards,
Jun

#2 lore raw

Re: [BUG REPORT] kernel BUG in ext4_write_inline_data_end or ext4_writepages

Quoted 49 lines · Jun Nie

Hi,
syzbot find a new bug[1] in ext4 that's similar with bug[0], that leads to reboot.
While the bug[0] can be fixed with patch[2] from Bin. This new bug is still triggered with the patch[2], and log[3] is collected. Both log[1] and log[3] are
collected when testing bug[4] on the mainline.

[0] https://syzkaller.appspot.com/bug?id=5bafe4554067100b70f58a81268aa06ea3f9c345
[1] https://syzkaller.appspot.com/text?tag=CrashLog&x=16325fc3880000
[2] https://lore.kernel.org/lkml/CABymUCN+NSzkunRqFs8LgqjT6vXz-gyyZYn0hQWf8V9kmcO0Hw@mail.gmail.com/T/
[3] https://syzkaller.appspot.com/text?tag=CrashLog&x=155abe7b880000
[4] https://syzkaller.appspot.com/bug?id=899b37f20ce4072bcdfecfe1647b39602e956e36

[   38.932317][  T494] Call Trace:
[   38.935437][  T494]  <TASK>
[   38.938393][  T494]  ext4_write_inline_data_end+0xa39/0xdf0
[   38.943946][  T494]  ? put_page+0xa0/0xa0
[   38.947936][  T494]  ? ext4_da_write_begin+0x6f0/0x8d0
[   38.953055][  T494]  ? pipe_zero+0x240/0x240
[   38.957308][  T494]  ext4_da_write_end+0x1e2/0x950
[   38.962082][  T494]  ? ext4_da_write_begin+0x8d0/0x8d0
[   38.967204][  T494]  generic_perform_write+0x401/0x5f0
[   38.972326][  T494]  ? generic_file_direct_write+0x6c0/0x6c0
[   38.977994][  T494]  ? generic_write_checks_count+0x4b0/0x4b0
[   38.983694][  T494]  ext4_buffered_write_iter+0x35f/0x640
[   38.989074][  T494]  ext4_file_write_iter+0x198/0x1cd0
[   38.994194][  T494]  ? futex_unqueue+0x156/0x180
[   38.998795][  T494]  ? futex_wait+0x4c5/0x5c0
[   39.003307][  T494]  ? futex_wait_setup+0x320/0x320
[   39.008168][  T494]  ? avc_policy_seqno+0x1b/0x70
[   39.012862][  T494]  ? ext4_file_read_iter+0x470/0x470
[   39.017976][  T494]  vfs_write+0x8b5/0xef0
[   39.022056][  T494]  ? file_end_write+0x1b0/0x1b0
[   39.026739][  T494]  ? mutex_lock+0xb6/0x130
[   39.030994][  T494]  ? bit_wait_io_timeout+0x110/0x110
[   39.036117][  T494]  ? __fget_files+0x2d9/0x330
[   39.040630][  T494]  ? __fdget_pos+0x268/0x300
[   39.045054][  T494]  ? ksys_write+0x77/0x2c0
[   39.049307][  T494]  ksys_write+0x198/0x2c0
[   39.053472][  T494]  ? save_fpregs_to_fpstate+0x210/0x210
[   39.058855][  T494]  ? __ia32_sys_read+0x90/0x90
[   39.063465][  T494]  ? __kasan_check_write+0x14/0x20
[   39.068403][  T494]  ? switch_fpu_return+0x129/0x270
[   39.073348][  T494]  __x64_sys_write+0x7b/0x90
[   39.077783][  T494]  do_syscall_64+0x2f/0x50
[   39.082030][  T494]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
Quoted 3 lines

Regards,
Jun
.

I analyze that the above issue should be caused by the concurrency of inline data conversion and buffer write.
At present, I haven't thought of any good solution.