There is "__iopt_area_unfill_domain" WARNING in v6.3-rc2 kernel
Hi Jason and kernel experts,
Greeting!
Platform: x86 platforms
There is "__iopt_area_unfill_domain" WARNING in v6.3-rc2 kernel:
All detailed info: https://github.com/xupengfe/syzkaller_logs/tree/main/230314_094459___iopt_area_unfill_domain
Reproduced code: https://github.com/xupengfe/syzkaller_logs/blob/main/230314_094459___iopt_area_unfill_domain/repro.cKconfig: https://github.com/xupengfe/syzkaller_logs/blob/main/230314_094459___iopt_area_unfill_domain/kconfig_origin
v6.3 issue dmesg: https://github.com/xupengfe/syzkaller_logs/blob/main/230314_094459___iopt_area_unfill_domain/eeac8ede17557680855031c6f305ece2378af326_dmesg.log
Bisect info: https://github.com/xupengfe/syzkaller_logs/blob/main/230314_094459___iopt_area_unfill_domain/bisect_info.log
"
[ 24.464930] memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=329 'systemd' [ 32.196744] ------------[ cut here ]------------ [ 32.197234] WARNING: CPU: 0 PID: 557 at drivers/iommu/iommufd/pages.c:294 __iopt_area_unfill_domain+0x152/0x560 [ 32.197954] Modules linked in: [ 32.198195] CPU: 0 PID: 557 Comm: repro Not tainted 6.3.0-rc2-eeac8ede1755 #1 [ 32.198777] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 [ 32.199605] RIP: 0010:__iopt_area_unfill_domain+0x152/0x560 [ 32.200029] Code: d2 0f ff 44 8b 64 24 54 48 8b 44 24 48 31 ff 44 89 e6 48 89 44 24 38 e8 fc d3 0f ff 45 85 e4 0f 85 eb 01 00 00 e8 0e d2 0f ff <0f> 0b e8 07 d2 0f ff 48 8b 44 24 38 89 5c 24 58 89 18 8b 44 24 54 [ 32.201354] RSP: 0018:ffffc9000108baf0 EFLAGS: 00010246 [ 32.201759] RAX: 0000000000000000 RBX: 00000000ffffffff RCX: ffffffff821e3f85 [ 32.202270] RDX: 0000000000000000 RSI: ffff88800faf0000 RDI: 0000000000000002 [ 32.202819] RBP: ffffc9000108bd18 R08: 000000000003ca25 R09: 0000000000000014 [ 32.203341] R10: 000000000003ca00 R11: 0000000000000024 R12: 0000000000000004 [ 32.203875] R13: 0000000000000801 R14: 00000000000007ff R15: 0000000000000800 [ 32.204383] FS: 00007f3499ce1740(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000 [ 32.204978] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 32.205393] CR2: 0000000020000243 CR3: 00000000179c2001 CR4: 0000000000770ef0 [ 32.205927] PKRU: 55555554 [ 32.206132] Call Trace: [ 32.206320] <TASK> [ 32.206491] ? __this_cpu_preempt_check+0x20/0x30 [ 32.206915] ? __this_cpu_preempt_check+0x20/0x30 [ 32.207299] ? lock_is_held_type+0xe6/0x140 [ 32.207630] ? rcu_read_lock_sched_held+0x57/0x80 [ 32.208000] ? __mutex_lock+0x13a/0xf80 [ 32.208327] ? write_comp_data+0x2f/0x90 [ 32.208643] ? write_comp_data+0x2f/0x90 [ 32.208948] ? __sanitizer_cov_trace_pc+0x25/0x60 [ 32.209333] iopt_area_unfill_domain+0x32/0x40 [ 32.209688] iopt_table_remove_domain+0x23f/0x4c0 [ 32.210053] iommufd_device_selftest_detach+0x3a/0x90 [ 32.210451] iommufd_selftest_destroy+0x55/0x70 [ 32.210832] iommufd_object_destroy_user+0xce/0x130 [ 32.211214] iommufd_destroy+0xa2/0xc0 [ 32.211528] iommufd_fops_ioctl+0x206/0x330 [ 32.211851] ? __sanitizer_cov_trace_pc+0x25/0x60 [ 32.212212] ? write_comp_data+0x2f/0x90 [ 32.212541] __x64_sys_ioctl+0x10e/0x160 [ 32.212848] ? __pfx_iommufd_fops_ioctl+0x10/0x10 [ 32.213207] do_syscall_64+0x3b/0x90 [ 32.213511] entry_SYSCALL_64_after_hwframe+0x72/0xdc [ 32.213896] RIP: 0033:0x7f3499e0659d [ 32.214174] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d d3 08 0d 00 f7 d8 64 89 01 48 [ 32.215510] RSP: 002b:00007ffd7bbdb808 EFLAGS: 00000213 ORIG_RAX: 0000000000000010 [ 32.216071] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3499e0659d [ 32.216581] RDX: 0000000020000140 RSI: 0000000000003b80 RDI: 0000000000000003 [ 32.217108] RBP: 00007ffd7bbdb820 R08: 00007ffd7bbdb820 R09: 00007ffd7bbdb820 [ 32.217624] R10: 00007ffd7bbdb820 R11: 0000000000000213 R12: 0000000000401180 [ 32.218154] R13: 00007ffd7bbdb940 R14: 0000000000000000 R15: 0000000000000000 [ 32.218704] </TASK> [ 32.218899] irq event stamp: 18545 [ 32.219156] hardirqs last enabled at (18553): [<ffffffff811eac21>] __up_console_sem+0x91/0xb0 [ 32.219774] hardirqs last disabled at (18560): [<ffffffff811eac06>] __up_console_sem+0x76/0xb0 [ 32.220410] softirqs last enabled at (18388): [<ffffffff83024a4c>] __do_softirq+0x31c/0x49c [ 32.221014] softirqs last disabled at (18383): [<ffffffff8112b5a4>] irq_exit_rcu+0xc4/0x100 [ 32.221641] ---[ end trace 0000000000000000 ]---
"
Bisected and found bad commit:
"f4b20bb34c83dceade5470288f48f94ce3598ada
iommufd: Add kernel support for testing iommufd
"
It's just a suspected commit, because reverted above commit on top of v6.3-rc2 and made kernel failed, could not double confirm the commit for this issue.
From reproduced code, it seems related to ioctl IOMMU_TEST_OP_MOCK_DOMAIN, IOMMU_TEST_OP_CREATE_ACCESS and IOMMU_TEST_OP_ACCESS_PAGES related action. So it seems similar as issue:
https://lore.kernel.org/linux-iommu/ZBExkEW%[email protected]/T/#u
Anyway reported the above info and I hope it's helpful.
Thanks!
---
If you don't need the following environment to reproduce the problem or if you already have one, please ignore the following information.
How to reproduce:
git clone https://gitlab.com/xupengfe/repro_vm_env.git
cd repro_vm_env
tar -xvf repro_vm_env.tar.gz
cd repro_vm_env; ./start3.sh // it needs qemu-system-x86_64 and I used v7.1.0
// start3.sh will load bzImage_2241ab53cbb5cdb08a6b2d4688feb13971058f65 v6.2-rc5 kernel // You could change the bzImage_xxx as you want
You could use below command to log in, there is no password for root.
ssh -p 10023 root@localhost
After login vm(virtual machine) successfully, you could transfer reproduced binary to the vm by below way, and reproduce the problem in vm:
gcc -pthread -o repro repro.c
scp -P 10023 repro root@localhost:/root/
Get the bzImage for target kernel:
Please use target kconfig and copy it to kernel_src/.config make olddefconfig
make -jx bzImage //x should equal or less than cpu num your pc has
Fill the bzImage file into above start3.sh to load the target kernel in vm.
Tips:
If you already have qemu-system-x86_64, please ignore below info.
If you want to install qemu v7.1.0 version:
git clone https://github.com/qemu/qemu.git
cd qemu
git checkout -f v7.1.0
mkdir build
cd build
yum install -y ninja-build.x86_64
../configure --target-list=x86_64-softmmu --enable-kvm --enable-vnc --enable-gtk --enable-sdl make
make install
Thanks!
BR.