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 5E5DBCD98E1 for ; Tue, 16 Jun 2026 09:52:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1338971.1600063 (Exim 4.92) (envelope-from ) id 1wZQSc-0003yZ-J3; Tue, 16 Jun 2026 09:51:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1338971.1600063; Tue, 16 Jun 2026 09:51:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZQSc-0003yS-G3; Tue, 16 Jun 2026 09:51:58 +0000 Received: by outflank-mailman (input) for mailman id 1338971; Tue, 16 Jun 2026 09:51:57 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZQSb-0003yM-4n for xen-devel@lists.xenproject.org; Tue, 16 Jun 2026 09:51:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZQSa-0095hh-HZ for xen-devel@lists.xenproject.org; Tue, 16 Jun 2026 11:51:56 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a311cbc-bab6-0a2a0a5309dd-0a2a45039dee-2 for ; Tue, 16 Jun 2026 11:51:56 +0200 Received: from [209.85.128.47] (helo=mail-wm1-f47.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a311cbc-672d-0a2a45030019-d155802fa880-3 for ; Tue, 16 Jun 2026 11:51:56 +0200 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-490b8ac62baso41897205e9.0 for ; Tue, 16 Jun 2026 02:51:56 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa8b423sm65392005e9.11.2026.06.16.02.51.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 Jun 2026 02:51:55 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1781603516; x=1782208316; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=05fGKlc1rUu1TVLYOAFiDjjkaHU95ZE7aSJ6WAMBQJU=; b=C/YjfMAnqkJZd3qlqQx/ZED+Qe4iNDs2HfxgrRSFNPdLOyrVQIVghhzexTJZNJ19b1 NXKb9Wb8+IRcNlyzT5Io/686A7F0bAbwBXVcrZ6Yqn0PIfAQnTEoIAekDx1zUowp2nDA 5226ZpIYJb92H3ieRMyknV93+TQWlF9o8dxBLj77KvGvz4IvM8eVI1ZKI4m4PzaSqxsU 9uB1B3nj68n/bexewJxK/5qiyJAsamneYm9BqQkZ6w57pZPmyk9nAAoEvxA9Vky5Qq0U 0Waa0gcYhwGKlF8u1ZhUmbBu4OJXJ00ALhOiJdjc2tBUMTJbzKPM817IHtmbDSY1wnJH qBxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781603516; x=1782208316; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=05fGKlc1rUu1TVLYOAFiDjjkaHU95ZE7aSJ6WAMBQJU=; b=DVGEVhdOxprp6DelRKwbebzRgaF8Tamo6grmW9kGa3EbHBMMDpoSMUVzZiXBDku+sw fVjrWSdOrf88hub96TdGaVsWjawGGLjNDpTI23i+MmDmtXop2oYmvaK1R/Ubx5RCwu6W i2TK9fK+o6QSe4OSCXczV5CdrfSqGgPKtPm9C1F2LwaJkYpIMmjr2D5iWZ947L1BvNlF ggDvdxny/K60py4SIOmQ2vQXrmWLL3xG1lDxtIQKp8wvi0va1vM/XsllhTlnQiqgb5s2 uTNizKKbs8wL2ndOAPkKqqvZTW/amOW0fwQCr4KNsXn+IwUYSfCT62da1yKP4eDB2J+c CmlA== X-Gm-Message-State: AOJu0YxNPWIBv7vLJTF9d7DyWOx5yzKUoie/OJMGvkLbSXAYl07utL1g pv8XuwsC9XNZROwkX8/77E9frtoot68w6bapi0tjHCDm6cPRmdoU4MgigIkQEf5VuBqowEtr2KZ 16CA= X-Gm-Gg: Acq92OGLLFEm39SL65jSSsDjXz35dMWsa6yO2I8i5tDnJW4L9GX90yjpZ9e33Rmb09Q TbLnmeCzn0d/chr1YQJapg8ibFozLknDZuyVnvH8ilZVQG4ii+BijoGz/36/id7mO9qdyOeohDT Idu6YhR4CrKabQyHSuEGlzYdzFrT2TxjZWXYdGTkSKVGaiXoTc5f4T97AtFN2456e+wLSHlFk2v 52rcrAitfyAmZDrsXKiRPAB+ZbOGsy21BUN1hOTFroM0odCUS3eSaCIxnYpWgXYYPfD/PahkF9Q fvSiTDazBUlk7ApWsxiWNl7gords/Av/F/cJTKI5NHd5QvAvjMW5gbq6LEoBFl/4CvDlkgeuP3j p6QNqLZFa7l+EEcTsRHbIibSQqX6JzZ23iptr4vkHIu/Irz/aItpLVd0QW3p25s2O7/hkNLx3yJ uqYsvHCa/iN3rM/gtI8U5UOjIBGmntMNY2HgJvLeKJwxZuBDRz7p4WNX7T1qFbd38psn3Bakfw8 kHLadqMyXHWCWY= X-Received: by 2002:a05:600c:c4a6:b0:48f:e230:29f4 with SMTP id 5b1f17b1804b1-4922fafbd30mr36297345e9.15.1781603515634; Tue, 16 Jun 2026 02:51:55 -0700 (PDT) Message-ID: Date: Tue, 16 Jun 2026 11:51:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH for-4.22? 7/9] domctl: restrict permission check for XEN_DOMCTL_memory_mapping's remove form To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: "xen-devel@lists.xenproject.org" , Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , Oleksii Kurochko References: <5f49f890-426e-4076-8326-c2fbff433a35@suse.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72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Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-33051d/1781603516-3BB6C938-41553071/0/0 X-purgate-type: clean X-purgate-size: 2283 On 16.06.2026 11:08, Roger Pau Monné wrote: > On Mon, Jun 15, 2026 at 04:15:36PM +0200, Jan Beulich wrote: >> Like is already done for I/O ports on x86 and for IRQ unbinding, check >> only the requesting domain's permissions (for it to not interfere with >> MMIO backed by another stubdom DM), but not the target domain's: Removal >> should be okay even (perhaps: especially) when permissions were already >> revoked. >> >> Signed-off-by: Jan Beulich >> >> --- a/xen/common/domctl.c >> +++ b/xen/common/domctl.c >> @@ -436,11 +436,15 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xe >> goto domctl_out_unlock_rcuonly; >> #endif >> >> + /* >> + * NB: The double lock isn't really needed when !add, but is used anyway >> + * to keep things simple. >> + */ >> iocaps_double_lock(d, false); >> >> ret = -EPERM; >> if ( !iomem_access_permitted(current->domain, mfn, mfn_end) || >> - !iomem_access_permitted(d, mfn, mfn_end) ) >> + (add && !iomem_access_permitted(d, mfn, mfn_end)) ) > > You seem to be doing the opposite of what the commit message states > here, and checking for permissions on the target domain, not > permissions of the requesting domain? I'm always checking permissions of the requesting domain, while the target's are now checked only for "add". That's what the description also says. What's wrong with the description is ... > XEN_DOMCTL_ioport_mapping does check against current->domain, and not > against d. ... that it suggests this to be the behavior at the point of this patch, when it really is moved to that only in patch 8. The patches used to be ordered differently earlier on. I guess I should change the wording to be closer to what's used in "x86/domctl: don't imply I/O port permissions from I/O port mapping". > FWIW, we could also remove one branch here by doing: > > ret = -EPERM > if ( add && iomem_access_permitted(current->domain, mfn, mfn_end) ) > { > /* add logic. */ > } > else if ( !add ) > { > /* remove logic. */ > } Indeed I was wondering whether something like this would be worthwhile, but I opted for the variant with less overall churn. Jan