aboutsummaryrefslogtreecommitdiff
path: root/libexec
Commit message (Collapse)AuthorAgeFilesLines
* libexec: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-0411-17/+16
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314653
* Renumber copyright clause 4Warner Losh2017-02-282-2/+2
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Fully handle the special encoding of GOT[1] on mips64.John Baldwin2017-02-231-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MIPS ABI does not require the second GOT entry to be reserved for use by the runtime linker as on other architectures. Instead, static linkers use a special value in the second GOT entry to indicate if the entry is reserved. This value is supposed to consist of an address with the MSB set and the rest of the bits all zero which is an invalid user address. However, the old binutils currently in the tree uses the 32-bit mask value (2^31) on 64-bit MIPS instead of 2^63. This was fixed in upstream binutils in 2008 to use 2^63 on 64-bit MIPS. The first part of this change changes the runtime check in init_pltgot() to check for both values (2^31 and 2^63) when deciding whether to store the current object pointer in GOT[1] which fixes dynamic N64 binaries compiled with modern binutils. However, the initial version of this fix exposed another related bug in that _rtld_relocate_nonplt_self() was only checking for the new value (2^63) in GOT[1] and incorrectly treated GOT[1] as a local GOT entry (and did not relocate the final local GOT entry). To handle this, fix all of the places that check for GOT[1]'s status to use the same macro that checks for both values on N64. Reviewed by: kan, imp Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D9708 Notes: svn path=/head/; revision=314115
* Handle protected symbols in rtld.Konstantin Belousov2017-02-091-8/+12
| | | | | | | | | | | | | Protected symbol reference in GOT of the defining object must be resolved to itself, same as -Bsymbolic globally. Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D9317 Notes: svn path=/head/; revision=313494
* Try to fix the old "he capability is stupid" bug in gettytab(5)/getty(8)Alexey Dokuchaev2017-02-022-50/+46
| | | | | | | | | | | | | | | | | | | | | | | | | There is one capability explicitly documented in gettytab(5) as stupid: he. And it is indeed. It was meant to facilitate system hostname modification, but is hardly usable in practice because it allows very limited editing (e.g., it depends on a particular hostname length, making it non-generic). Replace it with simple implementation that treats ``he'' as POSIX extended regular expression which is matched against the hostname. If there are no parenthesized subexpressions in the pattern, entire matched string is used as the final hostname. Otherwise, use the first matched subexpression. If the pattern does not match, the original hostname is not modified. Using regex(3) gives more freedom, does not complicate the code very much, and makes a lot more sense, in turn making ``he'' less stupid and actually useful (e.g., it is now possible to obtain node or domain names from the original hostname string, without knowing it in advance). Reviewed by: jilles, manpages (wblock) Approved by: jilles (implied) Differential Revision: https://reviews.freebsd.org/D9244 Notes: svn path=/head/; revision=313107
* Remove a duplicate store when performing REL32 relocations in rtld.John Baldwin2017-01-301-1/+0
| | | | | | | | | | | | | The duplicate call to store_ptr() was added in r204687, but it should have no effect as it only stores an Elf_Sword and the later store_ptr() does a write that is at least as large if not larger. Reviewed by: jmallett Obtained from: CheriBSD (sort of) Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=313003
* Extend LD_UTRACE by also generating utrace(2) log events for runtime linkerPeter Jeremy2017-01-302-0/+2
| | | | | | | | | | | | errors. Reviewed by: kib, jhb Approved by: jhb(mentor) MFC after: 1 week Differential Revision: D9347 Notes: svn path=/head/; revision=312984
* Remove pc98 support completely.Yoshihiro Takahashi2017-01-281-4/+0
| | | | | | | | | I thank all developers and contributors for pc98. Relnotes: yes Notes: svn path=/head/; revision=312910
* Pull the R_AARCH64_TLSDESC code out into a common function and use them inAndrew Turner2017-01-251-8/+16
| | | | | | | | | | | | | | both the plt and non-plt case. This fixes an issue where libraries built with LLD can fail with "Unhandled relocation 1031" PR: 214971 Obtained from: 1 week Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=312764
* rtld: do not rely on a populated GOT on amd64Ed Maste2017-01-162-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | On rela architectures GNU BFD ld and gold store the relocation addend in GOT entries (in addition to the relocation's r_addend field). rtld previously relied on this to access its own _DYNAMIC symbol in order to apply its own relocations. However, recording addends in the GOT is not specified by the ABI, and some versions of LLVM's LLD linker leave the GOT uninitialized on rela architectures. BFD ld does not populate the GOT on sparc64, and sparc64 rtld has a machine-dependent rtld_dynamic_addr() function that returns the _DYNAMIC address. Use the same approach on amd64, obtaining the %rip- relative _DYNAMIC address following a suggestion from Rafael Espíndola. Architectures other than amd64 should be addressed in future work. PR: 214972 Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9180 Notes: svn path=/head/; revision=312288
* For the main binary, postpone enforcing relro read-only protectionKonstantin Belousov2017-01-121-8/+20
| | | | | | | | | | | | | until copy relocations are done. Newer binutils and lld seems to output copy into relro-protected range. Reported by: Rafael Espц╜ndola via emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=311984
* Fix acquisition of nested write compat rtld locks.Konstantin Belousov2017-01-101-23/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Obtaining compat rtld lock in write mode sets process signal mask to block all signals. Previous mask is stored in the global variable oldsigmask. If a lock is write-locked while another lock is already write-locked, oldsigmask is overwritten by the total mask and on the last unlock, all signals except traps appear to be blocked. Fix this by counting the write-lock nested level, and only storing to oldsigmask/restoring from it at the outermost level. Masking signals disables involuntary preemption for libc_r, and there could be no voluntary context switches in the locked code (dl_iterate_phdr(3) keeps a lock around user callback, but it was added long after libc_r was renounced). Due to this, remembering the level in the global variable after the lock is obtained should be safe, because no two libc_r threads can acquire different write locks in parallel. PR: 215826 Reported by: kami Tested by: yamagi@yamagi.org (previous version) To be reviewed by: kan Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=311886
* Use ANSI C definitions, update comment.Konstantin Belousov2017-01-101-4/+4
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=311879
* Conditionalize all code that uses tcpd.h behind `LIBWRAP` guardEnji Cooper2017-01-062-1/+11
| | | | | | | | | This will allow the code to stand by itself without libwrap MFC after: 2 weeks Notes: svn path=/head/; revision=311473
* Don't use high precision clock for expiration as only second portion isXin LI2016-12-261-7/+7
| | | | | | | | | used. MFC after: 2 weeks Notes: svn path=/head/; revision=310609
* Avoid use after free.Xin LI2016-12-261-4/+6
| | | | | | | | Reported by: Clang static code analyzer MFC after: 2 weeks Notes: svn path=/head/; revision=310608
* rtld: Fix a couple of bugs around the unloading of ELF filters.Mark Johnston2016-12-221-5/+23
| | | | | | | | | | | | | | - Pass the correct object to unload_filtees(). - Use a marker to restart iteration after unload_filtees() has returned. It calls dlclose() and may recursively remove entries from the global object list, so TAILQ_FOREACH_SAFE is not sufficient. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310422
* rtld: Ensure that dlopen() cannot obtain a reference on a doomed object.Mark Johnston2016-12-222-10/+9
| | | | | | | | | | | | | rtld drops the bind lock to call fini functions in an object prior to unmapping it. The new "doomed" state flag prevents the acquisition of new references for an object while the lock is dropped. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310421
* rtld: Fix a race between dl_iterate_phdr() and dlclose().Mark Johnston2016-12-222-5/+50
| | | | | | | | | | | | Add a transient reference count to ensure that the phdr argument to the callback remains valid while the bind lock is dropped. Reviewed by: kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310420
* Fix typo.Konstantin Belousov2016-12-161-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=310155
* Take write lock for rtld_bind before modifying obj_list in dl_iterate_phdr().Bryan Drewery2016-12-131-2/+2
| | | | | | | | | | | | This avoids a race with readers such as dladdr(3)/dlinfo(3)/dlsym(3) and the atexit(3) handler. This race was introduced in r294373. Reviewed by: markj, kib, kan MFC after: 2 weeks Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=310025
* Retire long-broken/unused static rtld supportEd Maste2016-12-024-19/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | rtld-elf has some vestigial support for building as a static executable. r45501 introduced a partial implementation with a prescient note that it "might never be enabled." r153515 introduced ELF symbol versioning support, and removed part of the unused build infrastructure for static rtld. GNU ld populates rela relocation addends and GOT entries with the same values, and rtld's run-time dynamic executable check relied on this. Alternate toolchains may not populate the GOT entries, which caused RTLD_IS_DYNAMIC to return false. Simplify rtld by just removing the unused check. If we want to restore static rtld support later on we ought to introduce a build-time #ifdef flag. PR: 214972 Reviewed by: kan MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8687 Notes: svn path=/head/; revision=309411
* Fix _mips_rtld_bind() to handle ELF filters.John Baldwin2016-11-232-4/+15
| | | | | | | | | | | | | | | | | | | MIPS does not use the common _rtld_bind() to handle runtime binding. Instead, it uses a private _mips_rtld_bind(). Update _mips_rtld_bind() to include the changes made to _rtld_bind() in r216695 and r218476 to support upgrading the read-locked rtld_bind_lock to a write lock when an object with a filter is encountered. While here, add a 'where' variable to track the location of the fixup in the GOT to make the code flow more closely match _rtld_bind(). Reviewed by: kib Obtained from: CheriBSD Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D8625 Notes: svn path=/head/; revision=309068
* Adjust r308689 to make rtld compilable with either in-tree orKonstantin Belousov2016-11-2110-14/+26
| | | | | | | | | | | | | | | | | | | (hopefully) stock gcc 4.2.1 on i386 and other arches. In particular: - Do not use %ebx in the asm constraints on i386, since rtld is compiled with -fPIC and gcc cannot handle GOT-base register reload (clang and newer gcc can). - Avoid direct use of [static N] construct in the function declaration/definion. In-tree gcc was patched to support this, but stock 4.2.1 cannot handle the feature. Requested by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=308925
* Pass CPUID[1] %edx (cpu_feature), %ecx (cpu_feature2) andKonstantin Belousov2016-11-1520-5/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | CPUID[7].%ebx (cpu_stdext_feature), %ecx (cpu_stdext_feature2) to the ifunc resolvers on x86. It is much more clean to use CPUID instruction in usermode to retrieve this information than to pass AT_HWCAP aux vector from kernel, on x86. Still, the change does allow for use of AT_HWCAP on arches where it is needed, by passing aux array to ifunc_init() initializer which should prepare arguments for ifunc resolvers. Current signature for resolvers on x86 is func_t iresolve(uint32_t cpu_feature, uint32_t cpu_feature2, uint32_t cpu_stdext_feature, uint32_t cpu_stdext_feature2); where arguments have identical meaning as the kernel variables of the same name. The ABIs allow to use resolvers with the void or shortened list of arguments. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D8448 Notes: svn path=/head/; revision=308689
* Assert that there is no unresolved symbols during rtld linking.Konstantin Belousov2016-11-151-1/+1
| | | | | | | | | | Reviewed by: emaste, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week X-Differential revision: https://reviews.freebsd.org/D8448 Notes: svn path=/head/; revision=308688
* Update hint to utilize user variable.Konstantin Belousov2016-11-151-1/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=308687
* Fix build when WITHOUT_BLACKLIST=yes is specifiedKurt Lidl2016-11-121-3/+0
| | | | | | | | | | | PR: 214409 Submitted by: matthew Reported by: matteo MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=308567
* Pass the correct flag to find_symdef() from _rtld_bind().John Baldwin2016-11-082-3/+3
| | | | | | | | | | | | | | | | When symbol versioning was added to rtld, the boolean 'in_plt' argument to find_symdef() was converted to a bitmask of flags. The first flag added was 'SYMLOOK_IN_PLT' which replaced the 'in_plt' bool. This happened to still work by accident as SYMLOOK_IN_PLT had the value of 1 which is the same as 'true', so there should be no functional change. Tested on: amd64 Reviewed by: kan MFC after: 2 weeks Sponsored by: DARPA / AFRL Notes: svn path=/head/; revision=308456
* Revisit blacklistd support in ftpdKurt Lidl2016-11-014-15/+50
| | | | | | | | | | | | | | | | Enhance blacklistd support to not log anything by default, unless blacklistd support is enabled on the command line. Document new flag in man page, cleanup patches to be less intrusive in code. Reported by: Rick Adams Reviewed by: cem, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8374 Notes: svn path=/head/; revision=308175
* Reference the libc symbols ypresp_{allfn,data} instead of local symbols.Mark Johnston2016-10-161-2/+2
| | | | | | | | | | This fixes a regression introduced in r285926. PR: 213506 MFC after: 3 days Notes: svn path=/head/; revision=307398
* Use SRCTOP instead of the longhand version for defining the path to contrib/atfEnji Cooper2016-09-202-2/+2
| | | | | | | | MFC after: 3 days Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=306029
* DIRDEPS_BUILD: Add some missing dirctories to the build.Bryan Drewery2016-08-312-0/+36
| | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=305148
* [mips] flip from =v to =r - let the compiler choose a temp register.Adrian Chadd2016-08-251-2/+2
| | | | | | | | | | =v is some ye olde gcc "use this specific register as the temp register" thing that they've deprecated and clang/llvm doesn't implement. Poked again and again by: sbruno Notes: svn path=/head/; revision=304823
* Import Dragonfly Mail Agent snapshort from 20160806 aka v0.11+Baptiste Daroussin2016-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Most important change being: dma - Fix security hole (#46) Affecting DragonFly 4.6 and earlier, Matt Dillon fixed this in base after finding out from BSDNow Episode 152. Comments following were from his commit which explains better than I. Just taking his change and putting it here as well. * dma makes an age-old mistake of not properly checking whether a file owned by a user is a symlink or not, a bug which the original mail.local also had. * Add O_NOFOLLOW to disallow symlinks. Thanks-to: BSDNow Episode 152, made me dive dma to check when they talked about the mail.local bug. MFC After: 2 days Notes: svn path=/head/; revision=304535
* Move defines common between rtld and libsysdecode into the header,Konstantin Belousov2016-08-122-27/+65
| | | | | | | | | | instead of copying inline into sources. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=304016
* Fill phdr and phsize for rtld object. It is needed forKonstantin Belousov2016-08-121-0/+4
| | | | | | | | | | | dl_iterate_phdr() reporting the correct values. PR: 211367 Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=304012
* Remove all remaining uses of TAILQ_FOREACH_FROM() from rtld-elf.Konstantin Belousov2016-08-121-10/+6
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=304011
* [mips] add support for using the MIPS user register for TLS data.Adrian Chadd2016-08-071-0/+54
| | | | | | | | | | | | | | | | | | | | | | | This work, originally from Stacey Son, uses the MIPS UserReg for reading the TLS data, and will fall back to the normal syscall path when it isn't supported. This code dynamically patches cpu_switch() to bypass the UserReg instruction so to avoid generating a machine exception. Thanks to sson for the original work, and to Dan Nelson for bringing it to date and testing it on MIPS32 with me. Tested: * mips64 (sson) * mips74k (dnelson_1901@yahoo.com) - AR9344 SoC, UserReg support * mips24k (adrian) - AR9331 SoC, no UserReg support Obtained from: sson, dnelson_1901@yahoo.com Notes: svn path=/head/; revision=303809
* Fix dlsym(RTLD_NEXT) handling to only return the next library in last ↵Bryan Drewery2016-07-151-1/+1
| | | | | | | | | | | | | | | | | | | library cases. The root of the problem here is that TAILQ_FOREACH_FROM will default to the head of the list if passed NULL, which will be the case if there are no libraries loaded after this one. Thus all libraries, including the current, were iterated in that case rather than none. This was broken in r294373. Reviewed by: markj (earlier version), cem, kib, ngie MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D7216 Notes: svn path=/head/; revision=302908
* Fix race for incrementally rebuilding VERSION_MAP.Bryan Drewery2016-07-031-2/+1
| | | | | | | | | | | | | | | | | The dependency is needed in PROG_FULL since only the build of PROG_FULL is using the LDFLAGS and depending on VERSION_MAP. This was not a problem with MK_DEBUG_FILES==no since it only builds PROG. This should probably be using bsd.lib.mk instead [1] Reported by: swills, gjb Reviewed by: emaste Noted by: rgrimes [1] Sponsored by: EMC / Isilon Storage Division Approved by: re (kib) Notes: svn path=/head/; revision=302325
* DIRDEPS_BUILD: Update dependenciesBryan Drewery2016-06-144-0/+8
| | | | | | | | Approved by: re (gjb) Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=301891
* Separate BLACKLIST vs BLACKLIST_SUPPORT properlyKurt Lidl2016-06-071-1/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=301553
* Update blacklist support in ftpd to clarify fd usageKurt Lidl2016-06-062-13/+11
| | | | | | | | | | | | | | | | The ftp daemon dups the control socket to stdin and uses that fd throughout the code. Clarify this usage slightly by changing from explicit use of "0" for the fd to a variable, to make it clear what the zero represents in the non-blacklist code. Make the blacklist_notify routine use STDIN_FILENO so as to have less of a "magic number" feel to the code. Reviewed by: cem Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6716 Notes: svn path=/head/; revision=301517
* Add blacklist support to rlogindKurt Lidl2016-06-052-3/+27
| | | | | | | | | | Reviewed by: rpaulo Approved by: rpaulo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6593 Notes: svn path=/head/; revision=301417
* DIRDEPS_BUILD: Connect new directories and update dependencies.Bryan Drewery2016-06-031-0/+11
| | | | | | | Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=301283
* Add blacklist support to fingerdKurt Lidl2016-06-032-0/+20
| | | | | | | | | | | Reviewed by: rpaulo Approved by: rpaulo Relnotes: YES Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D5916 Notes: svn path=/head/; revision=301243
* Add blacklist support to rshdKurt Lidl2016-06-032-1/+42
| | | | | | | | | | | Reviewed by: rpaulo Approved by: rpaulo Relnotes: YES Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6594 Notes: svn path=/head/; revision=301242
* Add blacklist support to ftpdKurt Lidl2016-06-034-0/+109
| | | | | | | | | | | Reviewed by: rpaulo Approved by: rpaulo Relnotes: YES Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D6703 Notes: svn path=/head/; revision=301241
* Add basic blacklist build supportKurt Lidl2016-06-022-0/+12
| | | | | | | | | | | Reviewed by: rpaulo Approved by: rpaulo Relnotes: YES Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D5913 Notes: svn path=/head/; revision=301226