Re: [syzbot] [block?] KCSAN: data-race in __filemap_add_folio / invalidate_bdev (3)

From: Dmitry Vyukov
Date: Mon Apr 24 2023 - 03:40:22 EST


On Mon, 24 Apr 2023 at 09:20, syzbot
<syzbot+8a416e3cb063d4787b0f@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 3e7bb4f24617 Merge tag '6.3-rc6-smb311-client-negcontext-f..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=13c2e6ebc80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=710057cbb8def08c
> dashboard link: https://syzkaller.appspot.com/bug?extid=8a416e3cb063d4787b0f
> compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/d1f21f86a5e7/disk-3e7bb4f2.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/5769a034d50c/vmlinux-3e7bb4f2.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/82288ce4b761/bzImage-3e7bb4f2.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+8a416e3cb063d4787b0f@xxxxxxxxxxxxxxxxxxxxxxxxx

invalidate_bdev() looks at mapping->nrpages to decide to
invalidate/not-invalidate. If it's updated concurrently, can't
invalidate_bdev() falsely decide to not invalidate?


> ==================================================================
> BUG: KCSAN: data-race in __filemap_add_folio / invalidate_bdev
>
> read-write to 0xffff8881023fec48 of 8 bytes by task 5672 on cpu 1:
> __filemap_add_folio+0x38c/0x720 mm/filemap.c:904
> filemap_add_folio+0x6f/0x150 mm/filemap.c:939
> filemap_create_folio mm/filemap.c:2545 [inline]
> filemap_get_pages+0x5d2/0xea0 mm/filemap.c:2605
> filemap_read+0x223/0x680 mm/filemap.c:2693
> blkdev_read_iter+0x2ca/0x370 block/fops.c:606
> call_read_iter include/linux/fs.h:1845 [inline]
> new_sync_read fs/read_write.c:389 [inline]
> vfs_read+0x39a/0x560 fs/read_write.c:470
> ksys_read+0xeb/0x1a0 fs/read_write.c:613
> __do_sys_read fs/read_write.c:623 [inline]
> __se_sys_read fs/read_write.c:621 [inline]
> __x64_sys_read+0x42/0x50 fs/read_write.c:621
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> read to 0xffff8881023fec48 of 8 bytes by task 3141 on cpu 0:
> invalidate_bdev+0x35/0x80 block/bdev.c:84
> bdev_disk_changed+0x102/0xbb0 block/partitions/core.c:668
> __loop_clr_fd+0x2b9/0x3b0 drivers/block/loop.c:1189
> loop_clr_fd drivers/block/loop.c:1257 [inline]
> lo_ioctl+0xe9e/0x12f0 drivers/block/loop.c:1563
> blkdev_ioctl+0x3a0/0x490 block/ioctl.c:615
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:870 [inline]
> __se_sys_ioctl+0xc9/0x140 fs/ioctl.c:856
> __x64_sys_ioctl+0x43/0x50 fs/ioctl.c:856
> do_syscall_x64 arch/x86/entry/common.c:50 [inline]
> do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80
> entry_SYSCALL_64_after_hwframe+0x63/0xcd
>
> value changed: 0x0000000000000000 -> 0x0000000000000001
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 0 PID: 3141 Comm: syz-executor.2 Not tainted 6.3.0-rc6-syzkaller-00188-g3e7bb4f24617 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023
> ==================================================================
>
>
> ---
> 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 syzkaller@xxxxxxxxxxxxxxxx.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@xxxxxxxxxxxxxxxx.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/0000000000007470fe05fa0fd8ba%40google.com.