From nobody Sun Feb 8 18:43:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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=1578320691; cv=none; d=zohomail.com; s=zohoarc; b=YJg3AVPOOzLipLJywyDHn7BkGJcO6i/zIWQVBj7QVwKjSiHpNRFYkib/FzLL08oZ8ntOpSb/3HJ15LGpDu3r54AV7QDhJXUZhpqsZxf473U93Ms76c7QXaVVgG7uWmOFp9zWtE+s7vp5bPit/OJW28bV3tapAs4RV6sEYptMpi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578320691; 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=C2eAJHtPupjdYOF+Vs3m1S9Ng0hskCu0Ft+IVsVmC0Y=; b=ZT288/2NQdOUODoZEkMaaeio/8OlE7U1vyWpUPpTumzyMhF0f8m2OUooDFlb/mPbRV/KEWdxluQZlDzMqsBVFpv+aY7T0fcgfkvgxvpHmlVq4FMCEKXD7yboPkRG4WYBU2mRoCe5MvvREbd5V2rMPe02j4bNyyRe7UFK7JXMIzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1578320691063402.4596826816487; Mon, 6 Jan 2020 06:24:51 -0800 (PST) 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-17-A4qFAWbwMfG9JQ35mWLBKQ-1; Mon, 06 Jan 2020 09:24:48 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id BEAA71005514; Mon, 6 Jan 2020 14:24:40 +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 9BF745C6DC; Mon, 6 Jan 2020 14:24:40 +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 5A6241803C32; Mon, 6 Jan 2020 14:24:40 +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 006EOS4T009616 for ; Mon, 6 Jan 2020 09:24:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7319D5D9CA; Mon, 6 Jan 2020 14:24:28 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F02515D9E1 for ; Mon, 6 Jan 2020 14:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578320689; 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=C2eAJHtPupjdYOF+Vs3m1S9Ng0hskCu0Ft+IVsVmC0Y=; b=hEtpQd4SxTob1jooZYbulbA3HFw84X4KGDnMrIQ0wwc1r5EHr8L7IIW91lTPC6uq/wIrD3 wJ4zoMqq4ZGC9vQ+1oICpbOcuV0gLxHcdjv9IK8tOIbOmxgmETh2i1WxF4wwX4knWzFVDb B//ASU8TID7/6xdjjNSJLJDzJ2He3V0= From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 6 Jan 2020 15:24:20 +0100 Message-Id: <90f24cf2ca039d3f709dbeb91484706f5a7c77f0.1578320640.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 Subject: [libvirt] [PATCH 2/2] vircgroupv2devices: Avoid double close on map FD 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.16 X-MC-Unique: A4qFAWbwMfG9JQ35mWLBKQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" When allowing/denying a device in devices CGroupV2 we have to write a BPF program for it. The program we put there is merely static and all it does it looks up a device in a hash table (also known as map in BPF terminology). A map is referenced via an FD which can be acquired via virBPFCreateMap() and like any other FD it should be closed when no longer needed. However, we close it twice: the first time in virCgroupV2DevicesAttachProg() which closes it unconditionally, and the second time in either virCgroupV2DevicesCreateProg() or virCgroupV2DevicesPrepareProg(). Remove the second close. Signed-off-by: Michal Privoznik --- src/util/vircgroupv2devices.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util/vircgroupv2devices.c b/src/util/vircgroupv2devices.c index 7ea3c70efb..402ce3f86f 100644 --- a/src/util/vircgroupv2devices.c +++ b/src/util/vircgroupv2devices.c @@ -494,7 +494,7 @@ virCgroupV2DevicesReallocMap(int mapfd, int virCgroupV2DevicesCreateProg(virCgroupPtr group) { - VIR_AUTOCLOSE mapfd =3D -1; + int mapfd =3D -1; =20 if (group->unified.devices.progfd > 0 && group->unified.devices.mapfd = > 0) return 0; @@ -503,13 +503,8 @@ virCgroupV2DevicesCreateProg(virCgroupPtr group) if (mapfd < 0) return -1; =20 - if (virCgroupV2DevicesAttachProg(group, mapfd, - VIR_CGROUP_V2_INITIAL_BPF_MAP_SIZE) <= 0) { - return -1; - } - - mapfd =3D -1; - return 0; + return virCgroupV2DevicesAttachProg(group, mapfd, + VIR_CGROUP_V2_INITIAL_BPF_MAP_SIZE= ); } =20 =20 @@ -530,10 +525,8 @@ virCgroupV2DevicesPrepareProg(virCgroupPtr group) if (newmapfd < 0) return -1; =20 - if (virCgroupV2DevicesAttachProg(group, newmapfd, max) < 0) { - VIR_FORCE_CLOSE(newmapfd); + if (virCgroupV2DevicesAttachProg(group, newmapfd, max) < 0) return -1; - } } =20 return 0; --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list