From nobody Sun Jul 26 10:12:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1783492847; cv=none; d=zohomail.com; s=zohoarc; b=AWRFiBF6/KrnL1KH0zbNQ4SAT/avvCymq+de2wqaVeLIOaVAkKUVLfq0ckOnfT22Bo8goTo1uANy9sBvqqCz83Az0pbv3uPCsuxuH5GCI87FRL8fTYqJl9N3OKQ7hNxxI5zSWmbhvD2wwLDHR9alaVzDEbPPFVBptr2Nc7Fevi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783492847; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dFjK7040VSDJVrCG8QTqORNFfMnw/hbLRV77DR5qG2w=; b=Y1/qUGIqZl3eEXabgfcTTswr7g1wx7BhnDISei3S87WVtIO507ackfdiZ3iL4ugqGFnQ75fpfVc5NLFjGYRHPaybvYb90q0G+4+p1p3eI6VP2izG+Qj4OI836pZN+ZcViri7W6SmlCsxhZfvKUsRcaNON+0CHRV+ZKTX84oxQag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1783492847714761.3145831754266; Tue, 7 Jul 2026 23:40:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1whLx2-0001uX-2B; Wed, 08 Jul 2026 02:40:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whLwp-0001tX-W0 for qemu-devel@nongnu.org; Wed, 08 Jul 2026 02:39:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whLwo-0005m3-23 for qemu-devel@nongnu.org; Wed, 08 Jul 2026 02:39:55 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-b4i_VazsN3u0HMgLpakg9Q-1; Wed, 08 Jul 2026 02:39:48 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E7C3A1955F73; Wed, 8 Jul 2026 06:39:46 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 668501955F7B; Wed, 8 Jul 2026 06:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783492791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dFjK7040VSDJVrCG8QTqORNFfMnw/hbLRV77DR5qG2w=; b=gJSdQHJt9CxMo1J793SflnxqRBCEinXPeegzFUG7hmeL7/FTU6VD3ngqN6VeByFf9WoW3v rlh39C1zUet2j3Fjhefbb38W/PX86FkuNbxsC7cppA3J73oB7PpvSdtmGUw39vjoVxS9bV YNeJ7X2egXNgzme6HtWXauytH0rZ6+Q= X-MC-Unique: b4i_VazsN3u0HMgLpakg9Q-1 X-Mimecast-MFC-AGG-ID: b4i_VazsN3u0HMgLpakg9Q_1783492787 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Amit Shah , Laurent Vivier , Jia Jia Subject: [PATCH] hw/virtio-rng: Fix host use-after-free (CVE-2026-50624) Date: Wed, 8 Jul 2026 08:39:44 +0200 Message-ID: <20260708063944.1788243-1-lvivier@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=lvivier@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1783492851271158500 Content-Type: text/plain; charset="utf-8" Fix a heap-use-after-free in the virtio-rng frontend when a delayed rng-random backend completion arrives after the virtio-rng device has been hot-unplugged. Fixes: CVE-2026-50624 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3917 Reported-by: Jia Jia Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- backends/rng.c | 16 ++++++++++++++++ hw/virtio/virtio-rng.c | 2 ++ include/system/rng.h | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/backends/rng.c b/backends/rng.c index ab94dfea850a..182269be4a83 100644 --- a/backends/rng.c +++ b/backends/rng.c @@ -68,6 +68,22 @@ static void rng_backend_free_request(RngRequest *req) g_free(req); } =20 +void rng_backend_cancel_request_entropy(RngBackend *s, + EntropyReceiveFunc *receive_entrop= y, + void *opaque) +{ + RngRequest *req, *next; + + QSIMPLEQ_FOREACH_SAFE(req, &s->requests, next, next) { + if (req->receive_entropy !=3D receive_entropy || + req->opaque !=3D opaque) { + continue; + } + QSIMPLEQ_REMOVE(&s->requests, req, RngRequest, next); + rng_backend_free_request(req); + } +} + static void rng_backend_free_requests(RngBackend *s) { RngRequest *req, *next; diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 66690a34dc97..a77ea5ab1385 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -234,6 +234,8 @@ static void virtio_rng_device_unrealize(DeviceState *de= v) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIORNG *vrng =3D VIRTIO_RNG(dev); =20 + rng_backend_cancel_request_entropy(vrng->rng, chr_read, vrng); + qemu_del_vm_change_state_handler(vrng->vmstate); timer_free(vrng->rate_limit_timer); virtio_del_queue(vdev, 0); diff --git a/include/system/rng.h b/include/system/rng.h index e383f87d20b2..5b0893eb2bd5 100644 --- a/include/system/rng.h +++ b/include/system/rng.h @@ -86,4 +86,18 @@ void rng_backend_request_entropy(RngBackend *s, size_t s= ize, * deleted. */ void rng_backend_finalize_request(RngBackend *s, RngRequest *req); + +/** + * rng_backend_cancel_request_entropy: + * @s: the backend that created the request + * @receive_entropy: the function invoked when entropy is available + * @opaque: data passed to @receive_entropy + * + * This function is used by the front-end to cancel all requests to a + * given backend. Requests to cancel are identified by the receive_entropy + * function and the data passed to the function. + */ +void rng_backend_cancel_request_entropy(RngBackend *s, + EntropyReceiveFunc *receive_entrop= y, + void *opaque); #endif --=20 2.54.0