From nobody Fri Apr 26 14:31:36 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=zte.com.cn 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 1637722229181919.4867135554817; Tue, 23 Nov 2021 18:50:29 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-292-a1dAyLSWPxCjiDMUi3bn9g-1; Tue, 23 Nov 2021 21:50:24 -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 2D55C81EE68; Wed, 24 Nov 2021 02:50:18 +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 E8EEE794A0; Wed, 24 Nov 2021 02:50:15 +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 4B45D1809C87; Wed, 24 Nov 2021 02:50:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AO2mENB017762 for ; Tue, 23 Nov 2021 21:48:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 422052166B40; Wed, 24 Nov 2021 02:48:14 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C74F2166B2D for ; Wed, 24 Nov 2021 02:48:11 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (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 51E35802813 for ; Wed, 24 Nov 2021 02:48:11 +0000 (UTC) Received: from mxus.zte.com.cn (mxus.zte.com.cn [20.112.44.237]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-513-EcY7FO7lPsCMo5mAV1QjWg-1; Tue, 23 Nov 2021 21:48:09 -0500 Received: from mxhk.zte.com.cn (unknown [192.168.250.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxus.zte.com.cn (FangMail) with ESMTPS id 4HzQGT3ymCz9wMTf for ; Wed, 24 Nov 2021 10:40:17 +0800 (CST) Received: from mse-fl2.zte.com.cn (unknown [10.30.14.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4HzQDJ3fdrz6FKGS for ; Wed, 24 Nov 2021 10:38:24 +0800 (CST) Received: from kjyxapp02.zte.com.cn ([10.30.12.201]) by mse-fl2.zte.com.cn with SMTP id 1AO2dwfA046867 for ; Wed, 24 Nov 2021 10:39:58 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-cloudhost8.localdomain (unknown [10.234.72.110]) by smtp (Zmail) with SMTP; Wed, 24 Nov 2021 10:39:58 +0800 X-MC-Unique: a1dAyLSWPxCjiDMUi3bn9g-1 X-MC-Unique: EcY7FO7lPsCMo5mAV1QjWg-1 X-Zmail-TransId: 3e88619da5fd009-91c5e From: Yi Wang To: libvir-list@redhat.com Subject: [PATCH] util: virExec may blocked by reading pipe if grandchild prematurely exit Date: Wed, 24 Nov 2021 10:33:11 +0800 Message-Id: <20211124023311.56979-1-wang.yi59@zte.com.cn> MIME-Version: 1.0 X-MAIL: mse-fl2.zte.com.cn 1AO2dwfA046867 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at 10-207-168-7 with ID 619DA610.000 by FangMail milter! X-FangMail-Envelope: 1637721617/4HzQGT3ymCz9wMTf/619DA610.000/192.168.250.138/[192.168.250.138]/mxhk.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 619DA610.000/4HzQGT3ymCz9wMTf 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 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 1AO2mENB017762 X-loop: libvir-list@redhat.com Cc: wang.yi59@zte.com.cn, Xu Chao , wang.liang82@zte.com.cn, xue.zhihong@zte.com.cn 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 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-ZM-MESSAGEID: 1637722230853100001 Content-Type: text/plain; charset="utf-8" From: Xu Chao When VIR_EXEC_DAEMON is set, if virPidFileAcquirePath/virSetInherit failed, then pipesync[0] can not be closed when granchild process exit, because pipesync[1] still opened in child process. and then saferead in child process may blocked forever, and left grandchild process in defunct state. Signed-off-by: Xu Chao Signed-off-by: Yi Wang Reviewed-by: Michal Privoznik --- src/util/vircommand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index fead373729..fa71f40d81 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -782,6 +782,9 @@ virExec(virCommand *cmd) } =20 if (pid > 0) { + /* close pipe[1], then the pipe can be closed if grandchild + * died prematurely */ + VIR_FORCE_CLOSE(pipesync[1]); /* The parent expect us to have written the pid file before * exiting. Wait here for the child to write it and signal us.= */ if (cmd->pidfile && --=20 2.27.0