]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agokevent.2: Add an xref to listen.2
Mark Johnston [Mon, 20 Jun 2022 16:19:40 +0000 (12:19 -0400)]
kevent.2: Add an xref to listen.2

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agovm: Fix racy checks for swap objects
Mark Johnston [Mon, 20 Jun 2022 16:18:15 +0000 (12:18 -0400)]
vm: Fix racy checks for swap objects

Commit 4b8365d752ef introduced the ability to dynamically register
VM object types, for use by tmpfs, which creates swap-backed objects.
As a part of this, checks for such objects changed from

  object->type == OBJT_DEFAULT || object->type == OBJT_SWAP

to

  object->type == OBJT_DEFAULT || (object->flags & OBJ_SWAP) != 0

In particular, objects of type OBJT_DEFAULT do not have OBJ_SWAP set;
the swap pager sets this flag when converting from OBJT_DEFAULT to
OBJT_SWAP.

A few of these checks are done without the object lock held.  It turns
out that this can result in false negatives since the swap pager
converts objects like so:

  object->type = OBJT_SWAP;
  object->flags |= OBJ_SWAP;

Fix the problem by adding explicit tests for OBJT_SWAP objects in
unlocked checks.

PR: 258932
Fixes: 4b8365d752ef ("Add OBJT_SWAP_TMPFS pager")
Reported by: bdrewery
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35470

2 years agoaio: Improve UMA usage
Mark Johnston [Mon, 20 Jun 2022 16:17:11 +0000 (12:17 -0400)]
aio: Improve UMA usage

- Remove the AIO proc zone.  This zone gets one allocation per AIO
  daemon process, which isn't enough to warrant a dedicated zone.  Plus,
  unlike other AIO structures, aiops are small (32 bytes with LP64), so
  UMA doesn't provide better space efficiency than malloc(9).  Change
  one of the malloc types in vfs_aio.c to make it more general.

- Don't set the NOFREE flag on the other AIO zones.  This flag means
  that memory allocated to the AIO subsystem is never freed back to the
  VM, so it's always preferable to avoid using it when possible.  NOFREE
  was set without explanation when AIO was converted to use UMA 20 years
  ago, but it does not appear to be required; all of the structures
  allocated from UMA (per-process kaioinfo, kaiocb, and aioliojob) keep
  track of references and get freed only when none exist.  Plus, these
  structures will contain dangling pointer after they're freed (e.g.,
  the "cred", "fd_file" and "uiop" fields of struct kaiocb), so
  use-after-frees are dangerous even when the structures themselves are
  type-stable.

Reviewed by: asomers
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35493

2 years agobpf: Zero pad bytes preceding BPF headers
Mark Johnston [Mon, 20 Jun 2022 16:03:37 +0000 (12:03 -0400)]
bpf: Zero pad bytes preceding BPF headers

BPF headers are word-aligned when copied into the store buffer.  Ensure
that pad bytes following the preceding packet are cleared.

Reported by: KMSAN
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agobpf: Correct a comment
Mark Johnston [Mon, 20 Jun 2022 16:02:59 +0000 (12:02 -0400)]
bpf: Correct a comment

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agovm_kern: Update KMSAN shadow maps when allocating kmem memory
Mark Johnston [Mon, 20 Jun 2022 16:01:09 +0000 (12:01 -0400)]
vm_kern: Update KMSAN shadow maps when allocating kmem memory

This addresses a couple of false positive reports for memory returned by
malloc_large().

Sponsored by: The FreeBSD Foundation

2 years agouma: Mark zeroed slabs as initialized for KMSAN
Mark Johnston [Mon, 20 Jun 2022 15:50:54 +0000 (11:50 -0400)]
uma: Mark zeroed slabs as initialized for KMSAN

Otherwise zone initializers can produce false positives, e.g., when
lock_init() attempts to detect double initialization.

Sponsored by: The FreeBSD Foundation

2 years agowpa: Restore missing patch
Cy Schubert [Mon, 20 Jun 2022 14:21:55 +0000 (07:21 -0700)]
wpa: Restore missing patch

In December after a failed MFV due to a now understood issue I had with
git -- git aborts with extremely large MFV -- this patch was removed
during the revert. Restore this patch.

PR: 264238
Fixes: 4b72b91a7132df1f77bbae194e1071ac621f1edb
MFC after: 1 week

2 years agostress2: Added a timeout to the test
Peter Holm [Mon, 20 Jun 2022 12:36:57 +0000 (14:36 +0200)]
stress2: Added a timeout to the test

2 years agostress2: Fix process handling error
Peter Holm [Mon, 20 Jun 2022 12:35:59 +0000 (14:35 +0200)]
stress2: Fix process handling error

2 years agopf tests: basic 'tagged' test for Ethernet rules
Kristof Provost [Tue, 31 May 2022 12:55:15 +0000 (14:55 +0200)]
pf tests: basic 'tagged' test for Ethernet rules

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D35364

2 years agopf tests: basic 'tagged' test for Ethernet rules
Kristof Provost [Tue, 31 May 2022 12:40:05 +0000 (14:40 +0200)]
pf tests: basic 'tagged' test for Ethernet rules

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D35363

2 years agopf: support matching on tags for Ethernet rules
Kristof Provost [Tue, 31 May 2022 12:00:52 +0000 (14:00 +0200)]
pf: support matching on tags for Ethernet rules

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D35362

2 years agoloader: GELI encrypted disk should still use device name disk
Toomas Soome [Mon, 20 Jun 2022 06:51:44 +0000 (09:51 +0300)]
loader: GELI encrypted disk should still use device name disk

geli_probe_and_attach() does pick geli_devsw structure for
encrypted disks, the implementation depends on device
name "disk" when device type is DEVT_DISK, but geli_devsw is
setting name field "gelidisk".

PR: 264282
Submitted by: yamagi@yamagi.org
Reported by: yamagi@yamagi.org
MFC after: 2 weeks

2 years agogetnetent(3): Add documentation for missing reentrant functions
Fernando Apesteguía [Wed, 26 May 2021 12:34:49 +0000 (14:34 +0200)]
getnetent(3): Add documentation for missing reentrant functions

Add gethostbyname_r, gethostbyname2_r and gethostbyaddr_r signatures and
descriptions.

PR: 249154
Reported by: asomers@
Approved by: manpages (imp@), Pau Amma
Differential Revision: https://reviews.freebsd.org/D30385

2 years agogetnetent(3): Add missing reentrant functions
Fernando Apesteguía [Fri, 21 May 2021 15:25:25 +0000 (17:25 +0200)]
getnetent(3): Add missing reentrant functions

Add documentation for gethostbyname_r, gethostbyname2_r and gethostbyaddr_r

Create proper MLINKs for the new functions.

PR: 249154
Reported by: asomers@
Approved by: manpages (0mp@), Pau Amma
Differential Revision:  https://reviews.freebsd.org/D30469

2 years agouserboot is missing vdisk_dev
Toomas Soome [Thu, 9 Jun 2022 06:56:19 +0000 (09:56 +0300)]
userboot is missing vdisk_dev

Add vdisk device support in userboot configuration.

MFC after: 1 week

2 years agotree.3: document RB_AUGMENT
Doug Moore [Sun, 19 Jun 2022 16:55:44 +0000 (11:55 -0500)]
tree.3: document RB_AUGMENT

Document the RB_AUGMENT macro, and provide an example of its use.
Reviewed by: alc, kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35518

2 years agotest_diskread(): detect end of the disk
Toomas Soome [Wed, 1 Jun 2022 07:28:43 +0000 (10:28 +0300)]
test_diskread(): detect end of the disk

Detect the end of the disk condition. This may happpen when
disk image is truncated and the reads are addressing blocks past
image end.

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

2 years agoloader.efi: fix panic() after BS off
Toomas Soome [Wed, 8 Sep 2021 00:14:51 +0000 (03:14 +0300)]
loader.efi: fix panic() after BS off

panic() is using multiple services - attempting to read
keyboard, accessing time functions and finally, exiting the loader.

Protect all the accessed listed above. Note, when BS are off,
we really can not just exit the loader, we only can reboot.

MFC after: 1 week

2 years agonfscl: Clean up the code by removing #if(n)def APPLE
Rick Macklem [Sat, 18 Jun 2022 20:43:02 +0000 (13:43 -0700)]
nfscl: Clean up the code by removing #if(n)def APPLE

The definition of "APPLE" was used by the Mac OSX port.
For FreeBSD, this definition is never used, so remove
the references to it to clean up the code.

This commit should not result in a semantics change.

2 years agostruct kinfo_file changes needed for lsof to work using only usermode APIs`
Damjan Jovanovic [Fri, 17 Jun 2022 13:37:40 +0000 (16:37 +0300)]
struct kinfo_file changes needed for lsof to work using only usermode APIs`

Add kf_pipe_buffer_[in/out/size] fields to kf_pipe, and populate them.

Add a kf_kqueue struct to the kf_un union, to allow querying kqueue state,
and populate it.

Populate the kf_sock_rcv_sb_state and kf_sock_snd_sb_state fields in
kf_sock for INET/INET6 sockets, and populate all other fields for all
transport layer protocols, not just TCP.

Bump __FreeBSD_version.

Differential revision: https://reviews.freebsd.org/D34184
Reviewed by: jhb, kib, se
MFC after: 1 week

2 years agoKERN_LOCKF: report kl_file_fsid consistently with stat(2)
Damjan Jovanovic [Fri, 17 Jun 2022 13:28:16 +0000 (16:28 +0300)]
KERN_LOCKF: report kl_file_fsid consistently with stat(2)

PR: 264723
Reviewed by: kib
Discussed with: markj
MFC after: 1 week

2 years agomixer: remove volume backwards compat, add % interpretation
Kyle Evans [Sat, 30 Apr 2022 03:12:56 +0000 (22:12 -0500)]
mixer: remove volume backwards compat, add % interpretation

The current situation is fairly confusing, where an integer is interpreted
as a percent until you slap a decimal on it and magically it becomes an
absolute value.

Let's have a flag day in 14.0 and remove this shim entirely.  Setting with
percent can still be useful, so allow a trailing '%' to indicate as such.
As a side effect, we tighten down the format allowed in the volume a little
bit by ensuring there's no trailing garbage after the value once it's
separated into left and right components.

Reviewed by: christos, hselasky, pauamma_gundo.com (manpages)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D35101

2 years agorc.d/hostid: remove useless cat
наб [Mon, 30 May 2022 23:18:12 +0000 (01:18 +0200)]
rc.d/hostid: remove useless cat

We've already read it and validated it ‒ re-reading is wasteful

PR: 264376

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Fri, 17 Jun 2022 23:46:11 +0000 (16:46 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c and
nfs_clstate.c.

This commit should not result in a semantics change.

2 years agonet80211 / LinuxKPI: 802.11: add Control Trigger Subframe information
Bjoern A. Zeeb [Fri, 17 Jun 2022 22:55:13 +0000 (22:55 +0000)]
net80211 / LinuxKPI: 802.11: add Control Trigger Subframe information

Add definitions related to 802.11ax Control Trigger frame format
needed for rtw89.

MFC after: 3 days

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Fri, 17 Jun 2022 21:51:11 +0000 (14:51 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c and
nfs_clvfsops.c. Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agoncurses: add SRCHDRS (ncurses_dll.h) to tinfo SRCS
Brooks Davis [Fri, 17 Jun 2022 19:34:58 +0000 (20:34 +0100)]
ncurses: add SRCHDRS (ncurses_dll.h) to tinfo SRCS

This avoids relying on the `includes` target to generate this header
which must be in .OBJDIR for the ncurses library to find it.

With an upcoming change libcompat build won't build a seperate
sysroot and will instead share with the 64-bit target which means the
`includes` target will not be called.

Sponsored by: DARPA, AFRL

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D35510

2 years agoiommu_gas: Correct a broken KASSERT
Alan Cox [Fri, 17 Jun 2022 17:03:06 +0000 (12:03 -0500)]
iommu_gas: Correct a broken KASSERT

If iommu_gas_find_space() ever called iommu_gas_uppermatch(), and it
succeeded in allocating space, then the subsequent KASSERT would be
triggered.  Change that KASSERT to accept either success or ENOMEM.

MFC after: 1 week

2 years agokldload: Bring functionality in line with manual page
Juraj Lutter [Fri, 17 Jun 2022 13:36:53 +0000 (15:36 +0200)]
kldload: Bring functionality in line with manual page

Honor -q parameter and do not display any warning messages when -q is
specified.

Approved by: dfr
MFC after: 2 weeks
Sponsored by: Resulta, s.r.o.
Differential Revision: https://reviews.freebsd.org/D35511

2 years agoRemove PAGE_SIZE from the kcov tests
Andrew Turner [Wed, 20 Apr 2022 17:33:00 +0000 (17:33 +0000)]
Remove PAGE_SIZE from the kcov tests

To allow for a dynamic page size on arm64 remove the static valud from
the kcov tests

Sponsored by: The FreeBSD Foundation

2 years agoRemove PAGE_SIZE from hastd
Andrew Turner [Tue, 3 May 2022 13:59:33 +0000 (14:59 +0100)]
Remove PAGE_SIZE from hastd

It may not be known at compile time so we should detect it at run time.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35118

2 years agoClean up in the pci host generic driver
Andrew Turner [Mon, 23 May 2022 09:41:36 +0000 (10:41 +0100)]
Clean up in the pci host generic driver

Add clean up on failure and a detach function to the pci host generic
driver.

Reviewed by: jhb (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35291

2 years agoFix the random source descriptions
Andrew Turner [Mon, 6 Jun 2022 12:11:19 +0000 (13:11 +0100)]
Fix the random source descriptions

 - Add the missing RANDOM_PURE_QUALCOMM description
 - Make RANDOM_PURE_VMGENID consistent with the other pure sources
   by including "PURE_" in the description.

Approved by: csprng (cem)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35412

2 years agodhclient: fix pcp:pcp cleanup failure
Kristof Provost [Fri, 17 Jun 2022 07:01:05 +0000 (09:01 +0200)]
dhclient: fix pcp:pcp cleanup failure

If isc-dhcp44-server is not installed (as is the case the project's CI
servers) we don't create ngctl.shutdown, causing the 'rm' to fail.
That in turn causes the cleanup function to return non-zero, which
causes kyua to consider the test failed.

Use 'rm -f' instead, so we don't error even if the file doesn't exist.

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

2 years agoiommu_gas: Eliminate unnecessary wrappers
Alan Cox [Tue, 14 Jun 2022 19:01:36 +0000 (14:01 -0500)]
iommu_gas: Eliminate unnecessary wrappers

Eliminate trivial wrappers for several iommu_gas functions that serve
no functional purpose.

Reviewed by: br, dougm, kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35487

2 years agostress2: Remove bsdlabel(8) from tests
Peter Holm [Fri, 17 Jun 2022 03:42:52 +0000 (05:42 +0200)]
stress2: Remove bsdlabel(8) from tests
Reported by: mhorne
Discussed with: kib

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Thu, 16 Jun 2022 23:46:06 +0000 (16:46 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Thu, 16 Jun 2022 23:17:13 +0000 (16:17 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agobhyve: Report an error for invalid UUIDs.
James Mintram [Thu, 16 Jun 2022 20:17:44 +0000 (13:17 -0700)]
bhyve: Report an error for invalid UUIDs.

Reviewed by: rgrimes, grehan, jhb
Differential Revision: https://reviews.freebsd.org/D30050

2 years agoamd64: Stop using REP MOVSB for backward memmove()s.
Alexander Motin [Thu, 16 Jun 2022 18:51:50 +0000 (14:51 -0400)]
amd64: Stop using REP MOVSB for backward memmove()s.

Enhanced REP MOVSB feature of CPUs starting from Ivy Bridge makes
REP MOVSB the fastest way to copy memory in most of cases. However
Intel Optimization Reference Manual says: "setting the DF to force
REP MOVSB to copy bytes from high towards low addresses will expe-
rience significant performance degradation". Measurements on Intel
Cascade Lake and Alder Lake, same as on AMD Zen3 show that it can
drop throughput to as low as 2.5-3.5GB/s, comparing to ~10-30GB/s
of REP MOVSQ or hand-rolled loop, used for non-ERMS CPUs.

This patch keeps ERMS use for forward ordered memory copies, but
removes it for backward overlapped moves where it does not work.

This is just a cosmetic sync with kernel, since libc does not use
ERMS at this time.

Reviewed by:    mjg
MFC after: 2 weeks

2 years agoamd64: Stop using REP MOVSB for backward memmove()s.
Alexander Motin [Thu, 16 Jun 2022 17:01:12 +0000 (13:01 -0400)]
amd64: Stop using REP MOVSB for backward memmove()s.

Enhanced REP MOVSB feature of CPUs starting from Ivy Bridge makes
REP MOVSB the fastest way to copy memory in most of cases. However
Intel Optimization Reference Manual says: "setting the DF to force
REP MOVSB to copy bytes from high towards low addresses will expe-
rience significant performance degradation". Measurements on Intel
Cascade Lake and Alder Lake, same as on AMD Zen3 show that it can
drop throughput to as low as 2.5-3.5GB/s, comparing to ~10-30GB/s
of REP MOVSQ or hand-rolled loop, used for non-ERMS CPUs.

This patch keeps ERMS use for forward ordered memory copies, but
removes it for backward overlapped moves where it does not work.

Reviewed by: mjg
MFC after: 2 weeks

2 years agosocket: Fix a race between kevent(2) and listen(2)
Mark Johnston [Thu, 16 Jun 2022 14:10:45 +0000 (10:10 -0400)]
socket: Fix a race between kevent(2) and listen(2)

When locking the knote list for a socket, we check whether the socket is
a listening socket in order to select the appropriate mutex; a listening
socket uses the socket lock, while data sockets use socket buffer
mutexes.

If SOLISTENING(so) is false and the knote lock routine locks a socket
buffer, then it must re-check whether the socket is a listening socket
since solisten_proto() could have changed the socket's identity while we
were blocked on the socket buffer lock.

Reported by: syzkaller
Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35492

2 years agodebugnet: Fix an error handling bug in the DDB command tokenizer
Mark Johnston [Thu, 16 Jun 2022 14:05:10 +0000 (10:05 -0400)]
debugnet: Fix an error handling bug in the DDB command tokenizer

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agodebugnet: Handle batches of packets from if_input
Mark Johnston [Thu, 16 Jun 2022 14:02:00 +0000 (10:02 -0400)]
debugnet: Handle batches of packets from if_input

Some drivers will collect multiple mbuf chains, linked by m_nextpkt,
before passing them to upper layers.  debugnet_pkt_in() didn't handle
this and would process only the first packet, typically leading to
retransmits.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Wed, 15 Jun 2022 23:10:50 +0000 (16:10 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agotcp: fix TCPPCAP for kernels enabling VNET
Michael Tuexen [Wed, 15 Jun 2022 21:28:54 +0000 (23:28 +0200)]
tcp: fix TCPPCAP for kernels enabling VNET

Reviewed by: rscheff
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D35503

2 years agoXHCI: clear warm and port reset
Bjoern A. Zeeb [Tue, 14 Jun 2022 16:52:45 +0000 (16:52 +0000)]
XHCI: clear warm and port reset

It seems we do not clear UPS_C_BH_PORT_RESET and UPS_C_PORT_RESET
conditions after warm or port reset.  Add that code.

Obtained from: an old patch mainly debugging other problems
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D35483

2 years agoUSB: add quirks to XHCI
Bjoern A. Zeeb [Tue, 14 Jun 2022 16:39:31 +0000 (16:39 +0000)]
USB: add quirks to XHCI

While XHCI is very generic some revisions of chipsets have problems.
On dwc3 <= 3.00a Port Disable does not seem to work so we need to not
enable it.
For that introduce quirks to xhci so that controllers can steer
certain features.  I would hope that this is and remains the only one.

Obtained from: an old patch mainly debugging other problems
MFC after: 2 weeks
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D35482

2 years agoLinuxKPI: 802.11: ieee80211_start_tx_ba_session()
Bjoern A. Zeeb [Wed, 15 Jun 2022 21:02:45 +0000 (21:02 +0000)]
LinuxKPI: 802.11: ieee80211_start_tx_ba_session()

For as long as we do not implement the compat code for tx aggregation
return -EINVAL in ieee80211_start_tx_ba_session() as both rtw88 and
rtw89 check for this value and only then disable further attempts.

MFC after: 3 days

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Wed, 15 Jun 2022 20:10:44 +0000 (13:10 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agoifconfig.8: reflect removal of FDDI and Token Ring
Zhenlei Huang [Wed, 15 Jun 2022 17:49:27 +0000 (18:49 +0100)]
ifconfig.8: reflect removal of FDDI and Token Ring

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D35409

2 years agoiommu_gas: make iommu_gas_lowermatch non-recursive
Doug Moore [Wed, 15 Jun 2022 16:32:56 +0000 (11:32 -0500)]
iommu_gas: make iommu_gas_lowermatch non-recursive

Change the recursive implementation to one that uses parent pointers
to walk back up the rb-tree, to slightly improve performance.

Reviewed by: alc, kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35486

2 years agohwpmc: Reenable PME before reenabling counters.
Alexander Motin [Wed, 15 Jun 2022 15:39:37 +0000 (11:39 -0400)]
hwpmc: Reenable PME before reenabling counters.

Doing otherwise may lead to lost interrupts, that in combination
with hardware PMCs freezing may leave them frozen forever.  It may
also slightly improve profiling accuracy.

MFC after: 2 weeks

2 years agohwpmc: Correct sysctl description.
Alexander Motin [Wed, 15 Jun 2022 15:37:26 +0000 (11:37 -0400)]
hwpmc: Correct sysctl description.

MFC after: 2 weeks

2 years agoloader: Relax the check in is_kernphys_relocatable()
Mark Johnston [Wed, 15 Jun 2022 14:47:13 +0000 (10:47 -0400)]
loader: Relax the check in is_kernphys_relocatable()

The check fails in kernels compiled with KASAN because AddressSanitizer
inserts redzones around global variables, so the size of the "kernphys"
symbol is 32 rather than 8.  Thus we fall back to copying even though
it's not necessary.

Simply remove the size check.  I didn't want to extend the symbol size
check since there's no guarantee that AddressSanitizer will always emit
32 bytes for "kernphys".

Reviewed by: kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35448

2 years agokasan: Create a shadow for the bootstack prior to hammer_time()
Mark Johnston [Wed, 15 Jun 2022 14:48:16 +0000 (10:48 -0400)]
kasan: Create a shadow for the bootstack prior to hammer_time()

When the kernel is compiled with -asan-stack=true, the address sanitizer
will emit inline accesses to the shadow map.  In other words, some
shadow map accesses are not intercepted by the KASAN runtime, so they
cannot be disabled even if the runtime is not yet initialized by
kasan_init() at the end of hammer_time().

This went unnoticed because the loader will initialize all PML4 entries
of the bootstrap page table to point to the same PDP page, so early
shadow map accesses do not raise a page fault, though they are silently
corrupting memory.  In fact, when the loader does not copy the staging
area, we do get a page fault since in that case only the first and last
PML4Es are populated by the loader.  But due to another bug, the loader
always treated KASAN kernels as non-relocatable and thus always copied
the staging area.

It is not really practical to annotate hammer_time() and all callees
with __nosanitizeaddress, so instead add some early initialization which
creates a shadow for the boot stack used by hammer_time().  This is only
needed by KASAN, not by KMSAN, but the shared pmap code handles both.

Reported by: mhorne
Reviewed by: kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35449

2 years agoFix the test used to wait for AP startup on x86, arm64, riscv
Mark Johnston [Wed, 15 Jun 2022 14:29:39 +0000 (10:29 -0400)]
Fix the test used to wait for AP startup on x86, arm64, riscv

On arm64, testing pc_curpcb != NULL is not correct since pc_curpcb is
set in pmap_switch() while the bootstrap stack is still in use.  As a
result, smp_after_idle_runnable() can free the boot stack prematurely.

Take a different approach: use smp_rendezvous() to wait for all APs to
acknowledge an interrupt.  Since APs must not enable interrupts until
they've entered the scheduler, i.e., switched off the boot stack, this
provides the right guarantee without depending as much on the
implementation of cpu_throw().  And, this approach applies to all
platforms, so convert x86 and riscv as well.

Reported by: mmel
Tested by: mmel
Reviewed by: kib
Fixes: 8db2e8fd16c4 ("Remove the secondary_stacks array in arm64 and riscv kernels.")
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35435

2 years agopmap: Keep PTI page table pages busy
Mark Johnston [Wed, 15 Jun 2022 14:19:01 +0000 (10:19 -0400)]
pmap: Keep PTI page table pages busy

PTI page table pages are allocated from a VM object, so must be
exclusively busied when they are freed, e.g., when a thread loses a race
in pmap_pti_pde().  Simply keep PTPs busy at all times, as was done for
some other kernel allocators in commit
e9ceb9dd110e04fc19729b4e9fb1c8bfbb8398a3.

Also remove some redundant assertions on "ref_count":
vm_page_unwire_noq() already asserts that the page's reference count is
greater than zero.

Reported by: syzkaller
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35466

2 years agomount: revert the active vnode reporting feature
Doug Ambrisko [Tue, 14 Jun 2022 21:37:27 +0000 (14:37 -0700)]
mount: revert the active vnode reporting feature

Revert the computing of active vnode reporting since statfs is used
by a lot of tools.  Only report the vnodes used.

Reported by: mjg

2 years agolinuxkpi: Acquire giant when adding/removing i2c adapters
Emmanuel Vadot [Tue, 14 Jun 2022 11:23:26 +0000 (13:23 +0200)]
linuxkpi: Acquire giant when adding/removing i2c adapters

We need Giant as we run in a taskqueue_thread via linux_work.
This fix detaching amdgpu and i915kms.

Reviewed by: bz, hselasky, imp
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D35478

2 years agocontrib/bc: merge from vendor release 5.3.3
Stefan Eßer [Wed, 15 Jun 2022 09:54:13 +0000 (11:54 +0200)]
contrib/bc: merge from vendor release 5.3.3

This update fixes a build issue of release 5.3.2 on the FreeBSD base
system.

Merge commit '3f739b0595b7d6ac4bac9aaa1cae0910f11f92e2'

MFC after: 2 weeks

2 years agovendor/bc: import version 5.3.3
Stefan Eßer [Wed, 15 Jun 2022 09:34:25 +0000 (11:34 +0200)]
vendor/bc: import version 5.3.3

This version fixes a build issue caused by the strict compiler
warnings used when building FreeBSD base system components.

2 years agovm_fault: Avoid unnecessary object relocking in vm_fault_copy_entry()
Mark Johnston [Tue, 14 Jun 2022 20:37:35 +0000 (16:37 -0400)]
vm_fault: Avoid unnecessary object relocking in vm_fault_copy_entry()

Suggested by: alc
Reviewed by: alc, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35485

2 years agovm_fault: Fix a racy copy of page valid bits
Mark Johnston [Tue, 14 Jun 2022 20:36:54 +0000 (16:36 -0400)]
vm_fault: Fix a racy copy of page valid bits

We do not hold the object lock or a page busy lock when copying src_m's
validity state.  Prior to commit 45d72c7d7fca we marked dst_m as fully
valid.

Use the source object's read lock to ensure that valid bits are not
concurrently cleared.

Reviewed by: alc, kib
Fixes: 45d72c7d7fca ("vm_fault_copy_entry: accept invalid source pages.")
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35471

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Tue, 14 Jun 2022 20:35:25 +0000 (13:35 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agovendor/bc: import version 5.3.2
Stefan Eßer [Tue, 14 Jun 2022 20:06:28 +0000 (22:06 +0200)]
vendor/bc: import version 5.3.2

This update restores support for suppression of the prompt with -P
when using the libedit or libreadline libraries for command line
editing and history.

2 years agopmcannotate: Don't increment end address passed to objdump -d.
John Baldwin [Tue, 14 Jun 2022 17:52:54 +0000 (10:52 -0700)]
pmcannotate: Don't increment end address passed to objdump -d.

libpmc already returns an end address that is after the end of the
last instruction of a function (on both amd64 and arm64) as the end
address written to the annotate map file is computed as the start
address of the symbol plus the size.

Adding one could result in a curious failure where an entire
function's contents in assembly was reduced instead to only the first
instruction.  The reason is that when the end instruction is bumped by
one, objdump -d can append the first instruction of the next function
in its output.  However, since pmcannotate concatenates all of the
objdump -d output from various functions into a single file which it
then searches to find the assembly for a given file, if this
additional trailer was earlier in the file than the full function, the
trailer was chosen to represent the entire function resulting in the
truncated listing of the function.

Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D35399

2 years agonewvers.sh: Don't use return to exit.
John Baldwin [Tue, 14 Jun 2022 17:51:39 +0000 (10:51 -0700)]
newvers.sh: Don't use return to exit.

Commit acfb506b3d00 replaced an exit 0 when using -V with a return
instead.  FreeBSD's sh treats a return outside of a function like
exit, but this is a non-portable extension.  Other Bourne shells only
permit return to be used within a function and continue execution
(possibly with a warning).

To fix, don't reuse VARS_ONLY (which is intended to be set by other
scripts before sourcing newvers.sh directly) and instead use a new
variable (VARS_ONLY_EXIT) to restore the use of exit for the
non-sourced case.

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35481

2 years agofirmware: Map '@' in filenames to '_' in symbols.
John Baldwin [Tue, 14 Jun 2022 17:50:51 +0000 (10:50 -0700)]
firmware: Map '@' in filenames to '_' in symbols.

'@' is not a valid character in symbol names and can sometimes appear
in path names.

Reviewed by: imp, markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35480

2 years agorc.d/ntpd: Restart ntpd when resuming from sleep.
John Baldwin [Tue, 14 Jun 2022 17:42:51 +0000 (10:42 -0700)]
rc.d/ntpd: Restart ntpd when resuming from sleep.

ntpd does not always gracefully handle clock steps during resume.
This is probably most useful in conjunction with
ntpd_sync_on_start=YES which will work around any clock skew while
suspended.

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

2 years agoktls_test: Permit an option to skip tests not using ifnet TLS.
John Baldwin [Tue, 14 Jun 2022 17:35:01 +0000 (10:35 -0700)]
ktls_test: Permit an option to skip tests not using ifnet TLS.

If ktls.require_ifnet is set to true, then check the TLS offload mode
for tests sending and receiving records and skip the test if the
offload mode is not ifnet mode.

This can be used along with ktls.host to run KTLS tests against a NIC
supporting ifnet TLS and verify that expected cipher suites and
directions used ifnet TLS rather than software TLS.  Receive tests may
result in a false positive as receive ifnet TLS can use software as a
fallback.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35427

2 years agoktls_test: Permit connecting to a remote echo server for tests.
John Baldwin [Tue, 14 Jun 2022 17:34:51 +0000 (10:34 -0700)]
ktls_test: Permit connecting to a remote echo server for tests.

Previously ktls tests always executed over a local socket pair.
ktls.host can be set to a host to connect to with a single socket
instead.  The remote end is expected to echo back any data received
(such as the echo service).  The port can be set with ktls.port which
defaults to "echo".

This is primarily useful to permit testing NIC TLS offload use cases
where the traffic needs to transit the NIC.

Note that the variables must be set via
'kyua -v test_suites.FreeBSD.ktls.host=host'.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35426

2 years agoktls_test: Add a helper function to close sockets.
John Baldwin [Tue, 14 Jun 2022 17:34:38 +0000 (10:34 -0700)]
ktls_test: Add a helper function to close sockets.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35425

2 years agoddb: namespacing of struct command
Mitchell Horne [Tue, 14 Jun 2022 16:09:11 +0000 (13:09 -0300)]
ddb: namespacing of struct command

'command' is too generic for something specific to the kernel debugger;
change this so it is less likely to collide with local variable names.
Also rename struct command_table to struct db_command_table.

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

2 years agomodules: Only build MAC modules if options MAC is set
Mitchell Horne [Tue, 14 Jun 2022 16:07:30 +0000 (13:07 -0300)]
modules: Only build MAC modules if options MAC is set

They are not loadable otherwise.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D35369

2 years agomount: Fix an incorrect assertion in kernel_mount()
Mark Johnston [Tue, 14 Jun 2022 15:36:00 +0000 (11:36 -0400)]
mount: Fix an incorrect assertion in kernel_mount()

The pointer to the mount values may be null if an error occurred while
copying them in, so fix the assertion condition to reflect that
possibility.

While here, move some initialization code into the error == 0 block.  No
functional change intended.

Reported by: syzkaller
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agovm_object: Use the vm_object_(set|clear)_flag() helpers
Mark Johnston [Tue, 14 Jun 2022 15:35:20 +0000 (11:35 -0400)]
vm_object: Use the vm_object_(set|clear)_flag() helpers

... rather than setting and clearing flags inline.  No functional change
intended.

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35469

2 years agotruss: Make control message header parsing more robust
Mark Johnston [Tue, 14 Jun 2022 15:34:57 +0000 (11:34 -0400)]
truss: Make control message header parsing more robust

print_cmsg() was assuming that the control message chain is well-formed,
but that isn't necessarily the case for sendmsg(2).  In particular, if
cmsg_len is zero, print_cmsg() will loop forever.  Check for truncated
headers and try to recover if possible.

Reviewed by: tuexen
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35476

2 years agorip6: Fix a lock order reversal in rip6_bind()
Mark Johnston [Tue, 14 Jun 2022 15:27:38 +0000 (11:27 -0400)]
rip6: Fix a lock order reversal in rip6_bind()

See also commit 71a1539e3783.

Reported by: syzbot+9b461b6a07a83cc10daa@syzkaller.appspotmail.com
Reported by: syzbot+b6ce0aec16f5fdab3282@syzkaller.appspotmail.com
Reviewed by: glebius
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35472

2 years agopipe: Use a distinct wait channel for I/O serialization
Mark Johnston [Tue, 14 Jun 2022 14:52:03 +0000 (10:52 -0400)]
pipe: Use a distinct wait channel for I/O serialization

Suppose a thread tries to read from an empty pipe.  pipe_read() does the
following:

1. pipelock(), possibly sleeping
2. check for buffered data
3. pipeunlock()
4. set PIPE_WANTR and sleep
5. goto 1

pipelock() is an open-coded mutex; if a thread blocks in pipelock(), it
sleeps until the lock holder calls pipeunlock().

Both sleeps use the same wait channel.  So if there are multiple threads
in pipe_read(), a thread T1 in step 3 can wake up a thread T2 sleeping
in step 4.  Then T1 goes to sleep in step 4, and T2 acquires and
releases the pipelock, waking up T1 again.  This can go on indefinitely,
livelocking the process (and potentially starving a would-be writer).

Fix the problem by using a separate wait channel for pipelock().

Reported by: Paul Floyd <paulf2718@gmail.com>
Reviewed by: mjg, kib
PR: 264441
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35415

2 years agorc.d/wpa_supplicant: Remove the sleep to improve boot time
Cy Schubert [Sun, 12 Jun 2022 19:02:47 +0000 (12:02 -0700)]
rc.d/wpa_supplicant: Remove the sleep to improve boot time

bapt@ had discovered a noticeable boot improvement without the sleep.
Without the sleep does not affect warm or cold boot however a
service netif restart may cause dhclient to spend a few extra seconds
to rerequest the DHCP request.

Reported by: bapt
Reviewed by: bapt
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D35457

2 years agoRemove mips-specific Makefiles for /sbin and /usr/sbin
Mitchell Horne [Mon, 13 Jun 2022 13:21:18 +0000 (10:21 -0300)]
Remove mips-specific Makefiles for /sbin and /usr/sbin

They are no longer needed, but were likely missed simply because they
don't show up in a grep for 'mips'.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35475

2 years agonull_vptocnp(): busy nullfs mp instead of refing it
Konstantin Belousov [Fri, 10 Jun 2022 11:35:45 +0000 (14:35 +0300)]
null_vptocnp(): busy nullfs mp instead of refing it

null_nodeget() needs a valid mount point data, otherwise we might
race and dereference NULL.

Using MBF_NOWAIT makes non-forced unmount non-transparent for
vn_fullpath() over nullfs, but we make no guarantee that fullpath
calculation succeeds anyway.

Reported and tested by: pho
Reviewed by: jah
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35477

2 years agoiommu_gas: use to first-fit search for lowermatch
Doug Moore [Tue, 14 Jun 2022 05:47:22 +0000 (00:47 -0500)]
iommu_gas: use to first-fit search for lowermatch

Reverse the order of the search for a free space in lowermatch, to
make it a first-fit search. Iommu_gas_match_one always allocates from
the beginning of the free gap discovered from searching the tree, so
the current code isn't really allocating in a reverse first-fit
anyway, and making the search first-fit reduces the number of iommu
page table pages that are used.

Reported by: alc
Reviewed by: alc, kib
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D35458

2 years agostress2: Added a syzkaller reproducer. Enable all reaper tests
Peter Holm [Tue, 14 Jun 2022 04:59:32 +0000 (06:59 +0200)]
stress2: Added a syzkaller reproducer.  Enable all reaper tests

2 years agoCTL: Fix double command completions on HA failover.
Alexander Motin [Tue, 14 Jun 2022 04:24:39 +0000 (00:24 -0400)]
CTL: Fix double command completions on HA failover.

I've found couple cases when CTL_FLAG_SENT_2OTHER_SC flags were not
cleared on commands return from active node or the send failure.  It
created races when ctl_failover_lun() call before ctl_process_done()
could cause second ctl_done() and ctl_process_done() calls, causing
all sorts of problems.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

2 years agokern_thread.c: Fix i386 build
Cy Schubert [Tue, 14 Jun 2022 02:31:01 +0000 (19:31 -0700)]
kern_thread.c: Fix i386 build

Chase 4493a13e3bfbbdf8488993843281ec688057ee0f by updating static
assertions of struct proc.

2 years agoACPICA: Revert an upstream patch to appease useless warnings
Jung-uk Kim [Tue, 14 Jun 2022 01:40:30 +0000 (21:40 -0400)]
ACPICA: Revert an upstream patch to appease useless warnings

This patch removes warnings messages like the following added in ACPICA
20220331:

    ACPI Warning: Firmware issue: Excessive sleep time (0xxx ms > 10 ms)
    in ACPI Control Method (20220331/exsystem-347)

Note the original author of this patch wants to back it out:

https://github.com/acpica/acpica/pull/780

2 years agonfscl: Clean up the code by removing unused arguments
Rick Macklem [Mon, 13 Jun 2022 22:57:42 +0000 (15:57 -0700)]
nfscl: Clean up the code by removing unused arguments

The "void *stuff" (also called fstuff and dstuff) argument
was used by the Mac OSX port.  For FreeBSD, this argument
is always NULL, so remove it to clean up the code.

This commit gets rid of "stuff" for assorted functions
defined in nfs_clrpcops.c and called in nfs_clvnops.c.
Future commits will do the same for other functions.

This commit should not result in a semantics change.

2 years agoinclude/i386: fix release builds
Brooks Davis [Mon, 13 Jun 2022 20:37:34 +0000 (21:37 +0100)]
include/i386: fix release builds

Add a target to ensure the presence of /usr/include/i386
before we try to install files.  In the buildworld/installworld path
it gets created different ways, but for distribute (used in releases)
we need it in the subdir.

(Creating of this the x86, pc, powerpc directories is far too complex.
We should look for ways to simplify it.)

Reported by: lwhsu
Fixes: a09ea2bbc3053d3b2afdb2f7444e5e57a96bb891

2 years agoreap_kill_proc(): avoid singlethreading any other process if we are exiting
Konstantin Belousov [Mon, 16 May 2022 23:47:20 +0000 (02:47 +0300)]
reap_kill_proc(): avoid singlethreading any other process if we are exiting

This is racy because curproc process lock is not used, but allows the
process to exit faster.  It is userspace issue to create such race
anyway, and not fullfilling the guarantee that all reaper descendants
are signalled should be fine.

In collaboration with: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310

2 years agoreap_kill_subtree(): hold the reaper when entering it into the queue to handle later
Konstantin Belousov [Sun, 15 May 2022 22:52:09 +0000 (01:52 +0300)]
reap_kill_subtree(): hold the reaper when entering it into the queue to handle later

We drop proctree_lock, which allows the process to exit while memoized
in the list to proceed.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310

2 years agoreap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc()
Konstantin Belousov [Mon, 9 May 2022 21:41:23 +0000 (00:41 +0300)]
reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc()

Recorded reaper might loose its reaper status, so we should not assert
it, but check and avoid signalling if this happens.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 week
Differential revision: https://reviews.freebsd.org/D35310

2 years agoreap_kill_proc: do not retry on thread_single() failure
Konstantin Belousov [Tue, 3 May 2022 19:49:37 +0000 (22:49 +0300)]
reap_kill_proc: do not retry on thread_single() failure

The failure means that the process does single-threading itself, which
makes our action not needed.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310

2 years agoMake stop_all_proc_block interruptible to avoid deadlock with parallel suspension
Konstantin Belousov [Sat, 30 Apr 2022 23:29:25 +0000 (02:29 +0300)]
Make stop_all_proc_block interruptible to avoid deadlock with parallel suspension

If we try to single-thread a process which thread entered
procctl(REAP_KILL_SUBTREE), and sleeping waiting for us unlocking
stop_all_proc_blocker, we must be able to finish single-threading.  This
requires the sleep to be interruptible.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310

2 years agothread_single_end(): consistently maintain p_boundary_count for ALLPROC mode
Mark Johnston [Thu, 9 Jun 2022 04:17:32 +0000 (07:17 +0300)]
thread_single_end(): consistently maintain p_boundary_count for ALLPROC mode

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 week
Differential revision: https://reviews.freebsd.org/D35310

2 years agothread_unsuspend(): do not unuspend the suspended leader thread doing SINGLE_ALLPROC
Konstantin Belousov [Wed, 8 Jun 2022 01:27:30 +0000 (04:27 +0300)]
thread_unsuspend(): do not unuspend the suspended leader thread doing SINGLE_ALLPROC

markj wrote:
tdsendsignal() may unsuspend a target thread. I think there is at least
one bug there: suppose thread T is suspended in
thread_single(SINGLE_ALLPROC) when trying to kill another process with
REAP_KILL. Suppose a different thread sends SIGKILL to T->td_proc. Then,
tdsendsignal() calls thread_unsuspend(T, T->td_proc). thread_unsuspend()
incorrectly decrements T->td_proc->p_suspcount to -1.

Later, when T->td_proc exits, it will wait forever in
thread_single(SINGLE_EXIT) since T->td_proc->p_suspcount never reaches 1.

Since the thread suspension is bounded by time needed to do
thread_single(), skipping the thread_unsuspend_one() call there should
not affect signal delivery if this thread is selected as target.

Reported by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310

2 years agothread_single(): remove already checked conditional expression
Konstantin Belousov [Thu, 12 May 2022 11:47:40 +0000 (14:47 +0300)]
thread_single(): remove already checked conditional expression

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310