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 1B6E9C43219 for ; Tue, 1 Nov 2022 15:29:13 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.434830.687468 (Exim 4.92) (envelope-from ) id 1optCG-0007ou-G3; Tue, 01 Nov 2022 15:29:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 434830.687468; Tue, 01 Nov 2022 15:29: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 1optCG-0007oc-Cs; Tue, 01 Nov 2022 15:29:00 +0000 Received: by outflank-mailman (input) for mailman id 434830; Tue, 01 Nov 2022 15:28:58 +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 1optCE-0007Tl-Fg for xen-devel@lists.xenproject.org; Tue, 01 Nov 2022 15:28:58 +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 e6ee5cff-59f9-11ed-91b5-6bf2151ebd3b; Tue, 01 Nov 2022 16:28:57 +0100 (CET) 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 6151F2256A; Tue, 1 Nov 2022 15:28: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 312DD1346F; Tue, 1 Nov 2022 15:28:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ycfICTk7YWOJYAAAMHmgww (envelope-from ); Tue, 01 Nov 2022 15:28: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: e6ee5cff-59f9-11ed-91b5-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1667316537; 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=wnyre0lY6vh0o8N40Ag5noXJoA9j7rscMFp/jnaPIq8=; b=Zn1xF+Ym/ToL4Sea/vmyDRyR+YP9a0QGM/fOrIlRVDmhnWgjY67i9mtfxFj+fd6smJpMfC dB3+Hf2D27zHF24nuIjT/U7cH1kDHYB1SykNnHSFKuvibo1HnoNn504Bdgdo+L9ekqltmu 8A0EqqpmOYtjJ6oRGv3Q+TCaPMIcrUU= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH 02/20] tools/xenstore: call remove_domid_from_perm() for special nodes Date: Tue, 1 Nov 2022 16:28:24 +0100 Message-Id: <20221101152842.4257-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221101152842.4257-1-jgross@suse.com> References: <20221101152842.4257-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When destroying a domain, any stale permissions of the domain must be removed from the special nodes "@...", too. This was not done in the fix for XSA-322. Fixes: 496306324d8d ("tools/xenstore: revoke access rights for removed domains") Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- tools/xenstore/xenstored_domain.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 84b7817cd5..aa86892fed 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -227,6 +227,27 @@ static void unmap_interface(void *interface) xengnttab_unmap(*xgt_handle, interface, 1); } +static void remove_domid_from_perm(struct node_perms *perms, + struct domain *domain) +{ + unsigned int cur, new; + + if (perms->p[0].id == domain->domid) + perms->p[0].id = priv_domid; + + for (cur = new = 1; cur < perms->num; cur++) { + if (perms->p[cur].id == domain->domid) + continue; + + if (new != cur) + perms->p[new] = perms->p[cur]; + + new++; + } + + perms->num = new; +} + static int domain_tree_remove_sub(const void *ctx, struct connection *conn, struct node *node, void *arg) { @@ -277,6 +298,9 @@ static void domain_tree_remove(struct domain *domain) syslog(LOG_ERR, "error when looking for orphaned nodes\n"); } + + remove_domid_from_perm(&dom_release_perms, domain); + remove_domid_from_perm(&dom_introduce_perms, domain); } static int destroy_domain(void *_domain) -- 2.35.3