IABSD.fr/src/libexec/ld.so

Branch :


Log

Author Commit Date CI Message
d3e0725e 2020-08-11 23:32:06 clang 10 now emits calls to __multi3 from libcompiler_rt Hints from kettenis@, ok kettenis@ deraadt@
92e19e77 2020-07-18 16:41:43 Use the same names as the 64-bit PowerPC ELF ABI for the relocations.
122a6b72 2020-07-16 21:26:18 Rewrite loop to match what is written down in the ABI document. ok drahn@
af856e3a 2020-07-16 21:18:09 Make lazy binding work. Committing on behalf of drahn@ who is a bit busy.
89c7f3c9 2020-06-28 20:52:05 Disable powerpc64 lazy binding, code was not for 64 bit ABI DT_PPC_GOT is not used on powerpc64, delete.
61dad853 2020-06-28 17:58:40 Powerpc64 ld.so asm code needs to conform to Powerpc64 abi, not 32bit. ok kettenis@
6a2e3db8 2020-06-25 04:00:58 PowerPC64 ld.so code. Mostly ported, code runs far enough to start first symbol string lookup. build with -gdwarf-4 to remove asm warnings. Do not bother supporting 32 bit non-pic relocations in shared libraries. (however leave the code there for now)
c6bdb7a3 2020-05-08 11:04:50 ld.so(1) also ignores LD_LIBRARY_PATH an friends for set-group-ID executables While here, use consistent casing and don't use .Ev for set-user-ID/set-group-ID. from Miod
b3f796b2 2020-05-08 10:57:50 LD_DEBUG is ignored for set-user-ID and set-group-ID executables from Miod
fa9f1946 2020-03-27 22:17:47 Add missing space in stack smash handler error message. ok kettenis@, deraadt@
f74a2b77 2020-03-13 09:31:24 Anthony Steinhauser reports that 32-bit arm cpus have the same speculation problems as 64-bit models. To resolve the syscall speculation, as a first step "nop; nop" was added after all occurances of the syscall ("swi 0") instruction. Then the kernel was changed to jump over the 2 extra instructions. In this final step, those pair of nops are converted into the speculation-blocking sequence ("dsb nsh; isb"). Don't try to build through these multiple steps, use a snapshot instead. Packages matching the new ABI will be out in a while... ok kettenis
ded5ef52 2020-03-13 06:38:55 Anthony Steinhauser reports that 32-bit arm cpus have the same speculation problems as 64-bit models. For the syscall instruction issue, add nop;nop after swi 0, in preparation for jumping over a speculation barrier here later. (a lonely swi 0 was hiding in __asm in this file)
f377c767 2020-03-11 12:53:19 Anthony Steinhauser reports that 32-bit arm cpus have the same speculation problems as 64-bit models. For the syscall instruction issue, add nop;nop after swi 0, in preparation for jumping over a speculation barrier here later. ok kettenis
5ecc9681 2020-02-18 12:19:11 Now that the kernel skips the two instructions immediately following a syscall, replace the double nop with a dsb nsh; isb; sequence which stops the CPU from speculating any further. This fix was suggested by Anthony Steinhauser. ok deraadt@
0c401ffc 2020-01-26 02:19:43 Insert two nop instructions after each svc #0 instruction in userland. The will be replaced by a speculation barrier as soon as we teach the kernel to skip over these two instructions when returning from a system call. ok patrick@, deraadt@
3d8e19a1 2019-12-17 17:16:32 Eliminate failure returns from _dl_split_path(): if malloc fails just _dl_oom() Prompted by Qualys's leveraging malloc failure in _dl_split_path() to get stuff past. ok deraadt@ millert@
4b65c70c 2019-12-17 03:16:07 Don't look up env variables until we know we'll trust them. Otherwise, just delete them without looking. ok millert@
eee3c75f 2019-12-11 18:27:54 ld.so may fail to remove the LD_LIBRARY_PATH environment variable for set-user-ID and set-group-ID executables in low memory conditions. Reported by Qualys
f7d771ca 2019-12-09 23:15:03 When loading a library, mmap(2) may fail. Then everything gets unmapped and ld.so tries again with different random address layout. In this case, use the new libc executable address for msyscall(2), not one from the first try. Fixes sporadic bogus syscall on i386. OK deraadt@
e5659a93 2019-12-09 22:15:15 print addresses upon msyscall failure, for now
d9337de3 2019-12-07 22:57:47 Disable ltrace for objects linked with -znow, as at least on amd64, linking that was deletes the lazy relocation trampoline which ltrace currently depends on problem reported by tb@ directional feedback kettenis@ ok mpi@
93a664f2 2019-12-02 17:19:25 It is not always clear what ld.so was backed up to ld.so.backup, and better that folk doing development in here use their own cp tooling.
488dc415 2019-11-30 23:06:02 Sigh, fix i386 msyscall() case to permission the correct address range.
29ab13eb 2019-11-29 19:30:56 As additional paranoia, make a copy of system ld.so into obj/ld.so.backup We don't want to CLEANFILES this one. On occasion this comes in useful.
e5041725 2019-11-29 06:34:44 Repurpose the "syscalls must be on a writeable page" mechanism to enforce a new policy: system calls must be in pre-registered regions. We have discussed more strict checks than this, but none satisfy the cost/benefit based upon our understanding of attack methods, anyways let's see what the next iteration looks like. This is intended to harden (translation: attackers must put extra effort into attacking) against a mixture of W^X failures and JIT bugs which allow syscall misinterpretation, especially in environments with polymorphic-instruction/variable-sized instructions. It fits in a bit with libc/libcrypto/ld.so random relink on boot and no-restart-at-crash behaviour, particularily for remote problems. Less effective once on-host since someone the libraries can be read. For static-executables the kernel registers the main program's PIE-mapped exec section valid, as well as the randomly-placed sigtramp page. For dynamic executables ELF ld.so's exec segment is also labelled valid; ld.so then has enough information to register libc's exec section as valid via call-once msyscall(2) For dynamic binaries, we continue to to permit the main program exec segment because "go" (and potentially a few other applications) have embedded system calls in the main program. Hopefully at least go gets fixed soon. We declare the concept of embedded syscalls a bad idea for numerous reasons, as we notice the ecosystem has many of static-syscall-in-base-binary which are dynamically linked against libraries which in turn use libc, which contains another set of syscall stubs. We've been concerned about adding even one additional syscall entry point... but go's approach tends to double the entry-point attack surface. This was started at a nano-hackathon in Bob Beck's basement 2 weeks ago during a long discussion with mortimer trying to hide from the SSL scream-conversations, and finished in more comfortable circumstances next to a wood-stove at Elk Lakes cabin with UVM scream-conversations. ok guenther kettenis mortimer, lots of feedback from others conversations about go with jsing tb sthen
e8e9ef5b 2019-11-28 16:57:17 Unrevert: this change was unrelated
c8754c30 2019-11-28 16:54:29 Revert yesterday's _dl_md_reloc() and _dl_md_reloc_got() changes: something's broken on at least i386.
98a91d89 2019-11-27 01:24:35 Delete now obsolete comments
29c3eac4 2019-11-27 00:58:59 unifdef: hppa does HAVE_JMPREL and does not have DT_PROCNUM
4411ad54 2019-11-27 00:11:49 armv7 and aarch64 specify GLOB_DAT as having an addend, so treat it exactly like the ABS{32,64} relocation there. noted by and ok kettenis@
0e51d825 2019-11-26 23:38:52 Clean up _dl_md_reloc(): instead of having tables and piles of conditionals that handle a dozen relocation types for each, just have a nice little switch for the four specific relocations that actually occur. Besides being smaller and easier to understand, this fixes the COPY relocation handling to only do one symbol lookup, instead of looking up the symbol and then immediately looking it up again (with the correct flags to find the instance it needs). ok kettenis@
51a0cd2b 2019-11-26 02:50:11 Make aarch64, amd64, arm, and i386 more like sparc64: move non-lazy relocation from _dl_md_reloc() to _dl_md_reloc_all_plt() which has the minimal code to do it. Also, avoid division on PLTRELSZ; just use it to offset to the end. ok kettenis@
b883d3d1 2019-11-10 22:21:54 Simplify the handling of the explicit relocations based on ld.so only have NONE and REL32_64 relocations w/o symbol. ok visa@
5b60b03c 2019-11-10 22:20:10 unifdef HAVE_JMPREL, delete dt_pltrelsz handling (which was only used in the HAVE_JMPREL case anyway), and reduce #includes to match boot.c ok visa@
63ffa0e7 2019-11-10 22:18:14 Recommit CHECK_LDSO bits for mips64, verified on both loongson and octeon. ok visa@
2f142762 2019-10-24 22:11:10 Delete unused support for relocations that don't require alignment. ok mpi@ kettenis@
e3b0f1d9 2019-10-23 19:55:08 Prefer the size-independent ELF identifiers over the size-specific ones. Strip superfluous parens from return statements while here. Done programatically with two perl invocations idea ok kettenis@ drahn@ ok visa@
106b12d0 2019-10-21 02:36:43 Whoops: backout mips64+hppa CHECK_LDSO bits: they weren't done and weren't part of the review. My fail for forgetting to diff my tree against what was reviewed problem noted by deraadt@
17fa8871 2019-10-20 03:44:49 For more archs, ld.so itself only needs/uses the arch's "just add load offset" 'relative' relocation. Take advantage of that to simplify ld.so's self-reloc code: * give the exceptional archs (hppa and mips64) copies of the current boot.c as boot_md.c * teach the Makefile to use boot_md.c when present * reduce boot.c down to the minimum necessary to handle just relative reloc * teach the Makefile to fail if the built ld.so has other types of relocs ok visa@ kettenis@
d4afc0cd 2019-10-05 20:49:48 Tighten handling of pure relative DIR32 relocations and those referencing sections; despite being a RELA arch, ld.so was making assumptions about the initialization of the targeted location. Add the relative relocation optimization, handling relocations covered by the DT_RELACOUNT value in a tight loop. ok mpi@ deraadt@
d6b8755e 2019-10-05 00:08:50 Delete some obsolete debugging #ifdefs blocks ok mlarkin@, mpi@, krw@, deraadt@
d937a926 2019-10-04 17:42:16 Convert the child_list member from a linked list to a vector. ok mpi@
bae526ee 2019-10-03 06:10:53 Use a better algorithm for calculating the grpsym library order. The existing code did a full recursive walk for O(horrible). Instead, keep a single list of nodes plus the index of the first node whose children haven't been scanned; lookup until that index catches the end, appending the unscanned children of the node at the index. This also makes the grpsym list order match that calculated by FreeBSD and glibc in dependency trees with inconsistent ordering of dependent libs. To make this easier and more cache friendly, convert grpsym_list to a vector: the size is bounded by the number of objects currently loaded. Other, related fixes: * increment the grpsym generation number _after_ pushing the loading object onto its grpsym list, to avoid double counting it * increment the grpsym generation number when building the grpsym list for an already loaded object that's being dlopen()ed, to avoid incomplete grpsym lists * use a more accurate test of whether an object already has a grpsym list Prompted by a diff from Nathanael Rensen (nathanael (at) list.polymorpheus.com) that pointed to _dl_cache_grpsym_list() as a performance bottleneck. Much proding from robert@, sthen@, aja@, jca@ no problem reports after being in snaps ok mpi@
8d5943eb 2019-09-30 03:35:09 Oops: the call to ofree() in orealloc() was misconverted into a call to _dl_free(), which would trigger a "recursive call" assertion...if we had ever realloced in ld.so ok deraadt@
447a4a13 2019-09-02 12:43:54 Remove some duplicate symbol definitions. ok visa@ guenther@
e83568d5 2019-08-31 04:22:12 Delete the last argument to fit recent _dl_find_symbol change. ok guenther@
90273bfb 2019-08-06 04:01:41 Factor out TEXTREL mprotecting from the per-arch files into _dl_rtld(), hiding the actual grotty bits in inline functions ok mpi@
143e5acc 2019-08-04 23:51:45 Simplify _dl_find_symbol(). Currently, it returns three values: - the symbol it found, returned via the second argument - the base offset of the the object it was found in, via the return value - optionally: the object it was found in, returned via the last argument Instead, return a struct with the symbol and object pointers and let the caller get the base offset from the object's obj_base member. On at least aarch64, amd64, mips64, powerpc, and sparc64, a two word struct like this is passed in registers. ok mpi@, kettenis@
715d984b 2019-08-03 19:56:40 The ABI says JUMP_SLOT relocations don't have an addend, so don't add it in ok kettenis@
8f3b0808 2019-08-03 19:36:55 Suppress DWARF2 warnings on clang archs by building with -gdwarf-4 ok deraadt@, kettenis@
518321a8 2019-07-21 03:54:16 In 2004, we upgraded to binutils 2.14 with did -zcombreloc by default. In 2013, I implemented the single-entry LRU cache that gets the maximal symbol reuse from combreloc. Since then, the ld.so generic relocation symcache has been a waste of CPU and memory with 0% hit-rate, so kill it. ok mpi@
6eb4f976 2019-07-14 03:23:12 ld.so's $ORIGIN handling when argv[0] is a relative path was broken by the change in __getcwd(2)'s return value. Fix it by switching to the __realpath(2) syscall, eliminating the ld.so copy of realpath(). problem caught by regress and noted by bluhm@ ok deraadt@
395f4ca8 2019-07-01 15:58:38 Compile with -fno-jump-tables to avoid relocations in _dl_boot_bind() when building with clang. ok deraadt@, visa@
f4b4f15b 2019-07-01 15:57:34 Remove stray comma. ok deraadt@, visa@
9dfb6b44 2019-06-07 16:27:47 make gc workaround compile on non-clang
549b7b61 2019-06-04 02:35:40 Disable the unmapping of ld.so's boot data for now, as boehm-gc apparently follows some pointer into the middle of it. Best to keep things working while tracking down the wonkiness. problem noted by naddy@
de26657e 2019-05-12 23:32:42 Indentation fix
5c3b452c 2019-05-11 21:02:35 Prune visited leaves when walking dependencies to call init functions in topological sort order, reducing it to O(n) from O(2^n) (ouch!) diff from Nathanael Rensen (nathanael(at)list.polymorpheus.com) Much testing and pleading by robert@ and ajacoutot@ ok drahn@ mpi@
c0197e40 2019-05-10 13:29:21 ld.so boot cleanup support: - put functions and data which are only used before calling the executable's start function into their own page-aligned segments for unmapping (only done on amd64, arm64, armv7, powerpc, and sparc64 so far) - pass .init_array and .preinit_array functions an addition argument which is a callback to get a structure which includes a function that frees the boot text and data - sometimes delay doing RELRO processing: for a shared-object marked DF_1_INITFIRST do it after the object's .init_array, for the executable do it after the .preinit_array - improve test-ld.so to link against libpthread and trigger its initialization late libc changes to use this will come later ok kettenis@
466246de 2019-05-08 22:15:48 On retguard systems, remove the ld.so-local stack-protector handling functions because retguard uses hard-traps instead. ok mortimer.
9d9b0c10 2019-04-21 04:11:42 Now that all Elf_foo types are correct, we don't need to use Elf32_Word anywhere and can use Elf_Word instead. ok guenther
4e986f76 2019-04-21 03:41:13 On alpha, the buckets of DT_HASH are 8 bytes instead of 4 bytes. This was previously 'implemented' by having the Elf_Word typedef in <sys/exec_elf.h> vary, but that doesn't match the spec and breaks libelf so it's gone away. Implement the variation here by defining our own type locally for this. ok deraadt@
aadc5739 2019-04-19 08:59:40 Prevent clang from using builtins and jump tables in _dl_boot_bind() on mips64. They need relocation and consequently cannot be used in that function. OK kettenis@
87311ea8 2019-02-14 07:26:31 spelling/consistency fix; from nam nguyen
6e31582a 2019-02-03 03:44:06 _dl_cerror is trivial on powerpc; just inline the handling into the stubs based on a diff from miod@
d7a24b57 2019-02-03 02:20:36 _dl_cerror is trivial on alpha and m88k; just inline the hanlding into the stubs noted by miod@
c00e8a00 2019-01-25 18:13:13 On i386, ensure that the first PT_LOAD segment is below the W^X line unless it is writable. lld places read-only sections below the gap so this is needed to be able to retain W^X with lld. Note however the read-only sections below the W^X line are now executable on pre-NX machines and a possible source of gadgets. This is a change from Gnu ld where RO sections were ordered above the W^X line and not executable. okay drahn@ kettenis@ deraadt@
bf198cc6 2019-01-25 00:19:25 I am retiring my old email address; replace it with my OpenBSD one.
522be859 2018-12-05 04:28:32 Delete an unused struct member that has hid out here for 17 years
f939acc2 2018-12-03 05:29:56 DT_MIPS_RLD_MAP is an offset, so relocate it when present. This fixes handling of lld-linked executables on mips64. problem reported by visa@ and worked out with him
ac51d06c 2018-11-28 03:18:00 Implement support for DT_GNU_HASH, taking all the interesting bits from Matt Dillon's implementation in DragonFlyBSD commit 7629c631. One difference is that as long as DT_HASH is still present, ld.so will use that to get the total number of symbols rather than walking the GNU hash chains. Note that the GPLv2 binutils we have doesn't support DT_GNU_HASH, so this only helps archs were lld is used. ok kettenis@ mpi@
c9db2c6c 2018-11-22 21:37:29 Make alpha less special: _dl_boot_bind() is written to complete relocation of ld.so's GOT without using it, so _reloc_alpha_got() merely made the call to _dl_boot_bind() from asm simpler...while itself being a call that required special handling. diff and muild baking by miod@ ok guenther@
d4ca23ac 2018-11-20 01:38:59 On mips64, DT_DEBUG doesn't need mprotecting if it's in the GNU_RELRO segment ok visa@
25205068 2018-11-16 21:15:47 Finish ld.so's transition to GNU_RELRO: eliminate support for using __got_{start,end} to find a region to mark read-only. It was only used for binaries that didn't have a GNU_RELRO segment, but all archs have been using that for over a year. Since support for insecure-PLT layouts on powerpc and alpha have been removed, all archs handle GNU_RELRO the same way and the support can be moved from the MD code to the MI code. ok mpi@
49fb1b57 2018-11-16 05:05:44 Borrow an idea from DragonFly BSD: factor out the "does this symbol match what we're looking up?" logic from _dl_find_symbol_obj() into matched_symbol(), so that the former is just the "iterate across the hash" logic. matched_symbol() returns zero on "not found", one on "found strong symbol", and negative one on "found weak symbol". The last of those lets the caller give up on this object after finding a weak symbol, as there's no point in continuing to search for a strong symbol in the same object. ok mpi@
b5a21baa 2018-11-15 21:25:44 Put all the symbol lookup parameters (except the object being searched) and the return pointers into a structure and pass that to _dl_find_symbol_obj(). Set sl->sl_obj_out in _dl_find_symbol_obj() so that the callers don't need to each record the object. ok mpi@
9e9d93fd 2018-11-12 02:33:42 Delete support for non-secureplt binaries. The secure PLT format has been the default for years and ports doesn't appear to have anything patching to use the old format. ok deraadt@
b8058d5b 2018-11-09 07:53:14 Delete superfluous libc reach-around variables, left over from the old syscall stubs. Prompted by miod@'s poke on m88k ok visa@
043a04f9 2018-11-09 06:16:37 Delete superfluous libc reacharounds. Replace magic numbers with symbolic constants in ldasm.S Let the kernel do the cacheflush optimization. from miod@
989dfc87 2018-11-09 05:31:57 Delete support for obsolete BSS PLT format, which was last known to be used by the dearly departed editors/emacs21 port. Per naddy@, we'll keep an eye out for issues in the next ports bulk build
133128c4 2018-11-02 07:26:25 ld.so's malloc has no runtime option processing, so remove the setting flags and replace them by constants. ok deraadt@ guenther@
2668a398 2018-10-25 16:41:38 The compilers already put static arrays in .rodata when not written to; marking them const will keep a source change from silently moving them back to .data ok deraadt@ kettenis@
d1b0fb8f 2018-10-23 04:01:45 Delay processing of ld.so's own PT_GNU_RELRO section until after environment processing and malloc initialization, and then move variables set by those steps, including malloc's mopts structure, into the .data.rel.ro segment. This protects more data and eliminates the extra padding of the mopts. ok kettenis@
10200827 2018-10-22 01:59:08 Use int, not char*, for booleans ok millert@
6b54b65f 2018-10-01 22:53:48 Add retguard to arm64 ld.so. ok kettenis@
92ffaf13 2018-08-29 15:56:46 make ld.so build reproducible by including a FILE symbol and by removing -x from ld; this is only used for syspatch creation so builds are still randomized just as before ok guenther@
4e61412a 2018-07-24 09:27:44 Fix address calculation for _DYNAMIC. We want to address of _DYNAMIC itself, not the address of its GOT entry. The current code mixed the high bits of the GOT entry address with the low bits of the true address. This only worked by accident for small binaries where _DYNAMIC and its GOT entry happen to reside on the same page. ok guenther@, mortimer@
f6633b27 2018-07-09 10:12:14 unify the various per-arch syscall.h as much as possible ok kettenis guenther
acd0de91 2018-06-16 16:06:03 Add add PIE support for m88k (requires gcc4 toolchain) Convert __cerror to hidden visibility. from miod@
51e0f611 2018-06-08 19:24:46 Bail out if fchmod(2) fails. Don't quietly install ld.so.hints with mode 0600 because this adds overhead to shlib lookup for non-root processes. From Nan Xiao. ok guenther@
8b424531 2018-06-01 03:27:59 Bump ELF_RANDOMIZE_LIMIT to 1MB. ok deraadt@
1ed8c407 2018-05-15 20:37:48 On arm64 negate the whole 64-bit register otherwise system call wrappers that return ssize_t will not return a negative value upon error. Fixes dynamical loading of shared objects using dlopen(). ok guenther@
16d4e635 2018-04-27 06:49:06 Make sure ld.so doesn't use floating point registers, as the lazy-binding stub doesn't preserve them and some may be used for passing arguments ok kettenis@ deraadt@ mlarkin@
f4147939 2018-04-26 12:42:50 Use <fcntl.h> instead of <sys/file.h> for open() and friends. Delete a bunch of unnecessary #includes and sort to match style(9) while doing the above cleanup. ok deraadt@ krw@
91659d32 2018-03-09 14:55:44 Add support for the DF_TEXTREL flag. ok patrick@, millert@
4e496f3d 2018-02-09 22:13:04 Use a static chacha instance to fill randomdata sections. Avoids looping over a syscall for randomdata sections larger than 256B. ok djm@ deraadt@ kettenis@
2b5a4592 2018-02-07 18:59:20 sync with libc malloc: use consistent style for for loop in unmap(), no functional change
9777ac55 2018-02-04 20:41:58 Expand Type strings by one space, to fit ld.so, in the same ugly way "exe " was being handled.
5efa8d23 2018-02-01 11:14:23 don't forget to increment loop var; infinite loops spotted by sthen@
242436d2 2018-01-30 21:08:05 No need to add ffs.c as we use .VPATH to reach over into libc/string. ok otto@