From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id C86163858D3C for ; Thu, 5 May 2022 00:15:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C86163858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 84A0720172; Thu, 5 May 2022 02:15:47 +0200 (CEST) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 13TfPe2vcak4; Thu, 5 May 2022 02:15:47 +0200 (CEST) Received: from begin (anantes-655-1-33-15.w83-195.abo.wanadoo.fr [83.195.225.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 5BE372016B; Thu, 5 May 2022 02:15:47 +0200 (CEST) Received: from samy by begin with local (Exim 4.95) (envelope-from ) id 1nmP9n-006B39-1C; Thu, 05 May 2022 02:15:47 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited] hurd spawni: Fix reauthenticating closed fds Date: Thu, 5 May 2022 02:15:46 +0200 Message-Id: <20220505001546.1472436-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 00:15:50 -0000 When an fd is closed, the port cell remains, but the port becomes MACH_PORT_NULL, so we have to guard against it. --- sysdeps/mach/hurd/spawni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c index f19b688411..ffc62e660e 100644 --- a/sysdeps/mach/hurd/spawni.c +++ b/sysdeps/mach/hurd/spawni.c @@ -154,7 +154,7 @@ __spawni (pid_t *pid, const char *file, reauthenticated, or was newly opened on behalf of the child. */ error_t reauthenticate_fd (int fd) { - if (dtable_cells[fd] != NULL) + if (dtable_cells[fd] != NULL && dtable[fd] != MACH_PORT_NULL) { file_t newfile; mach_port_t ref = __mach_reply_port (); -- 2.35.1