From nobody Mon Nov 23 22:39:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1792762423; cv=none; d=zohomail.com; s=zohoarc; b=hsxUCYWVlbm5h3CcmnyVLHt321VuxX7WLv31yDrAH6HuAhtbuqCfGKr7SuqaHdbPfuV7TM9jBgyeKSOQC9zx10HacO1G4YWq5wSx3KoxpVgIP6CgCbrxWt3zQ9697rQHXDcwPng97ngK2aWXpvHVmgL4KLe8D+r75UFyyChkjwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792762423; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mguQbioMgtMh+Hd/Llm9Ull5AdKxQv7LibED4N9dzC4=; b=NJ37Z+F4lGyqyFDCKQ1UacWZlUgJqhvmdzTidNE8boKCJcsOU1fpPuJJgUL+reg6uzc0gGF5xiWQYmPxVuhIdZ+tWnOMohAgNWU5pJAIonNqrYoMLCsRXVhZl44vChCLP/lc05+B3F0rk2Olrb4mZ8x2frtXzstPmUqHhSLWC+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1792762423277501.83448616097076; Fri, 23 Oct 2026 06:33:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1459273.1671265 (Exim 4.92) (envelope-from ) id 1xKFOg-00029k-Tj; Fri, 23 Oct 2026 13:33:26 +0000 Received: by outflank-mailman (output) from mailman id 1459273.1671265; Fri, 23 Oct 2026 13:33:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xKFOg-00029d-QW; Fri, 23 Oct 2026 13:33:26 +0000 Received: by outflank-mailman (input) for mailman id 1459273; Fri, 23 Oct 2026 13:33:25 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xKFOf-00029X-Nl for xen-devel@lists.xenproject.org; Fri, 23 Oct 2026 13:33:25 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xKFOf-00000009CNX-2ZzA; Fri, 23 Oct 2026 13:33:25 +0000 Received: from 224.pool85-54-217.dynamic.orange.es ([85.54.217.224] helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xKFOf-0000000Ccbq-0y6g; Fri, 23 Oct 2026 13:33:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:Cc:To:From; bh=mguQbioMgtMh+Hd/Llm9Ull5AdKxQv7LibED4N9dzC4=; b=vphwwyHwktwkR/i37udhfAMaNk ZxdZtOk+5sQCc9oWfMBF02zknv6eauES7LXgtJVKnUJTzhUWzow3sqRmLSk0EZUTCx1zPsNuQgjAd 7kjlIjPgc4hZBTNzHh3x7SBVjHBGGSaZ/irAsnzTr0tvirLyqLWUe0fIpoHacz+8RQ8w=; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Teddy Astie , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini Subject: [PATCH] xen/vcpu: ensure no write when runstate handler is NULL Date: Fri, 23 Oct 2026 15:33:16 +0200 Message-ID: <20261023133316.64204-1-roger@xenproject.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1792762426518158500 Both the normal and the compat versions of VCPUOP_register_runstate_memory_area allow registering a NULL handler as a way to signal deregistration of the previous area, and update_runstate_area() will skip the update when the handler is NULL. However when handling the VCPUOP_register_runstate_memory_area hypercall itself there's an unconditional attempt to update the newly registered runstate area, without taking into account whether it points to NULL. Skip such update if the user-provided handle is NULL. Signed-off-by: Roger Pau Monn=C3=A9 --- xen/arch/x86/x86_64/domain.c | 4 ++++ xen/common/domain.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/xen/arch/x86/x86_64/domain.c b/xen/arch/x86/x86_64/domain.c index a02d4f569ee5..e4d49cbbfeb6 100644 --- a/xen/arch/x86/x86_64/domain.c +++ b/xen/arch/x86/x86_64/domain.c @@ -58,6 +58,10 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_H= ANDLE_PARAM(void) arg) rc =3D 0; guest_from_compat_handle(v->runstate_guest.compat, area.addr.h); =20 + /* NULL handle is deregistering the address. */ + if ( compat_handle_is_null(area.addr.h) ) + break; + if ( v =3D=3D current ) { XLAT_vcpu_runstate_info(&info, &v->runstate); diff --git a/xen/common/domain.c b/xen/common/domain.c index 6b52713518da..30a17b8b7edb 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -2330,6 +2330,10 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUE= ST_HANDLE_PARAM(void) arg) rc =3D 0; runstate_guest(v) =3D area.addr.h; =20 + /* NULL handle is deregistering the address. */ + if ( guest_handle_is_null(area.addr.h) ) + break; + if ( v =3D=3D current ) { __copy_to_guest(runstate_guest(v), &v->runstate, 1); --=20 2.55.0