From nobody Thu May 16 03:30:21 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1703076154958513.4730745039448; Wed, 20 Dec 2023 04:42:34 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id E5A391B9B; Wed, 20 Dec 2023 07:42:33 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 56AF21BBD; Wed, 20 Dec 2023 07:40:07 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 315A51AB1; Wed, 20 Dec 2023 07:38:56 -0500 (EST) Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A0A001B24 for ; Wed, 20 Dec 2023 07:38:54 -0500 (EST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id DDA9C186713E; Wed, 20 Dec 2023 15:38:51 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id EI2w81mgA7u3; Wed, 20 Dec 2023 15:38:51 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 63B371866740; Wed, 20 Dec 2023 15:38:51 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5U_djfq66BTm; Wed, 20 Dec 2023 15:38:51 +0300 (MSK) Received: from rbta-msk-lt-320952.astralinux.ru (unknown [79.174.32.216]) by mail.astralinux.ru (Postfix) with ESMTPSA id ED6F618639E1; Wed, 20 Dec 2023 15:38:50 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-Virus-Scanned: amavisd-new at astralinux.ru From: Egor Makrushin To: devel@lists.libvirt.org Subject: [PATCH v2] conf: fix integer overflow in virDomainControllerDefParseXML Date: Wed, 20 Dec 2023 15:38:08 +0300 Message-Id: <20231220123808.24725-1-emakrushin@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-MailFrom: emakrushin@astralinux.ru X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: 2R5WXYMS366TD6NRBKIZG3EPEWJ5W3HU X-Message-ID-Hash: 2R5WXYMS366TD6NRBKIZG3EPEWJ5W3HU X-Mailman-Approved-At: Wed, 20 Dec 2023 12:40:02 -0500 CC: sdl.libvirt@linuxtesting.org, Egor Makrushin X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1703076156289100001 Multiplication results in integer overflow. Thus, replace it with ULLONG_MAX and change def->opts.pciopts.pcihole64size type to ULL. Update variable usage according to new type. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Egor Makrushin Reviewed-by: Michal Privoznik --- v2: update variable type according to maintainer's proposal src/conf/domain_conf.c | 4 ++-- src/conf/domain_conf.h | 2 +- src/qemu/qemu_command.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 58a985fc5d..9f842937e6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8523,7 +8523,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xm= lopt, unsigned long long bytes; if ((rc =3D virParseScaledValue("./pcihole64", NULL, ctxt, &bytes, 1024, - 1024ULL * ULONG_MAX, false)) < 0) + ULLONG_MAX, false)) < 0) return NULL; =20 if (rc =3D=3D 1) @@ -23123,7 +23123,7 @@ virDomainControllerDefFormat(virBuffer *buf, =20 if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && def->opts.pciopts.pcihole64) { - virBufferAsprintf(&childBuf, "%lu%llu\n", def->opts.pciopts.pcihole64size); } =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0c5e2636e1..14901b37ba 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -707,7 +707,7 @@ struct _virDomainVirtioSerialOpts { =20 struct _virDomainPCIControllerOpts { bool pcihole64; - unsigned long pcihole64size; + unsigned long long pcihole64size; =20 /* the exact controller name is in the "model" subelement, e.g.: * diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 54fb8220e8..b45a5e4f80 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6211,7 +6211,7 @@ qemuBuildGlobalControllerCommandLine(virCommand *cmd, } =20 virCommandAddArg(cmd, "-global"); - virCommandAddArgFormat(cmd, "%s.pci-hole64-size=3D%luK", hosts= tr, + virCommandAddArgFormat(cmd, "%s.pci-hole64-size=3D%lluK", host= str, cont->opts.pciopts.pcihole64size); } } --=20 2.30.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org