summaryrefslogtreecommitdiff
path: root/scripts/Makefile.thinlto
diff options
context:
space:
mode:
authorLi Jinyue <jinyue.li@linux.alibaba.com>2026-10-22 02:52:48 +0000
committerAnup Patel <anup@brainfault.org>2026-11-16 18:06:15 +0530
commitca6d379ee2f123512c30aa5b0592db648186d9af (patch)
tree198ff75f7c03e7884189737959e6c78b1e67cfb8 /scripts/Makefile.thinlto
parentea4302d313014da5ea988f03ee7b88e29e161dcf (diff)
RISC-V: KVM: Fix double free of the split page cache
kvm_riscv_mmu_free_pgd() frees pgd_split_page_cache after dropping mmu_lock. It is reached from kvm_arch_flush_shadow_all(), i.e. from the MMU notifier ->release() callback, which can run concurrently for the same VM from exit_mmap() and from mmu_notifier_unregister() in kvm_destroy_vm(). The stage-2 teardown is serialized by mmu_lock and the second caller finds kvm->arch.pgd already cleared, but both callers then go on to free the cache, and kvm_mmu_free_memory_cache() does not tolerate concurrent callers: BUG: KASAN: double-free in kvfree+0x28/0x32 ... kfree+0xc4/0x428 kvfree+0x28/0x32 kvm_mmu_free_memory_cache+0x178/0x246 kvm_riscv_mmu_free_pgd+0x20e/0x2b4 kvm_arch_flush_shadow_all+0x1a/0x24 kvm_mmu_notifier_release+0x36/0x7c __mmu_notifier_release+0x182/0x66a exit_mmap+0x7f8/0x8c4 mmput+0x7e/0x2fc do_exit+0x57a/0x22b4 ... Freed by task 15956 on cpu 3 at 8926.103524s: ... kvm_mmu_free_memory_cache+0x178/0x246 kvm_riscv_mmu_free_pgd+0x20e/0x2b4 kvm_arch_flush_shadow_all+0x1a/0x24 kvm_mmu_notifier_release+0x36/0x7c mmu_notifier_unregister+0xf0/0x328 kvm_put_kvm+0x32a/0x7b8 kvm_vm_release+0x3a/0x50 __fput+0x330/0x974 The cache only feeds huge page splitting from VM ioctls, so it does not need to be released together with the page table. Free it from kvm_arch_destroy_vm() instead, which runs once after the MMU notifier has been unregistered, as arm64 and x86 already do. The error path in kvm_arch_init_vm() is not affected because the cache cannot have been filled at that point. Found by syzkaller. Fixes: 6c7f75ef096a ("RISC-V: KVM: Add the split page cache for ioctl context") Cc: stable@vger.kernel.org Signed-off-by: Li Jinyue <jinyue.li@linux.alibaba.com> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20261022025248.477832-1-jinyue.li@linux.alibaba.com Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions