From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id C36673858CDB for ; Sun, 2 Apr 2023 22:57:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C36673858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj6dL-0007pb-8Y; Sun, 02 Apr 2023 18:57:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=1grvWv54pY430vUu1UrrUGJbjjtwqkmKS2vZtqJlfFo=; b=h9VCSoRP+SD2brtOfYnG HVQ64KAj/0uOWzrPNgj7Vpl418hXfev9RycMZeEqVb8KY0Hna97+6GJFIxDCer7+NQ1fVnlVrJwSI BywJ/AZz66Ll0FEutPX3oUV2c21IEJUcP9TuoHpwUEQDpsp47tONE4+wuBVOenbz/+v5NJzM44p9A HyE6TViCaZhtEJWry90sJnG++Q+hECm7FgUZQx/NWPBiokB+XMPUZLCq10pl1EIjz/STlNq2e1XeT 4eNq4vs5mg4ZcdYUtCofNIEPmX/S8lzLargAeS1X022riSQWTEPqlbGkKMMvgLAR+3BLkPsc57h0P ROVLK6yZhfC3zQ==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj6dK-0003EC-Qu; Sun, 02 Apr 2023 18:57:10 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pj6dJ-00As2E-2V; Mon, 03 Apr 2023 00:57:09 +0200 Date: Mon, 3 Apr 2023 00:57:09 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [RFC PATCH glibc 08/34] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld Message-ID: <20230402225709.ty5gbk3dcmq577gx@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230319151017.531737-1-bugaevc@gmail.com> <20230319151017.531737-9-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230319151017.531737-9-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Sergey Bugaev, le dim. 19 mars 2023 18:09:51 +0300, a ecrit: > hurd/lookup-retry.c is compiled into rtld, the dynamic linker/loader. To > avoid pulling in file_set_size, file_utimens, tty/ctty stuff, more > string/memory code (memmove, strncpy, strcpy), and more strtoul/itoa > code, compile out support for O_TRUNC and FS_RETRY_MAGICAL when building > hurd/lookup-retry.c for rtld. None of that functionality is useful to > rtld during startup anyway. Keep support for FS_RETRY_MAGICAL("/"), > since that does not pull in much, and is required for following absolute > symlinks. > > The large number of extra code being pulled into rtld was noticed by > reviewing librtld.map & elf/librtld.os.map in the build tree. > > It is worth noting that once libc.so is loaded, the real __open, __stat, > etc. replace the minimal versions used initially by rtld -- this is > especially important in the Hurd port, where the minimal rtld versions > do not use the dtable and just pass real Mach port names as fds. Thus, > once libc.so is loaded, rtld will gain access to the full > __hurd_file_name_lookup_retry () version, complete with FS_RETRY_MAGICAL > support, which is important in case the program decides to > dlopen ("/proc/self/fd/...") or some such. > > Signed-off-by: Sergey Bugaev > --- > hurd/lookup-retry.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c > index 8850c4fd..99c98104 100644 > --- a/hurd/lookup-retry.c > +++ b/hurd/lookup-retry.c > @@ -177,7 +177,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) > > /* We got a successful translation. Now apply any open-time > action flags we were passed. */ > - > +#if !IS_IN (rtld) > if (!err && (flags & O_TRUNC)) > { > /* Asked to truncate the file. */ > @@ -189,6 +189,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) > __file_utimens (*result, atime, mtime); > } > } > +#endif > > if (err) > __mach_port_deallocate (__mach_task_self (), *result); > @@ -214,6 +215,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) > file_name = &retryname[1]; > break; > > +#if !IS_IN (rtld) > case 'f': > if (retryname[1] == 'd' && retryname[2] == '/') > { > @@ -358,8 +360,9 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port) > goto bad_magic; > break; > > - default: > bad_magic: > +#endif /* !IS_IN (rtld) */ > + default: > err = EGRATUITOUS; > goto out; > } > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.