From nobody Wed Oct 30 19:55:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=none) header.from=swemel.ru ARC-Seal: i=1; a=rsa-sha256; t=1694531456; cv=none; d=zohomail.com; s=zohoarc; b=kv4Q73/AYKbeaFNNCZFmO4fe4CEuIdoPboCqFejYADkZIGlsRLwVipRzPkWfS6ThrqTMBRfxlogcu4HHiBZg4S7q42K15oq0cwM/lraj5EnidvLzuEmywtLgvn7bgrf722fGTQqm2ZSZDVWsLPMd67A38v8WeZhVzFlkvmhYnK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694531456; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dstECjhYxJUm8WrrAvinvcRzzOjgut4vOYTEG7mY2mI=; b=Qplt2DgsAzlpI/Iko2xUNjlZC7fimoa2eJCvDB2RpfFEh5O7CjgRReo1YLYuKglBFF9M2Py1z4wHSeo3wGqrLQGYMHSZZoPz0gOZQnSSf2DWtkSTPb3qQ9KfhchoPmYmIw0hGUDGdkEbpHFwpTSzocatO1ynUwYz3yJBfCNeAOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=quarantine dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1694531455643587.2261107423733; Tue, 12 Sep 2023 08:10:55 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-671-pFvMF1Q5NqqLlYYV4r5Z9Q-1; Tue, 12 Sep 2023 11:10:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D3D8F1C068E1; Tue, 12 Sep 2023 15:10:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00B522156722; Tue, 12 Sep 2023 15:10:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 73AFB19465A8; Tue, 12 Sep 2023 15:10:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C3082194658D for ; Tue, 12 Sep 2023 14:51:26 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9592F40C6EC1; Tue, 12 Sep 2023 14:51:26 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8E9C840C6EBF for ; Tue, 12 Sep 2023 14:51:26 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FA4E29AB435 for ; Tue, 12 Sep 2023 14:51:26 +0000 (UTC) Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-29-eS_nrUODPC-RQq8mkriX4Q-1; Tue, 12 Sep 2023 10:51:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694531454; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dstECjhYxJUm8WrrAvinvcRzzOjgut4vOYTEG7mY2mI=; b=XI8/F2mPI4iOTTSXhHgzUKcN/lwHrJsTBRvU7Y5YIVHQXFXQn7Qf/wgllVWyeM+sQd8m8i uAURrTsIKI7vLPnM/IPkmvr9rCYyyPQYYCF93K4+6kq4t77qYri8WIQY3k+DaS+ojq/N63 0DI/XBrzminHbuoLM/FktvFlkch/j7Y= X-MC-Unique: pFvMF1Q5NqqLlYYV4r5Z9Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: eS_nrUODPC-RQq8mkriX4Q-1 From: Dmitry Frolov To: libvir-list@redhat.com Subject: [PATCH] fix uint64 underflow Date: Tue, 12 Sep 2023 17:50:16 +0300 Message-Id: <20230912145015.195505-1-frolov@swemel.ru> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dmitry Frolov Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: swemel.ru Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1694531459600100001 Content-Type: text/plain; charset="utf-8"; x-default="true" According to previous statement, 'free_mem' is less than 'needed_mem'. So, the subtraction 'free_mem - needed_mem' is negative, and will raise uint64 underflow. Signed-off-by: Dmitry Frolov --- src/libxl/libxl_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 6c167df63e..36be042971 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -940,7 +940,7 @@ libxlDomainFreeMem(libxl_ctx *ctx, libxl_domain_config = *d_config) if (free_mem >=3D needed_mem) return 0; =20 - target_mem =3D free_mem - needed_mem; + target_mem =3D needed_mem - free_mem; if (libxlSetMemoryTargetWrapper(ctx, 0, target_mem, /* relative */ 1, 0) < 0) goto error; --=20 2.34.1