From: Hans de Goede <hansg@kernel.org>
To: Fan Wu <fanwu01@zju.edu.cn>, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: virtualization@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] virt: vboxguest: fix use-after-free in balloon work
Date: Tue, 18 Aug 2026 15:58:57 +0200 [thread overview]
Message-ID: <151c7b8e-8ae7-4355-81bb-51fd487ef418@kernel.org> (raw)
In-Reply-To: <20260818081139.399994-1-fanwu01@zju.edu.cn>
Hi,
On 18-Aug-26 10:11, Fan Wu wrote:
> VMMDEV_EVENT_BALLOON_CHANGE_REQUEST is reported only after a guest
> userspace client enables it with VBOXGUEST_IOCTL_SET_EVENT_FILTER.
> The interrupt handler then queues the balloon work, which reads and
> writes the mem_balloon.get_req and change_req request buffers.
>
> vbg_pci_remove() calls free_irq() before vbg_core_exit(), but
> free_irq() only waits for the handler to return, not for any work it
> has queued. A balloon work still running on system_wq therefore
> touches the request buffers after vbg_core_exit() has freed them:
>
> CPU 0 (remove) IRQ handler system_wq
> free_irq() schedule_work(...)
> return
> vbg_core_exit()
> vbg_req_free(...) vbg_balloon_work()
> req->event_ack = ...
>
> Fix this by calling cancel_work_sync() on mem_balloon.work in
> vbg_core_exit(), before the request buffers are freed. The worker
> does not requeue itself, and the interrupt handler, the only place
> that queues it, can no longer run when vbg_core_exit() is reached:
> vbg_pci_remove() has already called free_irq(), and on the probe
> error path the irq was never requested. Draining the work once is
> therefore sufficient.
>
> This issue was found by an in-house static analysis tool.
>
> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:gpt-5.6
> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Regards,
Hans
> ---
> drivers/virt/vboxguest/vboxguest_core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c
> index b177a534b6a4..884e69d00f72 100644
> --- a/drivers/virt/vboxguest/vboxguest_core.c
> +++ b/drivers/virt/vboxguest/vboxguest_core.c
> @@ -1048,6 +1048,8 @@ int vbg_core_init(struct vbg_dev *gdev, u32 fixed_events)
> */
> void vbg_core_exit(struct vbg_dev *gdev)
> {
> + cancel_work_sync(&gdev->mem_balloon.work);
> +
> vbg_heartbeat_exit(gdev);
> vbg_guest_mappings_exit(gdev);
>
prev parent reply other threads:[~2026-08-18 13:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 8:11 [PATCH] virt: vboxguest: fix use-after-free in balloon work Fan Wu
2026-08-18 13:58 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=151c7b8e-8ae7-4355-81bb-51fd487ef418@kernel.org \
--to=hansg@kernel.org \
--cc=arnd@arndb.de \
--cc=fanwu01@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.