2023-04-24 08:13:08

by syzbot

[permalink] [raw]
Subject: [syzbot] [mm?] KCSAN: data-race in generic_fillattr / shmem_unlink (3)

Hello,

syzbot found the following issue on:

HEAD commit: cb0856346a60 Merge tag 'mm-hotfixes-stable-2023-04-19-16-3..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10b9e8bfc80000
kernel config: https://syzkaller.appspot.com/x/.config?x=fa4baf7c6b35b5d5
dashboard link: https://syzkaller.appspot.com/bug?extid=f682b67a78ce05867e78
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/a02dd7789fb2/disk-cb085634.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a1a1eac454f6/vmlinux-cb085634.xz
kernel image: https://storage.googleapis.com/syzbot-assets/bb0447014913/bzImage-cb085634.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

==================================================================
BUG: KCSAN: data-race in generic_fillattr / shmem_unlink

read-write to 0xffff888104d167b8 of 8 bytes by task 23887 on cpu 1:
shmem_unlink+0x102/0x190 mm/shmem.c:3036
vfs_unlink+0x261/0x3e0 fs/namei.c:4250
do_unlinkat+0x266/0x4f0 fs/namei.c:4316
__do_sys_unlink fs/namei.c:4364 [inline]
__se_sys_unlink fs/namei.c:4362 [inline]
__x64_sys_unlink+0x30/0x40 fs/namei.c:4362
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 0xffff888104d167b8 of 8 bytes by task 27823 on cpu 0:
i_size_read include/linux/fs.h:866 [inline]
generic_fillattr+0x13f/0x1e0 fs/stat.c:58
shmem_getattr+0x32a/0x3b0 mm/shmem.c:1068
vfs_getattr_nosec+0x1e3/0x3c0 fs/stat.c:133
vfs_getattr fs/stat.c:170 [inline]
vfs_statx+0x156/0x300 fs/stat.c:242
vfs_fstatat fs/stat.c:276 [inline]
__do_sys_newfstatat fs/stat.c:446 [inline]
__se_sys_newfstatat+0x8a/0x2a0 fs/stat.c:440
__x64_sys_newfstatat+0x55/0x60 fs/stat.c:440
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: 0x00000000000000c8 -> 0x00000000000000b4

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 27823 Comm: udevd Not tainted 6.3.0-rc7-syzkaller-00089-gcb0856346a60 #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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.


2023-04-24 08:42:00

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: [syzbot] [mm?] KCSAN: data-race in generic_fillattr / shmem_unlink (3)

On Mon, 24 Apr 2023 at 10:10, syzbot
<[email protected]> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: cb0856346a60 Merge tag 'mm-hotfixes-stable-2023-04-19-16-3..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=10b9e8bfc80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=fa4baf7c6b35b5d5
> dashboard link: https://syzkaller.appspot.com/bug?extid=f682b67a78ce05867e78
> 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/a02dd7789fb2/disk-cb085634.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/a1a1eac454f6/vmlinux-cb085634.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/bb0447014913/bzImage-cb085634.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]

I think shmem_unlink() needs to use i_size_write() to update the size.
Writes to i_size are not assumed to be atomic throughout the kernel
code.

> ==================================================================
> BUG: KCSAN: data-race in generic_fillattr / shmem_unlink
>
> read-write to 0xffff888104d167b8 of 8 bytes by task 23887 on cpu 1:
> shmem_unlink+0x102/0x190 mm/shmem.c:3036
> vfs_unlink+0x261/0x3e0 fs/namei.c:4250
> do_unlinkat+0x266/0x4f0 fs/namei.c:4316
> __do_sys_unlink fs/namei.c:4364 [inline]
> __se_sys_unlink fs/namei.c:4362 [inline]
> __x64_sys_unlink+0x30/0x40 fs/namei.c:4362
> 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 0xffff888104d167b8 of 8 bytes by task 27823 on cpu 0:
> i_size_read include/linux/fs.h:866 [inline]
> generic_fillattr+0x13f/0x1e0 fs/stat.c:58
> shmem_getattr+0x32a/0x3b0 mm/shmem.c:1068
> vfs_getattr_nosec+0x1e3/0x3c0 fs/stat.c:133
> vfs_getattr fs/stat.c:170 [inline]
> vfs_statx+0x156/0x300 fs/stat.c:242
> vfs_fstatat fs/stat.c:276 [inline]
> __do_sys_newfstatat fs/stat.c:446 [inline]
> __se_sys_newfstatat+0x8a/0x2a0 fs/stat.c:440
> __x64_sys_newfstatat+0x55/0x60 fs/stat.c:440
> 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: 0x00000000000000c8 -> 0x00000000000000b4
>
> Reported by Kernel Concurrency Sanitizer on:
> CPU: 0 PID: 27823 Comm: udevd Not tainted 6.3.0-rc7-syzkaller-00089-gcb0856346a60 #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 [email protected].
>
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/0000000000001db82205fa108b35%40google.com.