From nobody Fri May 3 18:37:52 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664520693; cv=none; d=zohomail.com; s=zohoarc; b=gFXzlQyuWj3yA5yYr+nE5LCh20IMOvu7nVKabViLETnevQSEcm6pZdCds53sFPUShqATAtsnj42y+15GWdtHfbIRv4Swpi66Yr/0Rnf4eVq0gslAuHj0diXhg1DypK8o6Mo4ISSqyCbBMOtGZmHM4jleEM7PplDSWHwYNan0J40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664520693; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=nXnoEco70nDPR9N00kt9ZjGS+OD7FkgNxe9sBgnfdNA=; b=X7jYciTX2SlsQFg5/9oNEL9AOUB53y4RHsZ3uPEoXH9as8hQFB522Y5EB0vNE2KA4cBu0//mcZ+zxIdDJkwOFRFZy/4Q+G3z1yQD1vOjdUISO3LBw8Foj2jYg8dhTXQO4HC1Bx+fK6kZxxYUkHO75JTzCLxHkuxxef0mcYCyDI0= 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=pass header.from= (p=none 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 1664520693620563.7732634798831; Thu, 29 Sep 2022 23:51:33 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-363-ExBfd8SxN62Nwt5x2pOsxw-1; Fri, 30 Sep 2022 02:51:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9155D811731; Fri, 30 Sep 2022 06:51:26 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3A9923177; Fri, 30 Sep 2022 06:51:24 +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 BB9401946A52; Fri, 30 Sep 2022 06:51:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 023A81946A4E for ; Fri, 30 Sep 2022 06:51:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E2D63492B06; Fri, 30 Sep 2022 06:51:23 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B6DE492B04 for ; Fri, 30 Sep 2022 06:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664520692; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nXnoEco70nDPR9N00kt9ZjGS+OD7FkgNxe9sBgnfdNA=; b=jGVzJArHD++TGwUA4Qwl22iStG7XMoHmu6LwZhzK1TiP0BZGVYtnAQH1GSwPoHPXrfZUbU zgkod9dY8rVY2+8++hVsmxZKTuat0FDtcbR1q8j23NCxgj/JqOcCEiMxH4Z35Gj8I+RnQC Zqmnfh8KMtWzdZJ0PJXcKD3vbzP3kJk= X-MC-Unique: ExBfd8SxN62Nwt5x2pOsxw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemuNamespaceMknodOne: Call g_file_read_link() in async-signal-safe fashion Date: Fri, 30 Sep 2022 08:51:21 +0200 Message-Id: <36baf29ce3c028dcfdfe3a18b21c356cee31be83.1664520681.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664520695275100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When creating a node in QEMU's namespace the whole link chain is created with it. Here, we use g_file_read_link() from the child (running inside the namespace) to learn whether a link exists and points to expected target. Now, when building the namespace there can't be any symlinks and this g_file_read_link() returns NULL always. And because we pass a local GError variable to it, glib tries to set it to a localized error message. This comes with creating a (static) hash table inside of g_strerror() and is guarded with a mutex. The hash table is also allocated using GSlice allocator instead of g_malloc, and since the latter is safe to use after fork (because it's documented to use plain malloc), glib went with the former, naturally. Now, GSlice allocator has plenty of internal mutexes and thus hitting a locked mutex is not that hard. Fortunately, we don't care about any error from g_file_read_link() and thus we can pass NULL which avoids calling g_strerror(). Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2120965 Signed-off-by: Michal Privoznik Reviewed-by: Jiri Denemark --- src/qemu/qemu_namespace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index a2c31310d9..311c66d46e 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -957,10 +957,9 @@ qemuNamespaceMknodOne(qemuNamespaceMknodItem *data) } =20 if (isLink) { - g_autoptr(GError) gerr =3D NULL; g_autofree char *target =3D NULL; =20 - if ((target =3D g_file_read_link(data->file, &gerr)) && + if ((target =3D g_file_read_link(data->file, NULL)) && STREQ(target, data->target)) { VIR_DEBUG("Skipping symlink %s -> %s which exists and points t= o correct target", data->file, data->target); --=20 2.35.1