Commit Graph

21206 Commits

Author SHA1 Message Date
Martin Matuska
c3afd20f13 MFV r368207:
Update libarchive to 3.5.0

Relevant vendor changes:
  Issue #1258: add archive_read_support_filter_by_code()
  PR #1347: mtree digest reader support
  Issue #1381: skip hardlinks pointing to itself on extraction
  PR #1387: fix writing of cpio archives with hardlinks without file type
  PR #1388: fix rdev field in cpio format for device nodes
  PR #1389: completed support for UTF-8 encoding conversion
  PR #1405: more formats in archive_read_support_format_by_code()
  PR #1408: fix uninitialized size in rar5_read_data
  PR #1409: system extended attribute support
  PR #1435: support for decompression of symbolic links in zipx archives
  Issue #1456: memory leak after unsuccessful archive_write_open_filename

MFC after:	1 week
2020-12-01 15:53:12 +00:00
Konstantin Belousov
ec5fed758c Ensure that threading library is initialized in pthread_mutex_init().
We need at least thr_malloc ready.  The situation is possible e.g. in case
of libthr being listed in DT_NEEDED before some of its consumers.

Reported and tested by:	lev
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-11-30 17:00:36 +00:00
Konstantin Belousov
412ef5da8a libc: Add pthread_attr_get_np(3) stub, reporting ESRCH.
This seems to be required by recent clang asan.
I do not see other way than put the symbol under FBSD_1.0 version.

PR:	251112
Reported by:	Andrew Stitcher <astitcher@apache.org>
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D27389
2020-11-28 12:19:20 +00:00
Mateusz Piotrowski
16e1abe4e0 libprocstat.3: Correct two occurrences of kvm_getprocs to procstat_getprocs
Submitted by:	otis_sk.freebsd.org
Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D26151
2020-11-26 22:49:05 +00:00
Konstantin Belousov
1a1b8b1cb3 Remove stray column.
Sponsored by:	The FreeBSD Foundation
MFC after: 3 days
2020-11-26 20:27:23 +00:00
Konstantin Belousov
20b8e1a25c Style.
Sponsored by:	The FreeBSD Foundation
MFC after: 3 days
2020-11-26 20:23:17 +00:00
Pawel Biernacki
569da02b0c libsysdecode: account for invalid protection flags
Reported by:	jhb
MFC with:	r368022
2020-11-26 09:07:45 +00:00
Konstantin Belousov
f2148ee019 Use designated initializers for libc pthread stubs' jump table.
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2020-11-25 17:04:26 +00:00
Pawel Biernacki
4cbec44397 libsysdecode: correctly decode mmap flags
r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the
case where different values were specified for PROT_MAX and regular flags.
Fix it.

Submitted by:	sigsys_gmail.com
Reported by:	sigsys_gmail.com
MFC after:	7 days
Differential Revision:	https://reviews.freebsd.org/D27312
2020-11-25 16:30:57 +00:00
John Baldwin
688f8b822c Remove the cloned file descriptors for /dev/crypto.
Crypto file descriptors were added in the original OCF import as a way
to provide per-open data (specifically the list of symmetric
sessions).  However, this gives a bit of a confusing API where one has
to open /dev/crypto and then invoke an ioctl to obtain a second file
descriptor.  This also does not match the API used with /dev/crypto on
other BSDs or with Linux's /dev/crypto driver.

Character devices have gained support for per-open data via cdevpriv
since OCF was imported, so use cdevpriv to simplify the userland API
by permitting ioctls directly on /dev/crypto descriptors.

To provide backwards compatibility, CRIOGET now opens another
/dev/crypto descriptor via kern_openat() rather than dup'ing the
existing file descriptor.  This preserves prior semantics in case
CRIOGET is invoked multiple times on a single file descriptor.

Reviewed by:	markj
Relnotes:	yes
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27302
2020-11-25 00:10:54 +00:00
John Baldwin
1925586e03 Honor the disabled setting for MSI-X interrupts for passthrough devices.
Add a new ioctl to disable all MSI-X interrupts for a PCI passthrough
device and invoke it if a write to the MSI-X capability registers
disables MSI-X.  This avoids leaving MSI-X interrupts enabled on the
host if a guest device driver has disabled them (e.g. as part of
detaching a guest device driver).

This was found by Chelsio QA when testing that a Linux guest could
switch from MSI-X to MSI interrupts when using the cxgb4vf driver.

While here, explicitly fail requests to enable MSI on a passthrough
device if MSI-X is enabled and vice versa.

Reported by:	Sony Arpita Das @ Chelsio
Reviewed by:	grehan, markj
MFC after:	2 weeks
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D27212
2020-11-24 23:18:52 +00:00
Jung-uk Kim
fe85238ef7 Remove support for SSLv3 from fetch(3).
Support for SSLv3 was already removed from OpenSSL (r361392).

Differential Revision:	https://reviews.freebsd.org/D24947
2020-11-24 22:10:33 +00:00
Ed Maste
33482dae89 libc: fix undefined behavior from signed overflow in strstr and memmem
unsigned char promotes to int, which can overflow when shifted left by
24 bits or more. this has been reported multiple times but then
forgotten. it's expected to be benign UB, but can trap when built with
explicit overflow catching (ubsan or similar). fix it now.

note that promotion to uint32_t is safe and portable even outside of
the assumptions usually made in musl, since either uint32_t has rank
at least unsigned int, so that no further default promotions happen,
or int is wide enough that the shift can't overflow. this is a
desirable property to have in case someone wants to reuse the code
elsewhere.

musl commit: 593caa456309714402ca4cb77c3770f4c24da9da

Obtained from:	musl
2020-11-19 00:03:15 +00:00
Ed Maste
7dbcd06e63 libc: optimize memmem two-way bad character shift
first, the condition (mem && k < p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.

second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.

musl commits:
8f5a820d147da36bcdbddd201b35d293699dacd8
122d67f846cb0be2c9e1c3880db9eb9545bbe38c

Obtained from:	musl
MFC after:	2 weeks
2020-11-19 00:02:12 +00:00
Ed Maste
4874ddfd37 clang-format libc string functions imported from musl
We have adopted these and don't consider them 'contrib' code, so bring
them closer to style(9).  This is a followon to r315467 and r351700.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-11-18 22:01:34 +00:00
Stefan Eßer
30d21d2795 Add function getlocalbase() to libutil.
This function returns the path to the local software base directory, by
default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.h
when building the world).

The value returned can be overridden by 2 methods:

- the LOCALBASE environment variable (ignored by SUID programs)
- else a non-default user.localbase sysctl value

Reviewed by:	hps (earlier version)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D27236
2020-11-18 19:44:30 +00:00
Alfredo Dal'Ava Junior
758f9acf8c msun tests: use standard floating-point exception flags on lrint and fenv tests
Some platforms have additional architecture-specific floating-point flags.
Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags,
so make sure to mask them appropriately.

This makes test pass on PowerPC64.

Reviewed by:	jhibbits, ngie
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D27202
2020-11-18 19:23:30 +00:00
Conrad Meyer
85078b8573 Split out cwd/root/jail, cmask state from filedesc table
No functional change intended.

Tracking these structures separately for each proc enables future work to
correctly emulate clone(2) in linux(4).

__FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof.

Reviewed by:	kib
Discussed with:	markj, mjg
Differential Revision:	https://reviews.freebsd.org/D27037
2020-11-17 21:14:13 +00:00
Alfredo Dal'Ava Junior
e7bd4f846f [POWERPC] msun: fix incorrect flag in fesetexceptflag
Fix incorrect mask being used when FE_INVALID bit is wanted by user.
The problem was noticed thanks to msun fenv tests.

Reviewed by:	jhibbits, luporl
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D27201
2020-11-17 12:36:59 +00:00
Kyle Evans
4be0a1b587 _umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE
Specifically, if we're waking up some value n > BATCH_SIZE, then the
copyin(9) is wrong on the second iteration due to upp being the wrong type.
upp is currently a uint32_t**, so upp + pos advances it by twice as many
elements as it should (host pointer size vs. compat32 pointer size).

Fix it by just making upp a uint32_t*; it's still technically a double
pointer, but the distinction doesn't matter all that much here since we're
just doing arithmetic on it.

Add a test case that demonstrates the problem, placed with the libthr tests
since one messing with _umtx_op should be running these tests. Running under
compat32, the new test case will hang as threads after the first 128 get
missed in the wake. it's not immediately clear how to hit it in practice,
since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed
to be around ~50 -- I did not spend much time digging into it.

The uintptr_t change makes no functional difference, but i've tossed it in
since it's more accurate (semantically).

Reported by:	Andrew Gierth (andrew_tao173.riddles.org.uk, inspection)
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27231
2020-11-17 03:34:01 +00:00
Kyle Evans
231f59920a _umtx_op: document UMTX_OP_SEM2_WAIT copyout behavior
This clever technique to get a time remaining back was added to support sem_clockwait_np.

Reviewed by:	kib, vangyzen
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D27160
2020-11-17 03:26:56 +00:00
Scott Long
8e1031086d Revert the whole getlocalbase() set of changes while a different design is
hashed out.
2020-11-15 20:24:59 +00:00
Scott Long
85a5fe290b Because getlocalbase() returns -1 on error, it needs to use a signed type
internally.  Do that, and make sure that conversations between signed and
unsigned don't overflow
2020-11-15 07:48:52 +00:00
Scott Long
bcf9ae2751 Fix a problem with r367686 related to the use of ssize_t. Not sure how this
escaped prior testing, but it should be better now.

Reported by:	lots
2020-11-14 19:04:36 +00:00
Scott Long
98b76d2227 Add the library function getlocalbase and its manual page. This helps to
unify the retrieval of the various ways that the local software base directory,
typically "/usr/local", is expressed in the system.

Reviewed by:	se
Differential Revision:	https://reviews.freebsd.org/D27022
2020-11-14 17:57:50 +00:00
Brooks Davis
827bd9d1c5 Add missing src.opts.mk include
This was missed in r364221 so tests were not built.

Reviewed by:	bdrewery
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27210
2020-11-13 23:18:04 +00:00
Mateusz Piotrowski
ec26a84475 Add a missing Nm macro
All functions documented in a manual page should be enumerated
with the Nm macros.
2020-11-13 14:56:34 +00:00
Mateusz Piotrowski
13d8393f6c Reference setprogname(3) in setproctitle(3)
The reference to setproctitle(3) in the setprogname(3) manual is already
in place.

MFC after:	3 days
2020-11-13 13:47:18 +00:00
Emmanuel Vadot
6cd88fe0e0 pkgbase: Move libprivatezstd from utilities to runtime
libarchive depends on it by default and tar uses libarchive.
So on a update :
1/ runtime contain tar
2/ runtime have libarchive in shlibs_required
3/ libarchive packages depends on utilities
4/ utilities depends on runtime
5/ kaboom

All users of libprivatezstd (libarchive related stuff and objcopy/ar)
are already in utilities.

Discussed with: bapt
2020-11-12 14:04:08 +00:00
John Baldwin
9ebe945bd7 Add C startup code tests for PIE binaries.
- Force dynamic to be a non-PIE binary.

- Add a dynamicpie test which uses a PIE binary.

Reviewed by:	andrew
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27127
2020-11-10 19:09:35 +00:00
John Baldwin
f9fd7337f6 Fix dso_handle_check for PIE executables.
PIE executables use crtbeginS.o and have a non-NULL dso_handle as a
result.

Reviewed by:	andrew, emaste
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27126
2020-11-10 19:07:30 +00:00
John Baldwin
ecad1d050c Rename __JCR_LIST__ to __JCR_END__ in crtend.c.
This is more consistent with the names used for .ctor and .dtor
symbols and better reflects __JCR_END__'s role.

Reviewed by:	andrew
Obtained from:	CheriBSD
MFC after:	2 weeks
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D27125
2020-11-10 19:04:54 +00:00
Thomas Munro
cc7edd258c Add collation version support to querylocale(3).
Provide a way to ask for an opaque version string for a locale_t, so
that potential changes in sort order can be detected.  Similar to
ICU's ucol_getVersion() and Windows' GetNLSVersionEx(), this API is
intended to allow databases to detect when text order-based indexes
might need to be rebuilt.

The CLDR version is extracted from CLDR source data by the Makefile
under tools/tools/locale, written into the machine-generated Makefile
under shared/colldef, passed to localedef -V, and then written into
LC_COLLATE file headers.  The initial version is 34.0.
tools/tools/locale was recently updated to pull down 35.0, but the
output hasn't been committed under share/colldef yet, so that will
provide the first observable change when it happens.  Other versioning
schemes are possible in future, because the format is unspecified.

Reviewed by:	bapt, 0mp, kib, yuripv (albeit a long time ago)
Differential Revision:	https://reviews.freebsd.org/D17166
2020-11-08 02:50:34 +00:00
Mateusz Guzik
bdcc222644 malloc: move malloc_type_internal into malloc_type
According to code comments the original motivation was to allow for
malloc_type_internal changes without ABI breakage. This can be trivially
accomplished by providing spare fields and versioning the struct, as
implemented in the patch below.

The upshots are one less memory indirection on each alloc and disappearance
of mt_zone.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D27104
2020-11-06 21:33:59 +00:00
Leandro Lupori
926da0492a pmcstat: fix PPC kernel symbol resolution
PowerPC kernel is of DYN type and it has a base address where it is
initially loaded, before being relocated. As the start address passed to
pmcstat_image_link() is where the kernel was relocated to, but the symbols
always use the original base address, we need to subtract it to get the
correct offset.

Reviewed by:	jhibbits
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D26114
2020-11-05 16:47:23 +00:00
Leandro Lupori
5cebdfc072 libpmc: add support for POWER8/9 PMCs
This change adds support for POWER8/9 performance counters.

Reviewed by:	jhibbits
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
Differential Revision:	https://reviews.freebsd.org/D26113
2020-11-05 16:41:28 +00:00
Edward Tomasz Napierala
7abf30d339 Make linux_errtbl[] static.
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27004
2020-11-03 19:12:33 +00:00
Stefan Eßer
23b4092837 Re-arrange some of the code to separate writable user tree variables from
R/O variables.

While here fix some nearby style. No functional change intended.

MFC after:	1 month
2020-11-02 18:48:06 +00:00
Mateusz Guzik
828afdda17 malloc: export kernel zones instead of relying on them being power-of-2
Reviewed by:	markj (previous version)
Differential Revision:	https://reviews.freebsd.org/D27026
2020-11-02 17:38:08 +00:00
Adrian Chadd
26c29e743b [libnetmap] Fix 32 bit compilation under gcc-6.4
Use uintptr_t to cast a uint64_t to a pointer type.
Yeah, it isn't technically correct for platforms with pointers
> 64 bits, but it's fine here.

This fixes 32 bit compat library builds on amd64 and also
mips32 builds.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D26790
2020-11-02 15:01:37 +00:00
Stefan Eßer
1ebef47735 Make sysctl user.local a tunable that can be written at run-time
This sysctl value had been provided as a read-only variable that is
compiled into the C library based on the value of _PATH_LOCALBASE in
paths.h.

After this change, the value is compiled into the kernel as an empty
string, which is translated to _PATH_LOCALBASE by the C library.

This empty string can be overridden at boot time or by a privileged
user at run time and will then be returned by sysctl.

When set to an empty string, the value returned by sysctl reverts to
_PATH_LOCALBASE.

This update does not change the behavior on any system that does
not modify the default value of user.localbase.

I consider this change as experimental and would prefer if the run-time
write permission was reconsidered and the sysctl variable defined with
CLFLAG_RDTUN instead to restrict it to be set at boot time.

MFC after:	1 month
2020-10-31 23:48:41 +00:00
Stefan Eßer
3b9795a2e8 Fix reversed condition after attempted style fix in r367196
Reported by:	xtouqh@hotmail.com
MFC after:	3 days
2020-10-31 12:10:43 +00:00
Stefan Eßer
d86926912c Fix style, no functional change
Submitted by:	kib
MFC after:	3 days
2020-10-31 11:44:10 +00:00
Stefan Eßer
77b793c465 Update man-pages to describe the user.localbase variable added in r367179.
MFC after:	3 days
2020-10-30 19:37:53 +00:00
Stefan Eßer
147eea393f Add read only sysctl variable user.localbase
The value is provided by the C library as for other sysctl variables in
the user tree. It is compiled in and returns the value of _PATH_LOCALBASE
defined in paths.h.

Reviewed by:	imp, scottl
Differential Revision:	https://reviews.freebsd.org/D27009
2020-10-30 18:48:09 +00:00
Edward Tomasz Napierala
1a8577fa68 Add defines for Linux errno values and use them to make linux_errtbl[]
more readable.  While here, add linux_check_errtbl() function to make
sure we don't leave holes.

No objections:	emaste (earlier version)
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26972
2020-10-29 14:23:52 +00:00
Brooks Davis
b0bffa3a4c Disable ssp raw test without ASAN
r366981 disabled ASAN when it might not be reliable (with an external
compiler), but this test is broken without ASAN so disable it completely
in that case.

PR:		250706
Reviewed by:	emaste, lwhsu
Differential Revision:	https://reviews.freebsd.org/D26982
2020-10-28 23:10:54 +00:00
Edward Tomasz Napierala
bce7ee9d41 Drop "All rights reserved" from all my stuff. This includes
Foundation copyrights, approved by emaste@.  It does not include
files which carry other people's copyrights; if you're one
of those people, feel free to make similar change.

Reviewed by:	emaste, imp, gbe (manpages)
Differential Revision:	https://reviews.freebsd.org/D26980
2020-10-28 13:46:11 +00:00
Alex Richardson
433f33d285 Significantly reduce compile time for googletest internal tests
Clang's optimizer spends a really long time on these tests at -O2, so we now
use -O0 instead. This reduces the -j32 time for lib/googletest/test from 131s
to 29s. Using -O0 also reduces the disk usage from 144MB (at -O2) / 92MB (at
-O1) to 82MB.

Reviewed By:	ngie, dim
Differential Revision: https://reviews.freebsd.org/D26751
2020-10-28 11:54:04 +00:00
Alan Cox
76c7af51ab Revise the description of MAP_STACK. In particular, describe the guard
in more detail.

Reviewed by:	bcr, kib, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D26908
2020-10-27 18:08:33 +00:00