Commit Graph

23052 Commits

Author SHA1 Message Date
Konstantin Belousov
72d5dedfa6 stdio: add test for 86a16ada1e: fflush() handling of errors
PR:	76398
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34044
2022-01-28 01:09:47 +02:00
John Baldwin
3a502289d3 Use uintptr_t for return type of _Unwind_GetCFA.
This matches the type in other unwind headers.

Reviewed by:	dim, emaste
Differential Revision:	https://reviews.freebsd.org/D34050
2022-01-27 10:53:21 -08:00
John Baldwin
b84693501a Use an unsigned 64-bit integer for exception class.
This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

Reviewed by:	imp, dim, emaste
Differential Revision:	https://reviews.freebsd.org/D34049
2022-01-27 10:34:35 -08:00
Kyle Evans
c9afc7680f tests: fix posix_spawnp_enoexec_fallback_null_argv0
This test was written because execvp was found to improperly handle the
argc == 0 case when it falls back from an ENOEXEC.  We could probably
mostly revert it now, but let's just fix the test for the time being and
circle back later to decide if we want to simplify execvp.  The test
will likely remain either way just to make sure execvp isn't working
around the newly enforced restriction with the fallback.

Fixes:	301cb491ea ("execvp: fix up the ENOEXEC fallback")
Reported by:	jenkins via lwhsu@
2022-01-27 11:22:49 -06:00
Andrew Turner
548a2ec49b Add PT_GETREGSET
This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19831
2022-01-27 11:40:34 +00:00
Kristof Provost
735748f30a libpfctl: fix creatorid endianness
We provide the hostid (which is the state creatorid) to the kernel as a
big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it
back to system endianness when we get it from the kernel.

This avoids a confusing mismatch between the value the user configures
and the value displayed in the state.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33989
2022-01-27 09:07:27 +01:00
Kyle Evans
773fa8cd13 execve: disallow argc == 0
The manpage has contained the following verbiage on the matter for just
under 31 years:

"At least one argument must be present in the array"

Previous to this version, it had been prefaced with the weakening phrase
"By convention."

Carry through and document it the rest of the way.  Allowing argc == 0
has been a source of security issues in the past, and it's hard to
imagine a valid use-case for allowing it.  Toss back EINVAL if we ended
up not copying in any args for *execve().

The manpage change can be considered "Obtained from: OpenBSD"

Reviewed by:	emaste, kib, markj (all previous version)
Differential Revision:	https://reviews.freebsd.org/D34045
2022-01-26 13:40:27 -06:00
Ed Maste
9c296a2105 geom: Add HiFive boot partitions
As documented in the HiFive Unmatched Software Reference Manual.

Reviewed by:	imp, mhorne
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34010
2022-01-26 10:54:45 -05:00
Ed Maste
3524dead81 gpart.8: minor tidying
Reported by:	igor(1)
2022-01-26 10:54:45 -05:00
Piotr Kubaj
0b2d2290fe powerpc: Enable LLDB on all powerpc architectures
While LLDB on powerpc and powerpcspe builds as-is, on powerpc64 and
powerpc64le it requires adding a couple of additional source files
to build.

Differential review:	https://reviews.freebsd.org/D34043
Approved by:	dim, imp, emaste
2022-01-26 15:03:27 +01:00
Andriy Gapon
1abf1e8c6b cam_get_device: resolve path links before parsing device name
The CAM subsystem uses bus:taget:lun tuple to address peripherals.  But
for convenience many userland programs such as camcontrol accept devices
names such as da0.  There is a libcam function, cam_open_device, to
support that.  It first calls cam_get_device() to parse the device name
as a driver name and a unit (and handle some special device name
prefixes) and then uses cam_lookup_pass() to find a matching pass
device.

This change extends cam_get_device() to apply realpath(3) to the device
name before parsing it.  This will allow to use tools such as camcontrol
and smartctl with symbolic links that could be friendlier (more
distinguished) names for devices.

MFC after:	3 weeks
Relnotes:	maybe
2022-01-26 11:25:31 +02:00
John Baldwin
8de1a8131e libthr: Use TLS_TCB_* in _tcb_[cd]tor.
This matches libc and rtld in using the alignment (TLS_TCB_ALIGN) from
machine/tls.h instead of hardcoding 16.

Reviewed by:	kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D34023
2022-01-25 11:38:34 -08:00
Konstantin Belousov
86a16ada1e __sflush(): on write error, if nothing was written, reset FILE state back
otherwise the data is just dropped.  Check for current position equal to
the buffer base at the entry of the function; if not equal, setvbuf()
was done from the write method and it is not our business to override
the decision.

PR:	76398
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34007
2022-01-25 17:26:05 +02:00
John Baldwin
b943d31594 Include the correct header for pdfork()'s prototype.
Reviewed by:	kib, markj
Obtained from:	CheriBSD
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33988
2022-01-24 09:52:12 -08:00
Martin Matuska
e92ffd9b62 zfs: merge openzfs/zfs@17b2ae0b2 (master) into main
Notable upstream pull request merges:
  #12766 Fix error propagation from lzc_send_redacted
  #12805 Updated the lz4 decompressor
  #12851 FreeBSD: Provide correct file generation number
  #12857 Verify dRAID empty sectors
  #12874 FreeBSD: Update argument types for VOP_READDIR
  #12896 Reduce number of arc_prune threads
  #12934 FreeBSD: Fix zvol_*_open() locking
  #12947 lz4: Cherrypick fix for CVE-2021-3520
  #12961 FreeBSD: Fix leaked strings in libspl mnttab
  #12964 Fix handling of errors from dmu_write_uio_dbuf() on FreeBSD
  #12981 Introduce a flag to skip comparing the local mac when raw sending
  #12985 Avoid memory allocations in the ARC eviction thread

Obtained from:	OpenZFS
OpenZFS commit:	17b2ae0b24
2022-01-22 23:05:15 +01:00
Dimitry Andric
3c3df36600 Sort SRCS in libcxxrt's Makefile, and use += to list sources
No functional change intended.

MFC after:	3 days
2022-01-22 21:08:55 +01:00
Ed Maste
6f6fbfa3a8 Remove quotes around Makefile .error/.warn/.info strings
The text after .error et al is emitted verbatim.

Reviewed by:	sjg
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33904
2022-01-22 14:03:07 -05:00
Konstantin Belousov
a393644ecb ptrace(2): document policies affecting access to the facility
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33986
2022-01-22 19:36:56 +02:00
наб
bc40713a8f
libspl: ASSERT*: !! for sizeof
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by !!ing ‒
this makes the sizeof target the ! result type (_Bool), instead

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes #12984
Closes #12986
2022-01-21 10:20:11 -08:00
Konstantin Belousov
7406ec4ea9 kqueue(2): Add note about format of the data for NOTE_EXIT
Noted by:	Dave Baukus <daveb@spectralogic.com>
PR:	261346
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-20 00:37:25 +02:00
наб
e1c720de7d
libefi: remove efi_type()
All it is right now is some #if 0ed Solaris code that returns ENOSYS,
and is only applicable for the Solaris blockdev layer.
In the Illumos gate, there's a single user: rmformat(1);
I recommend a read of the manual as a blast from the past, but, well

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Issue #12844
Closes #12969
2022-01-18 14:40:43 -08:00
Xin LI
cc68614da8 MFV f83ac37f1e: libbsdxml (expat) 2.4.3. 2022-01-17 16:34:41 -08:00
Mark Johnston
f75b1ff6e5 Revert "libthr: Use kern.stacktop for thread stack calculation."
The current ASLR stack gap feature will be removed, and with that the
need for this change, and the kern.stactop sysctl, is gone.  Moreover,
the approach taken in this revision does not provide compatibility for
old copies of libthr.so, and the revision should have also updated
__libc_map_stacks_exec().

This reverts commit 78df56ccfc.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33704
2022-01-17 11:41:49 -05:00
Xin LI
f83ac37f1e Vendor import of expat 2.4.3. 2022-01-16 18:55:26 -08:00
Ed Maste
2e9bc9d144 libc: correct SPDX tag on strstr.c
It was obtained from musl, and is MIT licensed.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-16 11:56:28 -05:00
Ed Maste
c6750f07b4 libc: fix misleading comment in strstr
Obtained from:	musl c53e9b239418
2022-01-16 11:52:29 -05:00
Stefan Eßer
10af8e45a8 fread.c: fix undefined behavior
A case of undefined behavior in __fread() has been detected by UBSAN
and reported by Mark Millard:

/usr/main-src/lib/libc/stdio/fread.c:133:10: runtime error: applying
zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior in
/usr/main-src/lib/libc/stdio/fread.c:133:10

While being benign (the NULL pointer is later passed to memcpy() with
a length argument of 0), this issue causes in the order of 600 Kyua
test cases to fail on systems running a world built with WITH_UBSAN
and WITH_ASAN.

The undefined behavior can be prevented by skipping operations that
have no effect for r == 0. Mark Millard has suggested to only skip
this code segment if fp->_p == NULL, but I have verified that for the
case of r == 0 no further argument checking is performed on the
addresses passed to memcpy() and thus no bugs are hidden from the
sanitizers due to the simpler condition chosen.

Reported by:	Mark Millard (marklmi@yahoo.com)
Tested by:	Mark Millard (marklmi@yahoo.com)
Differential Revision:	https://reviews.freebsd.org/D33903
MFC after:	2 weeks
2022-01-16 00:43:56 +01:00
наб
18168da727
module/*.ko: prune .data, global .rodata
Evaluated every variable that lives in .data (and globals in .rodata)
in the kernel modules, and constified/eliminated/localised them
appropriately. This means that all read-only data is now actually
read-only data, and, if possible, at file scope. A lot of previously-
global-symbols became inlinable (and inlined!) constants. Probably
not in a big Wowee Performance Moment, but hey.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12899
2022-01-14 15:37:55 -08:00
Ryan Moeller
69c5e694a1
FreeBSD: Fix leaked strings in libspl mnttab
The FreeBSD implementations of various libspl functions for getting
mounted device information were found to leak several strings which
were being allocated in statfs2mnttab but never freed.

The Solaris getmntany(3C) and related interfaces are expected to return
strings residing in static buffers that need to be copied rather than
freed by the caller.

Use static thread-local storage to stash the mnttab structure strings
from FreeBSD's statfs info rather than strings allocated on the heap by
strdup(3).

While here, remove some stray commented out lines.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #12961
2022-01-14 12:38:32 -08:00
Piotr Kubaj
9fc1314266 riscv64: enable ASAN and UBSAN
Differential review:	https://reviews.freebsd.org/D33875
Approved by:	dim, imp
2022-01-14 01:29:58 +01:00
наб
4737a9eb70
linux: libzfs: mount: fix uninitialised flags
They're later |=d with constants, but never reset

Caught by valgrind while investigating
https://github.com/openzfs/zfs/pull/12928#issuecomment-1007496550

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12954
2022-01-13 11:07:54 -08:00
Stefan Eßer
d106f982a5 qsort.c: prevent undefined behavior
Mark Milliard has detected a case of undefined behavior with the LLVM
UBSAN. The mandoc program called qsort with a==NULL and n==0, which is
allowed by the POSIX standard. The qsort() in FreeBSD did not attempt
to perform any accesses using the passed pointer for n==0, but it did
add an offset to the pointer value, which is undefined behavior in
case of a NULL pointer. This operation has no adverse effects on any
achitecture supported by FreeBSD, but could be caught in more strict
environments.

After some discussion in the freebsd-current mail list, it was
concluded that the case of a==NULL and n!=0 should still be caught by
UBSAN (or cause a program abort due to an illegal access) in order to
not hide errors in programs incorrectly invoking qsort().

Only the the case of a==NULL and n==0 should be fixed to not perform
the undefined operation on a NULL pointer.

This commit makes qsort() exit before reaching the point of
potentially undefined behvior for the case n==0, but does not test
the value of a, since the result will not depend on whether this
pointer is NULL or an actual pointer to an array if n==0.

The issue found by Mark Milliard in the whatis command has been
reported to the upstream (OpenBSD) and has already been patched
there.

MFC after:	1 week
2022-01-13 11:09:38 +01:00
Warner Losh
479ef15dfd libc: Teak comment about mips
Remove mips from the list of machines using TLS variant I and reformat
paragraph. No functional change intended.

Sponsored by:		Netflix
2022-01-10 10:15:15 -07:00
Eugene Grosbein
ba94a95402 gpart(8): add minimal reference to glabel(8) to manual page
MFC after:	1 week
2022-01-10 22:07:23 +07:00
Konstantin Belousov
6d06bc688e libc clnt_com_create: relock rpcsoc_lock earlier when port is obtained from portmapper
Otherwise on mapper failure we goto error handler which expect
rpscoc_lock owned, but we do not.

PR:	261051
Reported by:	RyanCai <ryancaicse@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-01-09 07:36:06 +02:00
Ed Maste
adc88b9c01 Build libclang also if LLDB is enabled
LLDB depends on libclang as it uses Clang as the expression parser.
Previously setting WITHOUT_CLANG but leaving LLDB enabled (as default)
resulted in a build failure.

Users who set WITHOUT_CLANG in order to reduce build time or size
might want to set WITHOUT_LLDB in addition to WITHOUT_CLANG, or use
WITHOUT_TOOLCHAIN instead.

PR:		260993
Reported by:	eugen
Reviewed by:	dim
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-07 15:23:55 -05:00
Rich Ercolani
d6c1bbdd65
Updated the lz4 decompressor
As an experiment, I stole the lz4 decompressor from
upstream lz4 (1.9.3), and landed it.

Feedback suggested that keeping the vendor lz4 code isolated and
unlinted was probably reasonable, so I lobbed it into its own file.

It also seemed reasonable to put the mostly-untouched* code into
lz4.c proper, and relegate the integrated and ZFS-specific code to
lz4_zfs.c.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12805
2022-01-07 10:36:49 -08:00
Jose Luis Duran
f5ccb3a33e file: Fix cross-compilation on Darwin/macOS
Darwin/macOS does not have pipe2(2).

Apply a similar guard as in f3d7ace4b2
after 43a5ec4eb4.

Pull Request: https://github.com/freebsd/freebsd-src/pull/574
2022-01-07 07:52:34 -07:00
Tino Reichardt
a798b485ae Remove sha1 hashing from OpenZFS, it's not used anywhere.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12895
Closes #12902
2022-01-06 16:16:28 -08:00
наб
5c8389a8cb module: icp: rip out the Solaris loadable module architecture
After progressively folding away null cases, it turns out there's
/literally/ nothing there, even if some things are part of the
Solaris SPARC DDI/DKI or the seventeen module types (some doubled for
32-bit userland), or the entire modctl syscall definition.
Nothing.

Initialisation is handled in illumos-crypto.c,
which calls all the initialisers directly

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Attila Fülöp <attila@fueloep.org>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12895
Closes #12902
2022-01-06 16:14:04 -08:00
Paul Dagnelie
399b98198a
Revert "zfs list: Allow more fields in ZFS_ITER_SIMPLE mode"
This reverts commit f6a0dac84a.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #12938
2022-01-06 11:12:53 -08:00
Warner Losh
f3d7ace4b2 file: Turns out we need xlocal.h protection
It turns out that we still need xlocal.h protection for when we're
cross building on Linux. Linux doesn't have this file, but os/x
does. Before, we'd assume we didn't have it, like old FreeBSD, when
cross compiling. After the latest update, all that code was removed so
cross compiling needs to be handled separaetly. Do so by defining
HAVE_XLOCALE_H only when we're not building on linux. This allows us
to build the mkmagic build tool needed to build file(1).

Sponsored by:		Netflix
Reviewed by:		jrtc27
Differential Revision:	https://reviews.freebsd.org/D33741
2022-01-04 14:12:59 -07:00
Mark Johnston
e2576591b9 libsysdecode: Decode sendmsg/recvmsg flags containing an underscore
Otherwise MSG_CMSG_CLOEXEC is not decoded.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-01-04 09:46:23 -05:00
Hans Petter Selasky
fff236e89d mixer(3): Revert: "Fix for header file pollution."
Differential Revision:	https://reviews.freebsd.org/D33732
Submitted by:	christos@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-04 12:35:23 +01:00
Hans Petter Selasky
55224280e2 mixer(3): Fix for header file pollution.
Differential Revision:	https://reviews.freebsd.org/D33732
Submitted by:	christos@
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-04 11:43:59 +01:00
Xin LI
43a5ec4eb4 file: upgrade to 5.41.
MFC after:	2 weeks
2022-01-03 22:03:39 -08:00
Konstantin Belousov
d9cacbf4b0 sched_get/setaffinity(): try to be more compatible with Linux
in handling the cpuset sizes different from sizeof(cpuset_t).

For both cases, cpuset size shorter than sizeof(cpuset_t) results
in EINVAL on Linux.

For sched_getaffinity(), be more permissive and accept cpuset size
larger than our cpuset_t, by clipping the syscall argument and zeroing
the rest of the output buffer.  For sched_setaffinity(), we should allow
shorter cpusets than current ABI size, again zeroing the rest of the bits.

With this change, python os.sched_get/setaffinity functions work.

Reported by:	se
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-01-03 04:31:40 +02:00
Xin LI
9026652101 libmagic: Remove support for older FreeBSD where xlocale was not available.
The MINIMUM_SUPPORTED_OSREL is 1002501 (FreeBSD 10.3), and xlocale is
supported there.

While I'm there, explicitly use config.h generated with --disable-bzlib
--disable-xzlib instead of deleting them manually.

MFC after:	2 weeks
2022-01-02 18:05:08 -08:00
наб
1f182103aa libzfs: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
0cad373e5c libnvpair: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
9028f99a79 libzutil: import: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
56050599c9 libzpool: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
57bff80ebf libshare: nfs: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
bfc1789703 libzfs_core: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
7fe47a2386 libefi: efi_type: fix unused, remove argsused
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:42:47 -08:00
наб
da5f5ec508 libspl: kmem.h: mark unused kmem_*() macro arguments used
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:36:12 -08:00
наб
42aaf0e7c4 libspl: ASSERT*: mark arguments as used
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12844
2021-12-23 09:35:47 -08:00
Martin Matuška
20f5c5b912
FreeBSD: fix world build after 143476ce8
Do not redefine the fallthrough macro when building with libcpp.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Martin Matuska <mm@FreeBSD.org>
Closes #12880
2021-12-20 14:28:43 -08:00
Philipp Riederer
8623bd962d
Fix error propagation from lzc_send_redacted
Any error from lzc_send_redacted is overwritten by the error of
send_conclusion_record; skip writing the conclusion record if there
was an earlier error.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Philipp Riederer <philipp@riederer.email>
Closes #12766
2021-12-20 10:50:46 -08:00
Robert Wing
7c9948c2e9 skip test case nvlist_send_recv__send_many_fds__dgram
If I'm not mistaken, the underlying sendmsg() for nvlist_send() is
failing with ENOBUFS. In turn, nvlist_recv() returns NULL because it
didn't receive the expected number of file descriptors.

Adjusting net.local.dgram.recvspace worked on my local machine, but on
CI the test still fails consistently.

PR:     260891
2022-01-02 12:26:07 -09:00
Dmitry Wagin
881059955a libc: Some enhancements to syslog(3)
This is a re-application of commit
2d82b47a5b, which was reverted since it
broke with syslog daemons that don't adjust the /dev/log recv buffer
size.  Now that the default is large enough to accomodate 8KB messages,
restore support for large messages.

PR:		260126
2021-12-31 12:57:01 -05:00
Warner Losh
cb264bc716 mips: Remove thread_db support
Sponsored by:		Netflix
2021-12-31 00:14:53 -07:00
Warner Losh
39034b1254 mips: remove pthread support
Sponsored by:		Netflix
2021-12-31 00:14:53 -07:00
Warner Losh
8ff32ab58e mips: remove libc
Remove mips specific libc code and build infrasturcture.

Sponsored by:		Netflix
2021-12-31 00:14:53 -07:00
Warner Losh
b94b8bf702 mips: Remove msun support
Decommision msun (libm) support for mips.

Sponsored by:		Netflix
2021-12-31 00:14:52 -07:00
Warner Losh
e8399cfbbd mips: Remove CSU
Remove the CSU support for mips.

Sponsored by:		Netflix
2021-12-31 00:14:52 -07:00
Warner Losh
fe532f1a50 libkvm: Remove mips support
libkvm references files in sys/mips, so remove it ahead of removing
sys/mips.

Sponsored by:		Netflix
2021-12-30 20:57:24 -07:00
Dimitry Andric
5e6a2d6eb2 Reapply: move libc++ from /usr/lib to /lib
As with other runtime components like libc or libcxxrt.

If desired we can stop linking devd statically after this change (to
achive approximately no net change in required root filesystem size).

We must set SHLIBDIR with ?= before including <src.opts.mk>, otherwise
that will have set SHBLIDIR to its default value of /usr/lib.

Otherwise, "make delete-old-libs" would suggest to delete libc++.so.1
from /usr/lib, while there was not yet a copy in /lib.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33123
2021-12-30 17:08:54 +01:00
Ed Maste
b6f7942cbc Revert "Move libc++ from /usr/lib to /lib"
This reverts commit 6b1c5775d1.
There are reports of errors with this change.

Reported by:	antoine
2021-12-30 10:25:58 -05:00
Stefan Eßer
e2650af157 Make CPU_SET macros compliant with other implementations
The introduction of <sched.h> improved compatibility with some 3rd
party software, but caused the configure scripts of some ports to
assume that they were run in a GLIBC compatible environment.

Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being
added to ports, but there still were compatibility issues due to
invalid assumptions made in autoconfigure scripts.

The differences between the FreeBSD version of macros like CPU_AND,
CPU_OR, etc. and the GLIBC versions was in the number of arguments:
FreeBSD used a 2-address scheme (one source argument is also used as
the destination of the operation), while GLIBC uses a 3-adderess
scheme (2 source operands and a separately passed destination).

The GLIBC scheme provides a super-set of the functionality of the
FreeBSD macros, since it does not prevent passing the same variable
as source and destination arguments. In code that wanted to preserve
both source arguments, the FreeBSD macros required a temporary copy of
one of the source arguments.

This patch set allows to unconditionally provide functions and macros
expected by 3rd party software written for GLIBC based systems, but
breaks builds of externally maintained sources that use any of the
following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR.

One contributed driver (contrib/ofed/libmlx5) has been patched to
support both the old and the new CPU_OR signatures. If this commit
is merged to -STABLE, the version test will have to be extended to
cover more ranges.

Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do
no longer require that option.

The FreeBSD version has been bumped to 1400046 to reflect this
incompatible change.

Reviewed by:	kib
MFC after:	2 weeks
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33451
2021-12-30 12:20:32 +01:00
John Baldwin
b406897911 iscsi: Handle large Text responses.
Text requests and responses can span multiple PDUs.  In that case, the
sender sets the Continue bit in non-final PDUs and the Final bit in
the last PDU.  The receiver responds to non-final PDUs with an empty
text PDU.

To support this, add a more abstract API in libiscsi which accepts and
receives key sets rather than PDUs.  These routines internally send or
receive one or more PDUs.  Use these new functions to replace the
handling of TextRequest and TextResponse PDUs in discovery sessions in
both ctld and iscsid.

Note that there is not currently a use case for large Text requests
and those are still always sent as a single PDU.  However, discovery
sessions can return a text response listing targets that spans
multiple PDUs, so the new API supports sending and receiving multi-PDU
responses.

Reported by:	Jithesh Arakkan @ Chelsio
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33548
2021-12-29 14:36:04 -08:00
Alexander Motin
62ed2d0152 libc: Fix build with -DNS_REREAD_CONF.
MFC after:	3 days
2021-12-29 17:01:05 -05:00
Ed Maste
6b1c5775d1 Move libc++ from /usr/lib to /lib
As with other runtime components like libc or libcxxrt.

If desired we can stop linking devd statically after this change (to
achive approximately no net change in required root filesystem size).

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33123
2021-12-29 14:51:28 -05:00
Kirk McKusick
1fa68dae46 Clarify the description of the EINTEGRITY error in intro(2).
Requested by: pauamma_gundo.com
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D18765
2021-12-28 16:39:46 -08:00
Ed Maste
5bc2e6e227 getfh: clarify that it is a privileged operation
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33629
2021-12-23 11:54:43 -05:00
Jessica Clarke
0aa8b18bc9 libc: Fix regexec when sizeof(char *) > sizeof(long)
The states macro is the type for engine.c to use, with states1 being a
local macro for regexec to use to determine whether it can use the small
matcher or not (by comparing nstates and 8*sizeof(states1)). However,
macro bodies are expanded in the context of their use, and so when
regexec uses states1 it uses the current value of states, which is left
over as char * from the large version (or, really, the multi-byte one,
but that reuses large's states). For all supported architectures in
FreeBSD, the two have the same size, and so this confusion is harmless.
However, for architectures like CHERI where that is not the case (or
Windows's LLP64 as discovered by LLVM and fixed in 2010 in 2e071faed8e2)
and sizeof(char *) is bigger than sizeof(long) regexec will erroneously
try to use the small matcher when nstates is between sizeof(long) and
sizeof(char *) (i.e. between 64 and 128 on CHERI, or 32 and 64 on LLP64)
and end up overflowing the number of bits in the underlying long if it
ever uses those high states. On weirder architectures where sizeof(long)
is greater than sizeof(char *) this also fixes it to not fall back on
the large matcher prematurely, but such architectures are likely limited
to the embedded space, if they exist at all.

Fix this by swapping round states and states1, so that states1 is
defined directly as being long and states is an alias for it for the
small matcher case.

Found by:	CHERI
2021-12-23 16:38:10 +00:00
John Baldwin
25700db366 libiscsiutil: Change keys_load/save to operate on data buffers.
This will be used in future changes to support large text requests
spanning multiple PDUs.

Provide wrapper functions keys_load/save_pdu that operate use a PDU's
data buffer.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33547
2021-12-22 10:43:24 -08:00
John Baldwin
2ccb8fde5e libiscsiutil: Use open_memstream to build the outgoing block of keys.
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33546
2021-12-22 10:43:23 -08:00
John Baldwin
fd99905b45 libiscsiutil: Fix a memory leak with negotiation keys.
When keys are loaded from a received PDU, a copy of the received keys
block is saved in the keys struct and the name and value pointers
point into that saved block.  Freeing the keys frees this block.

However, when keys are added to a keys struct to build a set of keys
later sent in a PDU, the keys data block pointer is not used and
individual key names and values hold allocated strings.  When the keys
structure was freed, all of these individual key name and value
strings were leaked.

Instead, allocate copies of strings for names and values when parsing
a set of keys from a received PDU and free all of the individual key
name and value strings when deleting a set of keys.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33545
2021-12-22 10:43:23 -08:00
John Baldwin
6378393308 Add an internal libiscsiutil library.
Move some of the code duplicated between ctld(8) and iscsid(8) into a
libiscsiutil library.

Sharing the low-level PDU code did require having a
'struct connection' base class with a method table to permit separate
initiator vs target behavior (e.g. in handling proxy PDUs).

Reviewed by:	mav, emaste
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D33544
2021-12-22 10:43:11 -08:00
Jessica Clarke
6d5297569e libc: Fix "harmless" iconv one-byte overread
Checking there are still bytes left must be done before dereferencing
the pointer, not the other way round. This is harmless on traditional
architectures since the result will immediately be thrown away, and all
callers are in separate translation units so there is no potential for
optimising based on this out-of-bounds read. However, on CHERI, pointers
are bounded, and so this will trap if fed a string that does not have a
NUL within the first len bytes.

Found by:	CHERI
Reviewed by:	brooks
2021-12-21 22:47:38 +00:00
Ed Maste
cb2d135015 csu: define STRIP_FBSDID
__FBSDID() places the provided string in the output object's .comment
section.  However, with the transition to Git $FreeBSD$ is no longer
expanded and so we emitted a literal $FreeBSD$.

$FreeBSD$ will be addressed in a holistic manner in the future, but at
least avoid embedding it into everything linked on FreeBSD (via csu).

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33594
2021-12-21 13:34:42 -05:00
Baptiste Daroussin
d93b4d3203 bsddialog: import version 0.0.2 2021-12-21 16:13:00 +01:00
Alfonso Siciliano
77a55d2c3b bsddialog: import snapshot 0.0.2 2021-12-21 16:06:19 +01:00
Li-Wen Hsu
71779dddff
libefivar(3): efi_set_variables_supported.3 should be efi_variables_supported.3
MFC after:	3 days
2021-12-21 20:42:39 +08:00
Emmanuel Vadot
13ef8134ef pkgbase: Create a FreeBSD-fetch package
It's useful for small image to fetch some data but we don't want to
install utilities nor bloat runtime.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33463
2021-12-21 10:17:46 +01:00
Emmanuel Vadot
93c4369096 pkgbase: Put more binaries/lib in runtime
Move some needed binaries/libs from FreeBSD-utilities to FreeBSD_runtime.
This is everything needed to boot to multiuser with FreeBSD-rc installed.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33435
2021-12-21 10:17:27 +01:00
Emmanuel Vadot
5abb10faa1 pkgbase: Put yellow pages programs to its own package
YP is less and less used, split them to users have the choice to not
install them.

MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33441
2021-12-21 10:17:22 +01:00
Robert Wing
a7cb27ce1c libnv: bump sysctl for nvlist_send_recv__send_many_fds__dgram test
Increase sysctl net.local.dgram.recvspace to 1M.

Reported by:    Jenkins
2021-12-20 15:57:47 -09:00
Simon J. Gerraty
623ecf2332 Move ve_check_hash prototype to libsecureboot-priv.h
Reviewed by: stevek
2021-12-18 16:34:58 -08:00
Brooks Davis
8010f4ad21 libusb: remove use of COMPAT_32BIT
This codepath used uint64_t's in place of pointers in structs and
arrays to allow 32-bit code to use 64-bit version of ioctls.  Now
that we support 32-bit compat natively this is no longer needed.

Reviewed by:	hselasky, jrtc27 (prior version)
2021-12-17 21:28:14 +00:00
наб
82e414f1b2 libshare: nfs: always try to mkdir()
This also works out to one syscall if the directory exists,
but is one syscall shorter if it doesn't.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:54:25 -08:00
наб
1e78b4eee0 libshare: nfs: set export file 644
The shares are publicly known anyway and can be interrogated by any
user, so this is a debugging aid more than anything.

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:54:14 -08:00
наб
9d4a44f0b8 linux/libshare: nfs: don't needlessly strdup() hostspec
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:54:09 -08:00
наб
605e03e51a libshare: nfs: share nfs_is_shared()
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:54:04 -08:00
наб
4e225e7316 libshare: nfs: share nfs_copy_entries()
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:54:00 -08:00
наб
c53f2e9b50 libshare: nfs: open temporary file once
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:53:54 -08:00
наб
f50697f95b libshare: nfs: retry flock() when interrupted
Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:53:49 -08:00
наб
bdf6464c6c freebsd/libshare: nfs: don't send SIGHUP to all processes
pidfile_open() sets *pidptr to -1 if the process currently holding
the lock is between pidfile_open() and pidfile_write(),
the subsequent kill(mountdpid) would potentially SIGHUP all
non-system processes except init: just sleep for half a millisecond
and try again in that case

Reviewed-by: Don Brady <don.brady@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12067
2021-12-17 12:53:25 -08:00
Math Ieu
caacda7a3e sched_get/setaffinity(3): pid 0 should designate current process
while FreeBSD' native sched_get/setaffinity use pid -1 for this.

PR:	260487
MFC after:	1 week
2021-12-17 07:31:09 +02:00
наб
eb51a9d747
zcommon: pre-iterate over sysfs instead of statting every feature
If sufficient memory (<2K, realistically) is available, libzfs_init()
can be significantly shorted by iterating over the correct sysfs
directory before registrations, we can turn 168 stats into 15/18
syscalls (3 opens (6 if built in), 3 fstats, 6 getdentses, and 3
closes), a tenfoldish reduction; this is probably a bit faster, too.

The list is always optional, and registration functions (and one-off
users) can simply pass NULL, which will fall back to the previous
mechanism

Also, don't allocate in zfs_mod_supported_impl, and use use access()
instead of stat(), since existence is really what we care about

Also, fix pre-prop-checking compat in fallback for built-in ZFS

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12089
2021-12-16 16:43:10 -08:00
Allan Jude
f6a0dac84a
zfs list: Allow more fields in ZFS_ITER_SIMPLE mode
If the fields to be listed and sorted by are constrained
to those populated by dsl_dataset_fast_stat(), then
zfs list is much faster, as it does not need to open each
objset and reads its properties.

A previous optimization by Pawel Dawidek
(0cee24064a) took advantage
of this to make listing snapshot names sorted only by name
much faster.

However, it was limited to `-o name -s name`, this work
extends this optimization to work with:
  - name
  - guid
  - createtxg
  - numclones
  - inconsistent
  - redacted
  - origin
and could be further extended to any other properties
supported by dsl_dataset_fast_stat() or similar, that do
not require extra locking or reading from disk.

Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Pawel Jakub Dawidek <pawel@dawidek.net>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Closes #11080
2021-12-16 11:56:22 -08:00
David E. O'Brien
0cd475f86b Document 7f911abe's new functions came in 11.0
Document that the 7f911abe "Add support to libkvm for reading vmcores
from other architectures." added functions appeared first in FreeBSD 11.0.
2021-12-15 16:18:59 -08:00
Mark Murray
03a88e3de9 * lib/msun/Makefile b/lib/msun/Makefile:
. Disconnect imprecise.c from the build.  This file can be deleted.
  . Add b_tgammal.c to the build for ld80 and ld128 targets.  The ld128
    is a 'git mv' of imprecise.c to ld128/b_tgammal.c.

* lib/msun/ld80/b_expl.c:
  . New file.  Implement __exp__D for ld80 targets.  This is based on
    bsdsrc/b_exp.c.

* lib/msun/ld80/b_logl.c:
  . New file.  Implement __log__D for ld80 targets.  This is based on
    bsdsrc/b_log.c.

* lib/msun/ld80/b_tgammal.c b/lib/msun/ld80/b_tgammal.c
  . New file.  Implement tgammal(x) for ld80 targets.

Submitted by:           Steve Kargl
Differential Revision:  https://reviews.freebsd.org/D33444
Reviewed by:            pfg
2021-12-15 18:36:20 +00:00
Mark Murray
455b2ccda3 * lib/msun/Makefile:
. Disconnect b_exp.c and b_log.c from the build.

* lib/msun/bsdsrc/b_exp.c:
  . Replace scalb() usage with C99's ldexp().
  . Replace finite(x) usage with C99's isfinite().
  . Whitespace changes towards style(9).
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Remove #if 0 ... #endif code, which has been present since svn r93211
    (2002-03-26).
  . New minimax polynomial coefficients.
  . Add comments to explain origins of some constants.
  . Use ansi-C prototype.  Remove K&R prototype.  Add static to prototype.

* lib/msun/bsdsrc/b_log.c:
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Fix comments to actually describe the code.
  . Reduce minimax polynomial from degree 4 to degree 3.
    This uses newly computed coefficients.
  . Use ansi-C prototype.  Remove K&R prototype.  Add static to prototype.
  . Remove volatile in declaration of u1.
  . Alphabetize decalaration list.
  . Whitespace changes towards style(9).
  . In argument reduction of x to g and m, replace use of logb() and
    ldexp() with a single call to frexp().  Add code to get 1 <= g < 2.
  . Remove #if 0 ... #endif code, which has been present since svn r93211
    (2002-03-26).
  . The special case m == -1022, replace logb() with ilogb().

* lib/msun/bsdsrc/b_tgamma.c:
  . Update comments.  Fix comments where needed.
  . Add float.h to get LDBL_MANT_DIG for weak reference of tgammal to tgamma.
  . Remove include of "mathimpl.h".  It is no longer needed.
  . Use "math.h" instead of <math.h>.
  . Add '#include math_private.h"
  . Add struct Double from mathimpl.h and include b_log.c and b_exp.c.
  . Remove forward declarations of neg_gam(), small_gam(), smaller_gam,
    large_gam() and ratfun_gam() by re-arranging the code to move these
    function above their first reference.
  . New minimax coefficients for polynomial in large_gam().
  . New splitting of a0 into a0hi nd a0lo, which include additional
    bits of precision.
  . Use ansi-C prototype.  Remove K&R prototype.
  . Replace the TRUNC() macro with a simple cast of a double entities
    to float before assignment (functional changes).
  . Replace sin(M_PI*z) with sinpi(z) and cos(M_PI*(0.5-z)) with cospi(0.5-z).

Submitted by:		Steve Kargl
Differential Revision:	https://reviews.freebsd.org/D33444
Reviewed by:		pfg
2021-12-15 18:36:19 +00:00
Andrew Gallatin
517a7adb11 Make hwpmc work for userspace binaries again
hwpmc has been utterly broken for userspace binaries, and has been
labeling all samples from userspace binaries as dubious frames. The
issues are that:

-The check for ph.p_offset & (-ph.p_align) == 0 was mostly bogus. The
 intent was to ignore all executable segments other than the first,
 which when using BFD appeared in the first page, but with current LLD
 a read-only data segment appears before the executable segment,
 pushing the latter into the second page or later. This meant no
 executable segment was ever found, and thus pi_vaddr remained
 0. Instead of relying on BFD's layout, track whether we've seen an
 executable segment explicitly with a local bool.

-Shared libraries were not parsing the segments to calculate pi_vaddr,
 resulting in it always being 0. Again, when using BFD, the executable
 segment started at the first page, and so pi_vaddr was genuinely
 meant to be 0, but not with LLD's current layout. This meant that
 pmcstat_image_link's offset calculation gave the base address of the
 segment in memory, rather than the base address of the whole library
 in memory, and so when adding that to pi_start/pi_end to get the
 range of the executable sections in memory it double-counted the
 offset of the first executable segment within the library. Thus we
 need to do the exact same parsing for ET_DYN as we do for ET_EXEC,
 which is simpler to write as special-casing ET_REL to not look for
 segments. Note that, whilst PT_INTERP isn't needed for shared
 libraries, it will be for PIEs, which pmcstat still fails to handle
 due to not knowing the base address of the PIE; we get the base
 address for libraries by MAP_IN events, and for rtld by virtue of the
 process's entry address being rtld's, but have no equivalent for the
 executable.

Fixes courtesy of jrtc27@.

Reviewed by: jrtc27, jhb (earlier version)
Differential Revision: https://reviews.freebsd.org/D33055
Sponsored by: Netflix
2021-12-15 08:38:36 -05:00
Dimitry Andric
20d425842a Remove set-but-unused variable from s_sincosl.c
This look like a copy and paste leftover.

Reported by:	enh@google.com (via freebsd-numerics@)
Reviewed by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
MFC after:	3 days
2021-12-14 22:50:30 +01:00
Mariusz Zaborski
f45ca435bd cap_net: fix verification of bind permission
MFC after:	5 days
2021-12-14 12:02:40 +01:00
Mariusz Zaborski
88910b8b7b cap_net: plug memory leak
MFC after:	5 days
2021-12-14 12:02:40 +01:00
наб
b7ef2340c2 libzfs: diff: simplify superfluous stdio
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:50:38 -08:00
наб
9bdf0c592b libzfs: diff: print_what() can return the symbol => get_what()
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:50:29 -08:00
наб
a72129edcb libzfs: diff: stream_bytes: use fputc, %hho formats chars
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:50:20 -08:00
наб
1cfb6ef36e libzfs: zpool_set_vdev_prop: remove unused vprop
Found by clang 14 with -Wunused-but-set-variable

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:50:09 -08:00
наб
9e184b7c35 linux: libspl: getmntany: remove unused argument
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:49:59 -08:00
наб
344bbc82e7 zfs, libzfs: diff: accept -h/ZFS_DIFF_NO_MANGLE, disabling path escaping
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12829
2021-12-13 15:49:40 -08:00
Mark Johnston
3aa0bc89c6 libdwarf: Add a weak uncompress() symbol
This works around brokenness in buildworld's bootstrapping logic: it
uses the source tree's metadata to collect dependency info (such as,
"libdwarf depends on libz") but links against static host libraries.
If these two are out of sync, as is the case if one builds a commit
prior to the introduction of the libz dependency, then the build fails
when trying to statically link nm(1).

Mitigate the problem by defining a weak uncompress() symbol which simply
returns an error.  This ensures that the build won't fail when
statically linking libdwarf without zlib.  The downside is that any
tools using libdwarf without zlib will now hit a runtime error if they
attempt to decode compressed sections, but at least they'll fail
deterministically, and compressed debug info is only enabled by default
in main.

In particular, this fixes building of branches lacking commit
dbf05458e3, such as releng branches, stable/12 and 13 and old
revisions of main.  Previously the nm(1) build would fail with:

ld: error: undefined symbol: uncompress
>>> referenced by libdwarf_elf_init.c:233
>>> (/usr/src/contrib/elftoolchain/libdwarf/libdwarf_elf_init.c:233)
>>>               libdwarf_elf_init.o:(_dwarf_elf_init) in archive
>>> /usr/lib/libdwarf.a

Reported by:	dim, ler, krion
Reviewed by:	imp, emaste
Fixes:		dbf05458e3 ("libdwarf: Support consumption of compressed ELF sections")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33419
2021-12-13 18:47:15 -05:00
Andrew Turner
71bf1c4cc5 Add accelerated arm64 sha512 to libmd
As with sha256 add support for accelerated sha512 support to libmd on
arm64. This depends on clang 13+ to build as this is the first release
with the needed intrinsics. Gcc should also support them, however from
a currently unknown release.

Reviewed by:	cem
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33373
2021-12-13 15:33:22 +00:00
Alfonso Siciliano
e41955dd2d bsddialog: import version 0.0.1 2021-12-13 08:54:07 +01:00
Bora Özarslan
08055452cb libkvm: fix kvm_walk_pages
Correct bitmap operations in _kvm_bitmap_next.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19183
2021-12-10 14:15:15 -05:00
Mateusz Piotrowski
58d60030ff gmultipath.8: Fix a typo
It's Word Wide Port Name, not World Word Port Name.

MFC after:	3 days
2021-12-10 14:33:34 +01:00
Florian Walpen
a9545eede4 Add idle priority scheduling privilege group to MAC/priority
Add an idletime user group that allows non-root users to run processes
with idle scheduling priority. Privileges are granted by a MAC policy in
the mac_priority module. For this purpose, the kernel privilege
PRIV_SCHED_IDPRIO was added to sys/priv.h (kernel module ABI change).

Deprecate the system wide sysctl(8) knob
security.bsd.unprivileged_idprio which lets any user run idle priority
processes, regardless of context. While the knob is still working, it is
marked as deprecated in the description and in the man pages.

MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D33338
2021-12-10 04:54:48 +02:00
John Baldwin
ae67737a4c libc: Remove _get_tp() and _set_tp().
Their uses have been replaced by _tcb_get() and _tcb_set() from
<machine/tls.h>.

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33354
2021-12-09 13:23:26 -08:00
John Baldwin
8bcdb144eb TLS: Use <machine/tls.h> for libc and rtld.
- Include <machine/tls.h> in MD rtld_machdep.h headers.

- Remove local definitions of TLS_* constants from rtld_machdep.h
  headers and libc using the values from <machine/tls.h> instead.

- Use _tcb_set() instead of inlined versions in MD
  allocate_initial_tls() routines in rtld.  The one exception is amd64
  whose _tcb_set() invokes the amd64_set_fsbase ifunc.  rtld cannot
  use ifuncs, so amd64 inlines the logic to optionally write to fsbase
  directly.

- Use _tcb_set() instead of _set_tp() in libc.

- Use '&_tcb_get()->tcb_dtv' instead of _get_tp() in both rtld and libc.
  This permits removing _get_tp.c from rtld.

- Use TLS_TCB_SIZE and TLS_TCB_ALIGN with allocate_tls() in MD
  allocate_initial_tls() routines in rtld.

Reviewed by:	kib, jrtc27 (earlier version)
Differential Revision:	https://reviews.freebsd.org/D33353
2021-12-09 13:23:05 -08:00
John Baldwin
75395023ff libthr: Use <machine/tls.h> for most MD TLS details.
Note that on amd64 this effectively removes the unused tcb_spare field
from the end of struct tcb since the definition of struct tcb in
<x86/tls.h> does not include that field.

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33352
2021-12-09 13:17:41 -08:00
John Baldwin
4c2f5bfbfa libc: Fix the alignment of the TCB to match rtld for several architectures.
- Use 16 byte alignment rather than 8 for aarch64, powerpc64, and RISC-V.

- Use 8 byte alignment rather than 4 for 32-bit arm, mips, and powerpc.

I suspect that mips64 should be using 16 byte alignment, but both libc
and rtld currently use 8 byte alignment.

Reviewed by:	kib, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33350
2021-12-09 13:16:57 -08:00
John Baldwin
9952b82b39 mips _libc_get_static_tls_base: Narrow scope of #ifdef.
Reviewed by:	kib, emaste, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33348
2021-12-09 13:16:34 -08:00
John Baldwin
5d8176337e libthr: Remove the DTV_OFFSET macro.
This macro is confusing as it is not related to the similarly named
TLS_DTV_OFFSET.  Instead, replace its one use with the desired
expression which is the same on all platforms.

Reviewed by:	kib, emaste, jrtc27
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33345
2021-12-09 13:15:38 -08:00
Konstantin Belousov
9f0fea5d03 Document new variant of swapoff(2)
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33343
2021-12-09 02:48:53 +02:00
Konstantin Belousov
5346570276 swapoff: add one more variant of the syscall
Requested and reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33343
2021-12-09 02:48:46 +02:00
Ed Maste
2a31cd215d Apply ASAN/UBSAN Makefile check only for build target
COMPILER_TYPE is not set during cleandir and perhaps other non-build
targets, and a build with ASAN or UBSAN enabled failed with an error
reporting that runtime libraries could not be built.

PR:		260099
Reviewed by:	dim
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32805
2021-12-08 17:02:45 -05:00
Michał Górny
8099a35446 libkvm: Fix kvm_getloadavg() on modern kernel vmcores
Fix kvm_getloadavg() to work correctly on vmcores for modern kernel
versions.  The kernels no longer include the `_fscale` symbol causing
the kvm_nlist() invocation to fail.  The code seemed to already assume
that `_fscale` could be missing but the early kvm_nlist() result check
has caused the function to fail if any symbol were missing.  Modify
it to only treat `_averunnable` as obligatory, and handle missing
`_fscale` gracefully.

Sponsored by:   The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32884
2021-12-07 15:36:34 -08:00
Paul Dagnelie
795075e638
Add const to nvlist functions to properly expose their real behavior
Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Paul Dagnelie <pcd@delphix.com>
Closes #12728
2021-12-06 18:19:13 -07:00
Jessica Clarke
7d232d647e libcrypt: Drop inclusion of libutil.h
This was rendered obsolete in 2012 by a0ee974f0b, since auth_getval
was the only reason the header was included.

MFC after:	1 week
2021-12-07 00:24:19 +00:00
Brooks Davis
022ce9617f libc: get rid of NO_P1003_1B make variable
There's no point in a knob to avoid installing a half dozen manpages.
It's undocumented and unused in the tree.  Online, the only metions
I've found are the FreeBSD source tree, a commit in DragonFly BSD
removing it, and some lists of build options for small systems where
it's inevitably redundant due to an accompanying NO_MAN.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D33310
2021-12-07 00:21:44 +00:00
Mark Johnston
cbdec8db18 libc: Add pdfork to the list of interposed system calls
Otherwise the asm stub is used and libthr interposition does not work.

Reviewed by:	kib
Fixes:		21f749da82 ("libthr: wrap pdfork(2), same as fork(2).")
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2021-12-06 18:32:43 -05:00
Konstantin Belousov
97722455cc fcntl(2): be more precise about third arg type
Also use the term operation consistently, over the command.

Reviewed by:	emaste, jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33277
2021-12-07 01:27:38 +02:00
Konstantin Belousov
794d3e8e63 fcntl(2): add F_KINFO operation
that returns struct kinfo_file for the given file descriptor.  Among
other data, it also returns kf_path, if file op was able to restore file
path.

Reviewed by:	jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33277
2021-12-06 22:18:09 +02:00
Jessica Clarke
8d5d329553 Bootstrap libz when cross-building from non-FreeBSD
This is needed now libdwarf depends on libz.

Fixes:		dbf05458e3 ("libdwarf: Support consumption of compressed ELF sections")
MFC after:	1 week
2021-12-06 19:16:28 +00:00
Robert Wing
5916ae1fb1 libnv: read entire datagram in nvlist_recv()
When SOCK_DGRAM is used, a portion of the datagram is discarded during
the initial recv() when getting the nvlist_header.

To workaround this, use MSG_PEEK for the initial recv() when using a
datagram socket.

Add tests for SOCK_DGRAM with nvlist_send()/nvlist_recv().

Differential Revision:	https://reviews.freebsd.org/D32722
2021-12-06 09:54:55 -09:00
Robert Wing
db158b9942 libnv: let nvlist_recv() pass flags to recv()
Differential Revision:	https://reviews.freebsd.org/D32721
2021-12-06 09:54:55 -09:00
Mark Johnston
dbf05458e3 libdwarf: Support consumption of compressed ELF sections
Automatically decompress zlib-compressed debug sections when loading
them.  This lets ctfcovert work on userland code after commit
c910570e75 ("Use compressed debug in standalone userland debug files
by default").

Reported by:	avg
Reviewed by:	avg, emaste
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33139
2021-12-06 10:37:49 -05:00
Baptiste Daroussin
f499134dd4 bsddialog: import snapshot 2021-12-05 2021-12-06 11:43:34 +01:00
Baptiste Daroussin
1b308d0631 bsddialog: vendor import 2021-12-05 2021-12-06 11:35:28 +01:00
Stefan Eßer
5e04571cf3 sys/bitset.h: reduce visibility of BIT_* macros
Add two underscore characters "__" to names of BIT_* and BITSET_*
macros to move them to the implementation name space and to prevent
a name space pollution due to BIT_* macros in 3rd party programs with
conflicting parameter signatures.

These prefixed macro names are used in kernel header files to define
macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h.

If C programs are built with either -D_KERNEL (automatically passed
when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET
(or this macros is defined in the source code before including the
bitset macros), then all macros are made visible with their previous
names, too. E.g., both __BIT_SET() and BIT_SET() are visible with
either of _KERNEL or _WANT_FREEBSD_BITSET defined.

The main reason for this change is that some 3rd party sources
including sched.h have been found to contain conflicting BIT_*
macros.

As a work-around, parts of shed.h have been made conditional and
depend on _WITH_CPU_SET_T being set when sched.h is included.
Ports that expect the full functionality provided by sched.h need
to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if
BIT_* macros are defined in that program, too.

This patch set makes all of sched.h visible again without this
parameter being passed and without any name space pollution due
to BIT_* macros becoming visible when sched.h is included.

This patch set will be backported to the STABLE branches, but ports
will need to use -D_WITH_CPU_SET_T as long as there are supported
releases that do not contain these patches.

Reviewed by:	kib, markj
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33235
2021-12-05 23:00:25 +01:00
Konstantin Belousov
79d650f262 swapoff(2): document extended syscall arguments
Reviewed by:	markj
Discussed with:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33165
2021-12-05 00:20:58 +02:00
Florian Walpen
bf2fa8d9d1 MAC/priority module for realtime privilege group
This is a MAC policy module that grants scheduling privileges based on
group membership.  Users or processes in the group realtime (gid 47) are
allowed to run threads and processes with realtime scheduling priority.
For timing-sensitive, low-latency software like audio/jack, running with
realtime priority helps to avoid stutter and gaps.

PR:	239125
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D33191
2021-12-04 20:19:25 +02:00
Chuck Silvers
dfd00261c9 librtld_db: Handle shlibs with discontiguous mappings.
Some shared libraries specify mappings that leave a gap (actually a
MAP_GUARD mapping) in between the file mappings (libcrypto.so was
the one I found), and this would cause rd_loadobj_iter() to report
the mapping info incorrectly, leaving out rdl_path and misreporting
rdl_offset for file mappings after the gap.  Fix rd_loadobj_iter()
to handle this situation.

Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32950
2021-12-03 11:07:30 -08:00
Konstantin Belousov
7a9423d6f3 procstat_getfiles_sysctl: do not require non-null ki_fd
ki_fd is legitimately NULL when 32bit process requests process data
from 64bit host kernel.  The field is not used by the code for sysctl
case;  procstat_getfiles_kvm() checks ki_fd.

PR:	260174
Reported by:	Damjan Jovanovic <damjan.jov@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-12-03 00:52:49 +02:00
Konstantin Belousov
0ea3e4a27b Style
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-12-03 00:52:49 +02:00
Cy Schubert
db0ac6ded6 Revert "wpa: Import wpa_supplicant/hostapd commit 14ab4a816"
This reverts commit 266f97b5e9, reversing
changes made to a10253cffe.

A mismerge of a merge to catch up to main resulted in files being
committed which should not have been.
2021-12-02 14:45:04 -08:00