From nobody Sat May 11 05:34:52 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1709635553756207.17614171327978; Tue, 5 Mar 2024 02:45:53 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7E70319C0; Tue, 5 Mar 2024 05:45:52 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 77708191D; Tue, 5 Mar 2024 05:44:45 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4A105190C; Tue, 5 Mar 2024 05:44:42 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 061161910 for ; Tue, 5 Mar 2024 05:44:40 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-NWr72LpINoCF0JeavE278w-1; Tue, 05 Mar 2024 05:44:39 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 34BF01C02C96 for ; Tue, 5 Mar 2024 10:44:39 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.3.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0F8F492BDC for ; Tue, 5 Mar 2024 10:44:38 +0000 (UTC) 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: NWr72LpINoCF0JeavE278w-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] virsh: Fix overflow error of freepages command Date: Tue, 5 Mar 2024 11:43:03 +0100 Message-ID: <41e7fd721dc74b20d0b31a345a372b8f4f5e34ad.1709635370.git.ajulis@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: VC33YXNFB4QXBVISG37SDAHP2Q7SO6CX X-Message-ID-Hash: VC33YXNFB4QXBVISG37SDAHP2Q7SO6CX X-MailFrom: ajulis@redhat.com 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; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header 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"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709635554751100001 Trying to print pages of a size larger than the UINT_MAX of the given platform (for example, around 4G on 64-bit intel), a system error was printed, but this is a legitimate request, fixed. vshCommandOptScaledInt requiers set maximum returning size for the variable '&bytes'. It was set as UINT_MAX, while the public API variable 'kibibytes', which loads the 'bytes' lately, is type of UINT. Since it's kibibytes, the value in bytes should be 1024* bigger and it still will works correctly. So the correct max size of bytes is UINT_MAX * 1024. Resolves: https://issues.redhat.com/browse/RHEL-23608 Signed-off-by: Adam Julis Reviewed-by: Michal Privoznik --- tools/virsh-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 6c14be865f..5a934d7a7f 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -335,7 +335,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); =20 - if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MA= X) < 0) + if (vshCommandOptScaledInt(ctl, cmd, "pagesize", &bytes, 1024, UINT_MA= X * 1024ULL) < 0) goto cleanup; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 --=20 2.43.2 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org