public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Samuel Thibault <sthibaul@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc] hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld
Date: Sun,  2 Apr 2023 23:28:04 +0000 (GMT)	[thread overview]
Message-ID: <20230402232804.52E933858C3A@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=543f0cfc9a82db19cc7e52c27dbdbeccd4fe68ea

commit 543f0cfc9a82db19cc7e52c27dbdbeccd4fe68ea
Author: Sergey Bugaev <bugaevc@gmail.com>
Date:   Sun Mar 19 18:09:51 2023 +0300

    hurd: Disable O_TRUNC and FS_RETRY_MAGICAL in rtld
    
    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 <bugaevc@gmail.com>
    Message-Id: <20230319151017.531737-9-bugaevc@gmail.com>

Diff:
---
 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 8850c4fd27..99c981046f 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;
 	    }

                 reply	other threads:[~2023-04-02 23:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230402232804.52E933858C3A@sourceware.org \
    --to=sthibaul@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).