Commit Graph

21240 Commits

Author SHA1 Message Date
Guangyuan Yang
a1d7836752 mmap(2): Update .Dd missed in the last commit
PR:		252097
MFC after:	1 week
2020-12-24 14:14:56 +00:00
Guangyuan Yang
81720dbab2 mmap(2): Fix a typo
PR:             252097
MFC after:      1 week
Reported by:    Nick Frampton <nick.frampton@akips.com>
2020-12-24 14:08:34 +00:00
Gordon Bergling
f6d234d870 libc: Fix most issues reported by mandoc
- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings

MFC after:	1 month
2020-12-19 14:54:28 +00:00
Jessica Clarke
ccb86b40c1 strerror.3: Fix whitespace issue introduced in r368714
MFC with:	368714
2020-12-18 22:10:17 +00:00
Mateusz Piotrowski
87394cdd01 strerror.3: Add an example for perror()
This is a nice and quick reference.

Reviewed by:	jilles, yuripv
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D27623
2020-12-17 12:41:47 +00:00
Yuri Pankov
3cd6e2390c nl_langinfo(3): document recognized item names
While here, remove .Tn macro usage (prompted by mandoc lint).

PR:		251468
Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D27606
2020-12-17 02:33:52 +00:00
Konstantin Belousov
675079b1ea Implement strerror_l().
Only for the arches that provide user-mode TLS.

PR: 251651
Requested by:	yuri
Discussed with:	emaste, jilles, tijl
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D27495
MFC after:	2 weeks
2020-12-16 09:02:09 +00:00
Hans Petter Selasky
1055793115 Be bug compatible with other operating systems by allowing non-sequential
interface numbering for USB descriptors in userspace. Else certain USB
control requests using the interface number, won't be recognized by the
USB firmware.

Refer to section 9.2.3 in the USB 2.0 specification:
Interfaces are numbered from zero to one less than the number of concurrent interfaces
supported by the configuration.

PR:		251784
MFC after:	1 week
Sponsored by:	Mellanox Technologies // NVIDIA Networking
2020-12-14 11:56:16 +00:00
Jessica Clarke
87973534d2 strdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSD
Linux claims 4.3BSD, we claim 4.4BSD and OpenBSD claims 4.3BSD-Reno. It turns
out that OpenBSD got it right: the function was added in late 1988 a few months
after 4.3BSD-Tahoe, well in advance of 4.3BSD-Reno.

Reviewed by:	bcr
Approved by:	bcr
Differential Revision:	https://reviews.freebsd.org/D27392
2020-12-14 00:50:45 +00:00
Martin Matuska
87c1ec0a31 MFV r368607:
Sync libarchive with vendor.

Vendor changes:
  Issue #1461: Unbreak build without lzma
  Issue #1462: warc reader: Fix build with gcc11
  Issue #1463: Fix code compatibility in test_archive_read_support.c
  Issue #1464: Use built-in strnlen on platforms where not available
  Issue #1465: warc reader: fix undefined behaviour in deconst() function

MFC after:	3 days
X-MFC-With:	368234
2020-12-13 16:26:37 +00:00
Stefan Eßer
6c2596f00c Change getlocalbase() to not allocate any heap memory
After the commit of the current version, Scott Long pointed out, that an
attacker might be able to cause a use-after-free access if this function
returned the value of the sysctl variable "user.localbase" by freeing
the allocated memory without the cached address being cleared in the
library function.

To resolve this issue, I have proposed the originally suggested version
with a statically allocated buffer in a review (D27370). There was no
feedback on this review and after waiting for more than 2 weeks, the
potential security issue is fixed by this commit. (There was no security
risk in practice, since none of the programs converted to use this
function attempted to free the buffer. The address could only have
pointed into the heap if user.localbase was set to a non-default value,
into r/o data or the environment, else.)

This version uses a static buffer of size LOCALBASE_CTL_LEN, which
defaults to MAXPATHLEN. This does not increase the memory footprint
of the library at this time, since its data segment grows from less
than 7 KB to less than 8 KB, i.e. it will get two 4 KB pages on typical
architectures, anyway.

Compiling with LOCALBASE_CTL_LEN defined as 0 will remove the code
that accesses the sysctl variable, values between 1 and MAXPATHLEN-1
will limit the maximum size of the prefix. When built with such a
value and if too large a value has been configured in user.localbase,
the value defined as ILLEGAL_PREFIX will be returned to cause any
file operations on that result to fail. (Default value is "/dev/null/",
the review contained "/\177", but I assume that "/dev/null" exists and
can not be accessed as a directory. Any other string that can be assumed
not be a valid path prefix could be used.)

I do suggest to use LOCALBASE_CTL_LEN to size the in-kernel buffer for
the user.localbase variable, too. Doing this would guarantee that the
result always fit into the buffer in this library function (unless run
on a kernel built with a different buffer size.)

The function always returns a valid string, and only in case it is built
with a small static buffer and run on a system with too large a value in
user.localbase, the ILLEGAL_PREFIX will be returned, effectively causing
the created path to be non-existent.

Differential Revision:	https://reviews.freebsd.org/D27370
2020-12-12 11:23:52 +00:00
Enji Cooper
d03bd62f31 timespec_get(3): sort SEE ALSO correctly
clock_gettime(2) should be mentioned before gettimeofday(2).

Reported by:	make manlint
MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-11 02:22:42 +00:00
Enji Cooper
0c424c64f8 cpuset{,_getaffinity,_getdomain}.2: fix SEE ALSO
Sort by manpage section, then sort entries alphabetically.

This makes the manpages `make manlint` clean.

MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-11 01:52:27 +00:00
Enji Cooper
92d4164179 aio_suspend.2: properly canonicalize .Dd
Months should be fully spelled as their local-specific equivalents: in this
case `Oct` should have been spelled like `October`.

Reported by:	make manlint
MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-11 00:28:28 +00:00
Enji Cooper
20daf0ca6e cap_enter(2): fix CAVEATS section
The CAVEATS section was misspelled as "CAVEAT" before this change. Fix the
spelling to identify issues related to the section.

Furthermore, given that the section order was incorrect, move the CAVEATS
section down to the bottom of the manpage, per the conventional section
order.

MFC after:	1 week
Reported by:	make manlint
Sponsored by:	DellEMC Isilon
2020-12-11 00:26:49 +00:00
Enji Cooper
2c96ea9ca0 posix_spawn(3): fix section that references vfork
`vfork(2)` should be referenced in paragraphs as `.Fn vfork`, not `vfork()`.
This change switches the reference to use `.Fn`, which in turn makes the
manpage `make manlint` clean.

MFC after:	1 week
Reported by:	make manlint
Sponsored by:	DellEMC Isilon
2020-12-11 00:20:04 +00:00
Enji Cooper
eca1933a55 getentropy(3): sort SEE ALSO sections
Sorting order should be done by manpage section (2 vs 3), then alphabetically.
This change fixes the order to sort by the manpage section, first.

Reported by:	make manlint
MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-11 00:15:57 +00:00
Enji Cooper
c80d36d0e0 arc4random(3): fix .Xr issues
- pthreads(3) should actually be pthread(3).
- getentropy(2) should actually be getentropy(3).

This makes the manpage `make manlint` clean.

MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-11 00:13:39 +00:00
Kenneth D. Merry
78adacd4ea Add the LTO-9 density code to libmt and the mt(1) man page.
These values are taken directly from the density report from an
IBM LTO-9 tape drive.  (Using mt getdensity)

A LTO-9 drive stores 18TB raw (45TB with compression) on an LTO-9 tape.

lib/libmt/mtlib.c:
        Add the LTO-9 density code, and bpmm/bpi values.

usr.bin/mt/mt.1:
        Add the LTO-9 density code, bpmm/bpi values and number of
	tracks.  Bump the man page date.

MFC after:	3 days
Sponsored by:	Spectra Logic
2020-12-10 21:06:06 +00:00
Kyle Evans
3b27074b25 libsysdecode: decode _UMTX_OP flags
Assume that UMTX_OP with a double underbar following is a flag, while any
underbar+alphanumeric combination immeiately following is an op.

This was a part of D27325.

Reviewed by:	kib
2020-12-09 03:22:44 +00:00
Kyle Evans
e04a83a3e1 _umtx_op(2): document recent addition of 32bit compat flags
This was part of D27325.

Reviewed by:	kib
2020-12-09 03:20:51 +00:00
Enji Cooper
00107a56e5 extattr_get_file(20: bump .Dd
This is being done for the formatting and context changes. While the net content
hasn't been changed, the content/context changes were sufficient to warrant the
date bump.

MFC after:	1 week
MFC with:	r368431, r368433, r368434, r368435
Sponsored by:	DellEMC Isilon
2020-12-08 04:18:16 +00:00
Enji Cooper
cf681016d4 extattr_get_file(2): clarify RETURN VALUES
While some of the syscalls' behavior were documented and implied in the
RETURN VALUES section by earlier, e.g., the DESCRIPTION sections, as having
behavior of the other calls (`*_fd` vs `*_file` vs `*_link`), there was a lot
of implied return value behavior in the section prior to this change.

Explicitly document the syscall behavior per the current implementation in
sys/kern/vfs_extattr.c so others can better develop based on its explicit
documented behavior instead of having to digest the context of the manpage to
understand the appropriate behavior.

MFC after:	1 week
MFC with:	r368431, r368433, r368434
Sponsored by:	DellEMC Isilon
2020-12-08 04:16:05 +00:00
Enji Cooper
f705523939 extattr_get_file(2): fix more formatting
- Remove an unnecessary trailing comma separating a two-item clause.
- Sort more function calls alphabetically (in the same vein as r368433).

MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-08 04:05:19 +00:00
Enji Cooper
e8e0f91b8b extattr_get_file(2): sort syscalls alphabetically
Although some sections of the manpage sort the syscalls alphabetically, many
core areas of the manpage do not. Sort the syscalls so it is easier to pick out
functional changes and to improve manpage readability.

This formatting change is also being done to make future functional changes
easier to spot.

MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-08 04:01:03 +00:00
Enji Cooper
403b2124d4 lio_listio(2): fix manlint error
The date with .Dd prior to this change isn't canonically spelled out: it
should have been "December", not "Dec".

MFC after:	1 week
Sponsored by:	DellEMC Isilon
2020-12-08 03:48:05 +00:00
Enji Cooper
9d610b1516 extattr_get_fd(2): fix manlint errors
- The CAVEATS section was misspelled as "CAVEAT".
- The CAVEATS section should come before the "BUGS" section and after
  other existing sections by convention.

MFC after:	1 week
Reported by:	make manlint
Sponsored by:	DellEMC Isilon
2020-12-08 03:43:00 +00:00
Kyle Evans
4afa7dd61a libc: regex: retire internal EMPTBR ("Empty branch present")
It was realized just a little too late that this was a hack that belonged in
individual regex(3)-using applications. It was surrounded in NOTYET and not
implemented in the engine, so remove it.
2020-12-05 03:18:48 +00:00
Kyle Evans
6b986646d4 libregex: implement \b and \B (word boundary, not word boundary)
This is the last of the needed GNU expressions before we can unleash bsdgrep
by default. \b is effectively an agnostic equivalent of \< and \>, while
\B will match every space that isn't making a transition from
nonchar -> char or char -> nonchar.
2020-12-05 03:16:05 +00:00
Kyle Evans
ca53e5aedf libregex: implement \` and \' (begin-of-subj, end-of-subj)
These are GNU extensions, generally equivalent to ^ and $ except that the
new syntax will not match beginning of line after the first in a multi-line
expression or the end of line before absolute last in a multi-line
expression.
2020-12-05 03:13:47 +00:00
Kyle Evans
7518fb346f libc: regex: factor out ISBOW/ISEOW macros
These will be reused for \b (word boundary, which matches both sides).

No functional change.
2020-12-05 02:23:11 +00:00
Conrad Meyer
78599c32ef Add CFI start/end proc directives to arm64, i386, and ppc
Follow-up to r353959 and r368070: do the same for other architectures.

arm32 already seems to use its own .fnstart/.fnend directives, which
appear to be ARM-specific variants of the same thing.  Likewise, MIPS
uses .frame directives.

Reviewed by:	arichardson
Differential Revision:	https://reviews.freebsd.org/D27387
2020-12-05 00:33:28 +00:00
Mark Johnston
b957b18594 Always use 64-bit physical addresses for dump_avail[] in minidumps
As of r365978, minidumps include a copy of dump_avail[].  This is an
array of vm_paddr_t ranges.  libkvm walks the array assuming that
sizeof(vm_paddr_t) is equal to the platform "word size", but that's not
correct on some platforms.  For instance, i386 uses a 64-bit vm_paddr_t.

Fix the problem by always dumping 64-bit addresses.  On platforms where
vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate
dump_avail[] to an array of uint64_t ranges.  With this change, libkvm
no longer needs to maintain a notion of the target word size, so get rid
of it.

This is a no-op on platforms where sizeof(vm_paddr_t) == 8.

Reviewed by:	alc, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27082
2020-12-03 17:12:31 +00:00
Cy Schubert
feb01b72ef Remove trailing whitespace.
MFC after:	1 week
2020-12-03 05:49:59 +00:00
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