]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
x86/kvm: Avoid freeing stack-allocated node in kvm_async_pf_queue_task
authorRyosuke Yasuoka <ryasuoka@redhat.com>
Sat, 6 Dec 2025 14:09:36 +0000 (23:09 +0900)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Jan 2026 09:01:32 +0000 (10:01 +0100)
commit95cc9e7cf03d3646abce4129d5c013af33a7df99
tree4f2b1c3f08f6e935e7615ae0815448d44225398a
parentc8ebd433459bcbf068682b09544e830acd7ed222
x86/kvm: Avoid freeing stack-allocated node in kvm_async_pf_queue_task

kvm_async_pf_queue_task() can incorrectly try to kfree() a node
allocated on the stack of kvm_async_pf_task_wait_schedule().

This occurs when a task requests a PF while another task's PF request
with the same token is still pending. Since the token is derived from
the (u32)address in exc_page_fault(), two different tasks can generate
the same token.

Currently, kvm_async_pf_queue_task() assumes that any entry found in the
list is a dummy entry and tries to kfree() it. To fix this, add a flag
to the node structure to distinguish stack-allocated nodes, and only
kfree() the node if it is a dummy entry.

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
Message-ID: <20251206140939.144038-1-ryasuoka@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kernel/kvm.c