Subject: Re: [syzbot] WARNING in btrfs_free_reserved_data_space_noquota

From: David Sterba <[email-masked]>
Date: Thu, 16 May 2024 17:38:54 +0200

On Tue, Nov 29, 2022 at 12:43:38AM -0800, syzbot wrote:
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    b7b275e60bcd Linux 6.1-rc7
> git tree:       upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=158a7b73880000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=2325e409a9a893e1
> dashboard link: https://syzkaller.appspot.com/bug?extid=adec8406ad17413d4c06
> compiler:       Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=169ccb75880000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17bf7153880000
> 
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/525233126d34/disk-b7b275e6.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/e8299bf41400/vmlinux-b7b275e6.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/eebf691dbf6f/bzImage-b7b275e6.xz
> mounted in repro: https://storage.googleapis.com/syzbot-assets/5423c2d2ad62/mount_0.gz
> 
> The issue was bisected to:
> 
> commit c814bf958926ff45a9c1e899bd001006ab6cfbae
> Author: ye xingchen <[email-masked]>
> Date:   Tue Aug 16 10:51:06 2022 +0000
> 
>     powerpc/selftests: Use timersub() for gettimeofday()
> 
> bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=118c3d03880000
> final oops:     https://syzkaller.appspot.com/x/report.txt?x=138c3d03880000
> console output: https://syzkaller.appspot.com/x/log.txt?x=158c3d03880000
> 
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email-masked]
> Fixes: c814bf958926 ("powerpc/selftests: Use timersub() for gettimeofday()")
> 
> RDX: 0000000000000001 RSI: 0000000020000280 RDI: 0000000000000005
> RBP: 00007ffd32e91c70 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000008000000 R11: 0000000000000246 R12: 0000000000000006
> R13: 00007ffd32e91cb0 R14: 00007ffd32e91c90 R15: 0000000000000006
>  </TASK>
> ------------[ cut here ]------------
> WARNING: CPU: 1 PID: 3764 at fs/btrfs/space-info.h:122 btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:154 [inline]
> WARNING: CPU: 1 PID: 3764 at fs/btrfs/space-info.h:122 btrfs_free_reserved_data_space_noquota+0x219/0x2b0 fs/btrfs/delalloc-space.c:179

Most likely fixed by 9e65bfca24cf1d ("btrfs: fix
qgroup_free_reserved_data int overflow"), it's an 32bit type overflow
that can cause various accounting errors, the function names match the
context.

#syz fix: btrfs: fix qgroup_free_reserved_data int overflow