]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 months agoAbstract UIO allocation and deallocation.
Alfredo Mazzinghi [Thu, 18 Jan 2024 13:04:41 +0000 (13:04 +0000)]
Abstract UIO allocation and deallocation.

Introduce the allocuio() and freeuio() functions to allocate and
deallocate struct uio. This hides the actual allocator interface, so it
is easier to modify the sub-allocation layout of struct uio and the
corresponding iovec array.

Obtained from: CheriBSD
Reviewed by: kib, markj
MFC after: 2 weeks
Sponsored by: CHaOS, EPSRC grant EP/V000292/1
Differential Revision: https://reviews.freebsd.org/D43711

4 months agoFix subr_uio.c style(9) with uses of sizeof.
Alfredo Mazzinghi [Wed, 17 Jan 2024 17:23:58 +0000 (17:23 +0000)]
Fix subr_uio.c style(9) with uses of sizeof.

Obtained from: CheriBSD
Reviewed by: jhb, kib, markj
MFC after: 2 weeks
Sponsored by: CHaOS, EPSRC grant EP/V000292/1
Differential Revision: https://reviews.freebsd.org/D43710

5 months agoread.2: Describe debug.iosize_max_clamp
Konstantin Belousov [Sat, 10 Feb 2024 09:40:07 +0000 (11:40 +0200)]
read.2: Describe debug.iosize_max_clamp

same as it is done for write.2.

PR: 276937
Reported by: bugs.freebsd.org@masklinn.net
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 months agotcp: stop timers and clean scoreboard in tcp_close()
Richard Scheffenegger [Sat, 10 Feb 2024 09:28:42 +0000 (10:28 +0100)]
tcp: stop timers and clean scoreboard in tcp_close()

Stop timers when in tcp_close() instead of doing that in tcp_discardcb().
A connection in CLOSED state shall not need any timers. Assert that no
timer is rescheduled after that in tcp_timer_activate() and verfiy that
this is also the expected state in tcp_discardcb().

PR: 276761
Reviewed By: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43792

5 months agotcp: stop doing superfluous work after sending RST
Richard Scheffenegger [Sat, 10 Feb 2024 09:24:10 +0000 (10:24 +0100)]
tcp: stop doing superfluous work after sending RST

When sending a RST control segment in tcp_output() it
means we are in TCPS_CLOSED state, called from tcp_drop().
Once the RST is sent, don't call tcp_timer_activate() or
update anything in tcpcb, since that will go away shortly.

PR: 276761
Provided by: glebius
Reviewed By: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43808

5 months agotcp: clean scoreboard when releasing the socket buffer
Richard Scheffenegger [Sat, 10 Feb 2024 09:16:08 +0000 (10:16 +0100)]
tcp: clean scoreboard when releasing the socket buffer

The SACK scoreboard is conceptually an extention of the socket
buffer. Remove it when the socket buffer goes away with
soisdisconnected(). Verify that this is also the expected
state in tcp_discardcb().

PR: 276761
Reviewed by: glebius, tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43805

5 months agocommitters-src: Extremely belatedly add myself
Jessica Clarke [Sat, 10 Feb 2024 06:07:14 +0000 (06:07 +0000)]
committers-src: Extremely belatedly add myself

5 months agoichsmb: add Cedar Fork PCI id
Kristof Provost [Fri, 9 Feb 2024 16:52:41 +0000 (17:52 +0100)]
ichsmb: add Cedar Fork PCI id

Sponsored by: Rubicon Communications, LLC ("Netgate")

5 months agocam: Check if cam_simq_alloc fails for the xpt bus during module init
John Baldwin [Fri, 9 Feb 2024 19:53:43 +0000 (11:53 -0800)]
cam: Check if cam_simq_alloc fails for the xpt bus during module init

This is very unlikely to fail (and if it does, CAM isn't going to work
regardless), but fail with an error rather than a gauranteed panic via
NULL pointer dereference.

PR: 276770
Reported by: Qiushi <w290680224@gmail.com>

5 months agopcib: Refine handling of resources allocated from bridge windows
John Baldwin [Fri, 9 Feb 2024 18:27:45 +0000 (10:27 -0800)]
pcib: Refine handling of resources allocated from bridge windows

Fix a long-standing layering violation in the original NEW_PCIB code
by not passing suballocated resources up to the parent bus for
activation and mapping.  Instead, handle activation and mapping of
sub-allocated resources in this driver.  When mapping resources,
request a mapping from a suitable sub-region of the resource allocated
from the parent bus for the associated bridge window.

Note that this does require passing RF_ACTIVE (with RF_UNMAPPED) when
allocating bridge window resources from the parent.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43690

5 months agopcib: Allocate PCI_RES_BUS resources with RF_ACTIVE
John Baldwin [Fri, 9 Feb 2024 18:27:45 +0000 (10:27 -0800)]
pcib: Allocate PCI_RES_BUS resources with RF_ACTIVE

The allocated bus numbers are in use so should be activated when
allocated.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43689

5 months agopcib: Make various bus methods private to pci_pci.c
John Baldwin [Fri, 9 Feb 2024 18:27:45 +0000 (10:27 -0800)]
pcib: Make various bus methods private to pci_pci.c

These functions are not used by pcib subclasses so do not need to
be exposed in pcib_private.h.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43688

5 months agoacpi: Cleanup handling of suballocated resources
John Baldwin [Fri, 9 Feb 2024 18:27:45 +0000 (10:27 -0800)]
acpi: Cleanup handling of suballocated resources

For resources suballocated from the system resource rmans, handle
those in the ACPI bus driver without passing them up to the parent.
This means using bus_generic_rman_* for several bus methods for
operations on suballocated resources.  For bus_map/unmap_resource,
find the system resource allocated from the parent bus (nexus) that
contains the range being mapped and request a mapping of that parent
resource.

This avoids a layering violation where nexus drivers were previously
asked to manage the activation and mapping of resources created
belonging to the ACPI resource managers.

Note that this does require passing RF_ACTIVE (with RF_UNMAPPED) when
allocating system resources from the parent.

While here, don't assume that the parent bus (nexus) provides a
resource list that sysres resources are placed on.  Instead, create a
dedicated resource_list in the ACPI bus driver's softc to hold sysres
resources.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43687

5 months agoacpi: Use bus_generic_alloc_resource instead of duplicating it
John Baldwin [Fri, 9 Feb 2024 18:27:45 +0000 (10:27 -0800)]
acpi: Use bus_generic_alloc_resource instead of duplicating it

No functional change, but it is cleaner to use the existing generic
wrappers rather than KOBJ methods directly.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43686

5 months agoacpi: Use kobj typedefs for new-bus method prototypes
John Baldwin [Fri, 9 Feb 2024 18:27:44 +0000 (10:27 -0800)]
acpi: Use kobj typedefs for new-bus method prototypes

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43685

5 months agobsdinstall: Add new Auto option to netconfig interface selection dialog
Jessica Clarke [Fri, 9 Feb 2024 18:13:47 +0000 (18:13 +0000)]
bsdinstall: Add new Auto option to netconfig interface selection dialog

This changes the OK / Cancel buttons into Auto / Manual / Cancel, with
Auto being the default. Manual behaves like OK used to, i.e. presents a
series of dialogs asking exactly how to configure the interface, and
Cancel is unchanged, exiting with exit code 1. Auto will attempt to
configure IPv4+DHCP and IPv6+SLAAC with no interaction, failing only if
neither can be configured, thereby supporting all of IPv4-only,
IPv6-only and dual-stack environments. If at least one DNS server is
provided, it will also skip asking for DNS settings, otherwise it will
act like Manual mode for the purposes of DNS settings and prompt. For a
standard dual-stack environment this cuts down the number of netconfig
dialogs from 6 (interface, IPv4, DHCP, IPv6, SLAAC, DNS) to just the
first one.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D43731

5 months agolibsys: add guards to MD manpages
Brooks Davis [Fri, 9 Feb 2024 17:21:15 +0000 (17:21 +0000)]
libsys: add guards to MD manpages

This avoids duplicate installations which fail packaging tests.

Reported by: emaste

5 months ago/etc/rc add trace debug and verify
Simon J. Gerraty [Fri, 9 Feb 2024 17:15:58 +0000 (09:15 -0800)]
/etc/rc add trace debug and verify

Debugging boot issues can be helped by
logging each rc.d script as it is run
and being able to selectively enable/disable set -x
debug.sh provides an elaborate framework for debugging shell scripts.

For secure systems, we want to be paranoid about what we read
during boot.

dot() simply reads (.) arg file if it exists
vdot() if mac_veriexec is active, ignore unverified files
otherwise behaves much the same as dot()
safe_dot()  in safe_eval.sh allows reading an untrusted file;
limiting the input to simple variable assignments.

In load_rc_config allow caller to provide an option to indicate how to
handle its arg:
-v use vdot()
-s use sdot() which will try to use vdot() and fallback to safe_dot()
The default is to read using dot()

rc_run_scripts()
encapsulate the running of rc.d scripts
so that we can easily call it more than twice.

We vdot local.rc.subr to pick up extensions (like
run_rc_scripts_final) and overrides.

We also allow rc.subr.local or rc.conf to set rc_config_xtra
eg (rc_config_xtra=XXX for historic compatibility)

rc use set -o verify around the reading in of rc.subr
This has no effect if mac_veriexec is not active, but if it is; ensures
rc.subr has not been tampered with.

Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43671

5 months agontb: Add Intel Xeon Gen4 support
Austin Zhang [Wed, 7 Feb 2024 18:55:02 +0000 (12:55 -0600)]
ntb: Add Intel Xeon Gen4 support

The NTB hardware of XEON Ice lake and Sapphire Rapids has register mapping changes
Add a new NTB_XEON_GEN4 device type and use it to conditionalize driver logic differs

Reviewed by: vangyzen, dab
Sponsored by: Dell Technologies
Differential Revision: https://reviews.freebsd.org/D43291

5 months agoarm64: Add a GENERIC-KMSAN kernel configuration
Alexander Stetsenko [Thu, 8 Feb 2024 19:28:17 +0000 (14:28 -0500)]
arm64: Add a GENERIC-KMSAN kernel configuration

Reviewed by: imp
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43153

5 months agofusefs: only test for incoherency if FN_SIZECHANGE is set
Emil Tsalapatis [Thu, 8 Feb 2024 01:13:43 +0000 (20:13 -0500)]
fusefs: only test for incoherency if FN_SIZECHANGE is set

FUSE emits spurious incoherency warnings in writethrough mode. The
warnings are triggered by setattr calls generated by vnode truncation
turning the cached va_size vattr stale, causing comparisons with the
fresh version provided by the server to fail. Only validate the vnode's
va_size vattr if the FN_SIZECHANGE flag is set.

This is a part of the research work at RCSLab, University of Waterloo.

Reviewed by: asomers
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/1110

5 months agoifconfig: a typo fixed in the man page
Maxim Konovalov [Fri, 9 Feb 2024 01:40:00 +0000 (01:40 +0000)]
ifconfig: a typo fixed in the man page

PR: 276878

5 months agolibsys: actually install manpages
Brooks Davis [Thu, 8 Feb 2024 18:21:56 +0000 (18:21 +0000)]
libsys: actually install manpages

In initial hacking I'd bluntly disabled manpage installation in libsys,
then later disabled them for libc, but forgot to fix the former leading
to no syscall manapages.

PR: 276887
Reported by: Martin Birgmeier <d8zNeCFG@aon.at>

5 months agolibsys: move some missed manpages
Brooks Davis [Thu, 8 Feb 2024 19:41:11 +0000 (19:41 +0000)]
libsys: move some missed manpages

Fixes: 29d079c96491 - libsys: move __libsys_interposer consumers

5 months agotcp: ensure tcp_sack_partialack does not inflate cwnd after RTO
Richard Scheffenegger [Thu, 8 Feb 2024 18:56:27 +0000 (19:56 +0100)]
tcp: ensure tcp_sack_partialack does not inflate cwnd after RTO

The implicit assumption of snd_nxt always being larger than
snd_recover is not true after RTO. In that case, cwnd
would get inflated to ssthresh, which may be much larger
than the current pipe (data in flight).

Reviewed By:           tuexen, #transport
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43653

5 months agoMerge commit f577bfb99528 from llvm-project (by Alexander Potapenko):
Dimitry Andric [Thu, 8 Feb 2024 19:19:27 +0000 (20:19 +0100)]
Merge commit f577bfb99528 from llvm-project (by Alexander Potapenko):

  [sanitizer][msan] fix AArch64 vararg support for KMSAN (#70660)

  Cast StackSaveAreaPtr, GrRegSaveAreaPtr, VrRegSaveAreaPtr to pointers to
  fix assertions in getShadowOriginPtrKernel().

Fixes: https://github.com/llvm/llvm-project/issues/69738
  Patch by Mark Johnston.

Requested by: markj
MFC after: 3 days

5 months agotcp: calculate ssthresh on RTO according to RFC5681
Richard Scheffenegger [Thu, 8 Feb 2024 18:12:19 +0000 (19:12 +0100)]
tcp: calculate ssthresh on RTO according to RFC5681

per RFC5681, only adjust ssthresh on the initital
retransmission timeout. Since RTO often happens
during loss recovery, while cwnd no longer tracks
all data in flight, calculcate pipe properly.

Reviewed By:           tuexen, #transport
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43768

5 months agotraceroute6: Update .PATH and include path after traceroute moved
Mark Johnston [Thu, 8 Feb 2024 17:57:33 +0000 (12:57 -0500)]
traceroute6: Update .PATH and include path after traceroute moved

Fixes: 9b7a920a12a9 ("traceroute: move from contrib to usr.sbin")

5 months agotcp: use tcp_fixed_maxseg instead of tcp_maxseg in cc modules
Richard Scheffenegger [Thu, 8 Feb 2024 16:56:29 +0000 (17:56 +0100)]
tcp: use tcp_fixed_maxseg instead of tcp_maxseg in cc modules

tcp_fixed_maxseg() is the streamlined calculation of typical
tcp options and more suitable for heavy use in the congestion
control modules on every received packet.

No external functional change.

Reviewed By:           tuexen, #transport
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43779

5 months agounix: retire LOCAL_CONNWAIT
Gleb Smirnoff [Thu, 8 Feb 2024 17:00:23 +0000 (09:00 -0800)]
unix: retire LOCAL_CONNWAIT

This socket option was added in 6a2989fd54a9 together with LOCAL_CREDS.
Both options originate from NetBSD.  The LOCAL_CREDS seems to be used by
some software and is covered by our test suite.

The main problem with LOCAL_CONNWAIT is that it doesn't work as
documented. A basic test shows that connect(2) indeed blocks, but
accept(2) on the other side does not wake it up.  Indeed, I don't see what
code in the accept(2) path would go into the peer socket of a unix/stream
listener's child and would make wakeup(&so->so_timeo).  I tried the test
even on a FreeBSD 6.4-RELEASE and it produced the same results as on
CURRENT.

The other thing that puzzles me is why that option would be useful even if
it worked? Because on unix/stream you can send(2) immediately after
connect(2) and that would put data on the peer receive buffer even before
listener had done accept(2). In other words, one side can do connect(2)
then send(2), only after the remote side would make accept(2) and the
remote would see the data sent before the accept(2).  Again this
undocumented feature of unix(4) is present on all versions from FreeBSD 6
to CURRENT.

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

5 months agotests/unix_passfd: add a comment for send_a_lot
Gleb Smirnoff [Thu, 8 Feb 2024 17:00:23 +0000 (09:00 -0800)]
tests/unix_passfd: add a comment for send_a_lot

Explain why SOCK_DGRAM and SOCK_STREAM differ in this edge case.  While
here improve output in case of a failure.

5 months agotests/unix_passfd: test that control mixed with data creates records
Gleb Smirnoff [Thu, 8 Feb 2024 17:00:23 +0000 (09:00 -0800)]
tests/unix_passfd: test that control mixed with data creates records

If socket has data interleaved with control it would never allow to read
two pieces of data, neither two pieces of control with one recvmsg(2).  In
other words, presence of control makes a SOCK_STREAM socket behave like
SOCK_SEQPACKET, where control marks the records. This is not a documented
or specified behavior, but this is how it worked always for BSD sockets.
If you look closer at it, this actually makes a lot of sense, as if it
were the opposite both the kernel code and an application code would
become way more complex.

The change made recvfd_payload() to return received length and requires
caller to do ATF_REQUIRE() itself.  This required a small change to
existing test rights_creds_payload.  It also refactors a bit f28532a0f363,
pushing two identical calls out of TEST_PROTO ifdef.

Reviwed by: markj
Differential Revision: https://reviews.freebsd.org/D43724

5 months agotests/unix_passfd: fix typos - assignment instead of comparison
Gleb Smirnoff [Thu, 8 Feb 2024 17:00:23 +0000 (09:00 -0800)]
tests/unix_passfd: fix typos - assignment instead of comparison

This typos were actually hiding a kernel bug, see 541e6a989cae.

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

5 months agounix/stream: do not put empty mbufs on the socket
Gleb Smirnoff [Thu, 8 Feb 2024 17:00:23 +0000 (09:00 -0800)]
unix/stream: do not put empty mbufs on the socket

It is a legitimate case to use sendmsg(2) to send control only, with zero
bytes of data and then recvmsg(2) them with zero length iov, receiving
control only.  This sendmsg(2)+recmsg(2) would leave a zero length mbuf on
the top of the socket buffer.  If you now try to repeat this combo again,
your recvmsg(2) would not return control data, because it sits behind an
MT_DATA mbuf and you have provided zero length uio_resid. IMHO, best
strategy to deal with zero length buffers in a chain is to not put them
there in the first place.  Thus, solve this right in uipc_send() instead
of touching soreceive_generic().

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

5 months agotraceroute: remove rcsid tags
Lexi Winter [Sat, 3 Feb 2024 13:24:26 +0000 (13:24 +0000)]
traceroute: remove rcsid tags

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1100

5 months agotraceroute: remove configuration #defines
Lexi Winter [Sat, 3 Feb 2024 13:19:03 +0000 (13:19 +0000)]
traceroute: remove configuration #defines

traceroute used a series of #defines to specify what features are
available on the host platform.  As traceroute is now in source, these
are unnecessary and complicate the code, so remove them.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1100

5 months agotraceroute: move from contrib to usr.sbin
Lexi Winter [Sat, 3 Feb 2024 13:10:09 +0000 (13:10 +0000)]
traceroute: move from contrib to usr.sbin

traceroute hasn't had a vendor import since 2002, while since then it's
had several significant FreeBSD-specific commits.  Since it's unlikely
another vendor import will happen, and to make the merge of traceroute6
into traceroute easier, import traceroute into usr.sbin.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1100

5 months agoarm64: Add pmap integration for KMSAN
Mark Johnston [Thu, 8 Feb 2024 16:11:02 +0000 (11:11 -0500)]
arm64: Add pmap integration for KMSAN

- In pmap_bootstrap_san(), allocate the root PTPs for the shadow maps.
  (For KASAN, this is done earlier since we need to do some special
  bootstrapping for the kernel stack.)
- Adjust ifdefs to include KMSAN.
- Expand the shadow maps when pmap_growkernel() is called.

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43405

5 months agoarm64: Simplify and improve KASAN shadow map bootstrapping
Mark Johnston [Thu, 8 Feb 2024 16:10:43 +0000 (11:10 -0500)]
arm64: Simplify and improve KASAN shadow map bootstrapping

- Move pmap_bootstrap_allocate_kasan_l2() close to the place where it is
  actually used.
- Simplify pmap_bootstrap_allocate_kasan_l2() a bit: eliminate some
  unneeded variables and zero and exclude each 2MB mapping as we go
  rather than doing that all at once.  Excluded regions will be
  coalesced.
- As a consequence of the previous point, ensure that we do not zero a
  preexisting 2MB mapping.
- Simplify pmap_bootstrap_san() and prepare it to work with KMSAN.

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43404

5 months agoarm64: Enable KMSAN when configured to do so
Alexander Stetsenko [Thu, 8 Feb 2024 16:04:52 +0000 (11:04 -0500)]
arm64: Enable KMSAN when configured to do so

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.

5 months agokmsan: Update kmsan.9 to note arm64 support
Mark Johnston [Thu, 8 Feb 2024 16:04:08 +0000 (11:04 -0500)]
kmsan: Update kmsan.9 to note arm64 support

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.

5 months agoarm64: Disable kernel superpage promotion when KMSAN is configured
Mark Johnston [Thu, 8 Feb 2024 16:02:48 +0000 (11:02 -0500)]
arm64: Disable kernel superpage promotion when KMSAN is configured

The break-before-make operation required to promote or demote a
superpage leaves a window where the KMSAN runtime can trigger a fatal
data abort.  More specifically, the code in pmap_update_entry() which
executes after ATTR_DESCR_VALID is cleared may implicitly attempt to
access KMSAN context via curthread, but we may be promoting or demoting
a 2MB page containing the curthread structure.

Reviewed by: imp
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43158

5 months agoarm64: Implement busdma bits for KMSAN
Mark Johnston [Thu, 8 Feb 2024 16:01:55 +0000 (11:01 -0500)]
arm64: Implement busdma bits for KMSAN

This works identically to amd64.  In particular, only the
bus_dma_bounce_impl busdma implementation handles KMSAN at the moment.

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43157

5 months agoarm64: Add msan.h
Mark Johnston [Thu, 8 Feb 2024 16:00:40 +0000 (11:00 -0500)]
arm64: Add msan.h

This is mostly a copy of amd64's msan.h, except that we currently do not
avoid shadowing the kernel itself, and we need a more restrictive upper
bound in kmsan_md_unsupported() to avoid probing non-existent shadow
mappings of device mappings.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43156

5 months agoarm64: Make KMSAN aware of exceptions
Mark Johnston [Thu, 8 Feb 2024 15:57:36 +0000 (10:57 -0500)]
arm64: Make KMSAN aware of exceptions

- Call kmsan_intr_enter() when an exception occurs.  This ensures that
  code running in the exception context does not clobber thread-local
  KMSAN state.
- Ensure that stack memory containing trap frames is treated as
  initialized.

Co-authored-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com>
Reviewed by: imp
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43155

5 months agoarm64: Define shadow maps for KMSAN
Mark Johnston [Thu, 8 Feb 2024 15:56:58 +0000 (10:56 -0500)]
arm64: Define shadow maps for KMSAN

Both are the same size as the kernel map.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D43154

5 months agock/aarch64: Specify output operands for ck_pr_md_store_*
Mark Johnston [Thu, 8 Feb 2024 15:53:10 +0000 (10:53 -0500)]
ck/aarch64: Specify output operands for ck_pr_md_store_*

This is a backport of upstream commit d1e9f03b89:

    ck_pr/aarch64: Specify output operands for ck_pr_md_store_*

    As in commit 2f9acab, we want to specify output operand widths so that
    MSAN compiler instrumentation correctly updates the shadow map.  In
    particular, LLVM's implementation depends on having type information for
    output operands, even when that's not otherwise necessary.  Without it,
    KMSAN in FreeBSD generates false positives on aarch64.

Reviewed by: cognet
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.

5 months agokmsan: Add some additional bus_space accessors
Mark Johnston [Thu, 8 Feb 2024 15:40:11 +0000 (10:40 -0500)]
kmsan: Add some additional bus_space accessors

These are needed for arm64 support.

Co-authored-by: Alexander Stetsenko <alex.stetsenko@klarasystems.com>
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.

5 months agoarm64: Fix the unwind.c build when sanitizers are enabled
Mark Johnston [Thu, 8 Feb 2024 15:39:40 +0000 (10:39 -0500)]
arm64: Fix the unwind.c build when sanitizers are enabled

The presence of -fno-sanitize-memory-param-retval without an
accompanying -fsanitize=kernel-memory triggers a compiler error.

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.

5 months agozfs: merge openzfs/zfs@229b9f4ed
Martin Matuska [Thu, 8 Feb 2024 12:39:04 +0000 (13:39 +0100)]
zfs: merge openzfs/zfs@229b9f4ed

Notable upstream pull request merges:
 #15769 082338875 Add 'zpool status -e' flag to see unhealthy vdevs
 #15804 a0d3fe72b libzdb: Initial breakout of libzdb
 #15847 229b9f4ed LUA: Backport CVE-2020-24370's patch

Obtained from: OpenZFS
OpenZFS commit: 229b9f4ed05e6d14fb4d73fa04a71e99b01bb534

5 months agosystat(1): Plug memory leak
Hiroki Sato [Thu, 8 Feb 2024 06:45:04 +0000 (15:45 +0900)]
systat(1): Plug memory leak

The procstat_getprocs() function call in procgetinfo() allocated
a buffer but it was not freed properly.

5 months agorelease: Add AZURE to CLOUDWARE
Li-Wen Hsu [Thu, 8 Feb 2024 05:49:01 +0000 (13:49 +0800)]
release: Add AZURE to CLOUDWARE

Let Azure use the image directly built by the release engineering team.

Reviewed by: emaste
Approved by: cperciva (re)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41906

5 months agorescue: Don't explicitly link with libsys
Brooks Davis [Wed, 7 Feb 2024 19:58:33 +0000 (19:58 +0000)]
rescue: Don't explicitly link with libsys

libpthread contains the symbols we need when statically linked.  This
was a leftover from a prior version of ef9871c6205c that I failed to
remove before I pushed.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43782

5 months agoLUA: Backport CVE-2020-24370's patch
the-Chain-Warden-thresh [Wed, 7 Feb 2024 19:53:05 +0000 (03:53 +0800)]
LUA: Backport CVE-2020-24370's patch

CVE-2020-24370 is a security vulnerability in lua. Although the CVE
description in CVE-2020-24370 said that this CVE only affected lua
5.4.0, according to lua this CVE actually existed since lua 5.2. The
root cause of this CVE is the negation overflow that occurs when you
try to take the negative of 0x80000000. Thus, this CVE also exists in
openzfs. Try to backport the fix to the lua in openzfs since the
original fix is for 5.4 and several functions have been changed.

https://github.com/advisories/GHSA-gfr4-c37g-mm3v
https://nvd.nist.gov/vuln/detail/CVE-2020-24370
https://www.lua.org/bugs.html#5.4.0-11
https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb1786

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: ChenHao Lu <18302010006@fudan.edu.cn>
Closes #15847

5 months agoBelatedly bump __FreeBSD_version for libsys
Brooks Davis [Wed, 7 Feb 2024 19:45:27 +0000 (19:45 +0000)]
Belatedly bump __FreeBSD_version for libsys

5 months agolibthr: filter rather than link with libsys
Brooks Davis [Wed, 7 Feb 2024 19:38:16 +0000 (19:38 +0000)]
libthr: filter rather than link with libsys

The allows gcc + GNU ld to link programs with -m32 -pthread without
erroring out due to _umtx_op_err being undefined (unless -lsys is added
to the link command.

We now always link _umtx_op_err into libthr (not just when it's static)
and filter it with libsys so we call that implementation.  The dynamic
implementations (at least the assembly ones) should likely become stubs
as a further refinement.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43783

5 months agolibc: don't directly link libsys
Brooks Davis [Wed, 7 Feb 2024 19:37:55 +0000 (19:37 +0000)]
libc: don't directly link libsys

It is sufficent to add it as a filter.

Reported by: kib
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43781

5 months agoAdd 'zpool status -e' flag to see unhealthy vdevs
Cameron Harr [Wed, 7 Feb 2024 17:12:12 +0000 (09:12 -0800)]
Add 'zpool status -e' flag to see unhealthy vdevs

When very large pools are present, it can be laborious to find
reasons for why a pool is degraded and/or where an unhealthy vdev
is. This option filters out vdevs that are ONLINE and with no errors
to make it easier to see where the issues are. Root and parents of
unhealthy vdevs will always be printed.

Testing:
ZFS errors and drive failures for multiple vdevs were simulated with
zinject.

Sample vdev listings with '-e' option
- All vdevs healthy
    NAME        STATE     READ WRITE CKSUM
    iron5       ONLINE       0     0     0

- ZFS errors
    NAME        STATE     READ WRITE CKSUM
    iron5       ONLINE       0     0     0
      raidz2-5  ONLINE       1     0     0
        L23     ONLINE       1     0     0
        L24     ONLINE       1     0     0
        L37     ONLINE       1     0     0

- Vdev faulted
    NAME        STATE     READ WRITE CKSUM
    iron5       DEGRADED     0     0     0
      raidz2-6  DEGRADED     0     0     0
        L67     FAULTED      0     0     0  too many errors

- Vdev faults and data errors
    NAME        STATE     READ WRITE CKSUM
    iron5       DEGRADED     0     0     0
      raidz2-1  DEGRADED     0     0     0
        L2      FAULTED      0     0     0  too many errors
      raidz2-5  ONLINE       1     0     0
        L23     ONLINE       1     0     0
        L24     ONLINE       1     0     0
        L37     ONLINE       1     0     0
      raidz2-6  DEGRADED     0     0     0
        L67     FAULTED      0     0     0  too many errors

- Vdev missing
    NAME        STATE     READ WRITE CKSUM
    iron5       DEGRADED     0     0     0
      raidz2-6  DEGRADED     0     0     0
        L67     UNAVAIL      3     1     0

- Slow devices when -s provided with -e
    NAME        STATE     READ WRITE CKSUM  SLOW
    iron5       DEGRADED     0     0     0     -
      raidz2-5  DEGRADED     0     0     0     -
        L10     FAULTED      0     0     0     0  external device fault
        L51     ONLINE       0     0     0    14

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Cameron Harr <harr1@llnl.gov>
Closes #15769

5 months agogicv3_its: Drop a couple of redundant vm_offset_t casts
Jessica Clarke [Wed, 7 Feb 2024 16:24:34 +0000 (16:24 +0000)]
gicv3_its: Drop a couple of redundant vm_offset_t casts

These are already vm_offset_t, no need to cast.

5 months agovmm: Expose more registers to VM_GET_REGISTER
Mark Johnston [Wed, 7 Feb 2024 13:47:24 +0000 (08:47 -0500)]
vmm: Expose more registers to VM_GET_REGISTER

In a follow-up revision the gdb stub will support sending an XML target
description to gdb, which lets us send additional registers, including
the ones added in this patch.

Reviewed by: jhb
MFC after: 1 month
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D43665

5 months agobhyve: Add support for the 'p' query
Mark Johnston [Wed, 7 Feb 2024 13:46:59 +0000 (08:46 -0500)]
bhyve: Add support for the 'p' query

This lets gdb query individual registers.  It's easy to implement and is
used by gdb when attaching to a CHERI target, so let's support it.

Sponsored by: Innovate UK
Reviewed by: corvink, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43664

5 months agoacpica: Fix my mismerge
Warner Losh [Wed, 7 Feb 2024 05:47:42 +0000 (22:47 -0700)]
acpica: Fix my mismerge

I merged in the limits.h include. I should have resolved this by
deleting it (since we have no easy way to 'fix' it with compat headers).
GENERIC doesn't bring in the debugger, but LINT does...

Sponsored by: Netflix

5 months agoBelatedly update version and date for sendmail 8.18.1 upgrade
Gregory Neil Shapiro [Wed, 7 Feb 2024 02:03:47 +0000 (02:03 +0000)]
Belatedly update version and date for sendmail 8.18.1 upgrade

5 months agolib/libc: version auxiliary libsys.so
Brooks Davis [Wed, 7 Feb 2024 00:46:38 +0000 (00:46 +0000)]
lib/libc: version auxiliary libsys.so

We need to use libsys.so.7 so that we can work without /usr and because
we're bound a specific ABI.

Reported by: jtrc27, kib
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43772

5 months agolibsys: fix powerpcspe build
Brooks Davis [Wed, 7 Feb 2024 00:46:33 +0000 (00:46 +0000)]
libsys: fix powerpcspe build

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D43771

5 months agoleapseconds: Update to the canonical place.
Warner Losh [Tue, 6 Feb 2024 23:11:38 +0000 (16:11 -0700)]
leapseconds: Update to the canonical place.

IERS is the source of truth for leap seconds. Their leapsecond file is
updated most quickly and is always right (unlike the IANA one which
often lags). IERS operates this public service for the express purpose
of random people downloading it. Their terms of service are compatible
with open source (we could include this in our release). Rather than
fighting with questions around this because the IANA one changed
locations or the auto update script broken, just use this.

This is in preference to the NIST ftp copy. NIST is in the process of
retiring their FTP services.

Sponsored by: Netflix
Reviewed by: philip, delphij, cy
Differential Revision: https://reviews.freebsd.org/D43752

5 months agoarm: Move locore-v6.S to locore.S
Warner Losh [Tue, 6 Feb 2024 22:46:06 +0000 (15:46 -0700)]
arm: Move locore-v6.S to locore.S

As a separate commit, now move locore-v6.S to locore.S. This makes git
annotate work, at least back to 2014 when Ian created locore-v6.S. svn
didn't save enough metadata for the converter to allow it to go back
further.

Sponsored by: Netflix

5 months agoarm: Use locore-v6.S directly
Warner Losh [Tue, 6 Feb 2024 22:42:03 +0000 (15:42 -0700)]
arm: Use locore-v6.S directly

Use locore-v6.S directly, rather than indirectly via including
locore.S. This loses acle-compat.h inclusion, but that's only needed for
gcc 4.8 and earlier. Since we don't support anything that old, there's
no need for it here.

Sponsored by: Netflix

5 months agoarm: Catchup to atmel retirement
Warner Losh [Tue, 6 Feb 2024 22:26:17 +0000 (15:26 -0700)]
arm: Catchup to atmel retirement

AT91 boot2 loaders have been long gone, and don't support the AT91 parts
that have armv7 cores (since we don't have specific support for
that). Mentioning its interface is OBE, so remove it.

Sponsored by: Netflix

5 months agoddb: Remove useless includes
Warner Losh [Tue, 6 Feb 2024 22:20:02 +0000 (15:20 -0700)]
ddb: Remove useless includes

systm.h was included for boothowto here, but it's not used here, so drop
this include. Also sys/cdefs.h isn't needed, drop it too.

Sponsored by: Netflix

5 months agovnic: fix compilation of an IPv6 only kernel
Michael Tuexen [Tue, 6 Feb 2024 21:47:16 +0000 (22:47 +0100)]
vnic: fix compilation of an IPv6 only kernel

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

5 months agogit-arc: Retain color status messages
Warner Losh [Tue, 6 Feb 2024 21:16:51 +0000 (14:16 -0700)]
git-arc: Retain color status messages

Newer versions of archanist have an --ansi option to always include the
ansi colors when doing an arc list (or any command really). Add this to
the arc list that's relevant. Add filter to filter out the 'bolding'
though since that interferes with our parsing. This should restore the
color output after df834e06bbc7.

Fixes: df834e06bbc7
Sponsored by: Netflix
Reviewed by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D43459

5 months agolibcompat: silence -Wdeprecated-non-prototype
Piotr Pawel Stefaniak [Sat, 3 Feb 2024 18:12:42 +0000 (19:12 +0100)]
libcompat: silence -Wdeprecated-non-prototype

by removing unnecessary re-declarations and converting K&R-style
function definitions.

Differential Revision: https://reviews.freebsd.org/D43723
Reviewed by: imp, emaste

5 months agopf: add a probe point to BOUND_IFACE
Kristof Provost [Fri, 2 Feb 2024 20:51:50 +0000 (21:51 +0100)]
pf: add a probe point to BOUND_IFACE

It's been useful at least once, so we may as well keep it.

Sponsored by: Rubicon Communications, LLC ("Netgate")

5 months agoRevert "hier.7: add /lib/casper directory"
Konstantin Belousov [Tue, 6 Feb 2024 04:48:16 +0000 (06:48 +0200)]
Revert "hier.7: add /lib/casper directory"

This reverts commit 407345752d0330766c86b5600740152c34be3ff0.
No longer needed since helpers are moved to /lib.

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D43758

5 months agopf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex
Kajetan Staszkiewicz [Mon, 5 Feb 2024 16:22:31 +0000 (17:22 +0100)]
pf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex

The redirection pool stored in r->rpool.cur is used for loadbalancing
and cur can change whenever loadbalancing happens, which is for every
new connection. Therefore it can't be trusted outside of pf_map_addr()
and the r->rpool->mtx mutex. After evaluating the ruleset, loadbalancing
decission is made in pf_map_addr() called from within pf_create_state()
and stored in the state itself.

This patch modifies BOUND_IFACE() so that it only uses the information
already stored in the state which has been obtained in a way which
respects the r->rpool->mtx mutex.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D43741

5 months agoRevert "pf: Ensure that st->kif is obtained in a way which respects the r->rpool...
Kristof Provost [Tue, 6 Feb 2024 16:22:59 +0000 (17:22 +0100)]
Revert "pf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex"

This commit is correct, but was misattributed. Revert so we can re-apply
with the correct author set.

This reverts commit 6d4a140acfdf637bb559d371c583e4db478e1549.

5 months agovmm: Fix compiling error with BHYVE_SNAPSHOT
Vitaliy Gusev [Tue, 6 Feb 2024 15:36:17 +0000 (10:36 -0500)]
vmm: Fix compiling error with BHYVE_SNAPSHOT

The return values of copyin() and copyout() must be checked.
vm_snapshot_buf_cmp() is unused by the kernel and was incorrectly
implemented, so just remove it.

Reviewed by: markj
Sponsored by: vStack
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43754

5 months agoarm64: Add netmap(4) to default kernel config
Daniel Roethlisberger [Tue, 6 Feb 2024 15:26:13 +0000 (10:26 -0500)]
arm64: Add netmap(4) to default kernel config

Allows the development, testing and deployment of netmap(4)-based code
on arm64 without having to recompile the kernel.  netmap(4) is already
in the amd64 and powerpc64 default configs, so it does not seem
unreasonable to also provide it on arm64 by default.

Note that netmap(4) is useful even on systems without NIC that fully
support it.

Reviewed by: vmaffione
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D43702

5 months agomsgs: Use C99 bool instead of defining our own
Collin Funk [Tue, 6 Feb 2024 12:40:05 +0000 (04:40 -0800)]
msgs: Use C99 bool instead of defining our own

Use stdbool.h definitions instead of defining non-standard ones.

Signed-off-by: Collin Funk <collin.funk1@gmail.com>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1105

5 months agofix poweroff regression from 9cdf326b4f by delaying shutdown_halt
Andriy Gapon [Tue, 6 Feb 2024 08:55:13 +0000 (10:55 +0200)]
fix poweroff regression from 9cdf326b4f by delaying shutdown_halt

The regression affected ACPI-based systems without EFI poweroff support
(including VMs).

The key reason for the regression is that I overlooked that poweroff is
requested by RB_POWEROFF | RB_HALT combination of flags.  In my opinion,
that command is a bit bipolar, but since we've been doing that forever,
then so be it.  Because of that flag combination, the order of
shutdown_final handlers that check for either flag does matter.

Some additional complexity comes from platform-specific shutdown_final
handlers that aim to handle multiple reboot options at once.  E.g.,
acpi_shutdown_final handles both poweroff and reboot / reset.  As
explained in 9cdf326b4f, such a handler must run after shutdown_panic to
give it a chance.  But as the change revealed, the handler must also run
before shutdown_halt, so that the system can actually power off before
entering the halt limbo.

Previously, shutdown_panic and shutdown_halt had the same priority which
appears to be incompatible with handlers that can do both poweroff and
reset.

The above also applies to power cycle handlers.

PR: 276784
Reported by: many
Tested by: Katsuyuki Miyoshi <katsubsd@gmail.com>,
Masachika ISHIZUKA <ish@amail.plala.or.jp>
Fixes: 9cdf326b4fae run acpi_shutdown_final later to give other handlers a chance
MFC after: 1 week

5 months agoofed: fix warnings during libibverbs compilation
Bartosz Sobczak [Tue, 6 Feb 2024 02:43:48 +0000 (18:43 -0800)]
ofed: fix warnings during libibverbs compilation

create_qp_handle_resp_common_cleanup should be void
__ibv_cleanup_wq should use wq->cond for cond destroy
both issues were overlooked in:
a687910 ('Cleanup pthread locks in ofed RDMA verbs')

Signed-off-by: Bartosz Sobczak <bartosz.sobczak@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: sean.lim@dell.com, vangyzen@, erj@
MFC after: 1 day
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D43491

5 months agoBRT: Fix FICLONE/FICLONERANGE shortened copy
Brian Behlendorf [Tue, 6 Feb 2024 00:44:45 +0000 (16:44 -0800)]
BRT: Fix FICLONE/FICLONERANGE shortened copy

On Linux the ioctl_ficlonerange() and ioctl_ficlone() system calls
are expected to either fully clone the specified range or return an
error.  The range may be for an entire file.  While internally ZFS
supports cloning partial ranges there's no way to return the length
cloned to the caller so we need to make this all or nothing.

As part of this change support for the REMAP_FILE_CAN_SHORTEN flag
has been added.  When REMAP_FILE_CAN_SHORTEN is set zfs_clone_range()
will return a shortened range when encountering pending dirty records.
When it's clear zfs_clone_range() will block and wait for the records
to be written out allowing the blocks to be cloned.

Furthermore, the file range lock is held over the region being cloned
to prevent it from being modified while cloning.  This doesn't quite
provide an atomic semantics since if an error is encountered only a
portion of the range may be cloned.  This will be converted to an
error if REMAP_FILE_CAN_SHORTEN was not provided and returned to the
caller.  However, the destination file range is left in an undefined
state.

A test case has been added which exercises this functionality by
verifying that `cp --reflink=never|auto|always` works correctly.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #15728
Closes #15842

5 months agospeaker: Use standard C bool
John Baldwin [Mon, 5 Feb 2024 23:40:34 +0000 (15:40 -0800)]
speaker: Use standard C bool

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

5 months agoi386: Use bool for booleans in getmemsize
John Baldwin [Mon, 5 Feb 2024 23:39:31 +0000 (15:39 -0800)]
i386: Use bool for booleans in getmemsize

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

5 months agofib_algo(4): Lower level of algorithm switching messages to LOG_INFO
Marius Strobl [Mon, 5 Feb 2024 19:36:13 +0000 (20:36 +0100)]
fib_algo(4): Lower level of algorithm switching messages to LOG_INFO

Otherwise, with the default flm_debug_level of LOG_NOTICE, it's rather
easy to trigger debug messages such as:
[fib_algo] inet.0 (bsearch4#18) rebuild_fd_flm: switching algo to
radix4_lockless

Also, the "severity" of these events generally only justifies LOG_INFO
and not LOG_NOTICE.

Reviewed by: melifaro

5 months agosdhci_fsl_fdt(4): Actually use modified SDHCI capabilities
Marius Strobl [Mon, 5 Feb 2024 19:08:33 +0000 (20:08 +0100)]
sdhci_fsl_fdt(4): Actually use modified SDHCI capabilities

SDHCI_QUIRK_MISSING_CAPS needs to be set unconditionally so sdhci(4)
adheres to the slot caps and caps2 set by sdhci_fsl_fdt(4). However,
so far this bug didn't have an impact as the front-end only filters
SDHCI_CAN_DO_SUSPEND, which in turn isn't used, yet.

5 months agoacpica: Create merge commit against vendor branch
Warner Losh [Mon, 5 Feb 2024 22:13:57 +0000 (15:13 -0700)]
acpica: Create merge commit against vendor branch

Merge tracking branch 'vendor/acpica' for vendor/acpica/20230628, and
resolve conflicts.

This deletes files that we've deleted since the last merge (during SVN
times it seems) so future merges don't bring them up.

It resolves conflicts in several files that we have modified (but we can
likely fix the build system so we don't have to modify them since it's
almost all headers) and one ifndef kernel that could be solved with an
empty #define.

It also deletes new files in the platform directory that are similar to
prior non-freebsd platform files we've deleted.

The net delta: +1 line.

Sponsored by: Netflix

5 months agopf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex
Igor Ostapenko [Mon, 5 Feb 2024 16:22:31 +0000 (17:22 +0100)]
pf: Ensure that st->kif is obtained in a way which respects the r->rpool->mtx mutex

The redirection pool stored in r->rpool.cur is used for loadbalancing
and cur can change whenever loadbalancing happens, which is for every
new connection. Therefore it can't be trusted outside of pf_map_addr()
and the r->rpool->mtx mutex. After evaluating the ruleset, loadbalancing
decission is made in pf_map_addr() called from within pf_create_state()
and stored in the state itself.

This patch modifies BOUND_IFACE() so that it only uses the information
already stored in the state which has been obtained in a way which
respects the r->rpool->mtx mutex.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D43741

5 months agolibc: make syscall stubs empty for shared lib
Brooks Davis [Fri, 5 Jan 2024 19:04:53 +0000 (19:04 +0000)]
libc: make syscall stubs empty for shared lib

They are always replaced by libsys so just make them empty.  In
https://reviews.freebsd.org/D14609 x86 variants call abort2, but that
requires per-arch assembly and should be of low value in the steady
state.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agoSYS.h: make _SYSCALL_BODY overridable
Brooks Davis [Fri, 5 Jan 2024 18:33:37 +0000 (18:33 +0000)]
SYS.h: make _SYSCALL_BODY overridable

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibc: link libsys as a auxiliary filter library
Brooks Davis [Wed, 15 Nov 2023 23:35:16 +0000 (23:35 +0000)]
libc: link libsys as a auxiliary filter library

At runtime, when rtld loads libc it will also load libsys.  For each
symbol that is present in both, the libsys one will override the libc
one.  It continues to be the case that program need only link against
libc (usually implicitly).  The linkage to libsys is automatic.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibthr: move _umtx_op_err() to libsys
Brooks Davis [Wed, 17 Jan 2024 20:26:52 +0000 (20:26 +0000)]
libthr: move _umtx_op_err() to libsys

Declare in sys/umtx.h and implement in libsys.  Explicitly link libthr
with libsys.

When building libthr static include _umtx_op_err so we don't break static
linkage with -lpthread.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibsys: plumb in to build
Brooks Davis [Wed, 15 Nov 2023 23:31:57 +0000 (23:31 +0000)]
libsys: plumb in to build

libsys provides the FreeBSD kernel interface (auxargs, system calls,
vdso).  It can be linked directly for programs using a non-standard
libc and will later be linked as a filter library to libc providing
the actual system call implementation.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibsys: generate private symbol map
Brooks Davis [Tue, 21 Nov 2023 18:30:00 +0000 (18:30 +0000)]
libsys: generate private symbol map

We now export all _ and __sys_ prefixed syscalls stubs from libc and
libsys so that libsys can replace them.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agomakesyscalls: generate private syscall symbols
Brooks Davis [Tue, 21 Nov 2023 16:55:06 +0000 (16:55 +0000)]
makesyscalls: generate private syscall symbols

For libsys we need to expose all the private symbols (_ and __sys_
prefixes) so libsys can replace the libc versions.  Rather than trying
to maintain a table, teach makesyscalls to generate it.

There are a small number of "_" prefixed symbols that are exposed as
public interfaces rather than in the private symbol space.  Since the
list is short, just hardcode it for now.

If doesn't appear that we need to export freebsd#_foo symbols for compat
system calls explicitly.  If it turns out we do, there are probably few
enough of them to handle seperately.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibc: move __getosreldate to libsys
Brooks Davis [Fri, 17 Nov 2023 20:13:40 +0000 (20:13 +0000)]
libc: move __getosreldate to libsys

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibc: move getpagesize(s) to libsys
Brooks Davis [Fri, 17 Nov 2023 18:55:25 +0000 (18:55 +0000)]
libc: move getpagesize(s) to libsys

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibc: elf auxiliary vector handling to libsys
Brooks Davis [Wed, 15 Nov 2023 20:53:28 +0000 (20:53 +0000)]
libc: elf auxiliary vector handling to libsys

This is part of the interface to the kernel and some syscall wrappers
depend on it so move it there.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908

5 months agolibc: compile _once in libsys
Brooks Davis [Tue, 21 Nov 2023 18:30:43 +0000 (18:30 +0000)]
libc: compile _once in libsys

auxv support requires _once(), but we don't want the libsys version
stomping on the libc version should they diverge in the future.  We
could rename it entierly, but for now just hook it in via Makefile.sys.

Reviewed by: kib, emaste, imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/908