From nobody Thu Nov 12 15:08:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1793101066; cv=none; d=zohomail.com; s=zohoarc; b=hzVO5j8KtE9/3+XzmLkL5BsFdHX3lxPTWRwKWMbhRQwlbBEAwkbZiKVZf0lmtNRUGz5sakiWDhlNxPYEQm0PFvK9kywc0o92mYGuByw2qJYWg0T/BD1L+Z0QHfRVUlCVhCxG/0Sg42TnqL7/0R0Q6uHcn3D++lEgZb0hdA7awcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793101066; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id:Cc; bh=h3mnjWH2tbdUWwJK/N/b+3V/4RNgG8u2KMeQ4dmWgps=; b=fZxNdvwuAkbtI9gX4129QRHPdl+gJxkNxPWRzFl/dmsuaG59YtYDaqa+9pqp1xndw1c1ueFiIgzwC6+m0dXfWA+xDUP21AwLzhYRoiWuyaI1p58AqSEUxqxsgpxpawi7SyS+GEC9AZQSSy/68NBzpYC+Oy0Ky7Z9WyE4lvBORF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1793101066168353.60934483884705; Tue, 27 Oct 2026 04:37:46 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B127041B0C; Tue, 27 Oct 2026 07:37:43 -0400 (EDT) Received: from [172.19.199.19] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 3167541BE2; Tue, 27 Oct 2026 07:36:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 292B33F33B; Tue, 27 Oct 2026 07:36:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 28EB83F289 for ; Tue, 27 Oct 2026 07:36:40 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-J639BjkZMheVr5cNzsWvLA-1; Tue, 27 Oct 2026 07:36:33 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 44121180067C for ; Tue, 27 Oct 2026 11:36:32 +0000 (UTC) Received: from mprivozn-thinkpadt14gen4.tpbc.csb (unknown [10.43.3.180]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A5420195608B for ; Tue, 27 Oct 2026 11:36:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1793101000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=h3mnjWH2tbdUWwJK/N/b+3V/4RNgG8u2KMeQ4dmWgps=; b=IGfpB+NeJl8AhKF75A7s3QziT7+Y+dUHEWbBwRNfiKUnxeJRYy9xukR5nAqG1BnL9xCrP0 dfrw1MTVg+q93tDB1+WX4OenDJbnUhExeAEJsxEWvPczlS7EXooDtiGlu3bPfqWi3dLiRN 0Z/Dyg2wM4o9oEIcZ34P1zRDSBvOk8o= X-MC-Unique: J639BjkZMheVr5cNzsWvLA-1 X-Mimecast-MFC-AGG-ID: J639BjkZMheVr5cNzsWvLA_1793100992 To: devel@lists.libvirt.org Subject: [PATCH] conf: Deny negative vcpu count Date: Tue, 27 Oct 2026 12:36:29 +0100 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: QfiM7g9d77k6nK49A464Ssmlf2U4wlyGgGb4k2iboLQ_1793100992 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QFVOP437S5ZE3V2E5HVQUTEFGSM6SLWP X-Message-ID-Hash: QFVOP437S5ZE3V2E5HVQUTEFGSM6SLWP X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1793101069968158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik When parsing part of domain XML, the number of vCPUs is parsed using virStrToLong_ui() which allows int wrapping (i.e. specifying -1 as a shortcut for UINT_MAX). Well, this is against: a) our RNG schema, which allows only positive integers, and b) documentation ("(value) ... must be between 1 and the maximum supported by the hypervisor"). Switch to virStrToLong_uip() which rejects negative numbers. Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/945 Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- I think I've seen another incarnation of this bug not so long ago, but couldn't find it. In the end, it doesn't matter. src/conf/domain_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69c2304f28..51140aa652 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18410,7 +18410,7 @@ virDomainVcpuParse(virDomainDef *def, if (!(tmp =3D virXMLNodeContentString(vcpuNode))) return -1; =20 - if (virStrToLong_ui(tmp, NULL, 10, &maxvcpus) < 0) { + if (virStrToLong_uip(tmp, NULL, 10, &maxvcpus) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("maximum vcpus count must be an integer")); return -1; --=20 2.56.0