mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Link Lin <linkl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	 "Michael S . Tsirkin" <mst@redhat.com>,
	 David Hildenbrand <david@kernel.org>,
	virtualization@lists.linux.dev,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, prasin@google.com,
	 duenwen@google.com, jasowang@redhat.com,
	xuanzhuo@linux.alibaba.com,
	 Ammar Faizi <ammarfaizi2@openresty.com>,
	jiaqiyan@google.com,  ahwilkins@google.com,
	Greg Thelen <gthelen@google.com>,
	 Alexander Duyck <alexander.duyck@gmail.com>,
	stable@vger.kernel.org
Subject: Re: [RFC] virtio_balloon: fix Use-After-Free in page reporting during PM freeze
Date: Mon, 13 Jul 2026 12:41:07 -0700 (PDT)	[thread overview]
Message-ID: <59e3dae7-a203-2e1d-3b65-875b7e0e122b@google.com> (raw)
In-Reply-To: <CALUx4KQ=bYTpDoDAZ+iVb7Ehaa0LmyPDsEWk3xFFmTVYKrpAUA@mail.gmail.com>

On Thu, 9 Jul 2026, Link Lin wrote:

> > > Fix this by:
> > > 1. Unregistering page reporting in virtballoon_freeze() prior to calling
> > >    remove_common(). This clears the RCU pr_dev_info pointer and flushes/
> > >    cancels prdev->work on system_wq via cancel_delayed_work_sync().
> > > 2. Re-registering page reporting in virtballoon_restore() after the
> > >    virtqueues are re-initialized and virtio_device_ready() has been called.
> > > 3. Unwinding virtqueue initialization via remove_common() in
> > >    virtballoon_restore() if page_reporting_register() fails.
> >
> > AI review thinks the patch didn't do the above:
> >         https://sashiko.dev/#/patchset/20260709224330.946683-1-linkl@google.com
> 
> The AI reviewer might not have parsed the entirety of the fix I proposed.
> The patch submitted definitely includes the changes to virtballoon_restore()
> for steps 2 and 3 (re-registering page reporting and unwinding init_vqs
> on failure). It seems the AI failed to parse the diff correctly. See:
> 
> +       if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) {
> +               ret = page_reporting_register(&vb->pr_dev_info);
> +               if (ret)
> +                       goto out_remove_vqs;
> +       }
> +
>         if (towards_target(vb))
>                 virtballoon_changed(vdev);
>         update_balloon_size(vb);
>         return 0;
> +
> +out_remove_vqs:
> +       remove_common(vb);
> +       return ret;
>  }
> 
> > It also might have found a couple of pre-existing bugs in there.
> 
> Indeed. Regarding the first pre-existing bug found by the AI (leaving the
> OOM notifier registered during suspend, leading to a UAF if memory pressure
> spikes during S4 hibernation):
> 
> I actually addressed this in the commit message:
> 
>   "(Note: The OOM Notifier and Shrinker/Free Page Hinting features suffer
>   from an identical lifecycle flaw and are also vulnerable to UAFs during
>   S4 hibernation when memory pressure spikes. This patch focuses on Free
>   Page Reporting, which runs periodically, to ensure clean backports to
>   stable kernels)."
> 
> Regarding the second pre-existing bug the AI flagged (leaving uncancelled
> works on system_freezable_wq if virtballoon_restore fails on the cold path):
> the AI is correct that this asynchronous work cancellation failure exists.
> 
> Since these are separate, pre-existing lifecycle bugs, would you prefer I
> roll fixes for the OOM notifier, shrinker/free page hinting, and work
> cancellations into a v2 of this patch, or submit them as a separate patch
> series to keep the stable backports clean?
> 

I think it would be best to have separate patches for each fix; Andrew, 
please correct me if you'd prefer one patch to address everything.

  reply	other threads:[~2026-07-13 19:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 22:43 Link Lin
2026-07-09 23:12 ` Andrew Morton
2026-07-10  0:45   ` Link Lin
2026-07-13 19:41     ` David Rientjes [this message]
2026-07-13 19:43       ` Michael S. Tsirkin
2026-07-14 13:17 ` David Hildenbrand (Arm)
2026-07-14 13:24   ` Michael S. Tsirkin
2026-07-14 18:05     ` Link Lin
2026-07-17  3:02       ` Link Lin
2026-07-14 18:21     ` David Rientjes
2026-07-14 18:52       ` Michael S. Tsirkin

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=59e3dae7-a203-2e1d-3b65-875b7e0e122b@google.com \
    --to=rientjes@google.com \
    --cc=ahwilkins@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.duyck@gmail.com \
    --cc=ammarfaizi2@openresty.com \
    --cc=david@kernel.org \
    --cc=duenwen@google.com \
    --cc=gthelen@google.com \
    --cc=jasowang@redhat.com \
    --cc=jiaqiyan@google.com \
    --cc=linkl@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mst@redhat.com \
    --cc=prasin@google.com \
    --cc=stable@vger.kernel.org \
    --cc=vbabka@kernel.org \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox