From patchwork Tue Apr 19 13:52:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12818553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EE84C4332F for ; Tue, 19 Apr 2022 13:53:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.308146.523705 (Exim 4.92) (envelope-from ) id 1ngoHs-0003nb-EP; Tue, 19 Apr 2022 13:53:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 308146.523705; Tue, 19 Apr 2022 13:53:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ngoHs-0003nU-BS; Tue, 19 Apr 2022 13:53:00 +0000 Received: by outflank-mailman (input) for mailman id 308146; Tue, 19 Apr 2022 13:52:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ngoHr-0003n8-7U for xen-devel@lists.xenproject.org; Tue, 19 Apr 2022 13:52:59 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 04ee214f-bfe8-11ec-a405-831a346695d4; Tue, 19 Apr 2022 15:52:58 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 99CC12112B; Tue, 19 Apr 2022 13:52:57 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 52884139F6; Tue, 19 Apr 2022 13:52:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qIzvErm+XmL/EgAAMHmgww (envelope-from ); Tue, 19 Apr 2022 13:52:57 +0000 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" X-Inumbo-ID: 04ee214f-bfe8-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650376377; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U4wJ7ITwhPEI/c6FS563E3yxL+vilAPqU1YHXYgdh9M=; b=Hf6Slkfb596jSsL3JpkD7yHvevxLV4Qye9KDHHZ/dDIveP3Ydu2S3uG2BMPWYjShF7hr// b2WPKajFuirm/rkkY0+WSALlMYvz2yySc2cxBP1+6Jl8nmLjgaJT+D1J6aDCC8ZmF3EAZ9 Pc/xwSB3toL7eopkTTrpsWGYanuwNlQ= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu , Cheyenne Wills Subject: [PATCH v3 1/3] xen: fix XEN_DOMCTL_gdbsx_guestmemio crash Date: Tue, 19 Apr 2022 15:52:52 +0200 Message-Id: <20220419135254.21729-2-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220419135254.21729-1-jgross@suse.com> References: <20220419135254.21729-1-jgross@suse.com> MIME-Version: 1.0 A hypervisor built without CONFIG_GDBSX will crash in case the XEN_DOMCTL_gdbsx_guestmemio domctl is being called, as the call will end up in iommu_do_domctl() with d == NULL: (XEN) CPU: 6 (XEN) RIP: e008:[] iommu_do_domctl+0x4/0x30 (XEN) RFLAGS: 0000000000010202 CONTEXT: hypervisor (d0v0) (XEN) rax: 00000000000003e8 rbx: ffff830856277ef8 rcx: ffff830856277fff ... (XEN) Xen call trace: (XEN) [] R iommu_do_domctl+0x4/0x30 (XEN) [] S arch_do_domctl+0x7f/0x2330 (XEN) [] S do_domctl+0xe56/0x1930 (XEN) [] S do_domctl+0/0x1930 (XEN) [] S pv_hypercall+0x99/0x110 (XEN) [] S arch/x86/pv/domain.c#_toggle_guest_pt+0x11/0x90 (XEN) [] S lstar_enter+0x128/0x130 (XEN) (XEN) Pagetable walk from 0000000000000144: (XEN) L4[0x000] = 0000000000000000 ffffffffffffffff (XEN) (XEN) **************************************** (XEN) Panic on CPU 6: (XEN) FATAL PAGE FAULT (XEN) [error_code=0000] (XEN) Faulting linear address: 0000000000000144 Fix this issue by making sure the domain pointer has a sane value. Reported-by: Cheyenne Wills Fixes: e726a82ca0dc ("xen: make gdbsx support configurable") Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- V2: - use gdbsx_guest_mem_io() interface modification (Jan Beulich) V3: - avoid d being NULL (Andrew Cooper) --- xen/common/domctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 57135d4478..5879117580 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -308,7 +308,6 @@ long cf_check do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl) if ( op->domain == DOMID_INVALID ) { case XEN_DOMCTL_createdomain: - case XEN_DOMCTL_gdbsx_guestmemio: d = NULL; break; }