From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7701357D0C for ; Mon, 13 Jul 2026 19:41:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971671; cv=none; b=aKmJkFhf4HOT0U2+ZuuxQYv/zS9DV3I+q3PYHdbk8/Z+eDn3BGj4Sn/iuUQYfx8u9f7ETY+2TmSTrR8hCjPlE3krKdXmH10vpNJnzCXuFylDfUlZykfDIrMSkU35yvvibwL0/KWSJr6cFe1gYidtmMSOUe9CKO/23tqLSAPTAyc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783971671; c=relaxed/simple; bh=Z380FDqsxBLRnjMA6hntXYmI+33qpOSqSr+3iFUF4c4=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=bkl6gpKPBu95Xdm3FLT4CVV/5QtRhCmZ7/nWFlHN3iy6VbRt5+u+IzRaCyg2edqaU0ID9HfVE/3Hf1tdOen0q5F0C58h9ScGXEmyT2fUMmT3b1uoXKc/AuavNcZTgoWXJiNZOD7iMgX4bsyQRqkgO6ZXKAO7rm0PBdJyMjwf6gI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K43GFH2y; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K43GFH2y" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2cede6375caso35425ad.0 for ; Mon, 13 Jul 2026 12:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783971669; x=1784576469; darn=vger.kernel.org; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WLh7SflYriIICq2322YWz4Oz4v42mpNRc7r49x5w7jo=; b=K43GFH2yL+r/OsUVMv27QZYXyl2G9SUmmydd+wUcOzHdHc9x0wk5t/LiRIwqaG2sps /aO4aA9/7dq537hGDOEvOCPw/QTu0M3EJACXQioqM83r1QIy6ZkpzvItOdMfLLBNxRj8 GyKDl0gRwI5WL6S9Le3f76ujp9lcizDWNspFfXxURJCtT9Bc3S9ngaafwfjbZ27SWIY+ vskqCJGrb7zXwBqyxlTO4/wgI9h/qXTg5Vm0YO3iDov1pzHlskgfdNbRm7+SZk6e1Qiv L5zLctQkAfLwxn1xFsZp1UWuLFhuJppkGADsy8+FZUwToI9FQBnWFgR0r+9IKmMjeWbW CIiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783971669; x=1784576469; h=content-type:mime-version:references:message-id:in-reply-to:subject :cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WLh7SflYriIICq2322YWz4Oz4v42mpNRc7r49x5w7jo=; b=hgeuEQrPtQnBrYXLO6F4egNEASrfcRDkP/dvElCqzLx/s9zfvypDLB4vAkn5YOptyb 1KMlxp3TjNLYtGDP29Ln9xV9/ECxIf5h/GqxCUJ142UtgCn0Uaft9/QWI2Lr06DePas4 5O/Yua7Aj2PDkprT3HasQevxaSeOROTJVlWD4Rm33TtvUgQJA2HXIRkm9/u7IhlSaHLP EreZqx6uHNcYPenwO1q/7OUK4xykMoVgIv+g6P0EICHkxLLGk7pVC3qUzgsQSK/sc7PT Iqd9gB7/0xQIKahMbOMG6sYAVVzF8nymSvVN2BaP8AVoy7xxdOy9x24n3fAz55nqqZwa 435g== X-Forwarded-Encrypted: i=1; AHgh+Rr6UMcGkX2w/F445mJaYHfUOaE/WxF+f7PNUMUQHmOkuvnMfjYWlzm0VJu76vk40p3OhCWntsaT+eGpFf8=@vger.kernel.org X-Gm-Message-State: AOJu0YzUMNt0x9HCDcAjqMnOFKjprXu3XZgj2aWFjZACVrwPzmDczDJb iu3DUZulqculBwLJKckByW9C8TlPGC7pB+kNpo+ezC3qvfbM6MCWtjQMmAEo2/gyOQ== X-Gm-Gg: AfdE7ckp34R2Pb/iXKvVZfMWhv38LSQN5TyXbOeMEEwpUk4RSAzJM7twwPKWiV1RM1V mS7McvMyMK85Aach7zoD+KoTdzs0auWkyUozehpisJKR+y2D0pJ2MRXgoeJWavZvMjnC+6ia7No VZOnKZofhTGIlQbEZdfinYcgp17waBdcK6oTzslC19PrFW5spkfVXRKnGHz8biC4kQZQ/JIxULN YjE9MGZhg14RUlJQOUe6irjj3viHNejErUd9ai97CsFlHgHpAX/9/OEyaDnavYMVRKlB6Mgovvc dZsWeJMOEDMypYAgA9ZzSKGMNfONjQpf89ADJVMXvfIvbvgdYW4nRkl7fx2ruSzRoOmQdk++oPz Gapf7V9mKdYoCqYA1HsSfLMh00ChfMFJR+/pPCoXW32nLjj2siVzqldme4sLbhomS1IyYtv5mRV QbABh5vbhP1rOgrHW5bF2fdmTm8NgMqvNQYUFgzLSWID1WEuIglZ23GOjJ5Tkch9E2xhtFOTVeE 9zRpqkezyqWkIrRKftST3kxc5CZhOK7Vq3FVtg3FCZjbqWMy6xy6Q== X-Received: by 2002:a17:902:fd83:b0:2bd:6dad:3dfa with SMTP id d9443c01a7336-2cee1ccc432mr2429565ad.24.1783971668691; Mon, 13 Jul 2026 12:41:08 -0700 (PDT) Received: from [2a00:79e0:2eb4:9:4c33:68fb:770e:3e89] ([2a00:79e0:2eb4:9:4c33:68fb:770e:3e89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84a4f6c158bsm272977b3a.38.2026.07.13.12.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 12:41:07 -0700 (PDT) Date: Mon, 13 Jul 2026 12:41:07 -0700 (PDT) From: David Rientjes To: Link Lin cc: Andrew Morton , Vlastimil Babka , "Michael S . Tsirkin" , 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 In-Reply-To: Message-ID: <59e3dae7-a203-2e1d-3b65-875b7e0e122b@google.com> References: <20260709224330.946683-1-linkl@google.com> <20260709161253.6b5e9ba349f70a3ebfb8180f@linux-foundation.org> 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 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.