[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] xen/domctl: Fix double domid_free in XEN_DOMCTL_createdomain error path
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
- Date: Sun, 14 Sep 2025 13:16:05 +0000
- Accept-language: en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1CJzf1o3FIkwIZND5pCfpJAVKyuUylbQ8n2PwOOqp5A=; b=PR3wuc3AsEEwmDkInsBqe2DulFJAh18AY6/mtZqRCVL1PV0AYrp2GLzyDzIXiLmKFnou9NE+ta9F6yQx1x6CAEUTBIjIfdw//Pkvb2+DeE7TI0aJX1HE6pCYuJLFtbcITlqdOSyclsHWRPk1ok4v9gsoiqSw8xHthElvHt5+dL2y2Wad24mZcd5VSn5BpJBcEnCehtBW8X+TuQC7PfbHLhsSUGp0wqeGu3UpbK/J+65Hvfxkfnfla1tYnc/mS0F94f9lAEzf92F/GfAoffgxc1otUCk582JPnwSgxg9Gx/jZfUoojDNbjsTpJgcOhRf+4YS7JrPWg1WAOkkWrhrA4g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BUCoz7cJkjo/8x6YP47E82iDC+/7fySvX5rmXnlyHgW36tPicn5jBEKtqFifuy13YPvx/rsXkbYsb5pZkG7HacyxmO5wwtkuDqh0Ba38kke/8foQZoLOjQ03Y73fzPViSPLdPkUU4jNk9vbWzZPSniGMj51wuLVNnqWsuZ1V8xugnCUjTD19WKVjNkKmBWTBu+ouHAV63aePm9OrZS5/NuqDNRUwm3aijaJePe5z7TRur2oW74DP3fer5cZMN6sHsuhrLkMMUUIRVn1rJEJFIIwIbJ84oK/mHKvWnEx7k7sxyUgQSq25/FUZ+E8Xss+6ARnoHVgXjSVfYOY+G7yBBQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksii Moisieiev <Oleksii_Moisieiev@xxxxxxxx>
- Delivery-date: Sun, 14 Sep 2025 13:16:35 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcJXm5/L1/35fsPkySCbuTTizhog==
- Thread-topic: [PATCH v2] xen/domctl: Fix double domid_free in XEN_DOMCTL_createdomain error path
Remove redundant domid_free() call in the XEN_DOMCTL_createdomain error
handling path to prevent a double-free condition.
When domain_create() fails, it internally calls _domain_destroy() during
its cleanup routine, which already invokes domid_free() to release the
allocated domain ID. The additional domid_free() call in the domctl error
path creates a double-free scenario, triggering an assertion failure in
domid.c:
Assertion 'rc' failed at common/domid.c:84
The domain creation flow is:
1. domid_alloc() allocates a domain ID
2. domain_create() is called with the allocated ID
3. If domain_create() fails:
a) domain_create() calls _domain_destroy() internally
b) _domain_destroy() calls domid_free() to release the ID
c) domctl incorrectly calls domid_free() again
This double-free violates the domain ID management invariants and causes
system instability. The fix ensures domid_free() is called exactly once
per allocated domain ID, maintaining proper resource cleanup
semantics.
Fixes: 2d5065060710 ("xen/domain: unify domain ID allocation")
Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
---
Changes in v2:
- add "Fixes:" section to the commit description
xen/common/domctl.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 71e712c1f3..954d790226 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -421,7 +421,6 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t)
u_domctl)
d = domain_create(domid, &op->u.createdomain, false);
if ( IS_ERR(d) )
{
- domid_free(domid);
ret = PTR_ERR(d);
d = NULL;
break;
--
2.34.1
|