aboutsummaryrefslogtreecommitdiff
path: root/libexec
Commit message (Collapse)AuthorAgeFilesLines
* Teach /etc/rc.d/growfs how to handle systems running ZFS.Colin Percival2019-02-081-2/+22
| | | | | | | | | | | | | There are many cases which this code does not handle (e.g. ZFS mirrors) but the code can handle the single-disk case -- so it's enough to take care of the "disk image which gets booted into a VM with a larger than expected disk" case for which this firstboot script was created. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19095 Notes: svn path=/head/; revision=343918
* Remove All Rights ReservedWarner Losh2019-02-051-1/+1
| | | | | | | | Remove the all rights reserved clause from my copyright, and make other minor tweaks needed where that might have created ambiguity. Notes: svn path=/head/; revision=343811
* rtld: pacify -Wmaybe-uninitialized from gcc6Eric van Gyzen2019-02-011-0/+4
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=343672
* Rename rtld-elf/malloc.c to rtld-elf/rtld_malloc.c.Konstantin Belousov2019-01-302-3/+11
| | | | | | | | | | Then malloc.c file name is too generic to use it for libthr.a. Sponsored by: The FreeBSD Foundation MFC after: 13 days Notes: svn path=/head/; revision=343580
* Add header file missed in r343564.Konstantin Belousov2019-01-291-0/+45
| | | | | | | | | MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343565
* Adjust posix symbols from rtld-elf/malloc.c with the __crt_ prefix.Konstantin Belousov2019-01-294-16/+59
| | | | | | | | | | | | This allows to reuse the allocator in other environments that get malloc(3) and related functions from libc or interposer. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D18988 Notes: svn path=/head/; revision=343564
* rc(8): do not stop dhclient(8) when wpa_supplicant(8) / hostapd(8) is usedAndriy Voskoboinyk2019-01-271-3/+1
| | | | | | | | | | | They will stop it automatically ('Interface wlan0 is down, dhclient exiting'); use /etc/rc.d/dhclient stop command only when none of them is used. MFC after: 5 days Notes: svn path=/head/; revision=343499
* Remove now redundand ifunc relocation code which should have beenKonstantin Belousov2019-01-271-10/+0
| | | | | | | | | | | | | | | | removed as part of r341441. This call to reloc_non_plt() may crash if ifunc resolvers use the needed libraries symbols since the pass over the needed libs relocation is not yet done. The change in r341441 ensures the right relocation order otherwise. Submitted by: theraven MFC after: 1 week Discussed in: https://reviews.freebsd.org/D17529 Notes: svn path=/head/; revision=343484
* Fix potential buffer overflow and undefined behavior.Stefan Eßer2019-01-261-2/+2
| | | | | | | | | | | | | | | | The buffer allocated in read_chat() could be 1 element too short, if the chatstr parameter passed in is 1 or 3 charachters long (e.g. "a" or "a b"). The allocation of the pointer array does not account for the terminating NULL pointer in that case. Overlapping source and destination strings are undefined in strcpy(). Instead of moving a string to the left by one character just increment the char pointer before it is assigned to the results array. MFC after: 2 weeks Notes: svn path=/head/; revision=343479
* Use a private definition of osockaddr rather then relying on typeBrooks Davis2019-01-181-1/+2
| | | | | | | | | | | | namespace polution in sys/socket.h. Also remove support for operation on 4.3BSD. PR: 224529 Differential Revision: https://reviews.freebsd.org/D14505 Notes: svn path=/head/; revision=343161
* Revert r343093 until I can address the issues raised by kib@.Dag-Erling Smørgrav2019-01-171-27/+18
| | | | Notes: svn path=/head/; revision=343116
* Implement dlopenat(3).Dag-Erling Smørgrav2019-01-161-18/+27
| | | | | | | MFC after: 3 weeks Notes: svn path=/head/; revision=343093
* Fix rtld-elf compilation warning for powerpc64 ELFv2 ABIJustin Hibbits2019-01-131-1/+1
| | | | | | | | | | | | Summary: reloc_jmpslot function parameter 'defobj' is not used when using ELFv2 ABI Submitted by: alfredo.junior_eldorado.org.br Reviewed By: kib, git_bdragon.rtk0.net, emaste, jhibbits Differential Revision: https://reviews.freebsd.org/D18808 Notes: svn path=/head/; revision=342985
* rc.subr: Fix typoKyle Evans2019-01-061-2/+2
| | | | | | | | | | | | Originally intended as 'in case in needs to be re-invoked', but it was later decided (by myself) that 're-invoke itself' makes it more clear that the script is expected to use this in a way. Reported by: Jose Luis Duran (jlduran @ github) X-MFC-With: r342792 Notes: svn path=/head/; revision=342805
* rc.subr: Provide rc_service variable for service scriptsKyle Evans2019-01-051-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | Some rc scripts in ports (e.g. uwsgi, apache, openvpn) allow for 'application profiles' that usually require the rc script to be invoked again for each active profile. Because there's no consistent way to determine the path because it differs between manual/service(8) invocations and /etc/rc invocations, this leads to patterns like these: - www/uwsgi hardcodes the script path - security/openvpn guesses either $_file or $0 based on $0 = /etc/rc Instead of forcing rc scripts to guess, provide an rc_service variable to the scripts that gets set appropriately both for direct execution or when a script is being executed via run_rc_script (e.g. /etc/rc). This is our analog of an OpenRC variable with the same name, different case (RC_SERVICE). PR: 234614 Reported by: koobs Reviewed by: dteske, jilles MFC after: 3 days Notes: svn path=/head/; revision=342792
* rtld-elf: Fix powerpc64 TLS handling, matching powerpc's fixJustin Hibbits2019-01-011-1/+1
| | | | | | | | | | | | | We need to subtract the TLS_TCB_SIZE to get to the real data pointer, since r13 points to the end of the TCB structure. Prior to this, devel/protobuf-c port broke with recent update to devel/protobuf, which exposed this issue. Submitted by: andreast Reported by: Piotr Kubaj MFC after: 1 week Notes: svn path=/head/; revision=342671
* Remove iBCS2, part1: userspaceMateusz Guzik2018-12-192-21/+0
| | | | | | | | | | | | iBCS2 was disconnected from the build in 2015 (see r291419) bsdconfig parts submitted by dteske. Reviewed by: kib (previous version) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342242
* bootpd: validate hardware typeEd Maste2018-12-191-0/+4
| | | | | | | | | | | | | | | | Due to insufficient validation of network-provided data it may have been possible for a malicious actor to craft a bootp packet which could cause a stack buffer overflow. admbugs: 850 Reported by: Reno Robert Reviewed by: markj Approved by: so Security: FreeBSD-SA-18:15.bootpd Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=342227
* Conditionally install /etc/rc.d/audit* based on ${MK_AUDIT}Alan Somers2018-12-161-2/+6
| | | | | | | | | | | | | /usr/sbin/audit(dist)?d are only installed if ${MK_AUDIT} == yes. Their supporting scripts should only be installed in those instances as well. Submitted by: ngie Reviewed by: emaste MFC after: 2 weeks Pull Request: https://github.com/freebsd/freebsd/pull/242 Notes: svn path=/head/; revision=342153
* Remove, the now very outdated, timed.George V. Neville-Neil2018-12-152-23/+0
| | | | | | | | | | Submitted by: Kyle Spiers ksspiers at gmail Reviewed by: bcr,brooks,bz,sbruno Relnotes: yes Differential Revision: https://reviews.freebsd.org/D18505 Notes: svn path=/head/; revision=342139
* Improve R_AARCH64_TLSDESC relocation.Michal Meloun2018-12-1512-110/+199
| | | | | | | | | | | | | | | | | | | | | | The original code did not support dynamically loaded libraries and used suboptimal access to TLS variables. New implementation removes lazy resolving of TLS relocation - due to flaw in TLSDESC design is impossible to switch resolver function at runtime without expensive locking. Due to this, 3 specialized resolvers are implemented: - load time resolver for TLS relocation from libraries loaded with main executable (thus with known TLS offset). - resolver for undefined thread weak symbols. - slower lazy resolver for dynamically loaded libraries with fast path for already resolved symbols. PR: 228892, 232149, 233204, 232311 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D18417 Notes: svn path=/head/; revision=342113
* rc.subr: Implement list_vars without using 'read'Conrad Meyer2018-12-111-7/+19
| | | | | | | | | | | | | | | | | 'read' pessimistically read(2)s one byte at a time, which can be quite silly for large environments in slow emulators. In my boring user environment, truss shows that the number of read() syscalls to source rc.subr and invoke list_vars is reduced by something like 3400 to 60. ministat(1) shows a significant time difference of about -71% for my environment. Suggested by: jilles Discussed with: dteske, jhb, jilles Differential Revision: https://reviews.freebsd.org/D18481 Notes: svn path=/head/; revision=341803
* Implement R_AARCH64_TLS_DTPMOD64 and A_AARCH64_TLS_DTPREL64 relocations.Michal Meloun2018-12-081-0/+19
| | | | | | | | | | | | | | | | | | Although these are slightly obsolete in favor of R_AARCH64_TLSDESC, gcc -mtls-dialect=trad still use them. Please note that definition of TLS_DTPMOD64 and TLS_DTPREL64 are incorrectly exchanged in GNU binutils. TLS_DTPREL64 should be encoded to 1028 (as is defined in ARM ELF ABI) but binutils encode it to 1029. And vice versa, TLS_DTPMOD64 should be encoded to 1029 but binutils encode it to 1028. While I'm in, add also R_AARCH64_NONE. It can be produced as result of linker relaxation. MFC after: 1 week Notes: svn path=/head/; revision=341738
* Tidy up arm64 reloc_jmpslots() implementation.Michal Meloun2018-12-051-13/+4
| | | | | | | | | | | - don't relocate jump slots multiple times (if LD_BIND_NOW is defined). - process only R_AARCH64_JUMP_SLOT here, other relocation types are handled by reloc_plt(). MFC after: 1 week Notes: svn path=/head/; revision=341513
* Implement arm64 version of __tls_get_addr().Michal Meloun2018-12-051-0/+12
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=341512
* Fix style(9).Michal Meloun2018-12-052-6/+7
| | | | | | | | | Not a functional change. MFC after: 1 week Notes: svn path=/head/; revision=341511
* Some fixes for LD_BIND_NOW + ifuncs.Konstantin Belousov2018-12-032-42/+50
| | | | | | | | | | | | | | | | | | | | | | | | | - Do not perform ifunc relocations together with other PLT relocations in PLT. Instead, do it during an additional pass over the init list, so that ifuncs are resolved in the order of dso dependencies. This allows the ifuncs resolvers to call into depended libs. Init list now includes all objects instead of only objects with init/fini callables. - Disable relro protection around bind_now ifunc relocations. I considered calling ifunc resolvers of dso after initializers of all dependencies are processed, and decided that this is wrong/should not be supported. The order now is normal relocations for all objects->ifunc resolution in init order->initializers, where each step does complete pass over all loaded objects before moving to the next step. Reported, tested and reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18400 Notes: svn path=/head/; revision=341441
* Provide naive but self-contained implementations of memset(3) andKonstantin Belousov2018-12-031-0/+22
| | | | | | | | | | | | | | | | bzero(3) for rtld. This again reduces rtld dependency on libc, and in future, avoid ifunc relocations when the functions are converted to ifuncs in libc. Reported by: mjg Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18400 Notes: svn path=/head/; revision=341439
* disable BIND_NOW in libc, libthr, and rtldEd Maste2018-12-031-0/+1
| | | | | | | | | | | | | | | An issue remains with BIND_NOW and processes using threads. For now, restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and libthr. A patch is in review (D18400) that likely fixes this issue, but just disable BIND_NOW pending further testing after it is committed. PR: 233333 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=341429
* rtld: parse FreeBSD Feature Control note on the object load.Konstantin Belousov2018-11-232-0/+9
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=340858
* Revert r340843 - addressed independently in r340842!Conrad Meyer2018-11-231-4/+0
| | | | Notes: svn path=/head/; revision=340844
* rtld: Silence a false positive GCC 6.4.0 warningConrad Meyer2018-11-231-0/+4
| | | | | | | | | | | | The function reloc_non_plt has complicated variable lifetimes that GCC 6.4.0 (the version currently used by amd64-xtoolchain-gcc) misunderstands and produces an erroneous warning about. Silence it to allow the -Werror build to proceed. Reviewed by: emaste Notes: svn path=/head/; revision=340843
* Silence gcc warnings.Konstantin Belousov2018-11-231-0/+3
| | | | | | | | | Reported by: emaste Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=340842
* Allow forced start of ipmon in special cases where testing is desiredCy Schubert2018-11-221-1/+1
| | | | | | | | | | (or other special cases) and when ipfilter is disabled in rc.conf but started by other means. MFC after: 1 week Notes: svn path=/head/; revision=340754
* rtld: when immediate bind mode is requested, process irelocs in PLTKonstantin Belousov2018-11-201-2/+5
| | | | | | | | | | | | | | | | | immediately after other PLT relocs. Otherwise, if the object has relro page, we write to readonly page, and we would need to use mprotect(2) two more times to fix it. Note that resolve_object_ifunc() does nothing when called second time, so there is no need to avoid existing call. Reported and tested by: emaste PR: 233333 Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=340675
* Move definition of $jail_conf variable to /etc/defaults/rc.confEugene Grosbein2018-11-102-1/+1
| | | | | | | | | | from jail startup script so it can be successfully queried with the command "sysrc jail_conf". MFC after: 1 month Notes: svn path=/head/; revision=340321
* Handle the DT_MIPS_RLD_MAP_REL dynamic tag in RTLDAlex Richardson2018-11-071-0/+7
| | | | | | | | | | | | | | This dynamic tag contains the location of the .rld_map section relative to the location of the dynamic tag. For PIE MIPS binaries DT_MIPS_RLD_MAP can not be used since it contains an absolute address. Without this change GDB can not find the function program counters in other libraries and once I apply this change I can successfully run info sharedlibraries again. Reviewed By: kib Differential Revision: https://reviews.freebsd.org/D17867 Notes: svn path=/head/; revision=340218
* rtld: move relro enforcement after ifunc processingEd Maste2018-11-041-4/+4
| | | | | | | | | | | | | | | | | | | | | Previously the combination of relro (implicit), -z now and ifunc use resulted in a segfault when applying ifuncs after relro (test binary here just calls amd64_get_fsbase()): | % env LD_DEBUG=1 libexec/rtld-elf/obj/ld-elf.so.1 a.out | ... | enforcing main obj relro | ... | resolving ifuncs | reloc_jmpslot: *0x203198 = 0x189368ea4570 | zsh: bus error (core dumped) LD_DEBUG=1 obj/ld-elf.so.1 ~/a.out Reported by: Shawn Webb Reviewed by: kib Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=340137
* Remove Obj_Entry textsize member.Konstantin Belousov2018-11-043-6/+0
| | | | | | | | | | | It is unused after r340102, and more important, I do not see how to define textsize in both practically useful and correct way, for binaries with more that one executable segments. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=340107
* Flush data cache for executable loadable segments explicitly.Konstantin Belousov2018-11-032-4/+26
| | | | | | | | | | | | | | | Do not use textsize and do not flush everything between map base and base + textsize, because unmapped areas cannot be flushed. This makes Obj_Entry textsize only use go away, and I will remove it later. Reported by: tuexen Tested by: Mark Millard <marklmi26-fbsd@yahoo.com> Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=340102
* Run unbound-anchor when root.key is empty, not just when it is absent.Dag-Erling Smørgrav2018-11-011-1/+1
| | | | | | | | | PR: 232555 Submitted by: Ari Suutari <ari@stonepile.fi> MFC after: 3 days Notes: svn path=/head/; revision=339995
* Add new rc keywords: enable, disable, deleteDevin Teske2018-10-312-3/+30
| | | | | | | | | | | | | | | | | | This adds new keywords to rc/service to enable/disable a service's rc.conf(5) variable and "delete" to remove the variable. When the "service_delete_empty" variable in rc.conf(5) is set to "YES" (default is "NO") an rc.conf.d file (in /etc/ or /usr/local/etc) is deleted if empty after modification using "service $foo delete". Submitted by: lme (modified) Reviewed by: 0mp (previous version), lme, bcr Relnotes: yes Sponsored by: Smule, Inc. Differential Revision: https://reviews.freebsd.org/D17113 Notes: svn path=/head/; revision=339971
* Remove rtld use of libc amd64_set_fsbase().Konstantin Belousov2018-10-291-9/+19
| | | | | | | | | | | | One less non-trivial dependency of rtld on libc. Also, amd64_set_fsbase() is to be converted to ifunc, which I do not want to support inside rtld. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=339897
* Initialize ifunc calling machinery earlier.Konstantin Belousov2018-10-291-1/+2
| | | | | | | | | | | In particular, do it before the first call to allocate_initial_tls(), which contains MD parts to set the initial thread' TLS pointer. Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=339896
* rtld-elf: fix more warnings to allow compiling with WARNS=6Alex Richardson2018-10-298-25/+31
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17154 Notes: svn path=/head/; revision=339879
* rtld-elf: compile with WANRS=4 warnings other than -Wcast-alignAlex Richardson2018-10-2920-208/+249
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17153 Notes: svn path=/head/; revision=339878
* rtld-elf: make it compile with WARNS=3Alex Richardson2018-10-296-27/+34
| | | | | | | | | Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17150 Notes: svn path=/head/; revision=339877
* rtld: set obj->textsize correctlyAlex Richardson2018-10-292-4/+11
| | | | | | | | | | | | | | | | | | | | With lld-generated binaries the first PT_LOAD will usually be a read-only segment unless you pass --no-rosegment. For those binaries the textsize is determined by the next PT_LOAD. To allow both LLD and bfd 2.17 binaries to be parsed correctly use the end of the last PT_LOAD that is marked as executable instead. I noticed that the value was wrong while adding some debug prints for some rtld changes for CHERI binaries. `obj->textsize` only seems to be used by PPC so the effect is untested. However, the value before was definitely wrong and the new result matches the phdrs. Reviewed By: kib Approved By: brooks (mentor) Differential Revision: https://reviews.freebsd.org/D17117 Notes: svn path=/head/; revision=339876
* rcorder(8): add support for /etc/rc.resume, so it calls "rcorder -k resume"Eugene Grosbein2018-10-271-0/+18
| | | | | | | | | | | | | | | | and runs scripts containing "KEYWORD: resume" with single "resume" argument. Working example is the port sysutils/cpupdate that defines extra_commands="resume" to reload CPU microcode cleared by suspend/resume sequence. This change does nothing for a system having no scripts with KEYWORD: resume. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D15247 Notes: svn path=/head/; revision=339818
* makewhatis: do not try to operate on read-only mounted directoriesEugene Grosbein2018-10-271-2/+2
| | | | | | | | | just to fail later. MFC after: 1 month Notes: svn path=/head/; revision=339817