From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6335D35AC3E for ; Mon, 13 Jul 2026 19:43:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971807; cv=none; b=FYgB2VbL40CUEPrafBI04i8mOIO/wdxbEEKwRukT96khzDYqqPt6GN/84P7uF3v+QyPGkLWyFlcHlHE+GW2LRl44PyurJsOT0/RvkvF2auNRKxphsqca0AILtQPdUyA1Fx0fkousTcVFhq+c1DUxRdbGjOWUmDfzwGcPz6HuhSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971807; c=relaxed/simple; bh=+D5yjWN6rVMXpGyTufspKcyF6W9cMssILiwjIivzAPg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WW7st/HrNIsdIzGhGGIy0C0Q+LnOv1txlIlC8gMpjwjjsAAwzy7+B/ckD7vUe0+WshDmmMiXXNaqRFE3xDBHU0uYDzOuSd87EJrnEVwA80ZcpNf+keQfytP34hNjI+yNMISxX5aScGTlxgWir3e19IXg7mfLz3ljM+hjEsOCczw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aBDIKZHa; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=fJmqsdV2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aBDIKZHa"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="fJmqsdV2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783971804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Oh/99NzF4tGS13cUL+eRJ8P8DrHZhD3bwsodlnkuIoc=; b=aBDIKZHalXNWNIhdnnQfIgIyO1jRKG8xv+eESO+WctxpnLo8Hydv0enVwOmE3BsJ2OJoIo WF+PxwTHzEvuk611pV7FY+T42LibMzt+1s8lsz2lBHilpOjOGOxA/L0rwzDNHuBO+FdN3L VKw9nzmVChNNvNLKTdQBUbwUP2On9XU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-457-v2wOoXG-M1efYw-ltDwDMA-1; Mon, 13 Jul 2026 15:43:23 -0400 X-MC-Unique: v2wOoXG-M1efYw-ltDwDMA-1 X-Mimecast-MFC-AGG-ID: v2wOoXG-M1efYw-ltDwDMA_1783971802 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4784d0fb9cfso146714f8f.2 for ; Mon, 13 Jul 2026 12:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1783971802; x=1784576602; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Oh/99NzF4tGS13cUL+eRJ8P8DrHZhD3bwsodlnkuIoc=; b=fJmqsdV2/nmyZhsmqa+20YytvG02f5kGwRyg7PhVyez4MKCHf5jlDELR68rKrZZeVk IDkG/EK/AAFe2TcP/nTPSFJX8T3NBkG76MmkN3WcDpydpSqHF469Jf/Vi5ykXhsd+Vi5 iBYK/OgamXEALY9YV7havrHxZ/xctWveOzA4bmIohzpWSwqx2Qb1XrNphqbeihBA5yEo /AbqJFFiUmiWF08P7XM2fR9o8JP1z0nB70p/JvNZ5JhpJ35yjrusBDyC1i5xF7zm//tZ 6FgOSwNKe+Fgo1DAno3qxrwrvQf6/nl2PaYZIaalcnmmetpgV4wVQBPj7X1mkSdaW1rf S09A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783971802; x=1784576602; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Oh/99NzF4tGS13cUL+eRJ8P8DrHZhD3bwsodlnkuIoc=; b=A4CtDEVgL5XLCoT12qGWlmIeUpEyMaAJJuE8Pjiooc5316LWVfKIzGlHsIrSHphA+1 ipGJ24/xQDSATR7kFVRdAr5XT9o1mjrd8lX2fUB5FNThCRrxY6DtWj8GCMLqjbG/XUvx 5/TJ3SIaj1x8HjfsEjR25p4oY4a/vwr/F96APtRxwSRqlN/INcd7N2dItBrS2VkETaRZ koeXifj9HXRUIUYLZqUQ3O9B5SiVe0c323tuvJjecz1GSoIbVScovNnmU+B7bqhoW5pL wi80FAl+TtFJPRzfGMF9jSZH6OCmZhkJy1AcQCt65Q98WQ9QLgaBpMV+yYTHc2Uf4fnb mnLA== X-Forwarded-Encrypted: i=1; AHgh+RpDG6GRlwpNMzkEncmfYgO+gz6+eQf+798bvXvwrT/24x/QF1xwcBwfVyurcNckC20h9OEfURZzttRLpgQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzjdOi4Kj8JoTVzqQLPx/0gqS353TJdJ2bpXeMqth/NONGcnTbA OmGBiFgSA4MW2ttpMo3jUZxqofhZEXYkzMreE1BnzysbITvf1H2XODJYsaeRB5nvNz8PJxOh5dW FpPhi82Jo44JMd/4U44hEqHn2vl9lgZ2VJSMsCgeKiELml0v9TjSuvopraheCnVSXjg== X-Gm-Gg: AfdE7clIgJBZiin33vs66oR+YXd3MtJh5SmzC1ZdQztIv4eG9wAChSQQ7+0UWg2w5ww TirIga7kkBt3byz8HK9/rGVDPYpD4LIthh8heQwm4fhmfUYotFzmycRPz+DvKAyBNTBOE//qjve NRfEkDWKzKisOO17M7b8uQdVpVTts9pF6PC4oXhmOD04/wGOhk5h0/sdf2PjXrznW68iHpLSx/C qq/zr2iRZ+q+FOog5N6hwZ4nB75Ani2TzYQBQYtvDIuoZvwUjkVd0CdZqCH51bafHeYB3f1Y4+R iV0Da0vR6sKiLXaSMIsq5ccfofa429FFCzL5/4fQhvuzMBg916Focy9dAMs4v+YPShjO+Zks/dP vjgrcRWc1nWDpsUxbpe/XrAimkdzKqq0+iwc= X-Received: by 2002:a05:6000:1841:b0:473:823:1924 with SMTP id ffacd0b85a97d-47f2dcd7860mr13165058f8f.39.1783971801739; Mon, 13 Jul 2026 12:43:21 -0700 (PDT) X-Received: by 2002:a05:6000:1841:b0:473:823:1924 with SMTP id ffacd0b85a97d-47f2dcd7860mr13165028f8f.39.1783971801248; Mon, 13 Jul 2026 12:43:21 -0700 (PDT) Received: from redhat.com (IGLD-80-230-24-117.inter.net.il. [80.230.24.117]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f4634e0e4sm1936476f8f.4.2026.07.13.12.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 12:43:20 -0700 (PDT) Date: Mon, 13 Jul 2026 15:43:17 -0400 From: "Michael S. Tsirkin" To: David Rientjes Cc: Link Lin , Andrew Morton , Vlastimil Babka , David Hildenbrand , 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 , jiaqiyan@google.com, ahwilkins@google.com, Greg Thelen , Alexander Duyck , stable@vger.kernel.org Subject: Re: [RFC] virtio_balloon: fix Use-After-Free in page reporting during PM freeze Message-ID: <20260713154243-mutt-send-email-mst@kernel.org> References: <20260709224330.946683-1-linkl@google.com> <20260709161253.6b5e9ba349f70a3ebfb8180f@linux-foundation.org> <59e3dae7-a203-2e1d-3b65-875b7e0e122b@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59e3dae7-a203-2e1d-3b65-875b7e0e122b@google.com> On Mon, Jul 13, 2026 at 12:41:07PM -0700, David Rientjes wrote: > 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. It does not matter much but yes separate ones are a bit better if each can be applied independently.