2023-11-22 15:10:49

by syzbot

[permalink] [raw]
Subject: [syzbot] [ext4?] WARNING in ext4_dio_write_end_io

Hello,

syzbot found the following issue on:

HEAD commit: 98b1cc82c4af Linux 6.7-rc2
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15e09a9f680000
kernel config: https://syzkaller.appspot.com/x/.config?x=6ae1a4ee971a7305
dashboard link: https://syzkaller.appspot.com/bug?extid=47479b71cdfc78f56d30
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c09a00e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=151d5320e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/39c6cdad13fc/disk-98b1cc82.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/5a77b5daef9b/vmlinux-98b1cc82.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5e09ae712e0d/bzImage-98b1cc82.xz

The issue was bisected to:

commit 91562895f8030cb9a0470b1db49de79346a69f91
Author: Jan Kara <[email protected]>
Date: Fri Oct 13 12:13:50 2023 +0000

ext4: properly sync file size update after O_SYNC direct IO

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17d0f0c8e80000
final oops: https://syzkaller.appspot.com/x/report.txt?x=1430f0c8e80000
console output: https://syzkaller.appspot.com/x/log.txt?x=1030f0c8e80000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
Fixes: 91562895f803 ("ext4: properly sync file size update after O_SYNC direct IO")

------------[ cut here ]------------
WARNING: CPU: 1 PID: 4481 at fs/ext4/file.c:391 ext4_dio_write_end_io+0x1db/0x220 fs/ext4/file.c:391
Modules linked in:
CPU: 1 PID: 4481 Comm: kworker/1:2 Not tainted 6.7.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Workqueue: dio/sda1 iomap_dio_complete_work
RIP: 0010:ext4_dio_write_end_io+0x1db/0x220 fs/ext4/file.c:391
Code: e8 6a 37 56 ff 4c 89 e2 4c 89 f6 48 89 ef e8 8c f6 ff ff 89 c3 eb 92 4c 89 ff e8 70 c7 ac ff e9 66 ff ff ff e8 46 37 56 ff 90 <0f> 0b 90 e9 34 ff ff ff e8 58 c7 ac ff e9 e9 fe ff ff 4c 89 ff e8
RSP: 0018:ffffc9000dd97c40 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000000081fd RCX: ffffffff8231521e
RDX: ffff88802a403b80 RSI: ffffffff823152ea RDI: 0000000000000006
RBP: ffff88807cf83eb0 R08: 0000000000000006 R09: 0000000000004000
R10: 00000000000081fd R11: 0000000000000001 R12: 0000000000004000
R13: 0000000000004000 R14: 0000000000000000 R15: ffff88807cf83e10
FS: 0000000000000000(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbc3a9779ee CR3: 0000000077984000 CR4: 0000000000350ef0
Call Trace:
<TASK>
iomap_dio_complete+0x149/0x9f0 fs/iomap/direct-io.c:91
iomap_dio_complete_work+0x56/0x80 fs/iomap/direct-io.c:146
process_one_work+0x886/0x15d0 kernel/workqueue.c:2630
process_scheduled_works kernel/workqueue.c:2703 [inline]
worker_thread+0x8b9/0x1290 kernel/workqueue.c:2784
kthread+0x2c6/0x3a0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242
</TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup


2023-11-22 17:11:27

by Jan Kara

[permalink] [raw]
Subject: Re: [syzbot] [ext4?] WARNING in ext4_dio_write_end_io

On Wed 22-11-23 07:10:31, syzbot wrote:
> syzbot found the following issue on:
>
> HEAD commit: 98b1cc82c4af Linux 6.7-rc2
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=15e09a9f680000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6ae1a4ee971a7305
> dashboard link: https://syzkaller.appspot.com/bug?extid=47479b71cdfc78f56d30
> compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13c09a00e80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=151d5320e80000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/39c6cdad13fc/disk-98b1cc82.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/5a77b5daef9b/vmlinux-98b1cc82.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/5e09ae712e0d/bzImage-98b1cc82.xz
>
> The issue was bisected to:
>
> commit 91562895f8030cb9a0470b1db49de79346a69f91
> Author: Jan Kara <[email protected]>
> Date: Fri Oct 13 12:13:50 2023 +0000
>
> ext4: properly sync file size update after O_SYNC direct IO
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17d0f0c8e80000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=1430f0c8e80000
> console output: https://syzkaller.appspot.com/x/log.txt?x=1030f0c8e80000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
> Fixes: 91562895f803 ("ext4: properly sync file size update after O_SYNC direct IO")
>
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 4481 at fs/ext4/file.c:391 ext4_dio_write_end_io+0x1db/0x220 fs/ext4/file.c:391

OK, so I could easily reproduce this which is good :). It took a bit longer
to actually debug what's going on. In the end I've confirmed this is a
false positive (the assertion isn't 100% reliable). What happens is that
the IO end completion races with expanding truncate (which is not
synchronized with DIO in any way) and the assertion sees a situation where
i_disksize was updated but i_size not yet. This is mostly harmless but we
better should complete the DIO only once we are sure truncate has updated
the i_size as well. I'll think how to best do this.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR