Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 1996 18:51:10 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        jdp@polstra.com, uh@NU.cs.fsu.edu
Cc:        freebsd-current@FreeBSD.org, j@uriah.heep.sax.de, nate@FreeBSD.org
Subject:   Re: make world
Message-ID:  <199601110751.SAA32761@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> > ...
>> > ===> rtld
>> > install -c -s -o bin -g bin -m 555  -fschg ld.so /usr/libexec
>> > install -c -o bin -g bin -m 444 rtld.1.gz  /usr/share/man/man1
>> > Memory fault
>> > *** Error code 139
>> > ...

>To me, this looks very much like something that might happen if you had
>just trashed your dynamic linker.  Hey!  What do you know?!  He had _just_
>installed a new dynamic linker.  What a coincidence!

>I don't like the way ld.so gets installed in the current Makefile.
>There are many hazards lurking there.

>I took a quick look at the sources of "install".  It looks like, with the
>options above, that install does this:

>    * unlinks the old version of /usr/libexec/ld.so
>    * copies the new version into /usr/libexec/ld.so
>    * runs /usr/bin/strip (itself dynamically-linked) on /usr/libexec/ld.so

>Now, looking at the sources to "strip", it seems that it opens its file
>read/write, and modifies it in place.

This shouldn't matter if ld.so is not run while it is being installed,
and the strip step is probably safe at all times since it doesn't move
the text or data blocks.

>...
>Here's the safest way I've found to install a new version of ld.so on a
>running system (taken from a shell script that I use):

>    test -f /usr/libexec/ld.so- && chflags noschg /usr/libexec/ld.so-
>    chflags noschg /usr/libexec/ld.so

>    install -c -s -o bin -g bin -m 555 ld.so /usr/libexec/ld.so+ &&
>    ln -f /usr/libexec/ld.so /usr/libexec/ld.so- &&
>    mv /usr/libexec/ld.so+ /usr/libexec/ld.so &&
>    chflags schg /usr/libexec/ld.so

>This make sure that the system is never, even for a moment, without an
>installed ld.so.  It also takes care not to write over the old version,
>which is still mmapped and possibly in use by running processes.

>I'm going to modify the Makefile for ld.so to do something like this,
>right away.

Erm, in -current, just use `install -C'.  It does everything (except the
fschg :-() atomically as a side effect of avoiding clobbering the file
metadata if the file data hasn't changed.  I want atomic installs to be
the usual case and prepared a bit for this.  The current implementation
does too much copying, but with a better implementation the only cost
for an ordinary install should be having to have enough disk space for
the temporary copy on the same file system as the target.  This
disadvantage is usually more than offset by the advantage of not running
out of disk space in the middle of an install.  (I've run out installing
libc.so several times.  Unlinking the target before copying usually
doesn't help in this case because libc.so is in use.)

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601110751.SAA32761>