Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: [netbsd-11] src/libexec/ld.elf_so



Module Name:    src
Committed By:   martin
Date:           Mon Jul 20 09:21:43 UTC 2026

Modified Files:
        src/libexec/ld.elf_so [netbsd-11]: rtld.c xmalloc.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #391):

        libexec/ld.elf_so/rtld.c: revision 1.228
        libexec/ld.elf_so/xmalloc.c: revision 1.27

ld.elf_so: Fix reversed sense of previous change to ASSERT macro.

Had tested the part of the change replacing botch("p") by botch(#p);
then didn't test the change from `if (!(p)) botch(#p)' to
`(__predict_false(p) ?  botch(#p) : (void)0)'.  Oops.

Now I have tested this with MALLOC_DEBUG enabled in ld.elf_so.
PR lib/59751: dlclose is not MT-safe depending on the libraries
unloaded

ld.elf_so: Set _rtld_objself.refcount = 1.

This is the object for ld.elf_so itself.  It can be opened with
dlopen("/usr/libexec/ld.elf_so"), and paths downstream of that assert
that the returned object has refcount > 0 to detect use-after-free
mistakes in rtld.  Since ld.elf_so must never be unloaded, let's just
make sure the reference count is always positive.

(It's conceivable that one could dlopen an object with a DT_RPATH
entry having "/usr/libexec" and a DT_NEEDED entry having "ld.elf_so",
causing recursive loading of ld.elf_so -- and if one then dlcloses
the same object, it might lead to trying to free _rtld_objself.  So
perhaps _rtld_load_object should just increment the reference count
of _rtld_objself itself.  But this is a simpler change that already
fixes some existing tests -- such as any rump tests -- when used with
an ld.elf_built with -DDEBUG.)

Followup for:
PR lib/59751: dlclose is not MT-safe depending on the libraries
unloaded


To generate a diff of this commit:
cvs rdiff -u -r1.221.2.4 -r1.221.2.5 src/libexec/ld.elf_so/rtld.c
cvs rdiff -u -r1.12.44.2 -r1.12.44.3 src/libexec/ld.elf_so/xmalloc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index