Commit Graph

21454 Commits

Author SHA1 Message Date
Konstantin Belousov
8d9ed174f3 open(2): Implement O_PATH
Reviewed by:	markj
Tested by:	pho
Discussed with:	walker.aj325_gmail.com, wulf
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29323
2021-04-15 12:48:24 +03:00
Konstantin Belousov
509124b626 Add AT_EMPTY_PATH for several *at(2) syscalls
It is currently allowed to fchownat(2), fchmodat(2), fchflagsat(2),
utimensat(2), fstatat(2), and linkat(2).

For linkat(2), PRIV_VFS_FHOPEN privilege is required to exercise the flag.
It allows to link any open file.

Requested by:	trasz
Tested by:	pho, trasz
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D29111
2021-04-15 12:48:11 +03:00
Konstantin Belousov
c78e124535 link(2): correct descriptor name in AT_RESOLVE_BENEATH description
Noted and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D29111
2021-04-15 12:47:40 +03:00
Yuri Pankov
adec9669ff expand @TPUT@ in ncurses manpages
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29761
2021-04-14 18:16:59 +03:00
Kristof Provost
4eabfe468b pfctl: Fix clearing rules counters
After the migration to libpfctl for rule retrieval we accidentally lost
support for clearing the rules counters.

Introduce a get_clear variant of pfctl_get_rule() which allows rules
counters to be cleared.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29727
2021-04-14 13:33:02 +02:00
Alexander Motin
e49d3eb403 Fix race in case of device destruction.
During device destruction it is possible that open() succeed, but
fdevname() return NULL, that can't be assigned to string variable.
Fix that by adding explicit NULL check.

Also while there switch from fdevname() to fdevname_r().

Sponsored by:	iXsystems, Inc.
MFC after:	2 weeks
2021-04-13 11:25:27 -04:00
Kurosawa Takahiro
2aa21096c7 pf: Implement the NAT source port selection of MAP-E Customer Edge
MAP-E (RFC 7597) requires special care for selecting source ports
in NAT operation on the Customer Edge because a part of bits of the port
numbers are used by the Border Relay to distinguish another side of the
IPv4-over-IPv6 tunnel.

PR:		254577
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D29468
2021-04-13 10:53:18 +02:00
Kurosawa Takahiro
600bd6ce06 pfctl, libpfctl: introduce pfctl_pool
Introduce pfctl_pool to be able to extend the pool part of the pf rule
without breaking the ABI.

Reviewed by:	kp
MFC after:	4 weeks
Differential Revision:	https://reviews.freebsd.org/D29721
2021-04-12 18:30:29 +02:00
Yuri Pankov
eeaf9d562f setclassenvironment: trim leading spaces in variable names
Trim leading spaces in variable names when the list is e.g.
pretty-formatted in /etc/login.conf or ~/.login_conf.

PR:		247947
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D25649
2021-04-12 01:05:10 +03:00
Piotr Pawel Stefaniak
1fdd6934d5 getdirentries.2: remove unnecessary space 2021-04-11 11:17:01 +02:00
Konstantin Belousov
4d9128da54 rtld: make dlerror() thread-local
PR:	95339
Discussed with:	arichardson
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29633
2021-04-10 17:33:34 +03:00
Konstantin Belousov
08bfbd4359 rtld: workaround for broken ABI
Right now, libthr does not initialize RtldLockInfo.rtli_version when calling
_rtld_thread_init(), which makes versioning the interface troublesome.

Add a workaround: if the calling object of _rtld_thread_init() exports
the "_pli_rtli_version" symbol, then consider rtli_version initialized.
Otherwise, forcibly set it to RTLI_VERSION_ONE, currently defined as
RTLI_VERSION.

Export "_pli_rtli_version" from libthr and properly initialize rtli_version.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29633
2021-04-10 17:33:33 +03:00
Dimitry Andric
bae9fd0b33 Only use -fp-exception-behavior=maytrap on x86, for now
After 3b00222f15, it turns out that clang only supports strict
floating point semantics for SystemZ and x86 at the moment, while for
other architectures it is still experimental.

Therefore, only use -fp-exception-behavior=maytrap on x86 for now,
otherwise this option results in "error: overriding currently
unsupported use of floating point exceptions on this target
[-Werror,-Wunsupported-floating-point-opt]" on other architectures.

Fixes:		3b00222f15
PR:		254911
MFC after:	1 week
2021-04-10 16:02:58 +02:00
Kristof Provost
15ca662208 libnv: Use PICFLAG rather than -fPIC
Suggested by:	andrew
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-04-10 15:43:28 +02:00
Dimitry Andric
3b00222f15 Avoid raising unexpected floating point exceptions in libm
When using clang with x86_64 CPUs that support AVX, some floating point
transformations may raise exceptions that would not have been raised by
the original code. To avoid this, use the -fp-exception-behavior=maytrap
flag, introduced in clang 10.0.0.

In particular, this fixes a number of test failures with ctanhf(3) and
ctanf(3), when libm is compiled with -mavx. An unexpected FE_INVALID
exception is then raised, because clang emits vdivps instructions to
perform certain divides. (The vdivps instruction operates on multiple
single-precision float operands simultaneously, but the exceptions may
be influenced by unused parts of the XMM registers. In this particular
case, it was calculating 0 / 0, which results in FE_INVALID.)

If -fp-exception-behavior=maytrap is specified however, clang uses
vdivss instructions instead, which work on one operand, and should not
raise unexpected exceptions.

Reported by:	olivier
Reviewed by:	arichardson
PR:		254911
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D29686
2021-04-10 13:59:57 +02:00
Kristof Provost
ab5707a5cf libpfctl: Fix u_* counters
struct pf_rule had a few counter_u64_t counters. Those couldn't be
usefully comminicated with userspace, so the fields were doubled up in
uint64_t u_* versions.

Now that we use struct pfctl_rule (i.e. a fully userspace version) we
can safely change the structure and remove this wart.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29645
2021-04-10 11:16:03 +02:00
Kristof Provost
e9eb09414a libpfctl: Switch to pfctl_rule
Stop using the kernel's struct pf_rule, switch to libpfctl's pfctl_rule.
Now that we use nvlists to communicate with the kernel these structures
can be fully decoupled.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29644
2021-04-10 11:16:02 +02:00
Kristof Provost
0d71f9f36e pfctl: Move ioctl abstraction functions into libpfctl
Introduce a library to wrap the pf ioctl interface.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29562
2021-04-10 11:16:02 +02:00
Kristof Provost
0dd13c7743 libnv: Build PIC
Build libnv as position independent code so we can use it from shared
libraries.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29561
2021-04-10 11:16:01 +02:00
Konstantin Belousov
dbd2053026 libc dl_iterate_phdr(): dlpi_tls_data is wrong
This is the same change as d36d681615, but for libc static implementaion
of dl_iterate_phdr().

Reported by:	emacsray@gmail.com
PR:	254774
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29623
2021-04-09 23:46:24 +03:00
Konstantin Belousov
ca46b5698e libc: implement __tls_get_addr() for static binaries
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29623
2021-04-09 23:46:24 +03:00
Konstantin Belousov
06d8a116bd libc: add _get_tp() private function
which returns pointer to tcb

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29623
2021-04-09 23:46:24 +03:00
Konstantin Belousov
7f7489eba3 libc: include rtld.h into static implementations of rtld interface
and resolve naming conficts

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29623
2021-04-09 23:46:24 +03:00
Konstantin Belousov
93c14c55ec libc: constify dummy error message string for dlfcn
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D29623
2021-04-09 23:46:23 +03:00
Dimitry Andric
7702d940ec Avoid -pedantic warnings about using _Generic in __fp_type_select
When compiling parts of math.h with clang using a C standard before C11,
and using -pedantic, it will result in warnings similar to:

bug254714.c:5:11: warning: '_Generic' is a C11 extension [-Wc11-extensions]
  return !isfinite(1.0);
          ^
/usr/include/math.h:111:21: note: expanded from macro 'isfinite'
                    ^
/usr/include/math.h:82:39: note: expanded from macro '__fp_type_select'
                                      ^

This is because the block that enables use of _Generic is conditional
not only on C11, but also on whether the compiler advertises support for
C generic selections via __has_extension(c_generic_selections).

To work around the warning without having to pessimize the code, use the
__extension__ keyword, which is supported by both clang and gcc. While
here, remove the check for __clang__, as _Generic has been supported for
a long time by gcc too now.

Reported by:	yuri
PR:		254714
MFC after:	1 week
2021-04-08 18:20:32 +02:00
Andrew Turner
4d9488674f Remove the last users of ARM_TP_ADDRESS
This was only needed on 32-bit arm prior to ARMv6. As we only support
ARMv6 or later remove it.

Reviewed by:	mannu
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D29624
2021-04-08 07:52:54 +00:00
Mariusz Zaborski
2b1d0c0087 fileargs: fix double caching of the same file
In situations when the current file name wasn't the first element on
the list we were cleaning the current name too early.
This might cause us to pre-cache the same file twice.
2021-04-07 21:16:37 +02:00
Konstantin Belousov
d36d681615 rtld dl_iterate_phdr(): dlpi_tls_data is wrong
dl_iterate_phdr() dlpi_tls_data should provide the TLS module segment
address, and not the TLS init segment address as it does now.

Reported by:	emacsray@gmail.com
PR:	254774
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-04-06 03:23:08 +03:00
Mark Johnston
3b666932d4 libc: Fix the WITH_HESIOD build
Reported by:	Daniel Braniss <danny@cs.huji.ac.il>
MFC after:	1 week
2021-04-05 16:30:00 -04:00
Konstantin Belousov
d218c6f6af amd64 fabs.S: use '.section .rodata' instead of '.rodata'
Seems to be an issue with older gnu as

Reported by:	rscheff
Sponsored by:	The FreeBSD Foundation
MFC after:	6 days
2021-04-04 22:33:22 +03:00
Konstantin Belousov
6d3f54fd09 amd64 fabs.S: put signbit into rodata instead of text
Noted by:	jrtc27
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-04-04 04:49:22 +03:00
Konstantin Belousov
4c2e9c35fb libc/<arch>/sys/cerror.S: fix typo
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2021-04-04 01:00:57 +03:00
Konstantin Belousov
f548033818 amd64 fabs(3): move signbit to .text
There is no reason for signbit quad to be writeable.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-04-04 01:00:57 +03:00
Ed Maste
29e54af43e libc: use standard LF line endings, not CRLF 2021-04-03 16:20:07 -04:00
Edward Tomasz Napierala
bfd8b9b826 pam: add option to not prompt for password if it's set to empty
Add a new option to pam_unix(8), "emptyok", which makes it not prompt
for password, if it's set to an empty one.  It is similar to "nullok",
which makes it not prompt for password if the hash itself is empty.

Reviewed By:	markj
Sponsored By:	NetApp, Inc.
Sponsored By:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D27569
2021-04-03 13:05:50 +01:00
Vincenzo Maffione
ab639bb287 libnetmap: reset errno in nmreq_register_decode()
The reset is necessary at the beginning of the function, because of
the errno logic in the error path (set errno to EINVAL if not set).
If errno is already set when calling the function, and the function
fails, the previous errno value will be inherited.
2021-04-02 14:31:57 +00:00
Vincenzo Maffione
45c67e8f6b netmap: several typo fixes
No functional changes intended.
2021-04-02 07:01:20 +00:00
Renato Botelho
345c30a94f libfetch: Retry with proxy auth when server returns 407
PR:		220468
Submitted by:	Egil Hasting <egil.hasting@higen.org> (based on)
Reviewed by:	kevans, kp
Approved by:	kp
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29533
2021-04-01 18:02:57 -03:00
Alex Richardson
85425bdc5a resolv_test: Fix racy exit check, remove mutexes, and reduce output
Instead of polling nleft[i] (without appropriate memory barriers!) and
using sleep() to detect the exit just call pthread_join() on all threads.

Also replace the use of a mutex that guarding the increments with atomic
fetch_add. This should reduce the runtime of this test on SMP systems.

Finally, remove all the debug printfs unless DEBUG_OUTPUT is set in
the environment.

Test Plan:	still fails sometimes on qemu (but maybe less often?)
Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D29390
2021-03-30 15:00:18 +01:00
Vincenzo Maffione
88024c4a52 libnetmap: restore changes in 26c29e743b
Commit f8113f0a65 accidentally
reverted some fixes introduced by 26c29e743b.
This change restores them.
2021-03-30 09:53:14 +00:00
Vincenzo Maffione
f8113f0a65 libnetmap: add support for the offset features
The companion libnetmap changes for the "offsets" kernel support added
in a6d768d845. This includes code to parse the "@offset=NNN"
option that can be appended to the port name by any nmport_* application.
Example:
   # pkt-gen -i 'netmap:em0@offset=16'
2021-03-29 16:38:37 +00:00
Piotr Pawel Stefaniak
b315a7296d sh(1): autocomplete commands
Without this patch, sh can autocomplete file names but not commands from
$PATH. Use libedit's facility to execute custom function for autocomplete,
but yield to the library's standard autocomplete function when cursor is
not at position 0.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D29361
2021-03-29 11:14:27 +02:00
Leandro Lupori
9f50aa45be [PowerPC64] Port optimized strcpy to PPC64LE
Submitted by:           Bruno Larsen <bruno.larsen@eldorado.org.br>
Reviewed by:            luporl, bdragon (IRC)
MFC after:              1 week
Sponsored by:           Eldorado Research Institute (eldorado.org.br)
Differential Revision:  https://reviews.freebsd.org/D29067
2021-03-25 13:20:12 -03:00
Leandro Lupori
2f56128403 [PowerPC64] Enforce natural alignment in bcopy
POWER architecture CPUs (Book-S) require natural alignment for
cache-inhibited storage accesses. Since we can't know the caching model
for a page ahead of time, always enforce natural alignment in bcopy.
This fixes a SIGBUS when calling the function with misaligned pointers
on POWER7.

Submitted by:		Bruno Larsen <bruno.larsen@eldorado.org.br>
Reviewed by:		luporl, bdragon (IRC)
MFC after:		1 week
Sponsored by:		Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D28776
2021-03-25 13:07:01 -03:00
Alex Richardson
5245bf7b92 lib/libc/net/nsdispatch.c: Fix missing unlock and add locking annotations
The error cases (goto fin) of _nsdispatch were missing the unlock.

This change also drops the checks for __isthreaded since the pthread stubs
are already no-ops if threads are not being used. Dropping those conditionals
allows clang's thread safety analysis to deal with the file and also makes
the code a bit more readable. While touching the file also add a few more
assertions in debug mode that the right locks are held.

Reviewed By:	markj
Differential Revision: https://reviews.freebsd.org/D29372
2021-03-25 11:22:10 +00:00
Alex Richardson
dd5ed53a2f RISC-V: Fix feenableexcept return value
The man page says "The feenableexcept(), fedisableexcept(), and
fegetexcept() functions return a bitmap of the exceptions that were
unmasked prior to the call.", so we should return zero not -1.

Reviewed By:	mhorne
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D29386
2021-03-25 11:16:20 +00:00
Dmitry Wagin
9bd7345212 libc: Some enhancements to syslog(3)
- Defined MAXLINE constant (8192 octets by default instead 2048) for
  centralized limit setting up. It sets maximum number of characters of
  the syslog message. RFC5424 doesn't limit maximum size of the message.
  Named after MAXLINE in syslogd(8).
- Fixed size of fmt_cpy buffer up to MAXLINE for rendering formatted
  (%m) messages.
- Introduced autoexpansion of sending socket buffer up to MAXLINE.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D27205
2021-03-23 12:49:58 -04:00
Alex Richardson
15211f1950 Silence unused parameter warnings in the RISC-V fenv.h
After increasing the lib/msun/tests WARNS to 6, this triggers a
compilation error for RISC-V.

Fixes:		87d65c747a ("lib/msun: Allow building tests with WARNS=6")
Reported by:	Jenkins
2021-03-22 17:49:24 +00:00
Alex Richardson
f33b4fa2f0 lib/msun/tests: Drop WARNS=6
This is the default already, so there is no need to override it.

Reported by:	kevans
2021-03-22 16:57:43 +00:00
Alex Richardson
dbb2d6f5e1 lib/msun/tests: Re-enable csqrt_test on AArch64
The LLVM bug was fixed a long time ago and with D29076 this test actually
passes now.

Reviewed By:	andrew
Differential Revision: https://reviews.freebsd.org/D29092
2021-03-22 16:57:43 +00:00