Commit Graph

23794 Commits

Author SHA1 Message Date
Richard Yao
73968defdd
Reject streams that set ->drr_payloadlen to unreasonably large values
In the zstream code, Coverity reported:

"The argument could be controlled by an attacker, who could invoke the
function with arbitrary values (for example, a very high or negative
buffer size)."

It did not report this in the kernel. This is likely because the
userspace code stored this in an int before passing it into the
allocator, while the kernel code stored it in a uint32_t.

However, this did reveal a potentially real problem. On 32-bit systems
and systems with only 4GB of physical memory or less in general, it is
possible to pass a large enough value that the system will hang. Even
worse, on Linux systems, the kernel memory allocator is not able to
support allocations up to the maximum 4GB allocation size that this
allows.

This had already been limited in userspace to 64MB by
`ZFS_SENDRECV_MAX_NVLIST`, but we need a hard limit in the kernel to
protect systems. After some discussion, we settle on 256MB as a hard
upper limit. Attempting to receive a stream that requires more memory
than that will result in E2BIG being returned to user space.

Reported-by: Coverity (CID-1529836)
Reported-by: Coverity (CID-1529837)
Reported-by: Coverity (CID-1529838)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14285
2023-01-23 13:16:22 -08:00
rob-wing
69f024a56e
Configure zed's diagnosis engine with vdev properties
Introduce four new vdev properties:
    checksum_n
    checksum_t
    io_n
    io_t

These properties can be used for configuring the thresholds of zed's
diagnosis engine and are interpeted as <N> events in T <seconds>.

When this property is set to a non-default value on a top-level vdev,
those thresholds will also apply to its leaf vdevs. This behavior can be
overridden by explicitly setting the property on the leaf vdev.

Note that, these properties do not persist across vdev replacement. For
this reason, it is advisable to set the property on the top-level vdev
instead of the leaf vdev.

The default values for zed's diagnosis engine (10 events, 600 seconds)
remains unchanged.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Rob Wing <rob.wing@klarasystems.com>
Sponsored-by: Seagate Technology LLC
Closes #13805
2023-01-23 13:14:25 -08:00
Xin LI
047153b416 MFV: xz 5.4.1.
MFC after:	3 days
2023-01-22 16:50:36 -08:00
Allan Jude
63267f7f77
zfs_receive_one: Check for the more likely error first
If zfs_receive_one() gets back EINVAL, check for the more likely case,
embedded block pointers + encryption and return that error, before
falling back to the less likely case, a resumable stream when the
kernel has not been upgraded to support resume.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Sponsored-by: rsync.net
Sponsored-by: Klara Inc.
Closes #14379
2023-01-20 11:11:54 -08:00
Pau Amma
5faf9f4dff Refresh CPU types and classes from sys/sys/pmc.h.
While here, fix a few nits.

Inspired by reviewing D35342.

Sources for trademark info
- https://www.arm.com/company/policies/trademarks (no Arm8, curiously)
- https://www.ibm.com/legal/copytrade?mhsrc=ibmsearch_a&mhq=trademark

Reviewed by:	carlavilla, luporl, mhorne
Approved by:	carlavilla (mentor), mhorne (src)
Differential Revision: https://reviews.freebsd.org/D35344
2023-01-18 21:50:49 +01:00
Jorgen Lundman
68c0771cc9
Unify Assembler files between Linux and Windows
Add new macro ASMABI used by Windows to change
calling API to "sysv_abi".

Reviewed-by: Attila Fülöp <attila@fueloep.org>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jorgen Lundman <lundman@lundman.net>
Closes #14228
2023-01-17 11:09:19 -08:00
Ameer Hamza
19d3961589
Use setproctitle to report progress of zfs send
This allows parsing of zfs send progress by checking the process
title.
Doing so requires some changes to the send code in libzfs_sendrecv.c;
primarily these changes move some of the accounting around, to allow
for the code to be verbose as normal, or set the process title. Unlike
BSD, setproctitle() isn't standard in Linux; thus, borrowed it from
libbsd with slight modifications.

Authored-by: Sean Eric Fagan <sef@FreeBSD.org>
Co-authored-by: Ryan Moeller <ryan@iXsystems.com>
Co-authored-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #14376
2023-01-17 10:17:35 -08:00
Christos Margiolis
e5f5ca7fee mixer(3): remove redundant argument in _mixer_readvol()
There's no reason to pass the mixer as an argument since we can fetch it
from mix_dev.  No functional change intended.

Reviewed by:	markj, hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38076
2023-01-17 08:08:59 -05:00
Gregory Neil Shapiro
3413ee88c3 Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds 2023-01-15 21:24:38 +00:00
Gregory Neil Shapiro
d89513ed20 Update for new library files in sendmail 8.17.1 2023-01-15 21:23:27 +00:00
Alexander V. Chernikov
b0286ee504 man: add Netlink reference to socket(2)
Reviewed by:	lwhsu, pauamma, gbe
Differential Revision: https://reviews.freebsd.org/D38054
2023-01-15 11:27:43 +00:00
Christos Margiolis
249526dace mixer(3): Add HEADNAME to TAILQ_HEAD declarations
This allows us to use the TAILQ_PREV and TAILQ_FOREACH_REVERSE_* macros,
useful for an out-of-tree consumer.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38055
2023-01-14 21:33:58 -05:00
Sean Eric Fagan
f32db40650 Allow a comma-separated list in login class capabilities,
by adding a version of strcspn that allows quoting.
2023-01-14 10:48:29 -08:00
Brooks Davis
a872c37054 xdr: store chars consistently
Cast char's through unsigned char before storing as an integer in
xdr_char(), this ensures that the encoded form is consistently not
sign-extended following Open Solaris's example.

Prior to this change, platforms with signed chars would sign extend
values with the high bit set but ones with unsigned chars would not
so 0xff would be stored as 0x000000ff on unsigned char platforms and
0xffffffff on signed char platforms.  Decoding has the same
result for either form so this is a largely cosmetic change, but it
seems best to produce consistent output.

For more discussion, see https://github.com/openzfs/zfs/issues/14173

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D37992
2023-01-12 18:16:17 +00:00
Gordon Bergling
29b36af998 libiscsiutil: Fix a typo in a source code comment
- s/sesion/session/

MFC after:	3 days
2023-01-11 11:52:55 +01:00
Gordon Bergling
085a77a677 libthr(3): Fix a typo in a source code comment
- s/extentions/extensions/

MFC after:	3 days
2023-01-11 11:48:14 +01:00
Dag-Erling Smørgrav
394cf6719a tzcode: Move configuration into separate header.
MFC after:	1 week
Sponsored by:	Klara, Inc.
2023-01-11 11:39:12 +01:00
Alan Somers
db1cdf2fab libcasper.3: document cap_init's single-threaded program requirement
Because it internally forks.

[skip ci]
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by	emaste, imp
Differential Revision: https://reviews.freebsd.org/D38020
2023-01-10 20:53:30 -07:00
Dag-Erling Smørgrav
bc42155199 Bring our tzcode up to date.
* Replay 2010[acflm] which had been merged but not recorded.
* Merge 2010n.
* Reorganize (unsplit) the code to match the upstream layout.
* Merge 2022[cdefg].

MFC after:      1 week
Sponsored by:   Klara, Inc.
2023-01-10 16:14:27 +01:00
Gleb Popov
016e46fd86 libc: Fix build with WITHOUT_MACHDEP_OPTIMIZATIONS=YES set.
Test Plan: `make buildword WITHOUT_MACHDEP_OPTIMIZATIONS=YES` on 14-CURRENT and 13-STABLE

Reviewed by: emaste

Differential Revision: https://reviews.freebsd.org/D38017

PR:		266900
2023-01-10 17:00:41 +03:00
Charles Suh
44a78c05b3
libzpool: fix ddi_strtoull to update nptr
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Charles Suh <charles.suh@gmail.com>
Closes #14360
2023-01-09 12:49:35 -08:00
Ameer Hamza
5091867ee6
zed: add hotplug support for spare vdevs
This commit supports for spare vdev hotplug. The
spare vdev associated with all the pools will be
marked as "Removed" when the drive is physically
detached and will become "Available" when the
drive is reattached. Currently, the spare vdev
status does not change on the drive removal and
the same is the case with reattachment.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #14295
2023-01-09 12:43:03 -08:00
Jessica Clarke
9fb118bebc libc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-V
These architectures fail to handle this special case, and will cause the
corresponding setjmp/_setjmp to return 0 rather than 1. Fix this and add
regression tests (also committed upstream).

PR:		268684
Reviewed by:	arichardson, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29363
2023-01-09 18:34:43 +00:00
Val Packett
0b4531511e copyright: chase my name and email change
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37945
2023-01-06 15:28:42 -05:00
Eugene Grosbein
2ce3ef5503 syslog: fix PID of forking process
Do not cache PID for a process that does not fabricate it,
calls openlog() before forking and does not call exec() thereafter.

PR:		268666
Fixes:		e9ae9fa937
Tested by:	kp
MFC after:	3 days
2023-01-03 15:58:36 +07:00
Eugene Grosbein
6ab555cff6 syslog(3): expand a commentary adding a reference to RFC 3164. 2023-01-01 15:28:42 +07:00
Xin LI
73ed8e77a7 MFV: xz 5.4.0
MFC after:	2 weeks
2022-12-31 20:25:17 -08:00
Konstantin Belousov
a98613f238 ptrace(2): document PT_SC_REMOTE
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:42 +02:00
Konstantin Belousov
0e07241c37 ptrace(2): explain how to select specific thread to operate on
Requested by:	emaste
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37590
2022-12-22 23:11:35 +02:00
Matthew Ahrens
018f26041d
deadlock between spa_errlog_lock and dp_config_rwlock
There is a lock order inversion deadlock between `spa_errlog_lock` and
`dp_config_rwlock`:

A thread in `spa_delete_dataset_errlog()` is running from a sync task.
It is holding the `dp_config_rwlock` for writer (see
`dsl_sync_task_sync()`), and waiting for the `spa_errlog_lock`.

A thread in `dsl_pool_config_enter()` is holding the `spa_errlog_lock`
(see `spa_get_errlog_size()`) and waiting for the `dp_config_rwlock` (as
reader).

Note that this was introduced by #12812.

This commit address this by defining the lock ordering to be
dp_config_rwlock first, then spa_errlog_lock / spa_errlist_lock.
spa_get_errlog() and spa_get_errlog_size() can acquire the locks in this
order, and then process_error_block() and get_head_and_birth_txg() can
verify that the dp_config_rwlock is already held.

Additionally, a buffer overrun in `spa_get_errlog()` is corrected.  Many
code paths didn't check if `*count` got to zero, instead continuing to
overwrite past the beginning of the userspace buffer at `uaddr`.

Tested by having some errors in the pool (via `zinject -t data
/path/to/file`), one thread running `zpool iostat 0.001`, and another
thread runs `zfs destroy` (in a loop, although it hits the first time).
This reproduces the problem easily without the fix, and works with the
fix.

Reviewed-by: Mark Maybee <mark.maybee@delphix.com>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #14239
Closes #14289
2022-12-22 11:48:49 -08:00
Jose Luis Duran
77e4249319 xlocale(3): Link man pages
- provide various missing MLINKS for library functions
- update various SEE ALSO section to include the
  new linked manual pages
- add various definitions of new functions like isideogram_l(3)
- document COMPATIBILITY for some functions
- bump man page dates

Reviewed by:	gbe, bcr
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/621
Differential Revision:	https://reviews.freebsd.org/D37203
2022-12-19 05:54:52 +01:00
John Baldwin
120eff994a ptrace.2: Fix warnings from igor.
Reviewed by:	pauamma, imp
Differential Revision:	https://reviews.freebsd.org/D37689
2022-12-15 11:26:57 -08:00
Ethan Coe-Renner
fb11b1570a Add color output to zfs diff.
This adds support to color zfs diff (in the style of git diff)
conditional on the ZFS_COLOR environment variable.

Signed-off-by: Ethan Coe-Renner <coerenner1@llnl.gov>
2022-12-15 10:14:32 -08:00
Ameer Hamza
9be34ec99e
Allow receiver to override encryption properties in case of replication
Currently, the receiver fails to override the encryption
property for the plain replicated dataset with the error:
"cannot receive incremental stream: encryption property
'encryption' cannot be set for incremental streams.". The
problem is resolved by allowing the receiver to override
the encryption property for plain replicated send.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #14253
Closes #13533
2022-12-13 17:30:46 -08:00
Allan Jude
dc95911d21
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.

This was committed before (9a9e2e343dfa2af28bf7910de77ae73aa006de62),
but was reverted due to a regression when used with an older kernel.

If the kernel does not populate zc->zc_objset_stats, we now fallback
to getting the properties via the slower interface, to avoid problems
with newer userland and older kernels.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Closes #14110
2022-12-13 17:27:54 -08:00
Martin Matuska
bd5e624a86 libarchive: merge from vendor branch
Libarchive 3.6.2

Important bug fixes:
  rar5 reader: fix possible garbled output with bsdtar -O (#1745)
  mtree reader: support reading mtree files with tabs (#1783)
  various small fixes for issues found by CodeQL

MFC after:	2 weeks
PR:		286306 (exp-run)
2022-12-13 20:21:13 +01:00
Piotr Kubaj
85dd853236 Revert "uname: switch machine to HW_MACHINE_ARCH"
Reverting because of issue in Makefile.inc1 during native builds:
make[1]: “.../freebsd/Makefile.inc1" line 163: Unknown target aarch64:aarch64.

Since I only tested this patch with make universe on amd64, this issue wasn't caught.

This reverts commit 83bf6ab568.
2022-12-12 15:42:05 +01:00
Piotr Kubaj
83bf6ab568 uname: switch machine to HW_MACHINE_ARCH
On powerpc64, powerpc64le and riscv64 some software wrongly assumes that
it runs on powerpc or riscv (32-bit).

Differential revision:	https://reviews.freebsd.org/D35962
Approved by:	alfredo, imp
2022-12-11 13:05:39 +01:00
Xin LI
0ca90ed42a MFV: xz 5.2.9
MFC after:	2 weeks
2022-12-08 23:52:06 -08:00
Richard Yao
5f73bbba43 Do not pass -1 to strerror() from zfs_send_cb_impl()
`zfs_send_cb_impl()` calls `dump_filesystems()`, which calls
`dump_filesystem()`, which will return `-1` as an error when
`zfs_open()` returns `NULL`.

This will be passed to `zfs_standard_error()`, which passes it to
`zfs_standard_error_fmt()`, which passes it to `strerror()`.

To fix this, we modify zfs_open() to set `errno` whenever it returns
NULL. Most of the cases already have `errno` set (since they pass it to
`zfs_standard_error_fmt()`, which makes this easy. Then we modify
`dump_filesystem()` to pass `errno` instead of `-1`.

Reported-by: Coverity (CID-1524598)
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14264
2022-12-08 14:15:27 -08:00
Alan Somers
6c93a2d0bc [skip ci] improvements to cap_sysctl.3
* Correct some function prototypes which were documented with the wrong
  pointer type.
* Clarify return values and requirements for freeing the limit handle.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	oshogbo
Differential Revision: https://reviews.freebsd.org/D37586
2022-12-08 12:45:47 -07:00
Gordon Bergling
0393604aa8 getservent.3: Mention the service.db
- reference /var/db/services.db
- reference services_mkdb(8)

Obtained from:	NetBSD
MFC after:	3 days
2022-12-07 10:26:13 +01:00
John Baldwin
42fb28cef4 Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.
GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>.  Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.

Reviewed by:	brooks, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37531
2022-12-04 16:25:21 -08:00
Ed Maste
52f2b03877 libdevdctl: update deprecated deprecation warning comment
The comment indicated -Wno-deprecated-declarations was used to avoid
warnings about deprecated auto_ptr and various deprecated function
objects from <functional>.  libdevdctl (now) does not use auto_ptr,
so don't mention it in the comment.

Sponsored by:	The FreeBSD Foundation
2022-12-04 10:17:37 -05:00
Ed Maste
e92d692345 libpmc: remove unused auto_ptr warning suppression
libpmc used -Wno-deprecated-declarations to silence warnings about usage
of deprecated std::auto_ptr, but there is (now) now use of auto_ptr in
libpmc.

Reviewed by:	mhorne
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37576
2022-12-02 18:52:30 -05:00
Ed Maste
dba226d43d googletest: remove unused auto_ptr warning suppression
lib/googletest used -Wno-deprecated-declarations to silence warnings
about usage of deprecated std::auto_ptr, but auto_ptr is not (now) used
anywhere in googletest.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37561
2022-11-30 19:34:52 -05:00
Alan Somers
34120c0c52 [skip ci] document first appearance of fhlink et al
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D37575
2022-11-30 14:57:56 -07:00
szubersk
3c1e1933b6 Fix GCC 12 compilation errors
Squelch false positives reported by GCC 12 with UBSan.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #14150
2022-11-30 13:45:53 -08:00
Guilherme Janczak
a6d40b0ad2 libc: remove unneeded sys/types.h include from several synopses
PR:	268028
Reviewed by:	kib
Discussed with:	imp
MFC after:	1 week
2022-11-30 00:45:07 +02:00
Brooks Davis
d6df4441c0
Don't leak packed recieved proprties
When local properties (e.g., from -o and -x) are provided, don't leak
the packed representation of the received properties due to variable
reuse.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14197
2022-11-29 09:51:35 -08:00
Minsoo Choo
adf3b84fc7
Add <limits.h> header
According to the UNIX standard, <pthread.h> does not include some
PTHREAD_* values which are included in <limits.h>. OpenZFS uses
some of these values in its code, and this might cause build failure on
systems that do not have these PTHREAD_* values in <pthread.h>

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Closes #14225
2022-11-28 13:24:17 -08:00
Ed Maste
f2865d7d55 pam.d: install hard link with same mode as target
Previously when using NO_ROOT we recorded a METALOG entry for the
pam.d/ftp hard link with a different file mode than the link target
pam.d/ftpd, which is not permitted.

This change is similar to 1dbb9994d4 for .profile

Sponsored by:	The FreeBSD Foundation
2022-11-24 08:14:44 -05:00
John Baldwin
74ad8d607d csu: Add missing GNU-stack annotations to note object files.
ld.bfd marks the stack as executable for the crt objects due to the
missing annotations which raises a fatal warning starting with version
2.39.
2022-11-18 12:22:23 -08:00
Richard Yao
0a0166c975 FreeBSD: do_mount() passes wrong string length to helper
It should pass `MNT_LINE_MAX`, but passes `sizeof (mntpt)`. This is
harmless because the strlen is not actually used by the helper, but
FreeBSD's Coverity scans complained about it.

This was missed in my audit of various string functions since it is not
actually passed to a string function.

Upon review, it was noticed that the helper function does not need to be
a separate function, so I have inlined it as cleanup.

Reported-by: Coverity (CID 1432079)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: szubersk <szuberskidamian@gmail.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14136
2022-11-18 11:34:25 -08:00
Richard Yao
31247c78b1 FreeBSD: get_zfs_ioctl_version() should be cast to (void)
FreeBSD's Coverity scans complain that we ignore the return value. There
is no need to check the return value so we cast it to (void) to suppress
further complaints by static analyzers.

Reported-by: Coverity (CID 1018175)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: szubersk <szuberskidamian@gmail.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14136
2022-11-18 11:33:12 -08:00
szubersk
28ea4f9b08 Ubuntu 22.04 integration: Cppcheck
Suppress a false positive found by new Cppcheck version.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #14148
2022-11-18 11:26:50 -08:00
John Baldwin
d3956e4673 vmm: Use struct vcpu in the instruction emulation code.
This passes struct vcpu down in place of struct vm and and integer
vcpu index through the in-kernel instruction emulation code.  To
minimize userland disruption, helper macros are used for the vCPU
arguments passed into and through the shared instruction emulation
code.

A few other APIs used by the instruction emulation code have also been
updated to accept struct vcpu in the kernel including
vm_get/set_register and vm_inject_fault.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37161
2022-11-18 10:25:37 -08:00
John Baldwin
2b4fe856f4 bhyve: Remove unused vm and vcpu arguments from vm_copy routines.
The arguments identifying the VM and vCPU are only needed for
vm_copy_setup.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D37158
2022-11-18 10:25:36 -08:00
Konstantin Belousov
ae507c25de amd64 libc: add missed GNU-stack annotation to memmove/memcpy
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2022-11-18 15:31:38 +02:00
Xin LI
dc58b3fca5 MFV: expat 2.5.0
MFC after:	2 weeks
2022-11-17 22:15:00 -08:00
Xin LI
9fc8132eca Vendor import of expat 2.5.0 2022-11-17 22:08:44 -08:00
Dag-Erling Smørgrav
f1ad5e3931 libarchive: Add missing MLINK.
Differential Revision: https://reviews.freebsd.org/D37398
2022-11-17 17:12:24 +01:00
Xin LI
9e6bbe47a5 MFV: Merge xz 5.2.8
Relnotes:	yes
MFC after:      2 weeks
2022-11-16 20:37:07 -08:00
John Baldwin
57fbafb8de libfetch: Pass a zeroed digest to DigestCalcResponse.
GCC 12 warns that passing "" (a constant of char[1]) to a parameter of
type char[33] could potentially overread.  It is not clear from the
context that c->qops can never be "auth-int" (and if it can't, then
the "auth-int" handling in DigestCalcResponse is dead code that should
be removed since this is the only place the function is called).

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D36825
2022-11-15 19:18:58 -08:00
Rick Macklem
032b04626b rpcb_clnt.c: Do not force use of UDP
Without this patch, the code in the rpcbind client forces
the use of UDP.  A comment notes that some rpcbind servers
only support UDP.  This makes NFSv3 mounts to Azure servers
impossible, since they require use of TCP for rpcbind.
Since the comment is very old (imported from NetBSD in 2001)
and I do not believe any UDP only rpcbind servers will
still exist, this patch comments out the code that forces
use of UDP, so that NFSv3 mounts to Azure servers can work.

For an NFSv3 mount, the "udp" mount option will still
make mount_nfs use UDP for rpcbind so that can be used
as a workaround for any old NFSv3 server that only
supports rpcbind over UDP (if any such server still exists).

I asked if doing this change is appropriate on freebsd-fs@
and I only got one reply (off list) that supported doing
the change.

PR:	267301
MFC after:	1 month
2022-11-13 12:16:06 -08:00
Kirk McKusick
5c7ba6bdf8 Fix for tunefs(8) unable to add a UFS/FFS soft update journal.
The reported bug is UFS: bad file descriptor: soft update journaling
can not be enabled on some FreeBSD-provided disk images – failed
to write updated cg.

The UFS library (libufs(3)) failed to reopen its disk descriptor
when first attempting to update a cylinder group. The error only
occurred when trying to add journaling to a filesystem whose first
cylinder group was too full to hold the journal.

PR:           259090
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2022-11-12 15:37:27 -08:00
Elyes HAOUAS
cb25444c05 lib/libsecureboot: Fix some typos
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/544
2022-11-11 10:38:39 -05:00
Mariusz Zaborski
16f0fdaddd
Allow to control failfast
Linux defaults to setting "failfast" on BIOs, so that the OS will not
retry IOs that fail, and instead report the error to ZFS.

In some cases, such as errors reported by the HBA driver, not
the device itself, we would wish to retry rather than generating
vdev errors in ZFS. This new property allows that.

This introduces a per vdev option to disable the failfast option.
This also introduces a global module parameter to define the failfast
mask value.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Mariusz Zaborski <mariusz.zaborski@klarasystems.com>
Sponsored-by: Seagate Technology LLC
Submitted-by: Klara, Inc.
Closes #14056
2022-11-10 13:37:12 -08:00
Dag-Erling Smørgrav
817f1f3064 libc: Don't warn about RRSIG replies.
PR:		213178
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D37303
2022-11-09 17:41:47 +01:00
Brooks Davis
ecbf02791f freebsd: simplify MD isa_defs.h
Most of this file was a pile of defines, apparently from Solaris that
controlled nothing in the source tree.  A few things controlled the
definition of unused types or macros which I have removed.

Considerable further cleanup is possible including removal of
architectures FreeBSD never supported.  This file should likely converge
with the Linux version to the extent possible.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14127
2022-11-07 15:55:37 -08:00
Brooks Davis
20b867f5f7 freebsd: add ifdefs around legacy ioctl support
Require that ZFS_LEGACY_SUPPORT be defined for legacy ioctl support to
be built.  For now, define it in zfs_ioctl_compat.h so support is always
built.  This will allow systems that need never support pre-openzfs
tools a mechanism to remove support at build time.  This code should
be removed once the need for tool compatability is gone.

No functional change at this time.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14127
2022-11-07 15:55:26 -08:00
Brooks Davis
abb42dc5e1 Make 1-bit bitfields unsigned
This fixes -Wsingle-bit-bitfield-constant-conversion warning from
clang-16 like:

lib/libzfs/libzfs_dataset.c:4529:19: error: implicit truncation
  from 'int' to a one-bit wide bit-field changes value from
  1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                flags.nounmount = B_TRUE;
				^ ~~~~~~

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14125
2022-11-03 10:16:16 -07:00
Brooks Davis
27d29946be
libuutil: deobfuscate internal pointers
uu_avl and uu_list stored internal next/prev pointers and parent
pointers (unused) obfuscated (byte swapped) to hide them from a long
forgotten leak checker (No one at the 2022 OpenZFS developers meeting
could recall the history.)  This would break on CHERI systems and adds
no obvious value.  Rename the members, use proper types rather than
uintptr_t, and eliminate the related macros.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14126
2022-11-03 09:57:05 -07:00
Brooks Davis
877790001e recvd_props_mode: use a uintptr_t to stash nvlists
Avoid assuming than a uint64_t can hold a pointer.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14131
2022-11-03 09:52:19 -07:00
Brooks Davis
250b2bac78 zfs_onexit_add_cb: make action_handle point to a uintptr_t
Avoid assuming than a uint64_t can hold a pointer and reduce the
number of casts in the process.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14131
2022-11-03 09:52:12 -07:00
Brooks Davis
5229071ba1 Improve RISC-V support
Check __riscv_xlen == 64 rather than _LP64 and define _LP64 if missing.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by:	Brooks Davis <brooks.davis@sri.com>
Closes #14128
2022-11-03 09:39:28 -07:00
Mark Johnston
d0f8e31761 getsockopt.2: Clarify the SO_REUSEPORT_LB text a bit
Refer to sockets rather than processes, since one can have multiple
sockets in a load-balancing group within the same process.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
2022-11-02 13:46:24 -04:00
Mark Johnston
34c8598eb1 libsysdecode: Match socket option names containing underscores
MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
2022-11-02 13:46:24 -04:00
John Baldwin
c9c9057c77 ktrace.2: Document KTRFAC_STRUCT_ARRAY.
Sponsored by:	DARPA
2022-11-02 10:35:26 -07:00
Mike Karels
631b82aca0 fetch: support EAI_ADDRFAMILY error, correct two error messages
With the change to return EAI_ADDRFAMILY from getaddrinfo(), fetch
would print "Unknown resolver error" for that error.  Add that error
and its string to libfetch's table, using an #ifdef just in case.
Correct error strings for EAI_NODATA (although it is currently unused)
and EAI_NONAME.  Should maybe rework the code to use gai_strerror(3),
but that doesn't map directly, and the current strings are shortened.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz
MFC after:      1 month
2022-11-02 11:03:31 -05:00
Mike Karels
1443613866 getaddrinfo: distinguish missing addrs from unresolvable names
Rework getaddrinfo(3) to return different error values for unresolvable
names (same as before, EAI_NONAME) and those without a requested addr
(EAI_ADDRFAMILY) when using DNS.  This is implemented via an added
error in the nsswitch layer, NS_ADDRFAMILY, which is used only by
getaddrinfo().  The error is passed through nsdispatch(3), but that
routine has no changes to handle this error.  The error originates in
the getaddrinfo DNS layer called via nsdispatch(), and is processed
by the search layer that calls nsdispatch().

While here, add a little style to returns near those that were
modified.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz
MFC after:      1 month
2022-11-02 11:03:31 -05:00
Mike Karels
e34adc71d3 gai_strerror.[c3]: re-enable EAI_ADDRFAMILY, EAI_NODATA
gai_strerror.c still has messages for EAI_ADDRFAMILY and EAI_NODATA,
but not the man page.  Re-add to the man page, and update comments
in the source.  Document the errors that are not in RFC 3493 or
POSIX.

Reviewed in https://reviews.freebsd.org/D37139 with related changes.

Reviewed by:    bz, pauamma
MFC after:      1 month
2022-11-02 11:03:31 -05:00
Kristof Provost
8a8af94240 pf: bridge-to
Allow pf (l2) to be used to redirect ethernet packets to a different
interface.

The intended use case is to send 802.1x challenges out to a side
interface, to enable AT&T links to function with pfSense as a gateway,
rather than the AT&T provided hardware.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37193
2022-11-02 15:45:23 +01:00
Kristof Provost
9f8f3a8e9a ipsec: add support for CHACHA20POLY1305
Based on a patch by ae@.

Reviewed by:	gbe (man page), pauamma (man page)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37180
2022-11-02 14:19:04 +01:00
Richard Yao
da3d266672
FreeBSD: Fix regression from kmem_scnprintf() in libzfs
kmem_scnprintf() is only available in libzpool. Recent buildbot issues
with showing FreeBSD results kept us from seeing this before
97143b9d31 was merged.

The code has been changed to sanitize the output from `kmem_scnprintf()`.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14111
2022-11-01 13:58:17 -07:00
Doug Rabson
c7631f9153 libc_nonshared: Move to clibs package
Its needed by libc.a which lives in clibs.

PR:	254173
2022-11-01 10:17:07 +00:00
Kristof Provost
444a77ca85 pf: expose syncookie active/inactive status
When syncookies are in adaptive mode they may be active or inactive.
Expose this status to users.

Suggested by:	Guido van Rooij
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-31 18:14:09 +01:00
Richard Yao
dcce0dc5f0
Fix oversights from 4170ae4e
4170ae4ea6 was intended to tackle TOCTOU
race conditions reported by CodeQL, but as an oversight, a file
descriptor was not closed and some comments were not updated.
Interestingly, CodeQL did not complain about the file descriptor leak,
so there is room for improvement in how we configure it to try to detect
this issue so that we get early warning about this.

In addition, an optimization opportunity was missed by mistake in
lib/libshare/os/linux/smb.c, which prevented us from truly closing the
TOCTOU race. This was also caught by Coverity.

Reported-by: Coverity (CID 1524424)
Reported-by: Coverity (CID 1526804)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14109
2022-10-31 10:01:04 -07:00
Jose Luis Duran
f0a15aafcb strfmon: Remove XXX marks
phantom@'s HDD crashed with the final version of strfmon.c, as explained
in 9d430a5991.

Now there are tests in place that cover these code paths.

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:09:32 +03:00
Jose Luis Duran
621bf91893 strfmon_l: Use specified locale for number formatting
strfmon_l does not take fully into consideration the explicitly passed
locale to perform the formatting.

Parallel universe bug report:	https://sourceware.org/bugzilla/show_bug.cgi?id=19633

Obtained from:	Darwin
Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:09:11 +03:00
Jose Luis Duran
29972f06f9 strfmon_test: Add a test for strfmon_l
Attempt to test the correctness of strfmon_l(3).

Items marked with XXX represent an invalid output.

Obtained from:	e7eba0044f

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:54 +03:00
Jose Luis Duran
edcee003e5 strfmon_test: Reserve space for the null terminator
Otherwise strfmon(3) could overflow the buffer.

Here is mostly done for correctness and illustrative purposes, as there
is no chance it could actually happen.

Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:33 +03:00
Jose Luis Duran
d96088b3ab strfmon_l(3): Add name to the man page
Reviewed by:	kib
PR:	267410
Github PR:	#620
MFC after:	1 week
2022-10-30 00:08:19 +03:00
Richard Yao
97143b9d31 Introduce kmem_scnprintf()
`snprintf()` is meant to protect against buffer overflows, but operating
on the buffer using its return value, possibly by calling it again, can
cause a buffer overflow, because it will return how many characters it
would have written if it had enough space even when it did not. In a
number of places, we repeatedly call snprintf() by successively
incrementing a buffer offset and decrementing a buffer length, by its
return value. This is a potentially unsafe usage of `snprintf()`
whenever the buffer length is reached. CodeQL complained about this.

To fix this, we introduce `kmem_scnprintf()`, which will return 0 when
the buffer is zero or the number of written characters, minus 1 to
exclude the NULL character, when the buffer was too small. In all other
cases, it behaves like snprintf(). The name is inspired by the Linux and
XNU kernels' `scnprintf()`. The implementation was written before I
thought to look at `scnprintf()` and had a good name for it, but it
turned out to have identical semantics to the Linux kernel version.
That lead to the name, `kmem_scnprintf()`.

CodeQL only catches this issue in loops, so repeated use of snprintf()
outside of a loop was not caught. As a result, a thorough audit of the
codebase was done to examine all instances of `snprintf()` usage for
potential problems and a few were caught. Fixes for them are included in
this patch.

Unfortunately, ZED is one of the places where `snprintf()` is
potentially used incorrectly. Since using `kmem_scnprintf()` in it would
require changing how it is linked, we modify its usage to make it safe,
no matter what buffer length is used. In addition, there was a bug in
the use of the return value where the NULL format character was not
being written by pwrite(). That has been fixed.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14098
2022-10-29 13:05:11 -07:00
Richard Yao
4170ae4ea6 Fix TOCTOU race conditions reported by CodeQL and Coverity
CodeQL and Coverity both complained about:

 * lib/libshare/os/linux/smb.c
 * tests/zfs-tests/cmd/mmapwrite.c
 	* twice
 * tests/zfs-tests/tests/functional/tmpfile/tmpfile_002_pos.c
 * tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c
	* coverity had a second complaint that CodeQL did not have
 * tests/zfs-tests/cmd/suid_write_to_file.c
	* Coverity had two complaints and CodeQL had one complaint, both
	  differed. The CodeQL complaint is about the main point of the
	  test, so it is not fixable without a hack involving `fork()`.

The issues reported by CodeQL are fixed, with the exception of the last
one, which is deemed to be a false positive that is too much trouble to
wrokaround. The issues reported by Coverity were only fixed if CodeQL
complained about them.

There were issues reported by Coverity in a number of other files that
were not reported by CodeQL, but fixing the CodeQL complaints is
considered a priority since we want to integrate it into a github
workflow, so the remaining Coverity complaints are left for future work.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14098
2022-10-29 13:04:10 -07:00
Andrew Innes
e09fdda977
Fix multiplication converted to larger type
This fixes the instances of the "Multiplication result converted to 
larger type" alert that codeQL scanning found.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Andrew Innes <andrew.c12@gmail.com>
Closes #14094
2022-10-28 09:30:37 -07:00
Andrew Innes
07de86923b
Aligned free for aligned alloc
Windows port frees memory that was alloc'd aligned in a different way
then alloc'd memory.  So changing frees to be specific.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Andrew Innes <andrew.c12@gmail.com>
Co-Authored-By: Jorgen Lundman <lundman@lundman.net>
Closes #14059
2022-10-26 15:08:31 -07:00
Emmanuel Vadot
e7a5a60ed5 pkgbase: Put devmatch in its own package
devmatch is useful on standalone machine but not on jails.
Put devinfo(8) and libdevinfo there too.

Differential Revision:	https://reviews.freebsd.org/D36229
2022-10-26 19:46:38 +02:00
Emmanuel Vadot
a7ffc94849 pkgbase: Put ufs related tools and lib in their own package
It's not really useful in a jail or in a mdroot or even if a users
wants to do a full zfs machine.

Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D36227
2022-10-26 19:46:34 +02:00
Emmanuel Vadot
a099694ecd pkgbase: Put libwrap in FreeBSD-tcpd package
It belongs there with the tcp wrapper utilities

Differential Revision:	https://reviews.freebsd.org/D36226
2022-10-26 19:46:32 +02:00
Emmanuel Vadot
a71ea7bea0 pkgbase: Put zfs utilities and lib in their own package
It is useful to have zfs utilities and lib in a separate package as
it allow users to create image that can support ZFS (i.e. not with
WITHOUT_ZFS in src.conf set) without bloating the default image with
all zfs tools (for example for jails).

Differential Revision:	https://reviews.freebsd.org/D36225
2022-10-26 19:46:30 +02:00
Emmanuel Vadot
0bf688786f pkgbase: Put geom utilities in their own package
For most users it's not needed to boot and they are also
available in the FreeBSD-rescue package in case an update
break and FreeBSD-geom package isn't updated correctly.

Differential Revision:	https://reviews.freebsd.org/D36224
2022-10-26 19:46:28 +02:00
Jose Luis Duran
7cfd67ce96 strfmon(3): Fix # explanation
There's only one value that specifies the number of digits after the
decimal point (oh, sorry, the "radix character") the other specifies the
number before...

While here, add a little more info on the effects of using the #n value.

Obtained from:	d1dd1a0864
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:48:20 +03:00
Jose Luis Duran
0efec50e9e strfmon(3): Remove repeated words
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
34f88528ed strfmon: Fix formatting of a second fixed-width value
There is a bug when formatting two consecutive values using fixed-widths
and the values need padding.  This was because the value of pad_size
was zeroed only every other time.

Format           Before                         After
[%8n] [%8n]      [ $123.45] [       $123.45]    [ $123.45] [ $123.45]

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
750fe3e6a4 strfmon: Fix an edge case when sep_by_space is 2
Fix an edge case by printing the required space when, the currency
symbol succeeds the value, a space separates the sign from the value and
the sign position precedes the quantity and the currency symbol.

In other words:

    n_cs_precedes = 0
    n_sep_by_space = 2
    n_sign_posn = 1

From The Open Group's localeconv[1]:

> When {p,n,int_p,int_n}_sep_by_space is 2:
> If the currency symbol and sign string are adjacent, a space separates
> them; otherwise, a space separates the sign string from the value.

    Format    Before        After
    [%n]      [-123.45¤]    [- 123.45¤]

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html

Obtained from:	Darwin
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
947efadc3d strfmon: Fix alignment when enclosed by parentheses
Take into consideration the possibility of quantities enclosed by
parentheses when aligning.

Matches the examples from The Open Group's:

Format  Before          After
%(#5n   [$   123.45]    [ $   123.45 ]  Use an alternative pos/neg style
        [($   123.45)]  [($   123.45)]
        [$ 3,456.78]    [ $ 3,456.78 ]

%!(#5n  [   123.45]     [    123.45 ]   Disable the currency symbol
        [(   123.45)]   [(   123.45)]
        [ 3,456.78]     [  3,456.78 ]

https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

SD5-XSH-ERN-29 is applied, updating the examples for %(#5n and %!(#5n.

Obtained from:	Darwin
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
6da51e19e3 strfmon: Trim the SPACE from international currency symbol
The international currency symbol (int_curr_symbol) has a mandatory
SPACE character as the last character.

Trim this space after reading it, otherwise this extra space will always
be printed when displaying the int_curr_symbol.

Fixes the output when the international currency format is selected
(%i).

    Locale         Format    Before           After
    en_US.UTF-8    [%i]      [USD 123.45]     [USD123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR ]    [123,45 EUR]

Note that the en_US.UTF-8 locale states that no space should be printed
between the currency symbol and the value (sep_by_space = 0).

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
9e03b903e3 strfmon: Avoid an out-of-bounds access
Avoid an out-of-bounds access when trying to set the space_char using an
international currency format (%i) and the C/POSIX locale.

The current code tries to read the SPACE from int_curr_symbol[3]:

    currency_symbol = strdup(lc->int_curr_symbol);
    space_char = *(currency_symbol+3);

But on C/POSIX locales, int_curr_symbol is empty.

Three implementations have been examined: NetBSD[1], Darwin[2], and
Illumos[3].  Only NetBSD has fixed it[4].

Darwin and NetBSD also trim the mandatory final SPACE character after
reading it.

    Locale         Format    Darwin/NetBSD    FreeBSD/Illumos
    en_US.UTF-8    [%i]      [USD123.45]      [USD 123.45]
    fr_FR.UTF-8    [%i]      [123,45 EUR]     [123,45 EUR ]

This commit only fixes the out-of-bounds access.

[1]: https://github.com/NetBSD/src/blob/trunk/lib/libc/stdlib/strfmon.c
[2]: https://opensource.apple.com/source/Libc/Libc-1439.141.1/stdlib/NetBSD/strfmon.c.auto.html
[3]: https://github.com/illumos/illumos-gate/blob/master/usr/src/lib/libc/port/locale/strfmon.c
[4]: 3d7b5d498a

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:17 +03:00
Jose Luis Duran
0afd11d50f strfmon: Fix typos in source code comments
s/defult/default
s/internaltion/international

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran
d5980dff6b strfmon: Fix typo in constant
s/SUPRESS_CURR_SYMBOL/SUPPRESS_CURR_SYMBOL

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran
f81dfea291 strfmon: Code cleanup
No functional change intended.
Not claiming full style(9) compliance.

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:40:16 +03:00
Jose Luis Duran
3f97d37ac5 strfmon_test: Add some tests
Attempt to test the correctness of strfmon(3).

Some of them were inspired from the examples section at:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html

Items marked with XXX represent an invalid output.

Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:29:26 +03:00
Jose Luis Duran
f91301cc79 strfmon_test: Fix typo and remove extra space
Reviewed by:	kib
PR:	267282
Github PR:	#619
MFC after:	1 week
2022-10-26 00:28:33 +03:00
Warner Losh
aec9453fec times: Use modern function definitions
Use the modern ANSI function defition syntax rather than the old K&R
syntax for times.

Sponsored by:		Netflix
2022-10-25 10:57:29 -06:00
Mark Johnston
3e9b4532d1 libvmmapi: Provide an interface for limiting rights on the device fd
Currently libvmmapi provides a way to get a list of the allowed ioctls
on the vmm device file, so that bhyve can limit rights on the device
file fd.  The interface is rather strange: it allocates a copy of the
list but returns a const pointer, so the caller has to cast away the
const in order to free it without aggravating the compiler.

As far as I can see, there's no reason to make a copy of the array, but
changing vm_get_ioctls() to not do that would break compatibility.  So
this change just introduces a better interface: move all rights-limiting
logic into libvmmapi.

Any new operations on the fd should be wrapped by libvmmapi, so also
discourage use of vm_get_device_fd().  Currently bhyve uses it only when
limiting rights on the device fd.

No functional change intended.

Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37098
2022-10-24 17:33:13 -04:00
Richard Yao
72a366f018
Linux: Fix big endian and partial read bugs in get_system_hostid()
Coverity made two complaints about this function. The first is that we
ignore the number of bytes read. The second is that we have a sizeof
mismatch.

On 64-bit systems, long is a 64-bit type. Paradoxically, the standard
says that hostid is 32-bit, yet is also a long type. On 64-bit big
endian systems, reading into the long would cause us to return 0 as our
hostid after the mask. This is wrong.

Also, if a partial read were to happen (it should not), we would return
a partial hostid, which is also wrong.

We introduce a uint32_t system_hostid stack variable and ensure that the
read is done into it and check the read's return value. Then we set the
value based on whether the read was successful. This should fix both of
coverity's complaints.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13968
2022-10-20 14:52:35 -07:00
Richard Yao
4ecd96371b Fix theoretical use of uninitialized values
Clang's static analyzer complains about this.

In get_configs(), if we have an invalid configuration that has no top
level vdevs, we can read a couple of uninitialized variables. Aborting
upon seeing this would break the userland tools for healthy pools, so we
instead initialize the two variables to 0 to allow the userland tools to
continue functioning for the pools with valid configurations.

In zfs_do_wait(), if no wait activities are enabled, we read an
uninitialized error variable.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14043
2022-10-19 17:10:21 -07:00
Richard Yao
d953bcbf6b Cleanup: Delete unnecessary pointer check from vdev_to_nvlist_iter()
This confused Clang's static analyzer, making it think there was a
possible NULL pointer dereference. There is no NULL pointer dereference.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14042
2022-10-18 15:39:32 -07:00
Richard Yao
c6b161e390 set_global_var() should not pass NULL pointers to dlclose()
Both Coverity and Clang's static analyzer caught this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14044
2022-10-18 15:35:13 -07:00
Mark Johnston
a4ee0edc4a libc: Make elf_aux_info() return an error if AT_USRSTACK* is undefined
Otherwise we do not fall back to sysctls if the auxv entries are not
defined by the kernel.  Arguably this is not a bug since we do not
support newer libc running on an older kernel, but we can be a bit more
gentle for the benefit of Valgrind or any other software which
synthesizes the auxv for virtualization purposes.

Reported by:	Paul Floyd <paulf2718@gmail.com>
MFC after:	1 week
Reviewed by:	brooks, kib
Differential Revision:	https://reviews.freebsd.org/D37036
2022-10-18 18:11:26 -04:00
Ed Maste
101ba46bb6 libproc: retire now-unused MIPS support
Discussed with:	imp
2022-10-17 14:17:25 -04:00
Mitchell Horne
4a9b1a1463 getpagesize(3): cross-reference getpagesizes(3)
MFC after:	3 days
2022-10-17 15:16:12 -03:00
Cy Schubert
865f46b255 unbound: Reapply Vendor import 1.17.0
Reapply 643f9a0581. 64d318ea98 was a
mismerge during fake rebase. Let's reapply it.

Changes include: Added ACL per interface, proxy protocol and bug fixes.

Announcement:   https://nlnetlabs.nl/news/2022/Oct/13/unbound-1.17.0-released/

Merge commit '643f9a0581e8aac7eb790ced1164748939829826' into main
2022-10-16 14:08:33 -07:00
Cy Schubert
8cee2ebac5 Revert "unbound: Vendor import 1.17.0"
This reverts commit 64d318ea98, reversing
changes made to 8063dc0320.

Revert a mismerge which reversed 8063dc0320.
2022-10-16 13:42:15 -07:00
Cy Schubert
64d318ea98 unbound: Vendor import 1.17.0
Added ACL per interface, proxy protocol and bug fixes.

Announcement:   https://nlnetlabs.nl/news/2022/Oct/13/unbound-1.17.0-released/

Merge commit '643f9a0581e8aac7eb790ced1164748939829826' into new_merge
2022-10-16 13:32:55 -07:00
Ashish SHUKLA
e6901a29bc
kvm_close(3): Check kd->sparse_map != NULL before munmap
PR:		266113
Reviewed by:	markj
2022-10-16 16:49:16 +00:00
Richard Yao
6a42939fcd
Cleanup: Address Clang's static analyzer's unused code complaints
These were categorized as the following:

 * Dead assignment		23
 * Dead increment		4
 * Dead initialization		6
 * Dead nested assignment	18

Most of these are harmless, but since actual issues can hide among them,
we correct them.

That said, there were a few return values that were being ignored that
appeared to merit some correction:

 * `destroy_callback()` in `cmd/zfs/zfs_main.c` ignored the error from
   `destroy_batched()`. We handle it by returning -1 if there is an
   error.

 * `zfs_do_upgrade()` in `cmd/zfs/zfs_main.c` ignored the error from
   `zfs_for_each()`. We handle it by doing a binary OR of the error
   value from the subsequent `zfs_for_each()` call to the existing
   value. This is how errors are mostly handled inside `zfs_for_each()`.
   The error value here is passed to exit from the zfs command, so doing
   a binary or on it is better than what we did previously.

 * `get_zap_prop()` in `module/zfs/zcp_get.c` ignored the error from
   `dsl_prop_get_ds()` when the property is not of type string. We
   return an error when it does. There is a small concern that the
   `zfs_get_temporary_prop()` call would handle things, but in the case
   that it does not, we would be pushing an uninitialized numval onto
   the lua stack. It is expected that `dsl_prop_get_ds()` will succeed
   anytime that `zfs_get_temporary_prop()` does, so that not giving it a
   chance to fix things is not a problem.

 * `draid_merge_impl()` in `tests/zfs-tests/cmd/draid.c` used
   `nvlist_add_nvlist()` twice in ways in which errors are expected to
   be impossible, so we switch to `fnvlist_add_nvlist()`.

A few notable ones did not merit use of the return value, so we
suppressed it with `(void)`:

 * `write_free_diffs()` in `lib/libzfs/libzfs_diff.c` ignored the error
   value from `describe_free()`. A look through the commit history
   revealed that this was intentional.

 * `arc_evict_hdr()` in `module/zfs/arc.c` did not need to use the
   returned handle from `arc_hdr_realloc()` because it is already
   referenced in lists.

 * `spa_vdev_detach()` in `module/zfs/spa.c` has a comment explicitly
   saying not to use the error from `vdev_label_init()` because whatever
   causes the error could be the reason why a detach is being done.

Unfortunately, I am not presently able to analyze the kernel modules
with Clang's static analyzer, so I could have missed some cases of this.
In cases where reports were present in code that is duplicated between
Linux and FreeBSD, I made a conscious effort to fix the FreeBSD version
too.

After this commit is merged, regressions like dee8934 should become
extremely obvious with Clang's static analyzer since a regression would
appear in the results as the only instance of unused code. That assumes
that Coverity does not catch the issue first.

My local branch with fixes from all of my outstanding non-draft pull
requests shows 118 reports from Clang's static anlayzer after this
patch. That is down by 51 from 169.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Cedric Berger <cedric@precidata.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13986
2022-10-14 13:37:54 -07:00
Richard Yao
19516b69ee
Fix potential NULL pointer dereference in lzc_ioctl()
Users are allowed to pass NULL to resultp, but we unconditionally assume
that they never do. When an external user does pass NULL to resultp, we
dereference a NULL pointer.

Clang's static analyzer complained about this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14008
2022-10-14 13:33:22 -07:00
Kyle Evans
ed7910fbac Revert "Avoid using TARGET_ARCH in llvm.build.mk"
This reverts commit 8534e6be81, and adds
a cautionary note that there are dragons about that should be considered
when changing it.

PR:		267026
Reviewed by:	dim, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D36981
2022-10-13 22:04:47 -05:00
Michael Tuexen
bc0d407676 Revert "listen(): improve POSIX compliance"
This reverts commit 76e6e4d72f.

Several programs in the tree use -1 instead of INT_MAX to use
the maximum value. Thanks to Eugene Grosbein for pointing this
out.
2022-10-12 04:33:00 +02:00
Michael Tuexen
76e6e4d72f listen(): improve POSIX compliance
Ensure that a negative backlog argument is handled as it if was 0.

Reviewed by:		markj@, glebius@
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D31821
2022-10-11 22:46:51 +02:00
Jessica Clarke
91a84eb5ba pmc.sandybridge(3): Fix a few EVENT_ vs Event inconsistencies
Every event other than these four is listed as Event X, Umask Y; fix
these to conform to that style.
2022-10-11 00:50:58 +01:00
Benedict Reuschling
44b0b943b8 Revert "Add extra EINVAL information about wrong block size to read(2)/write(2)"
This reverts commit 1c2be25f60.

kib@ pointed out that it is perfectly fine to write at arbitrary regular
file offsets. For example, in a 4K block size character device, geom
doesn't support writing / reading 515 byte blocks. The description is
perhaps not applicable to all EINVALs returned.
2022-10-08 10:23:51 +00:00
Richard Yao
72c99dc959
Handle possible null pointers from malloc/strdup/strndup()
GCC 12.1.1_p20220625's static analyzer caught these.

Of the two in the btree test, one had previously been caught by Coverity
and Smatch, but GCC flagged it as a false positive. Upon examining how
other test cases handle this, the solution was changed from
`ASSERT3P(node, !=, NULL);` to using `perror()` to be consistent with
the fixes to the other fixes done to the ZTS code.

That approach was also used in ZED since I did not see a better way of
handling this there. Also, upon inspection, additional unchecked
pointers from malloc()/calloc()/strdup() were found in ZED, so those
were handled too.

In other parts of the code, the existing methods to avoid issues from
memory allocators returning NULL were used, such as using
`umem_alloc(size, UMEM_NOFAIL)` or returning `ENOMEM`.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13979
2022-10-06 17:18:40 -07:00
Benedict Reuschling
1c2be25f60 Add extra EINVAL information about wrong block size to read(2)/write(2)
The read system call will return EINVAL if the current file offset is
not a multiple of the block size. This also applies to write(2). Add an
entry for EINVAL about this error to both man pages.

PR:			91149
Event:			Aberdeen Hackathon 2022
Differential Revision:	https://reviews.freebsd.org/D24617
2022-10-07 11:32:37 +00:00
Benedict Reuschling
d63104d253 Add information on how to load gmirror on boot to auto activate mirrors
PR:			234997
Reported by:		Michiel van Baak <michiel@vanbaak.eu>
Event:			Aberdeen Hackathon 2022
Differential Revision:	https://reviews.freebsd.org/D20577
2022-10-05 16:44:31 +00:00
Brooks Davis
c3fb59ed5c libc: Include quad support on long32 ABIs
Rather than not including it on all 64-bit platforms, just include it on
32-bit ones.

Reviewed by:	imp, jhb
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36422
2022-10-05 17:27:44 +01:00
Brooks Davis
77becb9325 Rename MACHINE_ABI and TARGET_ABI
The MACHINE_ABI and TARGET_ABI variables are used to set the middle of
the target triple (e.g., "-unknown-" or "-gnueabihf-"). They are not set
by any tool in the base system and I've only found the latter mentioned
in one review online. As such, rename them to to MACHINE_TRIPLE_ABI and
TARGET_TRIPLE_ABI to clear the way to use MACHINE_ABI as a supplement to
MACHINE_CPU, etc.

Reviewed by:	imp, jhb
Obtained from:	CheriBSD
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36420
2022-10-05 17:27:44 +01:00
Kristof Provost
1d090028d3 pf: use time_to for timestamps
Use time_t rather than uint32_t to represent the timestamps. That means
we have 64 bits rather than 32 on all platforms except i386, avoiding
the Y2K38 issues on most platforms.

Reviewed by:	Zhenlei Huang
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36837
2022-10-05 17:52:27 +02:00
Umer Saleem
383c3eb33d Add membar_sync abi change
It appears membar_sync was not present in libzfs.abi with other
membar_* functions. This commit updates libzfs.abi for membar_sync.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #13969
2022-10-04 09:54:58 -07:00
Umer Saleem
d9ac17a57f Expose libzutil error info in libpc_handle_t
In libzutil, for zpool_search_import and zpool_find_config, we use
libpc_handle_t internally, which does not maintain error code and it is
not exposed in the interface. Due to this, the error information is not
propagated to the caller. Instead, an error message is printed on
stderr.

This commit adds lpc_error field in libpc_handle_t and exposes it in
the interface, which can be used by the users of libzutil to get the
appropriate error information and handle it accordingly.

Users of the API can also control if they want to print the error
message on stderr.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #13969
2022-10-04 09:54:35 -07:00
Ed Maste
9515313b26 libc: Fix size range check in setvbuf
From enh at google.com via openbsd-tech mailing list via pfg@:

The existing test is wrong for LP64, where size_t has twice as many
relevant bits as int, not just one. (Found by inspection by
rprichard.)
2022-10-04 12:03:56 -04:00
Hans Petter Selasky
1024bb2633 qdivrem: Predict division by zero as false.
Division by zero triggers an arithmetic exception and should not be very
common. Predict this.

No functional change intended.

MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-10-04 13:51:06 +02:00
John Baldwin
ab9293239c qsort_b_test: Only build on clang.
GCC doesn't support -fblocks.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D36809
2022-10-03 16:14:39 -07:00
John Baldwin
d30a1689f5 libefivar: Fix a buffer overread.
DevPathToTextUsbWWID allocates a separate copy of the SerialNumber
string to append a null terminator if the original string is not
null terminated.  However, by using AllocateCopyPool, it tries to
copy 'Length + 1' words from the existing string containing 'Length'
characters into the target string.  Split the copy out to only
copy 'Length' characters instead.

Reviewed by:	imp, emaste
Reported by:	GCC 12 -Wstringop-overread
Differential Revision:	https://reviews.freebsd.org/D36826
2022-10-03 16:10:44 -07:00
John Baldwin
611cf39267 libfetch: Use memcpy in place of an odd strncpy.
The length passed to strncpy is the length of the source string, not
the destination buffer.  This triggers a non-fatal warning in GCC 12.
Hoewver, the code is also odd.  It is really just a memcpy of the
string without its nul terminator.  For that use case, memcpy is
clearer.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36824
2022-10-03 16:10:43 -07:00
John Baldwin
8f27c9d14a libiconv VIQR: Fix a use after free.
Use TAILQ_FOREACH_SAFE to walk to list of children mnemonics to free
them instead of TAILQ_FOREACH.

Reviewed by:	emaste
Reported by:	GCC 12 -Wuse-after-free
Differential Revision:	https://reviews.freebsd.org/D36821
2022-10-03 16:10:43 -07:00
John Baldwin
7973f26ad6 libedit: Disable -Wuse-after-free for chartype.c.
GCC 12 thinks ct_visual_string can reuse a pointer after it has been
reallocated, but in this case the warning appears false.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D36820
2022-10-03 16:10:43 -07:00
John Baldwin
996ee96597 libbegemot: Disable -Wuse-after-free.
The _xrealloc() function prints pointer values for internal assertion
failures and in one case does so after it has freed the pointer.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D36819
2022-10-03 16:10:43 -07:00
John Baldwin
c3a3d1fd6c libirdma: Drop clang-specific -ferror-limit.
This could use -fmax-errors on GCC, but tweaking the error limit is
unusual in the tree anyway.  Just remove it.

Reviewed by:	erj, imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36808
2022-10-03 16:10:42 -07:00
Richard Yao
d62bafee9f
Fix memory leak found by GCC static analyzer
GCC 12.1.1_p20220625's -fanalyzer found and reported this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Damian Szuberski <szuberskidamian@gmail.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13975
2022-10-03 13:41:58 -07:00
Hans Petter Selasky
aa87aa5232 libusb(3): Implement libusb_interrupt_event_handler() by exposing existing function.
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-10-02 17:32:59 +02:00
Dag-Erling Smørgrav
0aa2700123 Put OPIE to rest.
Differential Revision: https://reviews.freebsd.org/D36592
2022-10-02 03:37:29 +02:00
Richard Yao
67395be0c2
Fix userland dereference NULL return value bugs
* `zstream_do_token()` does not handle failures from `libzfs_init()`

 * `ztest_global_vars_to_zdb_args()` does not handle failures from
   `calloc()`.

 * `zfs_snapshot_nvl()` will pass an offset to a NULL pointer as a
   source to `strlcpy()` if the provided nvlist is `NULL`.

We handle these by doing what the existing error handling does for other
errors involving these functions.

Coverity complained about these. It had complained about several more,
but one was fixed by 570ca4441e and
another was a false positive. The remaining complaints labelled
"dereferece null return vaue" involve fetching things stored in
in-kernel data structures via `list_head()/list_next()`,
`AVL_PREV()/AVL_NEXT()` and `zfs_btree_find()`. Most of them occur in
void functions that have no error handling. They are much harder to
analyze than the two fixed in this patch, so they are left for a
follow-up patch.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13971
2022-09-30 17:02:57 -07:00
Tino Reichardt
a2d5643f88
Fix double const qualifier declarations
Some header files define structures like this one:

typedef const struct zio_checksum_info {
	/* ... */
	const char	*ci_name;
} zio_abd_checksum_func_t;

So we can use `zio_abd_checksum_func_t` for const declarations now.
It's not needed that we use the `const` qualifier again like this:
`const zio_abd_checksum_func_t *varname;`

This patch solves the double const qualifiers, which were found by
smatch.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #13961
2022-09-30 15:34:39 -07:00
Richard Yao
55d7afa4ad
Reduce false positives from Static Analyzers
Both Clang's Static Analyzer and Synopsys' Coverity would ignore
assertions. Following Clang's advice, we annotate our assertions:

https://clang-analyzer.llvm.org/annotations.html#custom_assertions

This makes both Clang's Static Analyzer and Coverity properly identify
assertions. This change reduced Clang's reported defects from 246 to
180. It also reduced the false positives reported by Coverityi by 10,
while enabling Coverity to find 9 more defects that previously were
false negatives.

A couple examples of this would be CID-1524417 and CID-1524423. After
submitting a build to coverity with the modified assertions, CID-1524417
disappeared while the report for CID-1524423 no longer claimed that the
assertion tripped.

Coincidentally, it turns out that it is possible to more accurately
annotate our headers than the Coverity modelling file permits in the
case of format strings. Since we can do that and this patch annotates
headers whenever `__coverity_panic__()` would have been used in the
model file, we drop all models that use `__coverity_panic__()` from the
model file.

Upon seeing the success in eliminating false positives involving
assertions, it occurred to me that we could also modify our headers to
eliminate coverity's false positives involving byte swaps. We now have
coverity specific byteswap macros, that do nothing, to disable
Coverity's false positives when we do byte swaps. This allowed us to
also drop the byteswap definitions from the model file.

Lastly, a model file update has been done beyond the mentioned
deletions:

 * The definitions of `umem_alloc_aligned()`, `umem_alloc()` andi
   `umem_zalloc()` were originally implemented in a way that was
   intended to inform coverity that when KM_SLEEP has been passed these
   functions, they do not return NULL. A small error in how this was
   done was found, so we correct it.

 * Definitions for umem_cache_alloc() and umem_cache_free() have been
   added.

In practice, no false positives were avoided by making these changes,
but in the interest of correctness from future coverity builds, we make
them anyway.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13902
2022-09-30 15:30:12 -07:00
Ed Schouten
af3c78886f Alter the prototype of qsort_r(3) to match POSIX, which adopted the
glibc-based interface.

Unfortunately, the glibc maintainers, despite knowing the existence
of the FreeBSD qsort_r(3) interface in 2004 and refused to add the
same interface to glibc based on grounds of the lack of standardization
and portability concerns, has decided it was a good idea to introduce
their own qsort_r(3) interface in 2007 as a GNU extension with a
slightly different and incompatible interface.

With the adoption of their interface as POSIX standard, let's switch
to the same prototype, there is no need to remain incompatible.

C++ and C applications written for the historical FreeBSD interface
get source level compatibility when building in C++ mode, or when
building with a C compiler with C11 generics support, provided that
the caller passes a fifth parameter of qsort_r() that exactly matches
the historical FreeBSD comparator function pointer type and does not
redefine the historical qsort_r(3) prototype in their source code.

Symbol versioning is used to keep old binaries working.

MFC:			never
Relnotes:		yes
Reviewed by:		cem, imp, hps, pauamma
Differential revision:	https://reviews.freebsd.org/D17083
2022-09-30 15:26:30 -07:00
Mariusz Zaborski
26573e2c7f cap_netdb: Fix description style
MFC after:	1 week
2022-09-29 19:51:42 +02:00
Mariusz Zaborski
facd6b58d5 libcapser: Add reference to cap_netdb
MFC after:	1 week
2022-09-29 19:51:04 +02:00
John Baldwin
5ceec6c105 pam_unix: Fix mismatch in array bounds for make_salt().
Reviewed by:	imp, emaste
Reported by:	GCC -Warray-parameter
Differential Revision:	https://reviews.freebsd.org/D36759
2022-09-28 14:04:48 -07:00
John Baldwin
5d27845e5a ldns: Disable -Warray-parameter warnings from GCC 12 on sha2.c.
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36758
2022-09-28 14:02:30 -07:00
John Baldwin
a2e41a585b libc rpc: Fix mismatches in prototypes for array bounds.
Various RPC functions used a bare pointer in function prototypes to
describe fixed-length buffer arguments but used a fixed-length array
in the function definition.  The manual page for these functions
describes the parameters as being fixed-length buffers, so update
the prototypes to match the definitions.

Reviewed by:	imp, emaste
Reported by:	GCC -Warray-parameter
Differential Revision:	https://reviews.freebsd.org/D36757
2022-09-28 14:01:36 -07:00
Brooks Davis
0eea46fb1f Remove telnetd
The telnetd codebase is unmaintained and has a number of quality
issues. Telnet has been largely supplanted by ssh. If needed, a port is
available (net/freebsd-telnetd), but a more maintained implementation
should be prefered.

While the telnet client suffers from the same issues, it is deemed
to be of lower risk and is required to connect to legacy devices, so
it remains.

Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D36620
2022-09-28 19:53:49 +01:00
Ameer Hamza
55c12724d3
zed: mark disks as REMOVED when they are removed
ZED does not take any action for disk removal events if there is no
spare VDEV available. Added zpool_vdev_remove_wanted() in libzfs
and vdev_remove_wanted() in vdev.c to remove the VDEV through ZED
on removal event.  This means that if you are running zed and
remove a disk, it will be properly marked as REMOVED.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #13797
2022-09-28 09:48:46 -07:00
Richard Yao
a51288aabb
Fix unsafe string operations
Coverity caught unsafe use of `strcpy()` in `ztest_dmu_objset_own()`,
`nfs_init_tmpfile()` and `dump_snapshot()`. It also caught an unsafe use
of `strlcat()` in `nfs_init_tmpfile()`.

Inspired by this, I did an audit of every single usage of `strcpy()` and
`strcat()` in the code. If I could not prove that the usage was safe, I
changed the code to use either `strlcpy()` or `strlcat()`, depending on
which function was originally used. In some cases, `snprintf()` was used
to replace multiple uses of `strcat` because it was cleaner.

Whenever I changed a function, I preferred to use `sizeof(dst)` when the
compiler is able to provide the string size via that. When it could not
because the string was passed by a caller, I checked the entire call
tree of the function to find out how big the buffer was and hard coded
it. Hardcoding is less than ideal, but it is safe unless someone shrinks
the buffer sizes being passed.

Additionally, Coverity reported three more string related issues:

 * It caught a case where we do an overlapping memory copy in a call to
   `snprintf()`. We fix that via `kmem_strdup()` and `kmem_strfree()`.

 * It caught `sizeof (buf)` being used instead of `buflen` in
   `zdb_nicenum()`'s call to `zfs_nicenum()`, which is passed to
   `snprintf()`. We change that to pass `buflen`.

 * It caught a theoretical unterminated string passed to `strcmp()`.
   This one is likely a false positive, but we have the information
   needed to do this more safely, so we change this to silence the false
   positive not just in coverity, but potentially other static analysis
   tools too. We switch to `strncmp()`.

 * There was a false positive in tests/zfs-tests/cmd/dir_rd_update.c. We
   suppress it by switching to `snprintf()` since other static analysis
   tools might complain about it too. Interestingly, there is a possible
   real bug there too, since it assumes that the passed directory path
   ends with '/'. We add a '/' to fix that potential bug.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13913
2022-09-27 16:47:24 -07:00
Richard Yao
7584fbe846
Cleanup: Switch to strlcpy from strncpy
Coverity found a bug in `zfs_secpolicy_create_clone()` where it is
possible for us to pass an unterminated string when `zfs_get_parent()`
returns an error. Upon inspection, it is clear that using `strlcpy()`
would have avoided this issue.

Looking at the codebase, there are a number of other uses of `strncpy()`
that are unsafe and even when it is used safely, switching to
`strlcpy()` would make the code more readable. Therefore, we switch all
instances where we use `strncpy()` to use `strlcpy()`.

Unfortunately, we do not portably have access to `strlcpy()` in
tests/zfs-tests/cmd/zfs_diff-socket.c because it does not link to
libspl. Modifying the appropriate Makefile.am to try to link to it
resulted in an error from the naming choice used in the file. Trying to
disable the check on the file did not work on FreeBSD because Clang
ignores `#undef` when a definition is provided by `-Dstrncpy(...)=...`.
We workaround that by explictly including the C file from libspl into
the test. This makes things build correctly everywhere.

We add a deprecation warning to `config/Rules.am` and suppress it on the
remaining `strncpy()` usage. `strlcpy()` is not portably avaliable in
tests/zfs-tests/cmd/zfs_diff-socket.c, so we use `snprintf()` there as a
substitute.

This patch does not tackle the related problem of `strcpy()`, which is
even less safe. Thankfully, a quick inspection found that it is used far
more correctly than strncpy() was used. A quick inspection did not find
any problems with `strcpy()` usage outside of zhack, but it should be
said that I only checked around 90% of them.

Lastly, some of the fields in kstat_t varied in size by 1 depending on
whether they were in userspace or in the kernel. The origin of this
discrepancy appears to be 04a479f706 where
it was made for no apparent reason. It conflicts with the comment on
KSTAT_STRLEN, so we shrink the kernel field sizes to match the userspace
field sizes.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13876
2022-09-27 16:35:29 -07:00
Jitendra Patidar
3ed9d6883b
Enforce "-F" flag on resuming recv of full/newfs on existing dataset
When receiving full/newfs on existing dataset, then it should be done
with "-F" flag. Its enforced for initial receive in checks done in
zfs_receive_one function of libzfs. Similarly, on resuming full/newfs
recv on existing dataset, it should be done with "-F" flag.

When dataset doesn't exist, then full/new recv is done on newly created
dataset and it's marked INCONSISTENT. But when receiving on existing
dataset, recv is first done on %recv and its marked INCONSISTENT.
Existing dataset is not marked INCONSISTENT. Resume of full/newfs
receive with dataset not INCONSISTENT indicates that its resuming newfs
on existing dataset. So, enforce "-F" flag in this case.

Also return an error from dmu_recv_resume_begin_check() in zfs kernel,
when its resuming full/newfs recv without force.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #13856
Closes #13857
2022-09-27 16:34:27 -07:00
Tino Reichardt
bf5b42f9c8
Fix double declaration of getauxval() for FreeBSD PPC
The extern declaration is only for Linux, move this line
into the right #ifdef section.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Co-authored-by: Martin Matuska <mm@FreeBSD.org>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #13934
Closes #13936
2022-09-26 10:32:22 -07:00
Xin LI
45ff071ddc scandir(3): Rename alphasort_thunk to scandir_thunk_cmp to
reflect that it is not alphasort-specific.

Reported by:	emaste
Reviewed by:	emaste
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D36708
2022-09-25 19:01:46 -07:00
Alfonso S. Siciliano
84823cc708
contrib/bsddialog: Import version 0.4
Improvements and changes to integrate bsddialog(1) with scripts in BASE.
Overview:

 * New options. --and-widget, --keep-tite, --calendar.
 * Change output format. Menus and --print-maxsize.
 * Redefine sizing. Fixed rows, cols and menurows became at the most.
 * Add DIAGNOSTICS. Error messages for bad arguments and options.
 * Add keys. Space for --menu, fast keys for --msgbox and --yesno.
 * Text. Change default text modification, add --cr-wrap.

See /usr/src/contrib/bsddialog/CHANGELOG '2022-09-24 Version 0.4'
for more detailed information.

Merge commit '9f24fda5a8e7ab8243e71473c7e2dc98b4877e64'
2022-09-25 15:09:16 +02:00
Alfonso S. Siciliano
9f24fda5a8
contrib/bsddialog: Import version 0.4
Improvements and changes to integrate bsddialog(1) with scripts in BASE.
Overview:

 * New options. --and-widget, --keep-tite, --calendar.
 * Change output format. Menus and --print-maxsize.
 * Redefine sizing. Fixed rows, cols and menurows became at the most.
 * Add DIAGNOSTICS. Error messages for bad arguments and options.
 * Add keys. Space for --menu, fast keys for --msgbox and --yesno.
 * Text. Change default text modification, add --cr-wrap.

See /usr/src/contrib/bsddialog/CHANGELOG '2022-09-24 Version 0.4'
for more detailed information.
2022-09-25 15:04:33 +02:00
Xin LI
a2dfb7224e file: upgrade to 5.43.
MFC after:	3 days
2022-09-24 19:16:39 -07:00
Richard Yao
ebe1d03616
Fix userland resource leaks
Coverity caught these. With the exception of the file descriptor leak in
tests/zfs-tests/cmd/draid.c, they are all memory leaks.

Also, there is a piece of dead code in zfs_get_enclosure_sysfs_path().
We delete it as cleanup.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13921
2022-09-23 16:55:26 -07:00
Richard Yao
2a493a4c71
Fix unchecked return values and unused return values
Coverity complained about unchecked return values and unused values that
turned out to be unused return values.

Different approaches were used to handle the different cases of
unchecked return values:

* cmd/zdb/zdb.c: VERIFY0 was used in one place since the existing code
  had no error handling. An error message was printed in another to
  match the rest of the code.

* cmd/zed/agents/zfs_retire.c: We dismiss the return value with `(void)`
  because the value is expected to be potentially unset.

* cmd/zpool_influxdb/zpool_influxdb.c: We dismiss the return value with
  `(void)` because the values are expected to be potentially unset.

* cmd/ztest.c: VERIFY0 was used since we want failures if something goes
  wrong in ztest.

* module/zfs/dsl_dir.c: We dismiss the return value with `(void)`
  because there is no guarantee that the zap entry will always be there.
  For example, old pools imported readonly would not have it and we do
  not want to fail here because of that.

* module/zfs/zfs_fm.c: `fnvlist_add_*()` was used since the
  allocations sleep and thus can never fail.

* module/zfs/zvol.c: We dismiss the return value with `(void)` because
  we do not need it. This matches what is already done in the analogous
  `zfs_replay_write2()`.

* tests/zfs-tests/cmd/draid.c: We suppress one return value with
  `(void)` since the code handles errors already. The other return value
  is handled by switching to `fnvlist_lookup_uint8_array()`.

* tests/zfs-tests/cmd/file/file_fadvise.c: We add error handling.

* tests/zfs-tests/cmd/mmap_sync.c: We add error handling for munmap, but
  ignore failures on remove() with (void) since it is expected to be
  able to fail.

* tests/zfs-tests/cmd/mmapwrite.c: We add error handling.

As for unused return values, they were all in places where there was
error handling, so logic was added to handle the return values.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13920
2022-09-23 16:52:03 -07:00
Richard Yao
d25153d555
set_global_var_parse_kv() should pass the pointer from strdup()
A comment says that the caller should free k_out, but the pointer passed
via k_out is not the same pointer we received from strdup(). Instead,
it is a pointer into the region we received from strdup(). The free
function should always be called with the original pointer, so this is
likely a bug.

We solve this by calling `strdup()` a second time and then freeing the
original pointer.

Coverity reported this as a memory leak.

Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13867
2022-09-23 10:51:14 -07:00
Xin LI
71f0c44a04 MFV 66082b6c88: libbsdxml (expat) 2.4.9 2022-09-21 00:02:38 -07:00
Xin LI
66082b6c88 Vendor import of expat 2.4.9. 2022-09-20 23:53:08 -07:00
Mateusz Guzik
402426c7d8
Add membar_sync
Provides the missing full barrier variant to the membar primitive set.

While not used right now, this is probably going to change down the
road.

Name taken from Solaris, to follow the existing routines.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
Closes #13907
2022-09-20 15:32:44 -07:00
Richard Yao
7c6d94728c
Call va_end() before return in zpool_standard_error_fmt()
Commit ecd6cf800b63704be73fb264c3f5b6e0dafc068d by marks in OpenSolaris
at Tue Jun 26 07:44:24 2007 -0700 introduced a bug where we fail to call
`va_end()` before returning.

The man page for va_start() says:

"Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function."

Coverity complained about this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13904
2022-09-20 15:20:56 -07:00
Richard Yao
e8bdc74528
Cleanup: Remove unused uu_pname code
Coverity caught a possible NULL pointer dereference in dead code. We can
delete it all.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chunwei Chen <david.chen@nutanix.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13900
2022-09-19 17:33:52 -07:00
Steve Kargl
620d855fac msun: correct comment
The comment in msun/src/e_jn.c lacks proper grammar, and is incorrect on
the choice of normalization entity.

PR:	266503
MFC after:	3 days
2022-09-19 21:40:07 +03:00
Jens Schweikhardt
ed5e7fb16c There's no PEM(3) anywhere around; delete reference. 2022-09-17 13:14:01 +02:00
Jens Schweikhardt
25c54b848e Reference correct section for free(3). 2022-09-17 13:12:44 +02:00
Brooks Davis
bb23932803 ktrace: make ktr_tid a long not intptr_t (NFC)
Long ago, ktr_tid was ktr_buffer which pointed to the buffer following
the header and was used internally in the kernel.  Use was removed in
efbbbf570d and it was repurposed as ktr_kid in c6854c347f.  For
ABI reasons, it stayed an intptr_t rather than becoming an lwpid_t at
the time.  Since it doesn't hold a pointer any more (unless you have
a ktrace.out from 2005), change the type to long which is alwasy the
same size on all supported architectures.  Add a suggestion to change
the type to lwpid_t (__int32_t) on a future ABI break.

Remove most remaining references to ktr_buffer, retaing a comment in
kdump.c explaining why negative values are treated as 0.  While here,
accept that pid_t and lwpid_t are of type int and simplify casts in
printf.

This changed was motivated by CheriBSD where intptr_t is 16-bytes
in the pure-capability ABI.

Reviewed by:	kib, markj
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D36599
2022-09-17 09:21:59 +01:00
Jens Schweikhardt
714300faec Change sysctl section to 3 as suggested by Benjamin Kaduk. 2022-09-17 09:35:49 +02:00
Tino Reichardt
48cf170d5a Add PPC cpu feature tests for FreeBSD and Linux
Add needed cpu feature tests for powerpc architecture.

Overview:
zfs_altivec_available() - needed by RAID-Z
zfs_vsx_available()     - needed by BLAKE3
zfs_isa207_available()  - needed by SHA2

Part 1 - Userspace
- use getauxval() for Linux and elf_aux_info() for FreeBSD
- direct including <sys/auxv.h> fails with double definitions
- so we self define the needed functions and definitions

Part 2 - Kernel space FreeBSD
- use exported cpu_features of <powerpc/cpu.h>

Part 3 - Kernel space Linux
- use cpu_has_feature() function of <asm/cpufeature.h>

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Tino Reichardt <milky-zfs@mcmilk.de>
Closes #13725
2022-09-16 14:25:53 -07:00
наб
6c8e9f09c2
Handle ECKSUM as new EZFS_CKSUM ‒ "insufficient replicas"
Add a meaningful error message for ECKSUM to common error messages.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #6805 
Closes #13808
Closes #13898
2022-09-16 13:59:25 -07:00
Chunwei Chen
1b6f3368dd
Fix unable to export zpool without nfs-utils
Don't return error in nfs_disable_share when nfs is not available, since
it wouldn't have been able to share in the first place.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #13534
Closes #13800
2022-09-16 13:43:26 -07:00
Jens Schweikhardt
a09bb0ed18 Correct a typo in man page references: rpcset_gss -> rpcsec_gss. 2022-09-16 22:38:42 +02:00
Konstantin Belousov
e03c7f5005 libthr: extract code to get main stack base and size into helpers
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:24:12 +03:00
Konstantin Belousov
e2879ece43 libc, libthr: use AT_USRSTACK{BASE,LIM} instead of sysctl("kern.usrstack") and get_rlimit(RLIMIT_STACK)
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:24:06 +03:00
Konstantin Belousov
ebf7a01594 libthr: use nitems() for mib length
Suggested by:	imp
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:23:59 +03:00
Konstantin Belousov
62b4fb22df auxv.3: Document AT_USRSTACKBASE and AT_USRSTACKLIM
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:23:46 +03:00
Konstantin Belousov
8f2668b060 _elf_aux_info(3): add support for AT_USRSTACK{BASE,LIM}
Reviewed by:	brooks, imp (previous version)
Discussed with:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36540
2022-09-16 23:23:32 +03:00
Jens Schweikhardt
e9e615c88a Fix dead references (wrong section) to sysctl(8). 2022-09-16 20:00:49 +02:00
Jens Schweikhardt
e6044abdbe More precise language: what is called data pointer, C calls object pointer.
Also delete reference to non-existing lint(1).
2022-09-16 19:40:11 +02:00
Jens Schweikhardt
59a1db5be6 Fix dead refs to pam(8) with pam(3) as well as some other PAM functions. 2022-09-16 19:33:30 +02:00
Jens Schweikhardt
cf13e67730 Fix dead reference to boot0(8) to point to boot0cfg(8). 2022-09-16 19:08:22 +02:00
Dag-Erling Smørgrav
1e8a0a3053 Add deprecation notices for OPIE.
Differential Revision: https://reviews.freebsd.org/D36593
2022-09-15 16:29:00 +02:00
Gordon Bergling
0090d18235 Update SEE ALSO sections for resolver.{3,5} and hosts.5
The mentioned document "Name Server Operations Guide for BIND" is
outdated, so remove it from the SEE ALSO section of hosts.5
and resolver.{3,5}.

PR:		266360
Reported by:	Graham Perrin <grahamperrin at FreeBSD dot org>
Reviewed by:	karels
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36557
2022-09-15 15:24:28 +02:00
Gordon Bergling
f2411b9257 flua: Fix a typo in a source code comment
- s/paramter/parameter/

MFC after:	3 days
2022-09-15 10:25:54 +02:00
Maxim Konovalov
acc3f0689a getaddrinfo(3): A typo fixed
PR:	266403
2022-09-14 05:08:45 +00:00
Richard Yao
fcd7293d4e
Remove incorrect free() in zfs_get_pci_slots_sys_path()
Coverity found this. We attempted to free tmp, which is a pointer to a
string that should be freed by the caller.

Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13864
2022-09-13 17:00:53 -07:00
Richard Yao
d5d10f2aef
Cleanup dead spa_boot code
Unused code detected by coverity.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13868
2022-09-13 16:40:10 -07:00
Richard Yao
710fd1ded6
zpool_load_compat() should create strings of length ZFS_MAXPROPLEN
Otherwise, `strlcat()` can overflow them.

Coverity found this.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Neal Gompa <ngompa@datto.com>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13866
2022-09-12 12:54:43 -07:00
Kristof Provost
6049ee60e0 libpfctl: improve syncookie watermark calculation
Ensure that we always pass sane limits for the high and low watermark
values.
This is especially important if users do something silly, like set the
state limit to 1. In that case we wound up calculating 0/0 as a limit,
which gets rejected by the kernel.

While here also shift the calculation to use uint64_t, so we don't end
up with overflows (and subsequently higher low than high values) with
very large state limits.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36497
2022-09-12 09:32:02 +02:00
Gordon Bergling
82007616d0 msun: Remove a double word in a source code comment
- s/to to/to/

MFC after:	3 days
2022-09-10 12:59:10 +02:00
Don Brady
ede037cda7
Make zfs-share service resilient to stale exports
The are a few cases where stale entries in /etc/exports.d/zfs.exports 
will cause the nfs-server service to fail when starting up.

Since the nfs-server startup consumes /etc/exports.d/zfs.exports, the 
zfs-share service (which rebuilds the list of zfs exports) should run 
before the nfs-server service.

To make the zfs-share service resilient to stale exports, this change 
truncates the zfs config file as part of the zfs share -a operation.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #13775
2022-09-09 10:54:16 -07:00
Gleb Popov
c44ca4c227 msun/Makefile: Fix conditional and unbreak the build.
Approved by:	imp
Fixes:	20adba8bc1
2022-09-09 11:07:33 +03:00
Gleb Popov
20adba8bc1 src.conf: Introduce WITHOUT_MACHDEP knob.
Summary:
This knob can be used to make buildsystem prefer generic C implentations of
various functions, instead of machine-specific assembler ones.

Test Plan: `make buildworld` on amd64

Reviewed by: imp, emaste

Differential Revision: https://reviews.freebsd.org/D36076

MFC after:	3 days
2022-09-09 09:54:28 +03:00
Xin LI
c65e42dbde libc: add test case for qsort_b(3)
Reviewed by: 	markj
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D36463
2022-09-06 23:11:46 -07:00
Felix Palmen
6f4d99c654 pam_unix: Remove bogus __unused attribute
Approved by:		cy, des, tcberner (mentor)
Differential Revision:	https://reviews.freebsd.org/D34320
2022-09-05 20:53:22 +02:00
Toomas Soome
1f5679569d libpmc: pmc_init() should avoid overflowing pmc_class_table
Use calloc().

Walk the class list we get from kernel, so we will not add something
the kernel does not know about.

Avoid picking headers from /usr/include.

Differential Revision:	https://reviews.freebsd.org/D36401
2022-09-05 15:23:20 +03:00
Gordon Bergling
10889539ee msun: Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:57:38 +02:00
Gordon Bergling
0970362787 libifconfig: Correct some typos in source code comments
- s/occured/occurred/
- s/the the/the/

MFC after:	3 days
2022-09-04 12:53:58 +02:00
Gordon Bergling
f0d4c2afd6 pmc(3): Correct some typos in event descriptions
- s/occured/occurred/
- s/the the/the/

MFC after:	3 days
2022-09-04 12:52:38 +02:00
Gordon Bergling
a52f4499ae libm: Correct some typos in source code comments
- s/modfied/modified/
- s/minimun/minimum/

While here, fix some mandoc warnings:

- whitespace at end of input line
- unusual Xr punctuation
- missing comma before name

Obtained from:	NetBSD
MFC after:	5 days
2022-09-03 19:14:02 +02:00
Alfonso S. Siciliano
2c9fd7655b
contrib/bsddialog: Import version 0.3
New features overview:
 * Unicode. User interface handles multi-column characters. API can
   handle char* like a multibyte character string. Internally wide
   characters are used for keyboard input, to adapt word wrapping and
   dynamic text auto-sizing for multi-column characters.
 * Forms refactoring. Complete rewrite deleting libformw dependency.
 * Theme. New utility options to save and load custom theme at run-time.
 * TUI navigation. Added keys to navigate input components. Changed
   default focus behavior of input dialogs to be LGPL-dialog-like; a new
   option can set the previous whiptail-like behavior.

See /usr/src/contrib/bsddialog/CHANGELOG '2022-08-29 Version 0.3'
for more detailed information.
2022-09-03 16:36:16 +02:00
Konstantin Belousov
44cf1e5eb4 libc/stdio: only roll FILE state back on EINTR
Reported by:	JunT <takimoto-j@kba.biglobe.ne.jp>
PR:	266171
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36427
2022-09-03 04:06:41 +03:00
Konstantin Belousov
120bacabfd __swbuf(): style
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36427
2022-09-03 04:06:41 +03:00
Gleb Smirnoff
8624f4347e divert: declare PF_DIVERT domain and stop abusing PF_INET
The divert(4) is not a protocol of IPv4.  It is a socket to
intercept packets from ipfw(4) to userland and re-inject them
back.  It can divert and re-inject IPv4 and IPv6 packets today,
but potentially it is not limited to these two protocols.  The
IPPROTO_DIVERT does not belong to known IP protocols, it
doesn't even fit into u_char.  I guess, the implementation of
divert(4) was done the way it is done basically because it was
easier to do it this way, back when protocols for sockets were
intertwined with IP protocols and domains were statically
compiled in.

Moving divert(4) out of inetsw accomplished two important things:

1) IPDIVERT is getting much closer to be not dependent on INET.
   This will be finalized in following changes.
2) Now divert socket no longer aliases with raw IPv4 socket.
   Domain/proto selection code won't need a hack for SOCK_RAW and
   multiple entries in inetsw implementing different flavors of
   raw socket can merge into one without requirement of raw IPv4
   being the last member of dom_protosw.

Differential revision:	https://reviews.freebsd.org/D36379
2022-08-30 15:09:21 -07:00
Brooks Davis
a28f833532 libprocstat: forward declare struct kinfo_proc
This allows libprocstat.h to be included without sys/user.h as
documented in the manpage.
2022-08-26 23:20:32 +01:00
George Wilson
2d5622f5be
Importing from cachefile can trip assertion
When importing from cachefile, it is possible that the builtin retry
logic will trip an assertion because it also fails to find the pool.
This fix addresses that case and returns the correct error message to
the user.

Reviewed-by: Richard Yao <ryao@gentoo.org>
Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Wilson <gwilson@delphix.com>
Closes #13781
2022-08-26 14:04:27 -07:00
Gleb Smirnoff
a358db5603 socket(2): bring documentation up tp date
o Undocument sockets that are no longer supported, or never were.
o Add AF_HYPERV. Note: PF_HYPERV isn't defined, no typo here.
o Point at ip(4) and ip6(4) instead of unwelcoming "not described here".

Reviewed by:		gbe, markj
Differential revision:	https://reviews.freebsd.org/D36284
2022-08-26 08:16:15 -07:00
Brian Behlendorf
9f346abbe8
Revert "Avoid panic with recordsize > 128k, raw sending and no large_blocks"
This reverts commit 80a650b7bb.  This change
inadvertently introduced a regression in ztest where one of the new ASSERTs
is triggered in dsl_scan_visitbp().

Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #12275 
Closes #13799
2022-08-25 13:33:32 -07:00
Aymeric Wibo
05c9a0158f libc: Add strverscmp(3) and versionsort(3)
Add a strverscmp(3) function to libc, a GNU extension I implemented by
reading its glibc manual page. It orders strings following a much more
natural ordering (e.g. "ent1 < ent2 < ent10" as opposed to
"ent1 < ent10 < ent2" with strcmp(3)'s lexicographic ordering).

Also add versionsort(3) for use as scandir(3)'s compar argument.

Update manual page for scandir(3) and add one for strverscmp(3).

Reviewed by:	pstef, gbe, kib
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D35807
2022-08-25 03:29:03 +03:00
Umer Saleem
a582d52993
Updates for snapshots_changed property
Currently, snapshots_changed property is stored in dd_props_zapobj, due
to which the property is assumed to be local. This causes a difference
in behavior with respect to other readonly properties.

This commit stores the snapshots_changed property in dd_object. Source
is not set to local in this case, which makes it consistent with other
readonly properties.

This commit also updates the date string format to include seconds.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #13785
2022-08-24 14:20:43 -07:00
Konstantin Belousov
a294e67973 Document scandirat(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:01 +03:00
Konstantin Belousov
9fb8e8eede libc: add scandirat(3)
Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
cb6e97f4da libc: split scandir() into scandir_dirp() and proper scandir()
The new helper scandir_dirp() takes DIR *, i.e. a pre-opened directory,
instead of the directory name.

Reviewed by:	emaste, imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
ea448a0a43 Link scandir_b(3) to scandir(3)
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Konstantin Belousov
aa5e19a9b3 scandir.3: Use .Fo instead of .Fn for long args
Reviewed by:	emaste, gbe (man pages), imp, kevans, markj, Aymeric Wibo <obiwac@gmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D36301
2022-08-24 22:26:00 +03:00
Emmanuel Vadot
15d781b532 lib: Gate libfigpar under MK_DIALOG
libfigpar is only used by dpv and dpv isn't built if WITHOUT_DIALOG
is set.
2022-08-16 21:15:12 +02:00
Jens Schweikhardt
e1ae2a285a Indicate the port where the referenced man pages come from. 2022-08-16 20:57:30 +02:00
Li-Wen Hsu
b80572fe3b
libc/locale tests: temporarily skip lib.libc.locale.c16rtomb_test.c16rtomb_utf_8_test
This test case starts failing after iconv changes on 2022-08-11.

PR:		265871
Sponsored by:	The FreeBSD Foundation
2022-08-16 13:18:15 +08:00
Dimitry Andric
8534e6be81 Avoid using TARGET_ARCH in llvm.build.mk
Apparently the TARGET_ARCH macro is not supposed to be used outside of
the top-level Makefiles. Directly use MACHINE_ARCH instead.

Noticed by:	imp, jrtc27
MFC after:	1 week
2022-08-14 13:11:52 +02:00
Jens Schweikhardt
0f6a767c02 Replace a dead cross reference with the proper (I think) macro. 2022-08-13 22:55:10 +02:00
Jens Schweikhardt
30f6269155 Fix wrong section number in man page cross references. 2022-08-13 22:42:23 +02:00
Jens Schweikhardt
d491167b38 Fix wrong section number in man page cross references. 2022-08-13 22:31:24 +02:00
Kirk McKusick
e688661642 Move the ability to search for alternate UFS superblocks from fsck_ffs(8)
into ffs_sbsearch() to allow use by other parts of the system.

Historically only fsck_ffs(8), the UFS filesystem checker, had code
to track down and use alternate UFS superblocks. Since fsdb(8) used
much of the fsck_ffs(8) implementation it had some ability to track
down alternate superblocks.

This change extracts the code to track down alternate superblocks
from fsck_ffs(8) and puts it into a new function ffs_sbsearch() in
sys/ufs/ffs/ffs_subr.c. Like ffs_sbget() and ffs_sbput() also found
in ffs_subr.c, these functions can be used directly by the kernel
subsystems. Additionally they are exported to the UFS library,
libufs(8) so that they can be used by user-level programs. The new
functions added to libufs(8) are sbfind(3) that is an alternative
to sbread(3) and sbsearch(3) that is an alternative to sbget(3).
See their manual pages for further details.

The utilities that have been changed to search for superblocks are
dumpfs(8), fsdb(8), ffsinfo(8), and fsck_ffs(8). Also, the prtblknos(8)
tool found in tools/diag/prtblknos searches for superblocks.

The UFS specific mount code uses the superblock search interface
when mounting the root filesystem and when the administrator doing
a mount(8) command specifies the force flag (-f). The standalone UFS
boot code (found in stand/libsa/ufs.c) uses the superblock search
code in the hope of being able to get the system up and running so
that fsck_ffs(8) can be used to get the filesystem cleaned up.

The following utilities have not been changed to search for
superblocks: clri(8), tunefs(8), snapinfo(8), fstyp(8), quot(8),
dump(8), fsirand(8), growfs(8), quotacheck(8), gjournal(8), and
glabel(8). When these utilities fail, they do report the cause of
the failure. The one exception is the tasting code used to try and
figure what a given disk contains. The tasting code will remain
silent so as not to put out a slew of messages as it trying to taste
every new mass storage device that shows up.

Reviewed by: kib
Reviewed by: Warner Losh
Tested by:   Peter Holm
Differential Revision: https://reviews.freebsd.org/D36053
Sponsored by: The FreeBSD Foundation
2022-08-13 12:43:40 -07:00
Alex Richardson
ac175bd33a Install working pkgconfig .pc files for compat libraries
The default ones are install them to /usr/libdata/pkgconfig, and we can't
use this path for compat libraries, so we use /usr/lib<suffix>/pkgconfigi here.

Test Plan:	grep -rn libdir= ./usr/lib32/pkgconfig/*.pc
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D34939
2022-08-11 23:18:34 +01:00
Kyle Evans
693f88c9da iconv_std: complete the //IGNORE support
Previously, it would only ignore failures due to csmapper conversion
failure.  It may be the case that the input string contains invalid
sequences that also need to be ignored.

A good example of //IGNORE application is sanitizing user- or remotely-
specified strings that are expected to be UTF-8; perhaps as part of a
pipeline that will feed the result into a system less tested against or
tolerant of illegal UTF-8 sequences.

Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34345
2022-08-11 11:42:20 -05:00
Kyle Evans
2300a22c97 libc: iconv: add mb_cur_min for encoder traits
A future commit will actually implement //IGNORE so that applications
using base iconv can, e.g., sanitize UTF-8 strings.  To do this, the
iconv_std module needs to be able to determine the minimum width for any
given encoding so that it can skip that many bytes in the input buffer.
This is mainly an issue for UTF-16 and UTF-32.

This commit bumps shlib versions to 5 for libiconv modules to reflect
the ABI change.  It also fixes OptionalObsoleteFiles to remove the
libiconv modules if WITHOUT_ICONV is in use.

re: _ENCODING_MB_CUR_MIN, note that this file (citrus_stdenc_template.h)
is included at the bottom of an encoding *implementation*, so the
implementation is free to #define it prior.  UTF1632 is a good example,
as it redefines the minimum to be a property on the encodinginfo, and
the minimum is set to 2 or 4 bytes for UTF-16 and UTF-32 respectively.

Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34344
2022-08-11 11:42:17 -05:00
Kyle Evans
c1f46b8fcb libc: iconv: push option ignore into citrus_iconv_open()
Make it vaguely aware of options in the sense that it now knows that it
can zap any trailing //.  It now copies the entire string in realsrc and
realdst, then terminates them at the options.

__bsd___iconv_open can now stop trying to allocate memory just for this
purpose, and the new version is technically more correct.  GNU libiconv
will ignore options on the `in` codeset and still do the right thing.

Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34343
2022-08-11 11:33:28 -05:00
Xin LI
e9a2e4d1d2 arc4random(3): Reduce diff with OpenBSD.
The main change was v1.57 by djm@:

  Randomise the rekey interval a little. Previously, the chacha20
  instance would be rekeyed every 1.6MB. This makes it happen at a
  random point somewhere in the 1-2MB range.

Reviewed by:	csprng (markm, cem)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D36088
2022-08-09 17:27:55 -07:00
Gordon Bergling
948168c778 libpathconv: bump man page dates
- bump the man page dates to the date of mandoc fixes

Reported by:	rpokala
X-MFC with:	094517119c
2022-08-09 10:05:31 +02:00
Eugene Grosbein
e9ae9fa937 syslog(3): unbreak log generation using fabricated PID
Recover application ability to supply fabricated PID
embedded into ident that was lost when libc switched
to generation of RFC 5424 log messages, for example:

logger -t "ident[$$]" -p user.notice "test"

It is essential for long running scripts.
Also, this change unbreaks matching resulted entries
by ident in syslog.conf:

!ident
*.* /var/log/ident.log

Without the fix, the log (and matching) was broken:

Aug  1 07:36:58 hostname ident[123][86483]: test

Now it works as expected and worked before breakage:

Aug  1 07:39:40 hostname ident[123]: test

Differential:	https://reviews.freebsd.org/D36005
MFC after:	2 weeks
2022-08-09 05:21:02 +07:00
Gordon Bergling
816ca3d10f libutil: Fix mandoc warnings
- missing comma before name
- possible typo in section name: Sh CAVEAT instead of CAVEATS
- useless macro: Tn
- blank line in fill mode, using .sp
- no blank before trailing delimiter: Dv NULL?

MFC after:	3 days
2022-08-07 16:30:24 +02:00
Gordon Bergling
094517119c libpathconv: Fix mandoc warnings in abs2rel(3) and rel2abs(3)
- cannot parse date, using it verbatim: Dec 15, 1997"
- sections out of conventional order: Sh SEE ALSO
- possible typo in section name: Sh EXAMPLE instead of EXAMPLES
- AUTHORS section without An macro

MFC after:	3 days
2022-08-07 14:53:53 +02:00