From patchwork Sat Apr 15 19:08:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1769309 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=utJ4Ogkk; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PzNCk46qgz1yZt for ; Sun, 16 Apr 2023 05:09:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C7443858289 for ; Sat, 15 Apr 2023 19:09:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C7443858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681585760; bh=iedb4sALa/xDDsEYJiUrKcZSBBWGCDaFhqYkgtSh8Hw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=utJ4Ogkk1HjArS1LuomvCmu+h5WoTv5Mm1EsM3T23KL2RCrbseIJOp2m30gU3luwc +B0JpjocF5kWGYAondgStYuBvZfnAkYlnrF+CcvEJNo8AG0Qx29Qtg+wOxKqbnxNOZ lVBsdhL0dwi8Ng98WuI1Z0c3KODUi1H3U+h4jtA4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id F17743858D20 for ; Sat, 15 Apr 2023 19:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F17743858D20 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2a8b1b51dbdso4385951fa.0 for ; Sat, 15 Apr 2023 12:09:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681585742; x=1684177742; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iedb4sALa/xDDsEYJiUrKcZSBBWGCDaFhqYkgtSh8Hw=; b=czebnTgkz+JA/GnNI4eIwmXRQoNkKK2Oo5Lt12ijcmYBfy5sfkev3nTltnByA8kiDh 6rkYpKRPU7aqAPwLM9zm0jjBpyeR8FAM7e9nizeeVsKYXz/c3E1/GTnFfDZI9N7SvK4M VecpccybA75Smvg4MVY2y5huI24griLjjF6VF8n4pyjDxT+Keh48WwEATSa9J3vVJQMk iQ2AZAHPxJZR9yPDGnPtM3MXnqepe+BARYLJlnDDQE31ot9xvTumhnrKFG4hWzWogx4a T427cZT/plkc+X5R9xfMMi++ERnUqfHVel4+HRBFXqEc9qv4fLOJsDySQfsHXFhDOq9g 2cZQ== X-Gm-Message-State: AAQBX9eHooEmkFXhdD8q+dbs4qeKeednOEKZqtZVaNF+jXRZ/J60WuKB iy5Bb/4TryEiMwZ9rcDK5cHnBA5XNINEuA== X-Google-Smtp-Source: AKy350YVEVnuQeohos2eD6nRv4zixC7MQ9Z51rDa9XjpmYQiJ5DDqjYJ9gFjqF771Xd9mm2QoQ6v2w== X-Received: by 2002:ac2:4848:0:b0:4db:28ce:e5ef with SMTP id 8-20020ac24848000000b004db28cee5efmr705658lfy.0.1681585741757; Sat, 15 Apr 2023 12:09:01 -0700 (PDT) Received: from surface-pro-6.. ([2a00:1370:818c:4a57:1942:fa6f:6d42:319f]) by smtp.gmail.com with ESMTPSA id j16-20020a19f510000000b00498f67cbfa9sm1391203lfb.22.2023.04.15.12.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 12:09:01 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Samuel Thibault , Sergey Bugaev Subject: [PATCH] hurd: Run init_pids () before init_dtable () Date: Sat, 15 Apr 2023 22:08:56 +0300 Message-Id: <20230415190856.109348-1-bugaevc@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230415175826.at5pjnu2wp54vlhv@begin> References: <20230415175826.at5pjnu2wp54vlhv@begin> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Much as the comment says, things on _hurd_subinit assume that _hurd_pid is already initialized by the time _hurd_subinit is run, so _hurd_proc_subinit has to run before it. Specifically, init_dtable () calls _hurd_port2fd (), which uses _hurd_pid and _hurd_pgrp to set up ctty handling. With _hurd_subinit running before _hurd_proc_subinit, ctty setup was broken: 13<--33(pid1255)->term_getctty () = 0 4<--39(pid1255) task16(pid1255)->mach_port_deallocate (pn{ 10}) = 0 13<--33(pid1255)->term_open_ctty (0 0) = 0x40000016 (Invalid argument) Fix this by running the _hurd_proc_subinit hook in the correct place -- just after _hurd_portarray is set up (so the proc server port is available in its usual place) and just before running _hurd_subinit. Fixes 1ccbb9258eed0f667edf459a28ba23a805549b36 ("hurd: Notify the proc server later during initialization"). Signed-off-by: Sergey Bugaev --- hurd/hurdinit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c index f88c5666..d0c7a831 100644 --- a/hurd/hurdinit.c +++ b/hurd/hurdinit.c @@ -54,6 +54,10 @@ _hurd_ports_use (int which, error_t (*operate) (mach_port_t)) DEFINE_HOOK (_hurd_subinit, (void)); +/* Hook for things which should be initialized as soon as the proc + server is available. */ +DEFINE_HOOK (_hurd_proc_subinit, (void)); + __typeof (_hurd_proc_init) _hurd_new_proc_init; /* below */ /* Initialize the library data structures from the @@ -105,6 +109,11 @@ _hurd_init (int flags, char **argv, */ } + /* Call other things which want to do some initialization. These are not + on the _hurd_subinit hook because things there assume that things done + here, like _hurd_pid, are already initialized. */ + RUN_RELHOOK (_hurd_proc_subinit, ()); + /* Call other things which want to do some initialization. These are not on the __libc_subinit hook because things there like to be able to assume the availability of the POSIX.1 services we provide. */ @@ -148,10 +157,6 @@ libc_hidden_def (_hurd_libc_proc_init) sure the arguments are never visible with `ps'. */ int _hide_arguments, _hide_environment; -/* Hook for things which should be initialized as soon as the proc - server is available. */ -DEFINE_HOOK (_hurd_proc_subinit, (void)); - /* Do startup handshaking with the proc server just installed in _hurd_ports. Call _hurdsig_init to set up signal processing. */ @@ -187,11 +192,6 @@ _hurd_new_proc_init (char **argv, /* Initialize proc server-assisted fault recovery for the signal thread. */ _hurdsig_fault_init (); - /* Call other things which want to do some initialization. These are not - on the _hurd_subinit hook because things there assume that things done - here, like _hurd_pid, are already initialized. */ - RUN_RELHOOK (_hurd_proc_subinit, ()); - /* XXX This code should probably be removed entirely at some point. This conditional should make it reasonably usable with old gdb's for a while. Eventually it probably makes most sense for the exec server to