]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
18 months agolinuxkpi: Adds more `SZ_*` macros
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:17:37 +0000 (18:17 +0100)]
linuxkpi: Adds more `SZ_*` macros

`SZ_2K` and `SZ_1G` were defined in irdma. They are removed from this
driver.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38150

(cherry picked from commit 04cbeeb59742a9e88d838e18b84004e9bb89ca00)

18 months agolinuxkpi: Define ENOKEY to 126.
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:14:25 +0000 (18:14 +0100)]
linuxkpi: Define ENOKEY to 126.

This is the same error code as Linux. This value is unused on FreeBSD.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38149

(cherry picked from commit f27b1399d68585f5edd83645c2a37a1580e7fb93)

18 months agolinuxkpi: Add `pci_device_is_present()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 17:46:37 +0000 (18:46 +0100)]
linuxkpi: Add `pci_device_is_present()`

This calls bus_child_present(9) internally.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38148

(cherry picked from commit 49b6d5ed142d6c59b7a517ff5660165d8647bd01)

18 months agolinuxkpi: Define `dev_dbg_ratelimited()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 00:15:03 +0000 (01:15 +0100)]
linuxkpi: Define `dev_dbg_ratelimited()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38145

(cherry picked from commit bbff0400c1d7728ae1759d8f740033a0a2f8aeff)

18 months agovt(4): Return errors from `vt_{,de}allocate()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 18:22:56 +0000 (19:22 +0100)]
vt(4): Return errors from `vt_{,de}allocate()`

This is useful to the DRM drivers to let them know if a device is
effectively used by the console.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38089

(cherry picked from commit 29ab19455484be96150fa5e87bd38aefb85c888a)

18 months agolinuxkpi: Fix `atomic_long_sub()` overflow
Jean-Sébastien Pédron [Sun, 15 Jan 2023 14:56:48 +0000 (15:56 +0100)]
linuxkpi: Fix `atomic_long_sub()` overflow

By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making
the atomic long overflow. Indeed the underlying FreeBSD atomic is based
on an unsigned long.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38090

(cherry picked from commit 9491ea7c68221ca7bc5e369ebb57660886ef1b13)

18 months agolinuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 12:22:19 +0000 (13:22 +0100)]
linuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`

The code comes from the i915 DRM driver.

In Linux commits b739f125e4ebd73d10ed30a856574e13649119ed and
b12d691ea5e01db42ccf3b4207e57cb3ce7cfe91 (Linux 5.13), the i915 DRM
driver dropped specific implementations to use Linux generic functions.
Therefore I moved the FreeBSD code from that i915 driver to linuxkpi.

However, these commits were later reverted (also in Linux 5.13) so the
i915 driver doesn't use these functions. But perhaps it will help in the
future.

To sum up, the code comes from the i915 DRM driver but it doesn't use it
(i.e. it continues to use its internal implementation).

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38088

(cherry picked from commit b99bc862324526b3ee6fad335618cbe85ad9e11e)

18 months agolinuxkpi: Add `sysfs_emit()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 23:23:33 +0000 (00:23 +0100)]
linuxkpi: Add `sysfs_emit()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38086

(cherry picked from commit 4fee6659c42c264e17dad7625f8663a45594d46b)

18 months agolinuxkpi: Add `complete` field to `struct dev_pm_ops`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:57 +0000 (23:23 +0100)]
linuxkpi: Add `complete` field to `struct dev_pm_ops`

This change breaks the KBI.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38085

(cherry picked from commit 0d4d9ee6f0f9379f3de6e2c684dab19922eda705)

18 months agolinuxkpi: Add `pm_suspend_via_firmware()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:35 +0000 (23:23 +0100)]
linuxkpi: Add `pm_suspend_via_firmware()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38084

(cherry picked from commit 270a13348065ebf2f02fbf88a02d42fa63a245fc)

18 months agolinuxkpi: Add `pm_runtime_suspended()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:14 +0000 (23:23 +0100)]
linuxkpi: Add `pm_runtime_suspended()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38083

(cherry picked from commit 710c6084d11025fb3640dc1146ae1b157475333b)

18 months agolinuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 00:48:43 +0000 (01:48 +0100)]
linuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38080

(cherry picked from commit 2272ccaa68c550e0e29801b9d881b2ea5ba12efa)

18 months agolinuxkpi: Define `synchronize_hardirq()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 00:27:40 +0000 (01:27 +0100)]
linuxkpi: Define `synchronize_hardirq()`

It currently does the same as `synchronize_irq()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38079

(cherry picked from commit a609ed795943673074b71aeafafabe46d08f1a6d)

18 months agolindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()`
Jean-Sébastien Pédron [Thu, 12 Jan 2023 23:41:32 +0000 (00:41 +0100)]
lindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()`

The `debugfs_create_x*()` variants are the same as their
`debugfs_create_u*()` equivalent, but they work with lowercase
hexadecimal.

While here, fix a few style(9) issues.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38087

(cherry picked from commit 976aa07a885b53e1bc2711082d2f6f113dbdd0bc)

18 months agolindebugfs: Add `debugfs_create_atomic_t()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 10:00:57 +0000 (11:00 +0100)]
lindebugfs: Add `debugfs_create_atomic_t()`

Reviewed by: jfree
Approved by: jfree
Differential Revision: https://reviews.freebsd.org/D37915

(cherry picked from commit f2044a3030fb2a657e59dee4b7e5865acff936bd)

18 months agolinuxkpi: Define `hrtimer_try_to_cancel()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 01:00:57 +0000 (02:00 +0100)]
linuxkpi: Define `hrtimer_try_to_cancel()`

It is the same as callout_stop(9) but the return values are different.

Reviewed by: hselasky
Approved by: hselasky
Differential Revision: https://reviews.freebsd.org/D38081

(cherry picked from commit bb651c77f5f71a38dd90b2eee214e7a2224421a7)

18 months agolinuxkpi: Define EBADSLT to 57
Jean-Sébastien Pédron [Mon, 2 Jan 2023 22:48:16 +0000 (23:48 +0100)]
linuxkpi: Define EBADSLT to 57

This is the same error code as Linux.

As emaste@ noted in the review, FreeBSD defines the following errno
values in `sys/errno.h`:
* 56 is `EISCONN`
* 57 is `ENOTCONN`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37935

(cherry picked from commit e8ce32bea30d599b481735a1d1b0a87ac06c5a66)

18 months agolinuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`
Jean-Sébastien Pédron [Mon, 2 Jan 2023 20:59:17 +0000 (21:59 +0100)]
linuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`

They are no-ops.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37933

(cherry picked from commit cf8f392260bf8e9b4e088f26f81ddb96bd97e91c)

18 months agolinuxkpi: Define `ioremap_cache()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 10:36:24 +0000 (11:36 +0100)]
linuxkpi: Define `ioremap_cache()`

It uses the `VM_MEMATTR_WRITE_BACK` flag on FreeBSD.

It replaces `ioremap_wb()` which doesn't exist in Linux. Perhaps it
existed in the past and was removed.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37916

(cherry picked from commit ed53e350d703b9e3ab78d137fd59a5a9dfef8b3f)

18 months agolinuxkpi: Add `gfp_mask` field to `struct shrink_control`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:56:46 +0000 (10:56 +0100)]
linuxkpi: Add `gfp_mask` field to `struct shrink_control`

bz@ asked if the KBI breakage is a concern here. My answer was that this
is the first time in the DRM drivers in Linux 5.13 (the version I'm
working on) that this structure is initialized (as a variable local to
the function in this case), so it shouldn't be a problem for the DRM
drivers.

However, I can't speak for other drivers maintained outside of the src
tree.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37913

(cherry picked from commit 3aa335d00ac860565d106eb47e931206641cd653)

18 months agolinuxkpi: Define `GFP_NOFS` in `linux/gfp.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:49:08 +0000 (10:49 +0100)]
linuxkpi: Define `GFP_NOFS` in `linux/gfp.h`

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37910

(cherry picked from commit c0c1c599c0ca7e8a15509503991f8cd97c292bea)

18 months agoAdd ck.h userspace shims for CK_SLIST_
Elliott Mitchell [Thu, 9 Feb 2023 23:27:12 +0000 (16:27 -0700)]
Add ck.h userspace shims for CK_SLIST_

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

(cherry picked from commit cd3193f640e26991d94d87a45ee9b6a953c56fb5)

18 months agotop: fix sorting by pid (-o pid)
Kyle Evans [Mon, 13 Feb 2023 06:39:04 +0000 (00:39 -0600)]
top: fix sorting by pid (-o pid)

The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2d8c ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

Reviewed by: pstef (D37083)

(cherry picked from commit deb63adf945d446ed91a9d84124c71f15ae571d1)

18 months agolibc: popen: slightly simplify cloexec logic
Kyle Evans [Mon, 13 Feb 2023 06:33:52 +0000 (00:33 -0600)]
libc: popen: slightly simplify cloexec logic

No need to check the mode again here; we know that `iop` wraps the
correct fd.

Reviewed by: bapt

(cherry picked from commit f123c6c425d4161b06f237996662496abbd78b94)

18 months agomd5: fix *sum -c with missing files
Kyle Evans [Mon, 13 Feb 2023 06:32:38 +0000 (00:32 -0600)]
md5: fix *sum -c with missing files

If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR: 267722
Reviewed by: emaste (earlier version)

(cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)

18 months agopatch: omit filename if the prompt was ignored
Kyle Evans [Tue, 24 Jan 2023 16:46:01 +0000 (10:46 -0600)]
patch: omit filename if the prompt was ignored

When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by: des
Sponsored by: Klara, Inc.

(cherry picked from commit 7e688ed493482c5346d969e7667856d8ced8d87a)

18 months agowg: tests: remove an obsolete workaround
Kyle Evans [Mon, 13 Feb 2023 05:59:21 +0000 (23:59 -0600)]
wg: tests: remove an obsolete workaround

PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by: jhb, markj

(cherry picked from commit e63dcbe7a2cb8f6b6932cef48e70f3372f4df737)

18 months agowg: add a test for the home jail socket feature
Kyle Evans [Mon, 13 Feb 2023 05:59:20 +0000 (23:59 -0600)]
wg: add a test for the home jail socket feature

This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by: jhb, markj (both earlier version)

(cherry picked from commit 96f4ab26633a457c52fdb9c45f48dcb052b408a4)

18 months agoamd64 ia32 vdso: always define some __vdso_ symbols
Konstantin Belousov [Sun, 5 Feb 2023 21:41:25 +0000 (23:41 +0200)]
amd64 ia32 vdso: always define some __vdso_ symbols

(cherry picked from commit ee844871206562c6aaaa14ee4576cb20895adb00)

18 months agoamd64: record a dependency of vdso on its linker script
Konstantin Belousov [Sun, 5 Feb 2023 21:40:31 +0000 (23:40 +0200)]
amd64: record a dependency of vdso on its linker script

(cherry picked from commit 5bb807fed4622b17f2b2aa837f5ebd124e08f904)

18 months agosesutil: plug memory leaks
Alan Somers [Wed, 19 Jan 2022 21:57:27 +0000 (14:57 -0700)]
sesutil: plug memory leaks

Sponsored by: Axcient
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D33955

(cherry picked from commit 09f29b03ddf857a366f338145693b5449e6ca5de)

18 months agoirdma: fix LINT-NOIP/NOINET/NOINET6 builds
Mitchell Horne [Mon, 30 May 2022 20:47:32 +0000 (17:47 -0300)]
irdma: fix LINT-NOIP/NOINET/NOINET6 builds

This module depends on the presence of both INET and INET6 options in
order to compile.

Reviewed by: erj
Fixes: cdcd52d41e24 ("irdma: Add RDMA driver for Intel(R) Ethernet...")
Differential Revision: https://reviews.freebsd.org/D35343

(cherry picked from commit acdfbc6cbe0a8a976d446216be84994c8ee8d5c1)

18 months agoloader: always install help files
Mitchell Horne [Thu, 11 Feb 2021 14:29:00 +0000 (10:29 -0400)]
loader: always install help files

Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR: 267134
Reported by: Daniel O'Connor <darius@dons.net.au>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28591

(cherry picked from commit 8859960436f5727f163a7b3468e08710c5e6d874)

18 months agodtrace: implement riscv dtrace_getustackdepth()
Mitchell Horne [Mon, 6 Feb 2023 18:23:42 +0000 (14:23 -0400)]
dtrace: implement riscv dtrace_getustackdepth()

Pretty trivial following other implementations. The existing
dtrace_getustack_common() does most of the work.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38303

(cherry picked from commit c6943b44f7d73176acd2e36e0615e1b2ded02c0a)

18 months agodtrace: Fix RISC-V user stack unwinder
Jessica Clarke [Mon, 6 Feb 2023 18:30:57 +0000 (14:30 -0400)]
dtrace: Fix RISC-V user stack unwinder

The unwind logic was copied from AArch64 which follows the peculiar
AACPS (where, unlike typical RISC architectures, its frame pointer
follows an x86/stack machine-like convention where the frame pointer
points at the bottom of the frame record, not the top). Delete the
pointless riscv_frame struct and fix this.

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28054

(cherry picked from commit 38720107324b3903f342bcb0306c72c4e4235053)

18 months agodtrace_asm.S: properly enter/exit user access
Mitchell Horne [Mon, 6 Feb 2023 18:04:21 +0000 (14:04 -0400)]
dtrace_asm.S: properly enter/exit user access

In order to read or write userspace memory without generating an access
fault, we must first enable the SUM bit in the sstatus CSR.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38298

(cherry picked from commit 0e563bde48b1af6bd472e940f04a8d76315749ab)

18 months agodtrace: handle page faults in riscv dtrace_trap()
Mitchell Horne [Mon, 6 Feb 2023 18:08:35 +0000 (14:08 -0400)]
dtrace: handle page faults in riscv dtrace_trap()

We must detect the correct amount to increment sepc, as it may have been
a compressed instruction that triggered the fault.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38299

(cherry picked from commit 06faad1de2c9aadcfd606d5f7121b201dbfbaa9d)

18 months agoUse maybe_yield() in a few more places
Mitchell Horne [Thu, 9 Feb 2023 15:42:53 +0000 (11:42 -0400)]
Use maybe_yield() in a few more places

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38186

(cherry picked from commit dc9b13736fce15ec3dc77a87e06d6406c92a0141)

18 months agoBoolify should_yield()
Mitchell Horne [Thu, 9 Feb 2023 15:35:11 +0000 (11:35 -0400)]
Boolify should_yield()

Do this ahead of adding a man page that describes the function. No
functional change.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38181

(cherry picked from commit d570418bd8918980e578ff78a229593766b832bb)

18 months agoUpdate comments referencing create_thread()
Mitchell Horne [Thu, 9 Feb 2023 15:34:38 +0000 (11:34 -0400)]
Update comments referencing create_thread()

The equivalent function is now named thread_create(). Mention
kthread_add() where it is also relevant.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38180

(cherry picked from commit a7a452fedc42d9e260224b7e2cd833df7287319f)

18 months agounbound: Fix config file path
Juraj Lutter [Tue, 17 Jan 2023 17:25:47 +0000 (18:25 +0100)]
unbound: Fix config file path

Commit 1838dec31895fd4752fa8631322ab93be0705a66 changed the
config file path to /usr/local/etc/unbound/unbound.conf which
is wrong for unbound in base.

Reported by: Ihor Antonov <ihor_AT_antonovs_family>
Reviewed by: zlei
Approved by: zlei
Differential Revision: https://reviews.freebsd.org/D38106

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66
(cherry picked from commit 1d577bedbae80ced38ccb834e6835e5fd98bc411)

18 months agounbound: Fix config.h
Cy Schubert [Sun, 15 Jan 2023 06:55:05 +0000 (22:55 -0800)]
unbound: Fix config.h

FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66

(cherry picked from commit 06b93ef8cda227d755d7f6cfa95d08c0ccc9dc2d)

18 months agounbound: Vendor import 1.17.1
Cy Schubert [Sun, 15 Jan 2023 05:39:31 +0000 (21:39 -0800)]
unbound: Vendor import 1.17.1

Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

(cherry picked from commit 1838dec31895fd4752fa8631322ab93be0705a66)

18 months agoheimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL
Cy Schubert [Tue, 7 Feb 2023 15:46:59 +0000 (07:46 -0800)]
heimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL

When the client sends kadmind a create principal (kadm_create) request
kadm_s_create_principal() returns an error before zeroing out ent (an
hdb entry structure wrapper -- hdb_entry_ex), resulting in a NULL
reference.

Fix obtained from upstream commit 35ea4955a.

PR: 268059
Reported by: Robert Morris <rtm@lcs.mit.edu>
Obtained from: Heimdal commit 35ea4955a

(cherry picked from commit 6a70e0b4cdc606931555cdc59dc6c8d4a3ab4e3e)

18 months agonetlink: add headers installation
Alexander V. Chernikov [Sat, 1 Oct 2022 16:31:58 +0000 (16:31 +0000)]
netlink: add headers installation

(cherry picked from commit 11ca01e9aa479559da240ceba17fdcdf2d1e97c3)

18 months agoahci: increase timout
Mariusz Zaborski [Fri, 10 Feb 2023 15:56:04 +0000 (16:56 +0100)]
ahci: increase timout

For some devices, like Marvell 88SE9230, it takes more time
to connect to the device. This patch introduces a special flag
that extends the timeout from around 100ms to around 500ms.

This change is based on the work of: Peter Eriksson <pen@lysator.liu.se>

PR: 243401
Reviewed by: imp
Tested by: dch
MFC after: 3 days
Sponsored by: Equinix
Sponsored by: SkunkWerks, GmbH
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38413

(cherry picked from commit f08ac4cb14c1c0740346a4363f82e1e1367c2bad)

18 months agotzcode: Resurrect tzsetwall(3) with a deprecation warning.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 18:35:34 +0000 (19:35 +0100)]
tzcode: Resurrect tzsetwall(3) with a deprecation warning.

This function has been around since 4.4BSD but was dropped upstream in 2020.  This went unnoticed when tzcode was updated.  Bring it back, but prepare for removing it before 14.0 is released.

PR: 269445
MFC after: 3 days
Reported by: val@packett.cool
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38445

(cherry picked from commit 71e0c8906e1a4ff774f8ae810aeb94af039eedb7)

18 months agossh: update to OpenSSH 9.2p1
Ed Maste [Mon, 6 Feb 2023 21:54:56 +0000 (16:54 -0500)]
ssh: update to OpenSSH 9.2p1

Release notes are available at https://www.openssh.com/txt/release-9.2

OpenSSH 9.2 contains fixes for two security problems and a memory safety
problem.  The memory safety problem is not believed to be exploitable.
These fixes have already been committed to OpenSSH 9.1 in FreeBSD.

Some other notable items from the release notes:

 * ssh(1): add a new EnableEscapeCommandline ssh_config(5) option that
   controls whether the client-side ~C escape sequence that provides a
   command-line is available. Among other things, the ~C command-line
   could be used to add additional port-forwards at runtime.

 * sshd(8): add support for channel inactivity timeouts via a new
   sshd_config(5) ChannelTimeout directive. This allows channels that
   have not seen traffic in a configurable interval to be
   automatically closed. Different timeouts may be applied to session,
   X11, agent and TCP forwarding channels.

 * sshd(8): add a sshd_config UnusedConnectionTimeout option to
   terminate client connections that have no open channels for a
   length of time. This complements the ChannelTimeout option above.

 * sshd(8): add a -V (version) option to sshd like the ssh client has.

 * scp(1), sftp(1): add a -X option to both scp(1) and sftp(1) to
   allow control over some SFTP protocol parameters: the copy buffer
   length and the number of in-flight requests, both of which are used
   during upload/download. Previously these could be controlled in
   sftp(1) only. This makes them available in both SFTP protocol
   clients using the same option character sequence.

 * ssh-keyscan(1): allow scanning of complete CIDR address ranges,
   e.g.  "ssh-keyscan 192.168.0.0/24". If a CIDR range is passed, then
   it will be expanded to all possible addresses in the range
   including the all-0s and all-1s addresses. bz#976

 * ssh(1): support dynamic remote port forwarding in escape
   command-line's -R processing. bz#3499

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f374ba41f55c1a127303d92d830dd58eef2f5243)

18 months agolocal-unbound-setup: Use default root certificates
Tijl Coosemans [Thu, 19 Jan 2023 17:13:35 +0000 (18:13 +0100)]
local-unbound-setup: Use default root certificates

Don't force /etc/ssl/cert.pem.  It does not exist by default, only if
security/ca_root_nss is installed.  Just use the default OpenSSL search
locations which are /etc/ssl/cert.pem and /etc/ssl/certs/.

The tls-system-cert option was added in Unbound 1.16.0.

Reviewed by: zlei
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38243

(cherry picked from commit 8932f7ce1783a10e9ba79c61d54077aa7693552e)

18 months agossh: fix SIZEOF_TIME_T #define on i386
Ed Maste [Wed, 8 Feb 2023 18:31:44 +0000 (13:31 -0500)]
ssh: fix SIZEOF_TIME_T #define on i386

Reported by: imp
Reviewed by: imp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38443

(cherry picked from commit 1aa9a35f6361cc898e2323e1f2823771eb4161da)

18 months agosbin/ping6: Remove remains of ping6.
Xin LI [Sun, 29 Jan 2023 23:21:25 +0000 (15:21 -0800)]
sbin/ping6: Remove remains of ping6.

(cherry picked from commit 195ec47b478a66fd935d59b2d189705f06f601cf)

18 months agorescue: Add fetch(1) to the rescue tool.
John Grafton [Sun, 29 Jan 2023 23:05:15 +0000 (15:05 -0800)]
rescue: Add fetch(1) to the rescue tool.

After a failed upgrade, having fetch(1) on a system that is
physically unnreachable would be very useful to download files
required to get the OS back up and functional.

On my system this adds 589,824 bytes (3.8%) to the binary size.

PR: 266224
Reported by: Dan Mahoney
Differential Revision: https://reviews.freebsd.org/D38193

(cherry picked from commit ea34aa4780e5a581732520ea579342af94684882)

rescue: Fix link order of SSL libraries and fetch.

ld.bfd requires libraries to be linked in order.  libssl requires
libcrypto.  libfetch requires libssl.  To fix the latter, move fetch
up above tar rather than listing the ssl libraries twice.

Reviewed by: delphij
Fixes: ea34aa4780e5 rescue: Add fetch(1) to the rescue tool.
Differential Revision: https://reviews.freebsd.org/D38304

(cherry picked from commit 0f031350f32b8760e0843a6476d67aa21116103b)

18 months agoFIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation
Konstantin Belousov [Sat, 4 Feb 2023 01:20:19 +0000 (03:20 +0200)]
FIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation

PR: 269261

(cherry picked from commit 3b6056204dd80cc866b7998ef0776247ebc42ce4)

18 months agonetlink: allow to override sb_max for netlink sockets.
Alexander V. Chernikov [Fri, 10 Feb 2023 16:07:17 +0000 (16:07 +0000)]
netlink: allow to override sb_max for netlink sockets.

Netlink sockets sometimes require larger buffers than other sockets.
For example, full-view IPv4 dump sent via netlink may consume 50+ megabytes.
The desired buffer may be bigger than the system maximum `sb_max`.
FreeBSD HEAD has a mechanism for overriding protocol `setsockopt()` handler,
 which netlink  uses to permit buffer reservations beyond `sb_max`.
 This behaviour is handy as it doesn't require system administrator to lift
 the limits for other sockets.
Stable/13 lack such muchanism, so a different approach has to be used.
This diff is a direct commit to stable/13 and it simply copies the logic from
 Netlink in -HEAD for checking if the larger buffer size should be permitted.

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

18 months agoRevert "netlink: allow to override sb_max for netlink sockets"
Alexander V. Chernikov [Fri, 10 Feb 2023 16:05:52 +0000 (16:05 +0000)]
Revert "netlink: allow to override sb_max for netlink sockets"

This reverts commit 4f81fdc0886f623043767866ebe4339bd12edf18.

18 months agonetlink: do not require elevated privileges when reading arp/ndp state.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:12:33 +0000 (14:12 +0000)]
netlink: do not require elevated privileges when reading arp/ndp state.

MFC after: 1 day

(cherry picked from commit 5a5436eb5d960b9e243f8196147c6a51ca4f9dee)

18 months agonetlink: allow to override sb_max for netlink sockets
Alexander V. Chernikov [Thu, 9 Feb 2023 21:36:43 +0000 (21:36 +0000)]
netlink: allow to override sb_max for netlink sockets

18 months agoefiserialio: use port settings (sio->Mode) for initial setup
Toomas Soome [Thu, 2 Feb 2023 14:01:02 +0000 (16:01 +0200)]
efiserialio: use port settings (sio->Mode) for initial setup

Use serial port setup done by system firmware.
ARM64 Hyper-V does hung if we attempt to override the defaults,
therefore we should default to use settings from firmware.

Tested by: schakrabarti@microsoft.com
PR: 266248
MFC after: 1 week

(cherry picked from commit c243de11cf7c4bb3d67bbc1655b149037e5b04f1)

18 months agoPost-13.2-branch updates
Colin Percival [Fri, 10 Feb 2023 00:38:08 +0000 (16:38 -0800)]
Post-13.2-branch updates

Rename stable/13 to -STABLE

Bump __FreeBSD_version

Approved by: re (implicit)
Sponsored by: https://www.patreon.com/cperciva

18 months agousr.sbin/kbdcontrol.c: Add backwards compatibility functions
Stefan Eßer [Mon, 6 Feb 2023 22:56:44 +0000 (23:56 +0100)]
usr.sbin/kbdcontrol.c: Add backwards compatibility functions

This commit allows a kbdcontrol binary built with a version of kbio.h
that supports Unicode characters in dead key maps to load and display
keymaps including the dead key tables on a kernel built with a
previous version of kbio.h (that only supported 8 bit characters in
the dead key map).

This commit is meant as a temporary compatibility shim that will be
reverted when it can be assumed that all relevant systems have been
upgraded to a kernel that uses the updated kbio.h.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38388

(cherry picked from commit b92f8e5c0dccd52ea194cabe835b7af0b5e91f09)

18 months agoSupport Unicode characters in keymap dead key tables
Stefan Eßer [Mon, 6 Feb 2023 22:48:47 +0000 (23:48 +0100)]
Support Unicode characters in keymap dead key tables

Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by: imp, brooks
Approved by: brooks
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38381

(cherry picked from commit 4972fb9276389fb87a790b415b1161cff395884c)

18 months agocontrib/bc: update to version 6.2.4
Stefan Eßer [Mon, 6 Feb 2023 21:33:56 +0000 (22:33 +0100)]
contrib/bc: update to version 6.2.4

This update contains only documentation changes (new main repository
URL and changed mail address of the program author) and changes to
the build system that do not affect the FreeBSD base system build.

MFC after: 3 days

(cherry picked from commit 4fca8e0f65a8bbbd1242c1f7d8e33b77c479f5de)

18 months agoipfilter: Fix use after free on packet with broken lengths
Cy Schubert [Thu, 2 Feb 2023 00:49:08 +0000 (16:49 -0800)]
ipfilter: Fix use after free on packet with broken lengths

Under the scenario with a packet with length of 67 bytes, a header length
using the default of 20 bytes and a TCP data offset (th_off) of 48 will
cause m_pullup() to fail to make sure bytes are arragned contiguously.
m_pullup() will free the mbuf chain and return a null. ipfilter stores
the resultant mbuf address (or the resulting NULL) in its fr_info_t
structure. Unfortuntely the eroneous packet is not flagged for drop.
This results in a kernel page fault at line 410 of sys/netinet/ip_fastfwd.c
as it tries to use a now previously freed, by m_pullup(), mbuf.

PR: 266442
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 79f7745c098a766d34a4e072cdd1a06e6d0829d5)

18 months agoipfilter: Correctly type ipf_pullup()
Cy Schubert [Tue, 31 Jan 2023 19:09:00 +0000 (11:09 -0800)]
ipfilter: Correctly type ipf_pullup()

ipf_pullup() outputs a pointer to ip_t. Though returning a pointer to
void does work, it is imprecise and not completely correct.

(cherry picked from commit c941e8c65d9df878136dc5d51d70256d33f7769f)

18 months agosqlite3: Vendor import of sqlite3 3.40.1
Cy Schubert [Fri, 6 Jan 2023 17:10:14 +0000 (09:10 -0800)]
sqlite3: Vendor import of sqlite3 3.40.1

Release notes at https://www.sqlite.org/releaselog/3_40_1.html.

Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz

Merge commit 'c728c97f5c838c9a873516c4499e4e1a41788ce7' into main

(cherry picked from commit 5ae830e9bacf120c5ab95d515814e2b815e839a6)

18 months agosockbufs: add sbreserve_locked_limit() with custom maxsockbuf limit.
Alexander V. Chernikov [Tue, 27 Sep 2022 13:52:11 +0000 (13:52 +0000)]
sockbufs: add sbreserve_locked_limit() with custom maxsockbuf limit.

Protocols such as netlink may need a large socket receive buffer,
 measured in tens of megabytes. This change allows netlink to
 set larger socket buffers (given the privs are in place), without
 requiring user to manuall bump maxsockbuf.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D36747

(cherry picked from commit 7b660faa9e30c15d3be9b2c44c3ca046a33331f4)

18 months agolibmd / md5: Add SHA-512/224.
Dag-Erling Smørgrav [Mon, 6 Feb 2023 16:57:36 +0000 (17:57 +0100)]
libmd / md5: Add SHA-512/224.

While there, remove .Tn from man pages.

Also remove an obsolete comment about the 80386.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D38373

(cherry picked from commit 2768d7056727c414241ebc4b9d26e62dd5460760)

18 months agosha512_224: Fix SHA512_224_Final() on little-endian machines.
Sebastian Huber [Mon, 6 Feb 2023 16:57:28 +0000 (17:57 +0100)]
sha512_224: Fix SHA512_224_Final() on little-endian machines.

PR: 266863
MFC after: 1 week
Reviewed by: allanjude, cperciva, des
Differential Revision: https://reviews.freebsd.org/D38372

(cherry picked from commit 6680cfe8e0eec4427716ab50d73ab8231dd9ab28)

18 months agocp: Add tests involving sparse files.
Dag-Erling Smørgrav [Wed, 1 Feb 2023 20:06:24 +0000 (21:06 +0100)]
cp: Add tests involving sparse files.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38290

(cherry picked from commit 822fa7ae1e3e7ed277e47e6de355387e524c6ee4)

cp: Simplify the common case.

* The allocated buffer is only used in the fallback case, so move it
  there.  The argument for passing it in from the caller was that if
  malloc(3) were to fail, we'd want it to fail before we started
  copying anything, but firstly, it was already not in the right place
  to ensure that, and secondly, malloc(3) never fails (except in very
  contrived circumstances, such as an unreasonable RLIMIT_AS or
  RLIMIT_DATA).

* Remove the mmap(2) option.  It is almost never beneficial,
  especially when the alternative is copy_file_range(2), and it adds
  needless complexity and indentation.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rmacklem, mav
Differential Revision: https://reviews.freebsd.org/D38291

(cherry picked from commit 6c85042afcbbf4cd0fb7e7c03226c7249081e690)

cp: Minor code cleanup.

* Fix includes in utils.c, cf. style(9).
* Fix type mismatch: readlink(2) returns ssize_t, not int.
* It is not necessary to set errno to 0 as fts_read(3) already does it.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D38369

(cherry picked from commit cb96a0ef0040fa7968245ab203ab70a7ed2d275d)

cp: Adjust the sparse file tests.

* The sparsity check was ineffective: it compared the apparent size in bytes to the actual size in blocks.  Instead, write a tool that reliably detects sparseness.
* Some of the seq commands were missing an argument.
* Based on empirical evidence, 1 MB holes are not necessarily large enough to be preserved by the underlying filesystem.  Increase the hole size to 16 MB.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: cracauer
Differential Revision: https://reviews.freebsd.org/D38414

(cherry picked from commit 8b418c83d175fde3b1f65210509ddcf2ac248d9f)

18 months agolibc: Add tests for strchrnul(3).
Dag-Erling Smørgrav [Wed, 1 Feb 2023 20:06:20 +0000 (21:06 +0100)]
libc: Add tests for strchrnul(3).

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D38286

(cherry picked from commit 606d0e4a9a862a7b4e3469a084834ca0e888afa4)

18 months agocmp: Print a summary on SIGINFO.
Dag-Erling Smørgrav [Tue, 31 Jan 2023 00:28:47 +0000 (01:28 +0100)]
cmp: Print a summary on SIGINFO.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38280

(cherry picked from commit 6673a5476d029cd5b47b2eed27032211a14f52bd)

cmp: Increase buffer size for non-mmap case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: rpokala
Differential Revision: https://reviews.freebsd.org/D38281

(cherry picked from commit 134841a7f3e5516a83732d40a4d42268c901a492)

18 months agow: Complete libxo transition.
Dag-Erling Smørgrav [Wed, 25 Jan 2023 06:21:13 +0000 (07:21 +0100)]
w: Complete libxo transition.

MFC after: 1 week
Sponsred by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38172

(cherry picked from commit d90ff31ae5cd9ba073fbd6a7b2367b5209ea534e)

w: Unlike err(3), xo_err(3) won't accept a null format string.

MFC after: 1 week
X-MFC-with: d90ff31ae5cd
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38192

(cherry picked from commit 6fc1bbbf62bda2f1b5be3a4be3d36bc964490ebe)

18 months agofind: Logic nit in man page.
Dag-Erling Smørgrav [Tue, 24 Jan 2023 08:53:35 +0000 (09:53 +0100)]
find: Logic nit in man page.

Arguments follow primaries, not the other way around.

MFC after: 1 week
Sponsored by: Klara, Inc.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38173

(cherry picked from commit 14ebab25e1231decd80a64194e9028a9ada8d6e6)

18 months agodf: Return non-zero status on write failure.
Dag-Erling Smørgrav [Tue, 17 Jan 2023 13:40:05 +0000 (14:40 +0100)]
df: Return non-zero status on write failure.

While here, complete the libxo conversion and switch return value to standard constants.

MFC after: 1 week
Sponsored by: Klara, Inc.
Differential revision: https://reviews.freebsd.org/D38097

(cherry picked from commit c968598479917f52022b86d0089a9835ddcf2799)

18 months agosbin/md5.c: fix -q -c for BSD style versions
Stefan Eßer [Tue, 26 Jul 2022 21:04:57 +0000 (23:04 +0200)]
sbin/md5.c: fix -q -c for BSD style versions

The BSD style commands (with names not ending in "sum") ignored the -c
options and the passed digest value when invoked with -q.

The man page stated that -q causes only the calculated digest to be
printed, but did not consider the case of both the -q and -c being
used in combination.

Since there is no warning that -c will be ignored when the -q option
is used, users night (and did) expect that the exit code would reflect
the matching of the calculated digest and the argument passed with -c.

This update implements and documents this expected behavior.

PR: 265461
Reported by: Dmitrij <bugs.freebsd@1fff.net>
MFC after: 2 weeks

(cherry picked from commit 9f3aa538e307743b2b5048d38f87b7fd32d0c596)

18 months agoupdate external URLs
Wolfram Schneider [Sat, 5 Feb 2022 08:19:56 +0000 (08:19 +0000)]
update external URLs

(cherry picked from commit 6981ec8bdff0f57833ab58747815e6e160eceaa2)

18 months agosockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().
Alexander V. Chernikov [Mon, 25 Jul 2022 19:46:40 +0000 (19:46 +0000)]
sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().

Implement Linux-variant of MSG_TRUNC input flag used in recv(), recvfrom() and recvmsg().
Posix defines MSG_TRUNC as an output flag, indicating packet/datagram truncation.
Linux extended it a while (~15+ years) ago to act as input flag,
resulting in returning the full packet size regarless of the input
buffer size.
It's a (relatively) popular pattern to do recvmsg( MSG_PEEK | MSG_TRUNC) to get the
packet size, allocate the buffer and issue another call to fetch the packet.
In particular, it's popular in userland netlink code, which is the primary driving factor of this change.

This commit implements the MSG_TRUNC support for SOCK_DGRAM sockets (udp, unix and all soreceive_generic() users).

PR: kern/176322
Reviewed by: pauamma(doc)
Differential Revision: https://reviews.freebsd.org/D35909
MFC after: 1 month

(cherry picked from commit be1f485d7d6bebc53b055cc165a11ada0ab5fb17)

18 months agomd5/tests: extend md5 test
Stefan Eßer [Mon, 6 Feb 2023 20:11:51 +0000 (21:11 +0100)]
md5/tests: extend md5 test

The testloop function is called with various parameters, but those
were ignored in the coreutils-c-test script. This was an oversight
and is fixed by passing the option to all invocations of the hash
functions in this test script.

Reported by: des
MFC after: 3 days

(cherry picked from commit d804497068c16bcb05383d7227d899f4ba59f706)

18 months agonetlink: allow path weight manipulations for single-path routes.
Alexander V. Chernikov [Sun, 29 Jan 2023 15:53:34 +0000 (15:53 +0000)]
netlink: allow path weight manipulations for single-path routes.

Add support for the scenario when user adds/deletes paths for a single
 prefix one-by-one, all with different weights.
This change adds a new FreeBSD-specific RTA attribute, NL_RTA_WEIGHT.
When dumping non-multipath routes, this attribute is added if the
 route weight is not RT_DEFAULT_WEIGHT.
When adding a new route, this attribute is parsed as a relative path
 weight.

MFC after: 2 weeks

(cherry picked from commit 3ebccb20d56455f4bef1366f942680d1b60828f6)

18 months agonetlink: export nextop group kernel index when dumping multipath route.
Alexander V. Chernikov [Sat, 28 Jan 2023 15:37:58 +0000 (15:37 +0000)]
netlink: export nextop group kernel index when dumping multipath route.

MFC after: 2 weeks

(cherry picked from commit 95b47ba6299401b487f29a05ac859629ee7d4f0b)

18 months agocarp: turn net.inet.carp.allow into a RW tunable
Boris Lytochkin [Sun, 29 Jan 2023 16:42:40 +0000 (16:42 +0000)]
carp: turn net.inet.carp.allow into a RW tunable

Currently CARP starts announcing its state when initialised, regardless
of the state of the other services provided by the server.
As a result, the device can become master while still loading the
firewall ruleset or initialising long-starting service.

This change adds the way to request delayed CARP start by setting the
  net.inet.carp.allow=0 in the loader.conf.

Differential Revision: https://reviews.freebsd.org/D38167
MFC after: 2 weeks

(cherry picked from commit ee49c5d33d93a6b10222f64a0dc16590ac2048a0)

18 months agonetlink: add "netlink" to the list of kernel features
Alexander V. Chernikov [Mon, 30 Jan 2023 11:13:51 +0000 (11:13 +0000)]
netlink: add "netlink" to the list of kernel features

Reduce the amount of debug messages on module init/detach.

MFC after: 1 week

(cherry picked from commit 7fc9cfa57ccd4ee8ee71f8edfacfc26afab9cd2e)

18 months agonetlink: add NETLINK to GENERIC.
Alexander V. Chernikov [Tue, 31 Jan 2023 14:22:11 +0000 (14:22 +0000)]
netlink: add NETLINK to GENERIC.

This is a followup of 692e19cf5195 (add netlink to GENERIC@amd64).

Netlink is a communication protocol defined in RFC 3549. It is async,
TLV-based protocol, providing 1-1 and 1-many communications between kernel
and userland. Netlink is currently used in Linux kernel to modify, read and
subscribe for nearly all networking states. Interface state, addresses, routes,
firewall, rules, fibs, etc, are controlled via Netlink.

Netlink support was added in D36002. It has got a number of improvements and
first customers since then:
* net/bird2 got netlink support, enabling route multipath in FreeBSD
* netlink-based devd notifications are being worked on ( D37574 ).
* linux(4) fully supports and depends on Netlink

Enabling Netlink in GENERIC targets two goals.
The first one is to provide stability for the third-party userland applications,
so they can rely on the fact that netlink always exists since 14.0 and potentially 13.2.
Loadable module makes life of the app delepers harder. For example, `net/bird2` can be
either build with netlink or rtsock support, but not both.

The second goal is to enable gradual conversion of the base userland tools
to use netlink(4) interfaces. Converting tools like netstat (D36529), route,
ifconfig one-by-one simplifies testing and addressing the feedback.
Othewise, switching all base to use netlink at once may be too big of a leap.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37783

(cherry picked from commit e80699a809a079c4e673940544d6ddd944e8d08e)

18 months agopytest: delete interfaces from inside the jail.
Alexander V. Chernikov [Wed, 25 Jan 2023 16:32:52 +0000 (16:32 +0000)]
pytest: delete interfaces from inside the jail.

This change follows the approach used in 80fc25025ffc, to
 minimise the impact of the delayed interface migration.

MFC after: 2 weeks

(cherry picked from commit 20ea7f26e41375828a390fba613b86acfe366add)

18 months agopytest: add an example test fetching test directory and ATF vars.
Alexander V. Chernikov [Wed, 25 Jan 2023 13:55:33 +0000 (13:55 +0000)]
pytest: add an example test fetching test directory and ATF vars.

MFC after: 2 weeks

(cherry picked from commit 864ea9abfb98493a157dc17be17c428080843bdd)

18 months agonetinet6: honor blackhole/unreach routes in the non-fastforwading code.
Alexander V. Chernikov [Sun, 22 Jan 2023 16:57:36 +0000 (16:57 +0000)]
netinet6: honor blackhole/unreach routes in the non-fastforwading code.

Currently, under the conditions specified below, IPv6 ingress packet
 processing can ignore blackhole/reject flag on the prefix. The packet
 will instead be looped locally till TTL expiration and a single ICMPv6
 unreachable message will be send to the source even in case of
 RTF_BLACKHOLE.
The following conditions needs hold to make the scenario happen:
* IPv6 forwarding is enabled
* Packet is not fast-forwarded
* Destination prefix has either RTF_BLACKHOLE or RTF_REJECT flag
Fix this behavior by checking for the blackhole/reject flags in
ip6_forward().

Reported by: Dmitriy Smirnov <fox@sage.su>
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D38164
MFC after: 3 days

(cherry picked from commit 30dd227cff75bdabaac2002a2b17095f3392a485)

18 months agoatf_pytest_wrapper: fix pytest output truncation
Jose Luis Duran [Wed, 28 Dec 2022 17:28:59 +0000 (17:28 +0000)]
atf_pytest_wrapper: fix pytest output truncation

Pass `-vv` to pytest in order to always get the full output.
While here, enforce the modeline.

Differential Revision: https://reviews.freebsd.org/D37894
MFC after: 2 weeks

(cherry picked from commit 058ac3e8063366dafa634d9107642e12b038bf09)

18 months agopytest: silence deprecation warning in the pytest atf wrapper
Jose Luis Duran [Wed, 28 Dec 2022 15:51:18 +0000 (15:51 +0000)]
pytest: silence deprecation warning in the pytest atf wrapper

Convert `pytest.mark` decorator to the `pytest.hookimpl()` one,
 as suggested by the
 https://docs.pytest.org/en/latest/deprecations.html#configuring-hook-specs-impls-using-markers

Differential Revision: https://reviews.freebsd.org/D37884
MFC after: 2 weeks

(cherry picked from commit eaeebfcb38599c94e89bbba3e9c7aeb821c84d71)

18 months agotests: Add an IPv4 loopback address of 127.0.0.1/8 to the lo0
Jose Luis Duran [Wed, 11 Jan 2023 14:33:58 +0000 (14:33 +0000)]
tests: Add an IPv4 loopback address of 127.0.0.1/8 to the lo0
 interface by default when creating VNETSs using pytest.

Reviewed By: asomers
Differential Revision: https://reviews.freebsd.org/D38021

(cherry picked from commit 4856aeaaed17726a1dfa5dd6c736e5b0851255b6)

18 months agoRead the arm64 far early in el0 exceptions
Andrew Turner [Wed, 25 Jan 2023 17:47:39 +0000 (17:47 +0000)]
Read the arm64 far early in el0 exceptions

When handling userspace exceptions on arm64 we need to dereference the
current thread pointer. If this is being promoted/demoted there is a
small window where it will cause another exception to be hit. As this
second exception will set the fault address register we will read the
incorrect value in the userspace exception handler.

Fix this be always reading the fault address before dereferencing the
current thread pointer.

Reported by: olivier@
Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D38196

(cherry picked from commit f29942229d24ebb8b98f8c5d02f3c8632648007e)

18 months agolinux(4): Attach netlink on i386.
Dmitry Chagin [Mon, 6 Feb 2023 14:00:44 +0000 (17:00 +0300)]
linux(4): Attach netlink on i386.

Discussed with: melifaro
MFC after: 3 days

(cherry picked from commit 07db1f36848c008efb7ab6b37e199212560833ae)

18 months agolinux(4): Microoptimize linux_ipc code to unindent else blocks.
Dmitry Chagin [Fri, 3 Feb 2023 16:17:34 +0000 (19:17 +0300)]
linux(4): Microoptimize linux_ipc code to unindent else blocks.

No functional change.

MFC after: 1 week

(cherry picked from commit eb08932156dc5801418924cf0bf9f167b15f7bf0)

18 months agolinux(4): Use designated initializers.
Dmitry Chagin [Fri, 3 Feb 2023 16:17:15 +0000 (19:17 +0300)]
linux(4): Use designated initializers.

MFC after: 1 week

(cherry picked from commit 3e0c56a717d6af3b680463b25388c7acd7cb8844)

18 months agolinux(4): Remove stale comment that no longer applies.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Remove stale comment that no longer applies.

MFC after: 1 week

(cherry picked from commit ce20c00e858f209f42d404eca597553e461e0892)

18 months agolinux(4): Microoptimize rt_sendsig() on amd64.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Microoptimize rt_sendsig() on amd64.

Drop proc lock earlier, before copying user stuff.

Pointed out by: kib
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38326
MFC after: 1 week

(cherry picked from commit 6ad07a4b2bdf0856545ff8495a7b3396695814fa)

18 months agolinux(4): Preserve fpu fxsave state across signal delivery on amd64.
Dmitry Chagin [Thu, 2 Feb 2023 17:21:37 +0000 (20:21 +0300)]
linux(4): Preserve fpu fxsave state across signal delivery on amd64.

PR: 240768
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38302
MFC after: 1 week

(cherry picked from commit a95cb95e12e537dbe70f9de18cc0fe98e4a5ebf5)

18 months agolinux(4): Deduplicate linux_trans_osrel().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_trans_osrel().

MFC after: 1 week

(cherry picked from commit 95b8603427d5759c5d6090ffaacfaf7f3b8fb926)

18 months agolinux(4): Deduplicate linux_copyout_strings().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_copyout_strings().

It is still present in the 32-bit Linuxulator on amd64.

MFC after: 1 week

(cherry picked from commit 6039e966ff276ff6bcb57f2f70e7d8ff376b24fd)

18 months agolinux(4): Deduplicate linux_fixup_elf().
Dmitry Chagin [Thu, 2 Feb 2023 14:58:07 +0000 (17:58 +0300)]
linux(4): Deduplicate linux_fixup_elf().

Use native routines to fixup initial process stack. On Arm64 linux_elf_fixup() is
noop, as it do the stack fixup (room for argc) in the linux_copyout_strings().

MFC after: 1 week

(cherry picked from commit 9e550625f867a23ea3d87a77aa3c216b79ecd790)

18 months agolinux(4): Add coredump support to i386.
Dmitry Chagin [Thu, 2 Feb 2023 14:58:06 +0000 (17:58 +0300)]
linux(4): Add coredump support to i386.

MFC after: 1 week

(cherry picked from commit cc1b0f7d9626bbd116429014444cbf61edf708a2)