Commit Graph

2506 Commits

Author SHA1 Message Date
Konstantin Belousov
daf5a897b9 Uppercase 'dso' to indicate that it is abbreviation.
Suggested by:	arichardson
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-06-02 17:33:10 +00:00
Konstantin Belousov
c1a813209c Do not allow to load ET_DYN object with DF_1_PIE flag set.
Linkers are supposed to mark PIE binaries with DF_1_PIE, such binary
cannot be correctly and usefully loaded neither by dlopen(3) nor as a
dependency of other object.  For instance, we cannot do anything
useful with COPY relocations, among other things.

Glibc already added similar restriction.

Requested and reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D25086
2020-06-02 16:20:58 +00:00
Konstantin Belousov
e82d19822e rtld: Add -b option to allow to specify image name different from arg0.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-31 22:37:33 +00:00
Konstantin Belousov
72bef4d8c6 rtld: Fix indent in print_usage().
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-31 21:56:07 +00:00
Konstantin Belousov
c8dd6c0599 rtld: Add -v switch to print some useful information about the rtld binary.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-31 21:53:15 +00:00
Konstantin Belousov
f393ade7c8 rtld: Add -p switch to direct exec mode summary line.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-31 21:34:21 +00:00
Konstantin Belousov
d89d55087f Add version indicators to rtld.
It is wrong to relate on __FreeBSD_version, either from
include/param.h, kernel, or libc, to check for rtld features.
Rtld might be from newer world than the running userspace.

Add special private symbols exported by rtld itself, to indicate the
changes in runtime behavior, and features that cannot be otherwise
detected or deduced at runtime.

Note that the symbols are not exported from libc, so they intentionally
cannot be linked against, and exported from the private namespace from rtld.
Consumers are required to use dlsym(3).  For instance, for
_rtld_version_laddr_offset, user should do
	ptr = dlsym(RTLD_DEFAULT, "_rtld_version_laddr_offset")
or even
	ptr = dlvsym(RTLD_DEFAULT,  "_rtld_version_laddr_offset",
	    "FBSDprivate_1.0");
Non-null ptr means that the change is present.

Also add _rtld_version__FreeBSD_version indicator to report the
headers version used at time of the rtld build.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24982
2020-05-26 19:22:46 +00:00
Konstantin Belousov
c8ad15b6ff Implement Solaris-like link_map l_refname member.
The implementation is based on the public documentation, in particular
dlinfo(3) from Solaris.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-22 17:52:09 +00:00
Konstantin Belousov
24ea64ded2 Convert linkmap_add() and linkmap_delete() to style(8).
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-05-22 17:23:09 +00:00
Konstantin Belousov
d0ca9a7fe4 Restore the binary compatibility for link_map l_addr.
Keep link_map l_addr binary layout compatible, rename l_addr to l_base
where rtld returns map base.  Provide relocbase in newly added l_addr.

This effectively reverts the patch to the initial version of D24918.

Reported by: antoine (portmgr)
Reviewed by:	jhb, markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24946
2020-05-21 22:24:23 +00:00
Konstantin Belousov
2c6d9dc0bb Change the samantic of struct link_map l_addr member.
It previously returned the object map base address, while all other
ELF operating systems return load offset, i.e. the difference between
map base and the link base.

Explain the meaning of the field in the man page.

Stop filling the mips-only l_offs member, which is apparently unused.

PR:	246561
Requested by:	Damjan Jovanovic <damjan.jov@gmail.com>
Reviewed by:	emaste, jhb, cem (previous version)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24918
2020-05-20 22:08:26 +00:00
Colin Percival
3cc620328f Move the devmatch rc.d script before netif in the boot process.
Prior to this change, using lagg to aggregate wired and wireless networks
was broken in the (relatively common) case where wifi drivers + firmware
are loaded by devmatch, since the interface didn't exist at the time when
the lagg interface was being created.

Suggested by:	imp
MFC after:	3 days
2020-05-16 18:37:48 +00:00
Konstantin Belousov
1659238a0c Implement RTLD_DEEPBIND.
PR:	246462
Tested by:	Martin Birgmeier <d8zNeCFG@aon.at>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24841
2020-05-15 11:58:01 +00:00
Eric van Gyzen
fac6dee9eb Remove tests for obsolete compilers in the build system
Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree.
Assume clang is at least 6, which was in 11.2-RELEASE.  Drop conditions
for older compilers.

Reviewed by:	imp (earlier version), emaste, jhb
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D24802
2020-05-12 15:22:40 +00:00
Michal Meloun
5a77ce24b6 Move ARM specific flags to arm/Makefile.inc
Requested by:	kib
MFC with:	r360463
2020-04-29 16:05:50 +00:00
Michal Meloun
7838a78269 Don't allow to use FPU inside of rtld library.
Clang10 may use FPU instructions for optimizing operations with
memory blocks. But we don't want to do lengthy save/restore of all
FPU registers across each rtld_start() call.

MFC after:	3 week
2020-04-29 14:06:42 +00:00
Konstantin Belousov
62af2dc3fb rtld: ignore static TLS segments when tracing.
For PIE binaries, ldd(1) performs dlopen(RTLD_TRACE) on the binary.
It is legal for binary to use initial exec TLS mode, but when such
binary (actually dso) is dlopened, we might not have enough free space
in the finalized static TLS segment.  Make ldd operational by skipping
TLS space allocation, we are not going to execute any code from the
dso anyway.

Reported by:	tobik
PR:	245677
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-04-22 18:39:45 +00:00
John Baldwin
0c0119856b Abort transfer if fseeko() fails.
CID:		1420215
Reviewed by:	asomers
MFC after:	1 week
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24454
2020-04-21 17:32:57 +00:00
Cy Schubert
12de77b3db Due to popular demand, revert r360102.
Reported by:	many
2020-04-19 21:38:03 +00:00
Cy Schubert
4574585e8f Conditionally install Kerberos rc files based on MK_KERBEROS_SCRIPTS
instead of MK_KERBEROS. The reason for this change is some users
prefer to build FreeBSD WITHOUT_KERBEROS, wanting to retain the
Kerberos rc scripts to start/stop MIT Kerberos or Heimdal from ports.

PR:		197337
Reported by:	Adam McDougall <ebay at looksharp.net>
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D24252
2020-04-19 17:01:21 +00:00
Konstantin Belousov
e5c3405ce8 Align initial-exec TLS segments to the p_vaddr % align.
This is continuation of D21163/r359634, which handled the alignment
for global mode.

Non-x86 arches are not handled, maintainers are welcomed.

Tested by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D24366
2020-04-19 09:28:59 +00:00
Mateusz Piotrowski
3e58608634 sshd: Warn about missing ssh-keygen only when necessary
The sshd service is using ssh-keygen to generate missing SSH keys.
If ssh-keygen is missing, it prints the following message:

> /etc/rc.d/sshd: WARNING: /usr/bin/ssh-keygen does not exist.

It makes sense when the key is not generated yet and
cannot be created because ssh-keygen is missing.

The problem is that even if the key is present on the host,
the sshd service would still warn about missing ssh-keygen
(even though it does not need it).

Reviewed by:	emaste
Approved by:	emaste (src)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D23911
2020-04-15 14:07:33 +00:00
Kyle Evans
3a166b3323 yp*: fix -fno-common build
This is mostly two problems spread out far and wide:
- ypldap_process should be declared properly
- debug is defined differently in many programs

For the latter, just extern it and define it everywhere that actually needs
it. This mostly works out nicely for ^/libexec/ypxfr, which can remove the
assignment at the beginning of main in favor of defining it properly.

-fno-common will become the default in GCC10/LLVM11.

MFC after:	3 days
2020-04-06 23:16:05 +00:00
Konstantin Belousov
2f06c66ad5 Make p_vaddr % p_align == p_offset % p_align for (some) TLS segments.
See https://sourceware.org/bugzilla/show_bug.cgi?id=24606 for the test case.
See https://reviews.llvm.org/D64930 for the background and more discussion.

Also this fixes another bug in malloc_aligned() where total size of
the allocated memory might be not enough to fit the aligned requested
block after the initial pointer is incremented by the pointer size.

Reviewed by:	bdragon
Tested by:	antoine (exp-run PR 244866), bdragon, emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D21163
2020-04-04 22:37:50 +00:00
Kyle Evans
28d832f993 flua: follow-up to r359453, don't bother with libedit in bootstrap
The bootstrap flua should not be used for REPL-like activities; exclude it
to save the dependency on libedit and not waste time with it.

X-MFC-With:	r359453
2020-03-30 20:01:44 +00:00
Kyle Evans
b4a19ee242 flua: enable readline bits, courtesy of libedit
This is a nicer experience when attempting to run ad-hoc lua bits in the
flua REPL.

PR:		245121
MFC after:	1 week
2020-03-30 18:43:05 +00:00
Baptiste Daroussin
fdf46c24f0 Revert r359294 per manu's request
It breaks etcupdate

Reported by:	cy
2020-03-25 08:35:55 +00:00
Emmanuel Vadot
77f0f1df8b pkgbase: Stop threating rc files as config files
rc scripts arent configuration files so use FILES instead of CONFS.
While here put rc scripts into related package (sendmail in the FreeBSD-sendmail
package, wpa_supplicant in the FreeBSD-wpa etc ...)

Reviewed by:	bapt, emaste
Differential Revision:	https://reviews.freebsd.org/D24177
2020-03-25 01:36:23 +00:00
Alexander V. Chernikov
7119cdc225 Make ICMP redirect processing depend on routing daemon.
Submitted by:	 lutz at donnerhacke.de
Reviewed by:	melifaro,rgrimes
Differential Revision:	https://reviews.freebsd.org/D23329
2020-03-23 15:27:10 +00:00
Leandro Lupori
e9f87d29a8 Add fsck_flags config option
On UFS with SU+J, sometimes fsck's default recovery from journal marks the
filesystem as clean but some errors remain.

With SU only, default fsck in preen mode sometimes thinks all errors have
been fixed but some still remain.

To address the issues above, this change adds a new config option:
fsck_flags.  By default it's set to -p, but the user may change it to -y
or -f -y, for instance, to force a full fsck after a system crash.

Submitted by:	jhibbits@ (original version)
Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D24087
2020-03-18 13:09:47 +00:00
Hiroki Sato
d80eccfc98 Remove /etc/host.conf, which was automatically generated from
nsswitch.conf for backward compatibility.  This file was used
over 19 years ago, before introducing nsdispatch() in the
name-service lookup APIs.

MFC after:	3 days
2020-03-18 08:17:24 +00:00
Brooks Davis
564b9ff2a7 Add an internal liblua and use it in flua.
The new liblua will be used in a forthcoming import of kyua.

Reviewed by:	kevans
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24090
2020-03-17 17:28:12 +00:00
Ed Maste
405e3338ac flua: implement chmod
Lua does not provide a native way to change the permission of a file.

Submitted by:	Yang Wang <2333@outlook.jp>
Reviewed by:	kevans
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24036
2020-03-13 15:40:35 +00:00
Ed Maste
13f7dbe822 retire amd(8)
autofs was introduced with FreeBSD 10.1 and is the supported method for
automounting filesystems.  As of r296194 the amd man page claimed that it
is deprecated.  Remove it from base now; the sysutils/am-utils port is
still available if necessary.

Discussed with:	cy
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2020-03-09 20:46:43 +00:00
Kyle Evans
924e10b809 tftpd: tests: raise targeted cstd to c11
r358556 added alignas() use to the functional tests, which isn't defined
until C11. Raise the -std to C11 to fix the build under freebsd-gcc{6,9}.

Reported by:	mhorne, Jenkins/CI
2020-03-05 22:45:16 +00:00
John Baldwin
fdf929ff91 Add support for the TFTP windowsize option described in RFC 7440.
The windowsize option permits multiple blocks to be transmitted
before the receiver sends an ACK improving throughput for larger
files.

Reviewed by:	asomers
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D23836
2020-03-02 22:19:30 +00:00
Warner Losh
600ee699ed Remove sparc64 source files from rtld-elf
These were missed in the prior sweep.

Submitted by:	jhb@
2020-02-26 23:17:16 +00:00
Warner Losh
8e0ff10d4b Remove sparc64 specific parts of rtld-elf. 2020-02-26 18:49:25 +00:00
Mateusz Guzik
0573d0a9b8 vfs: add realpathat syscall
realpath(3) is used a lot e.g., by clang and is a major source of getcwd
and fstatat calls. This can be done more efficiently in the kernel.

This works by performing a regular lookup while saving the name and found
parent directory. If the terminal vnode is a directory we can resolve it using
usual means. Otherwise we can use the name saved by lookup and resolve the
parent.

See the review for sample syscall counts.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23574
2020-02-20 16:58:19 +00:00
Konstantin Belousov
e3741c01c6 r357895: fix typo in the relocation name for i386 IRELATIVE.
Reported by: antoine
Sponsored by:	The FreeBSD Foundation
MFC after:	6 days
2020-02-14 12:59:27 +00:00
Konstantin Belousov
c5ca0d1132 Handle non-plt IRELATIVE relocations, at least for x86.
lld 10.0 seems to generate this relocation for rdtsc_mb() ifunc in our libc.

Reported, reviewed, and tested by:	dim (amd64, previous version)
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23652
2020-02-13 23:42:09 +00:00
Konstantin Belousov
c626c88e58 Fix indent.
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2020-02-12 12:23:46 +00:00
Konstantin Belousov
aef199e563 Use sigfastblock(2) in rtld.
This allows for rtld to not issue two sigprocmask(2) syscalls for each
symbol binding operation in single-threaded processes.  Rtld needs to
block signals as part of locking to ensure signal safety of the bind
process, because signal handlers might need to lazily resolve symbol
references.

As result, number of syscalls issued on startup by simple programs not
using libthr, is typically reduced 2x.  For instance, for hello world,
I see:
non-sigfastblock
# (truss ./hello > /dev/null) |& wc -l
      63
sigfastblock
# (truss ./hello > /dev/null) |& wc -l
      37

Tested by:	pho
Disscussed with:	cem, emaste, jilles
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D12773
2020-02-09 12:22:43 +00:00
Ryan Libby
28c0abcebb auditd_stop: wait_for_pids instead of sleeping
It's faster and more reliable to wait_for_pids than to sleep 1.

cem@ suggested just to remove auditd_stop() and use the rc.subr default
stop action (SIGTERM instead of audit -t), which has a built-in
wait_for_pids.  That may be a better solution.

Discussed with:	cem
Reviewed by:	asomers
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D23223
2020-02-06 08:32:30 +00:00
Dimitry Andric
fe1b3370c1 Fix the following -Werror warning from clang 10.0.0 in rbootd:
libexec/rbootd/rmpproto.c:335:49: error: multiple unsequenced modifications to 'filename' [-Werror,-Wunsequenced]
        filename = (filename = strrchr(filepath,'/'))? ++filename: filepath;
                 ~                                     ^

MFC after:	3 days
2020-01-28 19:19:55 +00:00
Eugene Grosbein
4c6076088a libexec/rc/rc.d/ipfw: style fix after r356943
Also, make sure it does not break for systems without ipfw code loaded.

MFC after:	1 months
X-MFC-with:	356943
2020-01-21 17:16:02 +00:00
Eugene Grosbein
7d82194866 Correct "service ipfw status" for INET6-only systems.
MFC after:	1 month
2020-01-21 17:02:57 +00:00
Mateusz Guzik
da8e950a27 rtld: remove hand rolled memset and bzero
They were introduced to take care of ifunc, but right now no architecture
provides ifunc'ed variants. Since rtld uses memset extensively this results in
a pessmization. Should someone want to use ifunc here they should provide a
mandatory symbol (e.g., rtld_memset).

See the review for profiling data.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D23176
2020-01-15 01:30:32 +00:00
Konstantin Belousov
7e3300e505 rtld: clean up Makefile.
Move all MD statements into $MACHINE_ARCH/Makefile.inc.
Unconditionally apply version script to rtld, the interpreter is not
functional without it for long time.

Reviewed by:	brooks, emaste
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D23083
2020-01-11 09:18:58 +00:00
Konstantin Belousov
1021c8d705 Stop prepending prefix to the result of realpath(3).
The path is already absolute.

Noted and reviewed by:	rstone
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23121
2020-01-11 09:08:02 +00:00