From nobody Thu May 2 00:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1533458746707942.783984832066; Sun, 5 Aug 2018 01:45:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9E64C03677B; Sun, 5 Aug 2018 08:45:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB9A761B92; Sun, 5 Aug 2018 08:45:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5872E18363F5; Sun, 5 Aug 2018 08:45:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w71GA4hk018993 for ; Wed, 1 Aug 2018 12:10:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B2C930001F0; Wed, 1 Aug 2018 16:10:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CB4C309128B; Wed, 1 Aug 2018 16:10:02 +0000 (UTC) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 52BFDC047B96; Wed, 1 Aug 2018 16:10:01 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id a5-v6so20474546qtp.2; Wed, 01 Aug 2018 09:10:01 -0700 (PDT) Received: from localhost.localdomain (177.207.219.111.static.gvt.net.br. [177.207.219.111]) by smtp.gmail.com with ESMTPSA id s19-v6sm11763172qtj.61.2018.08.01.09.09.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 09:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2WAMQ+V4EtbUtwJ1TNi4rwjthap3P0fJzWSEMnLkSoc=; b=U492E4nMSY5LSBI5DuKX/487FN/PCxNsq8TTs1yUNIeIMW9IjjR8tD7KfwRoLPG/Rz RE61pFe8cYh+FB3s91XgMP6Lp29wvRKJaruwbWHVMX6+15jfQjQ/GiW+n9XYVjrDfgU1 KkFhQp4oW97V2PGl+q2LwNIvIC17urbnyFwJw9qO438TVZawSc4GYlL4eWrWAinfNufw yS1/EkZAHJqLEel30LiXlU4a2I7ORMnnnA4IJGPo4DFSQOI1IP1c0gH/F/FwsG05wGgI K5B8GYjJJ0lGWnRuxEeSkMrsg2hgE7neDHJnsX3I42LHOWuOfc/fJLJeAqF7Mpt3HH7f CF1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2WAMQ+V4EtbUtwJ1TNi4rwjthap3P0fJzWSEMnLkSoc=; b=j45GdRuVpOm6PM+/Jp/6Ee4giPunylVAVDRpcu14Hp6rRMKibtO+isH12pal3TM8nD GBLUZyy6T730YaYy7hm0HbBxr7JcVwsc4DCC1nOmp6j/LPu7CB9Eq3fsuxGZ/MkbIXyn F83M+JDkUReEEK8YBkaTwo4xq1PgoXMmdQC7h8uwR1zxUsgJBpT9A0Ont/52Bq0UUOiH l9GVP3N3b1hTDVathk+/ZPLmI9ZaKTrQSVxMw0TQVfwaBxhphwEwDeIhd6P6dshd/9Xi ncqNQCsjiOlqNjEvsVU1ZXtAF+1gyBTeVwOj7fh022rlmOwD0XW4lNyvmPNhHGiUuTja o7kw== X-Gm-Message-State: AOUpUlHAFvlbM7E7Xkk5MvO+4uizHe0eluL3h0gvOawJRbtAd49BaQAx ZFt/Y95J1gOfu0qmhB/RZoSMlGcP X-Google-Smtp-Source: AAOMgpcNCogQbADyy7y1kgXQmi/2uq8460kGR9rXbW1otYVbYAlTEcJt1pFdaCJ7q/uVwQn2qkQwzg== X-Received: by 2002:ac8:17c2:: with SMTP id r2-v6mr26719855qtk.145.1533139800117; Wed, 01 Aug 2018 09:10:00 -0700 (PDT) From: Marcos Paulo de Souza To: libvir-list@redhat.com Date: Wed, 1 Aug 2018 13:09:33 -0300 Message-Id: <20180801160934.22839-2-marcos.souza.org@gmail.com> In-Reply-To: <20180801160934.22839-1-marcos.souza.org@gmail.com> References: <20180801160934.22839-1-marcos.souza.org@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 01 Aug 2018 16:10:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 01 Aug 2018 16:10:01 +0000 (UTC) for IP:'209.85.216.170' DOMAIN:'mail-qt0-f170.google.com' HELO:'mail-qt0-f170.google.com' FROM:'marcos.souza.org@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.216.170 mail-qt0-f170.google.com 209.85.216.170 mail-qt0-f170.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: hhan@redhat.com, Marcos Paulo de Souza Subject: [libvirt] [PATCH v2 1/2] esx: Do not crash SetAutoStart by double free X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 05 Aug 2018 08:45:45 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" SetAutoStart method cannot free virtualMachine using esxVI_ObjectContent_Free, since: esxVI_HostAutoStartManagerConfig_Free -> esxVI_AutoStartPowerInfo_Free -> esxVI_ManagedObjectReference_Free(item->key); item->key, in this context, is virtualMachine->obj, so calling esxVI_ObjectContent_Free creates a double free, becasuse esxVI_ObjectContent_Free also calls esxVI_ManagedObjectReference_Free(&item= ->obj). Removing the esxVI_ObjectContent_Free from SetAutoStart fixes this problem. Signed-off-by: Marcos Paulo de Souza --- src/esx/esx_driver.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index cee98ebcaf..3835e4cb3c 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3421,7 +3421,9 @@ esxDomainSetAutostart(virDomainPtr domain, int autost= art) newPowerInfo->stopAction =3D NULL; } =20 - esxVI_ObjectContent_Free(&virtualMachine); + /* HostAutoStartManagerConfig free method will call autoStartPowerInfo= Free + * in order to free virtualMachine, since newPowerInfo-> key points to + * virtualMachine */ esxVI_HostAutoStartManagerConfig_Free(&spec); esxVI_AutoStartDefaults_Free(&defaults); esxVI_AutoStartPowerInfo_Free(&powerInfoList); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 00:23:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15331398106602.440318180274403; Wed, 1 Aug 2018 09:10:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC576307CF2B; Wed, 1 Aug 2018 16:10:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F184194B9; Wed, 1 Aug 2018 16:10:07 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0A8304A460; Wed, 1 Aug 2018 16:10:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w71GA6WC019004 for ; Wed, 1 Aug 2018 12:10:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0105130001F0; Wed, 1 Aug 2018 16:10:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8ED93083322; Wed, 1 Aug 2018 16:10:05 +0000 (UTC) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D20C1307D875; Wed, 1 Aug 2018 16:10:04 +0000 (UTC) Received: by mail-qk0-f195.google.com with SMTP id b5-v6so13040144qkg.6; Wed, 01 Aug 2018 09:10:04 -0700 (PDT) Received: from localhost.localdomain (177.207.219.111.static.gvt.net.br. [177.207.219.111]) by smtp.gmail.com with ESMTPSA id s19-v6sm11763172qtj.61.2018.08.01.09.10.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 09:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=r/irHW12O2BlJ0scT8MOuAs2CFyoFCiirGcWlwyuwF0=; b=bj3ZPBQDVjRqkKTDne35kZow9OiKUJtNYtkUpss0U/m1HAnOnHXFEtP6w4Du8o6ETD Fymy/ioyyGYBPprRLqPU9FFBoRYYYJcNLNWNp0XCXwkF+uld1JKNSTt3w2aWrIufd4cp Kqn9OfUQjbV6e3SbUcVKQrJ3LQLvnJkQ5sgGGTBVRbi7ZP9o6OIRbuMFcGjN/KoAhSto fTiG13ZFl/uOJq0AO0YXYwaALXw102EUcrC322mP/GcrIX+hPnzVswXYSqngQcGGWBFF 6ciNyhbpyk1/2gnBq6XjWx4WVg3HRJ3xs1U0zZOLGrP1gUtrzvN+eDPLmNivN47g9cuq 1/IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=r/irHW12O2BlJ0scT8MOuAs2CFyoFCiirGcWlwyuwF0=; b=Y/EePYp/2vy5JTOu9BfPTLwqwFJi/wVqNkaT14217G3idve+uNwPHUVUrY0Kd32FdH ZY7NoVaAzy2L60gbvn6gr6zyRiYbCoAqHzKVBrRQeFgxu26ItfLwptzkOPJ8Zr2/BasZ 4805GPmJhA1arc7VWNdrhSjk8qVF14yJzniHnta6m7sc2Z5m+FefxA0nIrvKd+TdZQ55 oorDs9rv4l/sZQ5vWmuomsOW7ApZxtOOlpGp+wj1zAYfvaAvTd8e6eok1vx1v0sjfCob cljoAwlWDoxIwf8WEOwD8Ccfetzqn16SrQl1yf3oG0rC8EWnkUHOiJSnm7g7HRWTpJMD H1uQ== X-Gm-Message-State: AOUpUlESMnSf2nYekR9XUcny+JfRK5VVcO41tYLRtGQ74MD4HQouXQ3s 4t9bYdbztqvo3uGE4fgBcQQRMvC2 X-Google-Smtp-Source: AAOMgpdR6oeb0a/2Pgu166P6ubQhCsf7f0d0uZMIMlJqkQvEMwtHu+Gg5Is5/lei7zX/hhb8/MJT+w== X-Received: by 2002:a37:d683:: with SMTP id p3-v6mr25545288qkl.424.1533139803655; Wed, 01 Aug 2018 09:10:03 -0700 (PDT) From: Marcos Paulo de Souza To: libvir-list@redhat.com Date: Wed, 1 Aug 2018 13:09:34 -0300 Message-Id: <20180801160934.22839-3-marcos.souza.org@gmail.com> In-Reply-To: <20180801160934.22839-1-marcos.souza.org@gmail.com> References: <20180801160934.22839-1-marcos.souza.org@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 01 Aug 2018 16:10:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 01 Aug 2018 16:10:05 +0000 (UTC) for IP:'209.85.220.195' DOMAIN:'mail-qk0-f195.google.com' HELO:'mail-qk0-f195.google.com' FROM:'marcos.souza.org@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.195 mail-qk0-f195.google.com 209.85.220.195 mail-qk0-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: hhan@redhat.com, Marcos Paulo de Souza Subject: [libvirt] [PATCH v2 2/2] esx: Fix SetAutoStart invalid pointer free X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 01 Aug 2018 16:10:08 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" esxVI_AutoStartPowerInfo_Free, which is called from esxVI_HostAutoStartManagerConfig_Free, will always call VIR_FREE to free memory from {start,stop}Action, leading to a invalid pointer. With this patch applied, ESX can set autostart successfully to all it's domains. Signed-off-by: Marcos Paulo de Souza --- Changes from v1: * Stop calling VIR_ALLOC_N and strcpy, and use VIR_STRNDUP instead src/esx/esx_driver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 3835e4cb3c..dc07cf8770 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3394,9 +3394,15 @@ esxDomainSetAutostart(virDomainPtr domain, int autos= tart) newPowerInfo->startOrder->value =3D -1; /* no specific start order */ newPowerInfo->startDelay->value =3D -1; /* use system default */ newPowerInfo->waitForHeartbeat =3D esxVI_AutoStartWaitHeartbeatSetting= _SystemDefault; - newPowerInfo->startAction =3D autostart ? (char *)"powerOn" : (char *)= "none"; newPowerInfo->stopDelay->value =3D -1; /* use system default */ - newPowerInfo->stopAction =3D (char *)"none"; + + /* startAction and stopAction will be freed by esxVI_HostAutoStartMana= gerConfig_Free */ + if (VIR_STRNDUP(newPowerInfo->startAction, autostart ? "powerOn" : "no= ne", + autostart ? 7 : 4) < 1) + goto cleanup; + + if (VIR_STRNDUP(newPowerInfo->stopAction, "none", 4) < 1) + goto cleanup; =20 if (esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo, newPowerInfo) < 0) { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list