[syzbot] kernel BUG in workingset_activation (2)

8 views
Skip to first unread message

syzbot

unread,
Nov 15, 2022, 11:23:47ā€ÆAM11/15/22
to ak...@linux-foundation.org, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: f4bc5bbb5fef Merge tag 'nfsd-5.17-2' of git://git.kernel.o..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16c683d8700000
kernel config: https://syzkaller.appspot.com/x/.config?x=5707221760c00a20
dashboard link: https://syzkaller.appspot.com/bug?extid=644848628d5e12d5438c
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1691d2c2700000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16cde752700000

Bisection is inconclusive: the issue happens on the oldest tested release.

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=174c8174700000
final oops: https://syzkaller.appspot.com/x/report.txt?x=14cc8174700000
console output: https://syzkaller.appspot.com/x/log.txt?x=10cc8174700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+644848...@syzkaller.appspotmail.com

do_one_initcall+0x103/0x650 init/main.c:1300
do_initcall_level init/main.c:1373 [inline]
do_initcalls init/main.c:1389 [inline]
do_basic_setup init/main.c:1408 [inline]
kernel_init_freeable+0x6b1/0x73a init/main.c:1613
kernel_init+0x1a/0x1d0 init/main.c:1502
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
------------[ cut here ]------------
kernel BUG at include/linux/memcontrol.h:470!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 3678 Comm: syz-executor106 Not tainted 5.17.0-rc3-syzkaller-00043-gf4bc5bbb5fef #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:folio_memcg_rcu include/linux/memcontrol.h:470 [inline]
RIP: 0010:workingset_activation+0x4f2/0x5d0 mm/workingset.c:412
Code: 48 89 ef e8 50 01 00 00 c6 05 da cf d3 0b 01 0f 0b e9 0e fd ff ff e8 6d 90 cc ff 48 c7 c6 c0 0c b7 89 48 89 ef e8 2e 01 00 00 <0f> 0b e8 57 90 cc ff 0f 0b e9 e6 fb ff ff e8 4b 90 cc ff 48 c7 c6
RSP: 0018:ffffc90002ac7490 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
RDX: ffff8880729940c0 RSI: ffffffff81ab1de2 RDI: 0000000000000003
RBP: ffffea0001aa0000 R08: 0000000000000018 R09: 00000000ffffffff
R10: ffffffff8908d53c R11: 00000000ffffffff R12: 0000000000000000
R13: ffff8880b9c34da8 R14: dffffc0000000000 R15: 0000000000000003
FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa33152f1f0 CR3: 000000001b7f5000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
folio_mark_accessed+0x596/0xdd0 mm/swap.c:442
kvm_set_pfn_accessed arch/x86/kvm/../../../virt/kvm/kvm_main.c:2821 [inline]
kvm_set_pfn_accessed+0x1d8/0x220 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2818
handle_changed_spte_acc_track arch/x86/kvm/mmu/tdp_mmu.c:233 [inline]
handle_changed_spte_acc_track+0x1bc/0x290 arch/x86/kvm/mmu/tdp_mmu.c:225
handle_changed_spte arch/x86/kvm/mmu/tdp_mmu.c:485 [inline]
handle_removed_tdp_mmu_page arch/x86/kvm/mmu/tdp_mmu.c:370 [inline]
__handle_changed_spte+0xb93/0x13e0 arch/x86/kvm/mmu/tdp_mmu.c:475
handle_changed_spte arch/x86/kvm/mmu/tdp_mmu.c:483 [inline]
handle_removed_tdp_mmu_page arch/x86/kvm/mmu/tdp_mmu.c:370 [inline]
__handle_changed_spte+0xb84/0x13e0 arch/x86/kvm/mmu/tdp_mmu.c:475
handle_changed_spte arch/x86/kvm/mmu/tdp_mmu.c:483 [inline]
handle_removed_tdp_mmu_page arch/x86/kvm/mmu/tdp_mmu.c:370 [inline]
__handle_changed_spte+0xb84/0x13e0 arch/x86/kvm/mmu/tdp_mmu.c:475
__tdp_mmu_set_spte+0x227/0xa70 arch/x86/kvm/mmu/tdp_mmu.c:595
tdp_mmu_set_spte arch/x86/kvm/mmu/tdp_mmu.c:609 [inline]
zap_gfn_range+0xd4c/0xe00 arch/x86/kvm/mmu/tdp_mmu.c:751
__kvm_tdp_mmu_zap_gfn_range+0xdc/0x110 arch/x86/kvm/mmu/tdp_mmu.c:779
kvm_tdp_mmu_zap_gfn_range arch/x86/kvm/mmu/tdp_mmu.h:27 [inline]
kvm_tdp_mmu_zap_all+0x26/0x70 arch/x86/kvm/mmu/tdp_mmu.c:791
kvm_mmu_zap_all+0x27c/0x2c0 arch/x86/kvm/mmu/mmu.c:5983
kvm_mmu_notifier_release+0x5f/0xa0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:819
mn_hlist_release mm/mmu_notifier.c:319 [inline]
__mmu_notifier_release+0x1a9/0x600 mm/mmu_notifier.c:357
mmu_notifier_release include/linux/mmu_notifier.h:415 [inline]
exit_mmap+0x543/0x670 mm/mmap.c:3136
__mmput+0x122/0x4b0 kernel/fork.c:1114
mmput+0x56/0x60 kernel/fork.c:1135
exit_mm kernel/exit.c:507 [inline]
do_exit+0xa3c/0x2a30 kernel/exit.c:793
do_group_exit+0xd2/0x2f0 kernel/exit.c:935
__do_sys_exit_group kernel/exit.c:946 [inline]
__se_sys_exit_group kernel/exit.c:944 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:944
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fa3314b91f9
Code: Unable to access opcode bytes at RIP 0x7fa3314b91cf.
RSP: 002b:00007fffac3303d8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fa33152e350 RCX: 00007fa3314b91f9
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000000
R10: 0000000000000006 R11: 0000000000000246 R12: 00007fa33152e350
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:folio_memcg_rcu include/linux/memcontrol.h:470 [inline]
RIP: 0010:workingset_activation+0x4f2/0x5d0 mm/workingset.c:412
Code: 48 89 ef e8 50 01 00 00 c6 05 da cf d3 0b 01 0f 0b e9 0e fd ff ff e8 6d 90 cc ff 48 c7 c6 c0 0c b7 89 48 89 ef e8 2e 01 00 00 <0f> 0b e8 57 90 cc ff 0f 0b e9 e6 fb ff ff e8 4b 90 cc ff 48 c7 c6
RSP: 0018:ffffc90002ac7490 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000000
RDX: ffff8880729940c0 RSI: ffffffff81ab1de2 RDI: 0000000000000003
RBP: ffffea0001aa0000 R08: 0000000000000018 R09: 00000000ffffffff
R10: ffffffff8908d53c R11: 00000000ffffffff R12: 0000000000000000
R13: ffff8880b9c34da8 R14: dffffc0000000000 R15: 0000000000000003
FS: 0000000000000000(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa33152f1f0 CR3: 000000001b7f5000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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 syzk...@googlegroups.com.

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
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Andrew Morton

unread,
Nov 15, 2022, 2:27:34ā€ÆPM11/15/22
to syzbot, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, k...@vger.kernel.org
On Tue, 15 Nov 2022 08:23:44 -0800 syzbot <syzbot+644848...@syzkaller.appspotmail.com> wrote:

> Hello,
>
> syzbot found the following issue on:

Thanks.

> HEAD commit: f4bc5bbb5fef Merge tag 'nfsd-5.17-2' of git://git.kernel.o..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=16c683d8700000
> kernel config: https://syzkaller.appspot.com/x/.config?x=5707221760c00a20
> dashboard link: https://syzkaller.appspot.com/bug?extid=644848628d5e12d5438c
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1691d2c2700000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16cde752700000
>
> Bisection is inconclusive: the issue happens on the oldest tested release.
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=174c8174700000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=14cc8174700000
> console output: https://syzkaller.appspot.com/x/log.txt?x=10cc8174700000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+644848...@syzkaller.appspotmail.com
>
> do_one_initcall+0x103/0x650 init/main.c:1300
> do_initcall_level init/main.c:1373 [inline]
> do_initcalls init/main.c:1389 [inline]
> do_basic_setup init/main.c:1408 [inline]
> kernel_init_freeable+0x6b1/0x73a init/main.c:1613
> kernel_init+0x1a/0x1d0 init/main.c:1502
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
> ------------[ cut here ]------------
> kernel BUG at include/linux/memcontrol.h:470!

That's

VM_BUG_ON_FOLIO(folio_test_slab(folio), folio);

in folio_memcg_rcu().

I'll cc the KVM list.

Sean Christopherson

unread,
Nov 15, 2022, 3:07:42ā€ÆPM11/15/22
to Andrew Morton, syzbot, linux-...@vger.kernel.org, linu...@kvack.org, syzkall...@googlegroups.com, k...@vger.kernel.org
Thanks! Saw this internally, was waiting for it to hit the lists.

I haven't been able to repro the syzkaller test (abuses /dev/bus/usb crud), but
I believe the issue is that KVM attempts to mark a kmalloc'd page as accessed.
workingset_activation() doesn't expect this and invokes folio_memcg_rcu() on a
SLAB page, which triggers the VM_BUG.

I suspect this can be reproduced with a KVM selftest by mapping KVM's own vcpu->run
memory into the guest. I'll give that a shot.

In the meantime...

#sys test https://github.com/sean-jc/linux.git x86/no_slab_accessed

syzbot

unread,
Jun 28, 2023, 4:00:46ā€ÆAM6/28/23
to ak...@linux-foundation.org, gre...@linuxfoundation.org, k...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, lrh...@pku.edu.cn, sea...@google.com, st...@rowland.harvard.edu, syzkall...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 0143d148d1e882fb1538dc9974c94d63961719b9
Author: Ruihan Li <lrh...@pku.edu.cn>
Date: Mon May 15 13:09:55 2023 +0000

usb: usbfs: Enforce page requirements for mmap

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10a65abd280000
start commit: 59d0d52c30d4 AMerge tag 'netfs-fixes-20221115' of git://gi..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=11d3fa0b3feb5055
dashboard link: https://syzkaller.appspot.com/bug?extid=644848628d5e12d5438c
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14fdf3f1880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17b54702880000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: usb: usbfs: Enforce page requirements for mmap

Ruihan Li

unread,
Jun 28, 2023, 4:21:57ā€ÆAM6/28/23
to syzbot, ak...@linux-foundation.org, gre...@linuxfoundation.org, k...@vger.kernel.org, linux-...@vger.kernel.org, linu...@kvack.org, sea...@google.com, st...@rowland.harvard.edu, syzkall...@googlegroups.com, Ruihan Li
Correct.

#syz fix: usb: usbfs: Enforce page requirements for mmap

Thanks,
Ruihan Li

Reply all
Reply to author
Forward
0 new messages