From nobody Fri May 3 06:23:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623073685; cv=none; d=zohomail.com; s=zohoarc; b=nKq+qaQ04U+JbzY4xSoUOCOA4X9f3GJ09ETKdW1QK+0SExq/W8FTxZ7vDV6wGzP0WSDBo89Y11p3CMYAcbzqb1Ym7/dEqu4AgpzDhPVHIYb4I2ldO1fOtJttKp/J6BYmV1Dt67hDT6p7LhGCLLIJ85dS5h93ucY7mPVsJBc5FUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623073685; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VcYsXY5lic7GQQ4bqfgm2KIeBSXSALxMJodB2IvMwTQ=; b=ee5+n3wBSaEpZ8ibboDu6lqllyozIYOab1L3v6WZv10BBbgS9cfjSbFyABayk5vZQ0LO3+mngpK5a0Ni63vr01jUe39WxhusjCh9xFQ4kKOP0guGRQnuO5oHGq6bzwp6Y2a+ZAv9HkwYSJBonpT3tUJ1IHN8fB6NoTaeJxbTOmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623073685569664.1102997088112; Mon, 7 Jun 2021 06:48:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-pFX8STvANDC0rgQXQuazMQ-1; Mon, 07 Jun 2021 09:48:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5649F108C30B; Mon, 7 Jun 2021 13:47:58 +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 15F0E5D9FC; Mon, 7 Jun 2021 13:47:58 +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 482614EA6C; Mon, 7 Jun 2021 13:47:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 157Dlt0I002299 for ; Mon, 7 Jun 2021 09:47:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 700AF5D9DC; Mon, 7 Jun 2021 13:47:55 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id E82795D9C0 for ; Mon, 7 Jun 2021 13:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623073684; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VcYsXY5lic7GQQ4bqfgm2KIeBSXSALxMJodB2IvMwTQ=; b=S7AbqU6ZbPZ0p6BNRBvdgh3JDMlkFRgiNqtm1eYtT6kBQOztjDZB7C9K6wpEiB4d3Si7Wa 2vyvHnDPrVprofsAR+Su99x40nKPT4GGs1u1tNKsgAHkGErYSIdaKSDHSLDganH37oi7Bh NgR4fXtS14XP6SdWUypKp7RQCblXBsQ= X-MC-Unique: pFX8STvANDC0rgQXQuazMQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] ch_driver: Avoid driver double free Date: Mon, 7 Jun 2021 15:47:47 +0200 Message-Id: <04bf2b5f40a1e8c56ac324a860ed40f55589f8ed.1623073607.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" In one of my recent patches I made chStateInitialize() return VIR_DRV_STATE_INIT_SKIPPED if CH_CMD doesn't exist. What I did not realize back then was that chStateCleanup() would be called twice. This is not a problem per-se because the function is a NOP if driver is NULL. but the problem is that at the end it calls plain g_free(driver) which does not set driver to NULL. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 7baacd7400..374f6e5542 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -826,7 +826,7 @@ static int chStateCleanup(void) virObjectUnref(ch_driver->caps); virObjectUnref(ch_driver->config); virMutexDestroy(&ch_driver->lock); - g_free(ch_driver); + g_clear_pointer(&ch_driver, g_free); =20 return 0; } --=20 2.31.1 From nobody Fri May 3 06:23:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623073690; cv=none; d=zohomail.com; s=zohoarc; b=ZrznE9nQR5mYYBRHRakSGve5hlvDkFHp3WUR76Xe3FkhUCQBHw0neORtbR6rTZCqQ4jL/NrlU7ilQzfZjSrWUPcdrAD+b3hTfg+HfOTiXsnNpbx1dwZ1UnVmIBCKVoJ2y5oQGhTV6CcZR7SQmnmE1Ykh5QRgziGDPVDhIWK6z7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623073690; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L/n74OomW6MFQWEzD9fLNfF1xoDxVzFLflfZ7vD0aTM=; b=KREX3rTXPz6iuN+yD75v+iw625b21UORaP+sG7YQyB6SR1cD7S+FIB9Yn7/WPDmyF+pGcc6m23TOKtmo8QmgMHwEiUwi7cjmKNf8XFv//T6/WsLWUFljVDAJUxCkFu7X7lvl0e0fanTIuA7La0Yfa/s/lvecsCJtaJUE8OIx3L0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623073690565170.37417991064024; Mon, 7 Jun 2021 06:48:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-74-88HjiMiUN5yXJvtgGbQAbg-1; Mon, 07 Jun 2021 09:48:05 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 959C46415F; Mon, 7 Jun 2021 13:48:00 +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 7086D608BA; Mon, 7 Jun 2021 13:48:00 +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 33B331800BB8; Mon, 7 Jun 2021 13:47:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 157DluCe002315 for ; Mon, 7 Jun 2021 09:47:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4780C5D9E3; Mon, 7 Jun 2021 13:47:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFB935D9C0 for ; Mon, 7 Jun 2021 13:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623073689; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=L/n74OomW6MFQWEzD9fLNfF1xoDxVzFLflfZ7vD0aTM=; b=GlWJm2pQhi3qrQwUw7kyClpLpftECu9Nm9s0sas3wlE/2n7AXDuoRg0e3qQ54QBLLgg01L LaxYU3YuRZ5shFLC5+Zlk5OdHJZ5O+13W+VVbZ86RRB7uKFoDVeOiroCQ2VuOf32CzfrIr JWYl9Qy1fVcnRCvMzE/lEJfxU94dKAs= X-MC-Unique: 88HjiMiUN5yXJvtgGbQAbg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] virCHDriverConfig: Drop @uri member Date: Mon, 7 Jun 2021 15:47:48 +0200 Message-Id: <7a599281599fdc2d6b6927a3753dfd15519fcbf9.1623073607.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This member is unused (apart from only being set in virCHDriverConfigNew()), and never freed really (leading to a memleak). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/ch/ch_conf.c | 1 - src/ch/ch_conf.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/ch/ch_conf.c b/src/ch/ch_conf.c index 5f156dfe44..ed0fffe5d6 100644 --- a/src/ch/ch_conf.c +++ b/src/ch/ch_conf.c @@ -141,7 +141,6 @@ virCHDriverConfigNew(bool privileged) if (!(cfg =3D virObjectNew(virCHDriverConfigClass))) return NULL; =20 - cfg->uri =3D g_strdup(privileged ? "ch:///system" : "ch:///session"); if (privileged) { if (virGetUserID(CH_USER, &cfg->user) < 0) return NULL; diff --git a/src/ch/ch_conf.h b/src/ch/ch_conf.h index d856825377..37c36d9a09 100644 --- a/src/ch/ch_conf.h +++ b/src/ch/ch_conf.h @@ -35,7 +35,6 @@ struct _virCHDriverConfig { =20 char *stateDir; char *logDir; - char *uri; =20 uid_t user; gid_t group; --=20 2.31.1