]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
19 months agoarm64: rockchip: rk_gpio: Improve mode switching
Emmanuel Vadot [Wed, 22 Sep 2021 14:55:54 +0000 (16:55 +0200)]
arm64: rockchip: rk_gpio: Improve mode switching

Changing mode on a pin (input/output/pullup/pulldown) is a bit slow.
Improve this by caching what we can.
We need to check if the pin is in gpio mode, do that the first time
that we have a request for this pin and cache the result. We can't do
that at attach as we are a child of rk_pinctrl and it didn't finished
its attach then.
Cache also the flags specific to the pinctrl (pullup or pulldown) if the
pin is in input mode.
Cache the registers that deals with input/output mode and output value. Also
remove some register reads when we change the direction of a pin or when we
change the output value since the bit changed in the registers only affect output
pins.

(cherry picked from commit 87f642ac03e3cefea7048cb46b17810d01e97dd5)

19 months agoarm64: rockchip: pinctrl: Do not rely on the node name
Emmanuel Vadot [Wed, 10 Aug 2022 13:47:22 +0000 (15:47 +0200)]
arm64: rockchip: pinctrl: Do not rely on the node name

Node names for gpio bank were made generic in Linux 5.16 so stop
using them to map the gpio controller to the pin controller bank unit.

Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 8d6b3a85701062ee795a5aeabb0771c93a8f6f72)

19 months agoBBLog: improve sysctl variables
Cheng Cui [Sat, 24 Dec 2022 21:10:31 +0000 (22:10 +0100)]
BBLog: improve sysctl variables

Correct the format in sysctl net.inet.tcp.bb.disable_all and
sysctl net.inet.tcp.bb.log_auto_all.
Correct the format and the description in
net.inet.tcp.bb.log_auto_mode.

Reviewed by: rscheff, tuexen
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D37776

(cherry picked from commit 57cc27a3325af74553e852851d5e84e308ae79f4)

19 months agoppp: improve MSS clamping
Michael Tuexen [Thu, 8 Dec 2022 08:48:29 +0000 (09:48 +0100)]
ppp: improve MSS clamping

ppp supports MSS clamping for TCP/IPv4. This patch
* improves MSS clamping for TCP/IPv4 by using the MSS as specified
  in RFC 6691.
* adds support for MSS clamping for TCP/IPv6.

Reported by: Timo Voelker
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D37624

(cherry picked from commit cef3c4e0bab8bd5e84ab8cfa2fa48a1e3dca5876)

19 months agotcp: remove unused t_rttbest
Michael Tuexen [Wed, 16 Nov 2022 10:22:13 +0000 (11:22 +0100)]
tcp: remove unused t_rttbest

No functional change intended.

Reviewed by: rscheff@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D37401

(cherry picked from commit bd4f986644b3804e19b92d39f1f90ffabff83e14)

19 months agolibalias: improve handling of invalid SCTP packets
Michael Tuexen [Tue, 15 Nov 2022 20:05:02 +0000 (21:05 +0100)]
libalias: improve handling of invalid SCTP packets

In case of a paritial chunk only pretend the result is OK if
the packet is not the last fragment and there is a valid association.

PR: 267476

(cherry picked from commit 9a714376212ec1685fdc4cf254f2136a07ae6d2c)

19 months agoUnbreak builds having SCTP support compiled in
Michael Tuexen [Mon, 7 Nov 2022 07:50:51 +0000 (08:50 +0100)]
Unbreak builds having SCTP support compiled in

Including sctp_var.h requires INET to be defined if IPv4 support
is needed.

(cherry picked from commit 126f8248ccfee8e9252a8b449694b8619738599f)

19 months agosctp: improve sending of ABORT packets in response to INIT-ACKs
Michael Tuexen [Wed, 12 Oct 2022 23:05:44 +0000 (01:05 +0200)]
sctp: improve sending of ABORT packets in response to INIT-ACKs

Ensure that the initiate tag of the INIT-ACK chunk is used as the
verification tag of the packet containing the ABORT chunk.

Reported by: Suganya Dharma

(cherry picked from commit dd36606b1bc90d1459e0d04be4ea5859d3eabb16)

19 months agoSync TCP related kernel config options
Michael Tuexen [Mon, 10 Oct 2022 13:40:26 +0000 (15:40 +0200)]
Sync TCP related kernel config options

Add TCP_BLACKBOX to the remaining platforms (arm64, RISC-V) and add
TCP_RFC7413 to the remaining platform (RISC-V).

Reviewed by: rscheff@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36918

(cherry picked from commit ad20efdde208485db97027a00c4b08a7daa9c663)

19 months agotraceroute6: fix capabilities for the rcv socket
Michael Tuexen [Tue, 4 Oct 2022 21:34:58 +0000 (23:34 +0200)]
traceroute6: fix capabilities for the rcv socket

On the receive socket, recvmsg() and poll()/select() is called.
Therefore, CAP_EVENT is needed in addition to CAP_RECV.

While there, check the socket for readbility before calling recvmsg().

Reviewed by: markj@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36878

(cherry picked from commit 8ff4fc03e6933dd69f99a8f34f2aa0760300f248)

19 months agotcp: improve handling of SYN-ACK segments in TIMEWAIT state
Michael Tuexen [Mon, 3 Oct 2022 12:46:47 +0000 (14:46 +0200)]
tcp: improve handling of SYN-ACK segments in TIMEWAIT state

Only consider segments with the SYN bit set and the ACK bit cleared
as "new connection attempts", which result in re-using a connection
being in TIMEWAIT state. This results in consistent handling of
SYN-ACK segments.

Reviewed by: rscheff@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36864

(cherry picked from commit 2515552e6216095c3fa61d93ee024bb8861e07c2)

19 months agotcp: honor drop_synfin sysctl variable in TIME-WAIT
Michael Tuexen [Mon, 3 Oct 2022 10:48:30 +0000 (12:48 +0200)]
tcp: honor drop_synfin sysctl variable in TIME-WAIT

Reviewed by: rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36862

(cherry picked from commit f8b5681094dd752604bfa0603ba0be2873698f46)

19 months agotcp: fix stats counter for SYN_RCVD state when TCP-FO is used
Michael Tuexen [Sun, 28 Aug 2022 16:45:59 +0000 (18:45 +0200)]
tcp: fix stats counter for SYN_RCVD state when TCP-FO is used

Reviewed by: glebius
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36384

(cherry picked from commit c624b9a549f0fe82dd74dc66c9369e5da856b506)

19 months agotcp: improve BBLog for output events when using the FreeBSD stack
Michael Tuexen [Mon, 8 Aug 2022 11:07:10 +0000 (13:07 +0200)]
tcp: improve BBLog for output events when using the FreeBSD stack

Put the return value of ip_output()/ip6_output in the output event
instead of adding another one in case of an error. This improves
consistency with other similar places.

Reviewed by: rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D36085

(cherry picked from commit bd30a1216e03e14cfaa7e91b1fc72ad76e9cd240)

19 months agosctp: improve handling of send() calls with no user data`
Michael Tuexen [Mon, 8 Aug 2022 10:53:42 +0000 (12:53 +0200)]
sctp: improve handling of send() calls with no user data`

In particular, don't report EAGAIN on send() calls with no user
data, which might trigger a KASSERT in asyc IO.

Reported by: syzbot+3b4dc5d1d63e9bd01eda@syzkaller.appspotmail.com

(cherry picked from commit bb995f2ef0e75e2e9cc784fc36fc3eb02d3e3113)

19 months agosctp: tweak panic message
Michael Tuexen [Wed, 3 Aug 2022 15:28:15 +0000 (17:28 +0200)]
sctp: tweak panic message

(cherry picked from commit 979bc32c7c14f944a340058fcd1a580a7492f785)

19 months agotcp rack: simplify computation of rsm start and end
Michael Tuexen [Tue, 2 Aug 2022 10:45:56 +0000 (12:45 +0200)]
tcp rack: simplify computation of rsm start and end

While there, also fix the setting of the SYN related flag.

Reviewed by: rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D35862

(cherry picked from commit 1abc27dd52e5fd151472439004f20dc798887ae1)

19 months agotcp rack: fix switching to RACK when FIN has been sent
Michael Tuexen [Tue, 19 Jul 2022 18:28:25 +0000 (20:28 +0200)]
tcp rack: fix switching to RACK when FIN has been sent

Fix the rack sendmap entry in case a FIN has been sent when the
stack is switched over to RACK.

Reported by: syzbot+dd55e316428419e9354b@syzkaller.appspotmail.com
Reviewed by: rrs
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D35731

(cherry picked from commit 5b741298b11cdaec71877fa24b72764d1e697a33)

19 months agosctp: do not clobber listening socket with sockbuf operations
Gleb Smirnoff [Mon, 27 Jun 2022 16:21:45 +0000 (09:21 -0700)]
sctp: do not clobber listening socket with sockbuf operations

The problem was here since 779f106aa16, but a4fc41423f7 turned it
into a panic.

Reviewed by: tuexen
Reported by: syzcaller

(cherry picked from commit bafe71fd27201523ae91ef8320f551a609cda1a1)

19 months agosctp: add KASSERTs to ensure correct handling of listeners
Michael Tuexen [Mon, 27 Jun 2022 17:04:45 +0000 (19:04 +0200)]
sctp: add KASSERTs to ensure correct handling of listeners

This was suggested by markj@.

(cherry picked from commit 121ecca0d82b4a5ccee1a8bb01e50b026a22bb3f)

19 months 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
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D35503

(cherry picked from commit bf6c6162c7631b361f81e89b8539154dd738e828)

19 months agosctp: remove book keeping not needed anymore
Michael Tuexen [Wed, 8 Jun 2022 21:30:52 +0000 (23:30 +0200)]
sctp: remove book keeping not needed anymore

(cherry picked from commit ee9ee699d6b5ee7613c6a166d2db5dbb59389cfc)

19 months agosctp: cleanup, no functional change
Michael Tuexen [Wed, 8 Jun 2022 20:35:14 +0000 (22:35 +0200)]
sctp: cleanup, no functional change

(cherry picked from commit ad6ae52d1c2144b6bb6bca8edc485f3a97de2f4b)

19 months agosctp: improve handling of sctp inpcb flags
Michael Tuexen [Sat, 4 Jun 2022 05:35:54 +0000 (07:35 +0200)]
sctp: improve handling of sctp inpcb flags

Use an atomic operation when the inp is not write locked.

Reported by: syzbot+bf27083e9a3f8fde8b4d@syzkaller.appspotmail.com

(cherry picked from commit a5c2009dd8ab562435fb7cc2ac0922668f9511a8)

19 months agosctp: use a consistent view of the send parameters
Michael Tuexen [Sat, 28 May 2022 17:35:58 +0000 (19:35 +0200)]
sctp: use a consistent view of the send parameters

Reported by: syzbot+e26628a755f78bacff16@syzkaller.appspotmail.com

(cherry picked from commit 2646cd085850f047eb17c7df53823b1d48deca82)

19 months agosctp: ignore SCTP_SENDALL flag on 1-to-1 style sockets
Michael Tuexen [Sat, 28 May 2022 17:07:10 +0000 (19:07 +0200)]
sctp: ignore SCTP_SENDALL flag on 1-to-1 style sockets

(cherry picked from commit e2ceff302833ee5f90ac2437efe3670cafcbdd46)

19 months agosctp: improve handling of send() when association is shutdown
Michael Tuexen [Sat, 28 May 2022 15:40:17 +0000 (17:40 +0200)]
sctp: improve handling of send() when association is shutdown

Accept send() calls only when the association is not being
shut down or the expicit message EOR mode is used and the
application provides follow-up data.

Reported by: syzbot+341e9ebd9d24ca7dc62a@syzkaller.appspotmail.com

(cherry picked from commit 64b297e803bd8123bfef3fecaa1f8ceae9eea0e6)

19 months agosctp: cleanup of error paths
Michael Tuexen [Sat, 28 May 2022 15:15:14 +0000 (17:15 +0200)]
sctp: cleanup of error paths

(cherry picked from commit f21168e61404eacc6ad58a74ed9af92a8e5072df)

19 months agosctp: cleanup, no functional change except on error paths
Michael Tuexen [Sat, 28 May 2022 09:34:20 +0000 (11:34 +0200)]
sctp: cleanup, no functional change except on error paths

(cherry picked from commit 9cb70cb4769d2ef3a2e3b6d8bae8e0e59a4689e8)

19 months agosctp: more sb_cc related cleanups
Michael Tuexen [Mon, 23 May 2022 14:09:23 +0000 (16:09 +0200)]
sctp: more sb_cc related cleanups

No functional change intended. It allows a simpler patch for PR 260116.

(cherry picked from commit 5cebd8305afecad82f5d9628d8f7981d33559037)

19 months agosctp: use sb_avail() when accessing sb_acc for reading
Michael Tuexen [Sat, 14 May 2022 10:38:43 +0000 (12:38 +0200)]
sctp: use sb_avail() when accessing sb_acc for reading

This is a cleanup to simplify a patch for PR 260116.

PR: 260116

(cherry picked from commit edc5b6ea881d7e196fee8df7ebcd372f8f5b4469)

19 months agosctp: cleanup, no functional change intended
Michael Tuexen [Sat, 14 May 2022 06:30:41 +0000 (08:30 +0200)]
sctp: cleanup, no functional change intended

(cherry picked from commit f210e4fbc54ab78711bd5197b7097002ff3ae891)

19 months agosctp: improve path verification
Michael Tuexen [Sat, 14 May 2022 06:07:28 +0000 (08:07 +0200)]
sctp: improve path verification

Ensure that a HB can be sent faster than a HB.Interval when performing
path verification of a reachable peer address.

Thanks to Alexander Funke for finding the issue and proposing a fix.

(cherry picked from commit aab6e5bd1e2b2919604eed68f76d4a7bb73ccb0c)

19 months agosctp: improve path verification
Michael Tuexen [Sat, 14 May 2022 06:05:03 +0000 (08:05 +0200)]
sctp: improve path verification

When sending path confirmation heartbeats, do not take HB.interval
into account when the path is still reachable.

Thanks to Alexander Funke for finding the issue and suggesting a fix.

(cherry picked from commit 9312ba239e05b035c965e5790f70fe71a4ed2e8c)

19 months agosctp: improve consistency
Michael Tuexen [Sat, 14 May 2022 04:28:19 +0000 (06:28 +0200)]
sctp: improve consistency

No functional change intended.

(cherry picked from commit 9b2a35b3a96b44019d7884da9de92c4f92d64994)

19 months agosctp: improve locking
Michael Tuexen [Wed, 27 Apr 2022 14:07:31 +0000 (16:07 +0200)]
sctp: improve locking

While there, do some cleanup.

Reported by: syzbot+f475e054c454310bc26d@syzkaller.appspotmail.com

(cherry picked from commit 490a0f77de77321859eeeecc807f9cc7bb41dbcc)

19 months agosctp: cleanup
Michael Tuexen [Tue, 19 Apr 2022 19:40:22 +0000 (21:40 +0200)]
sctp: cleanup

MFC after: 3 days

(cherry picked from commit 89c6aba7cfa5327d814eb54336b3e9640cce0fac)

19 months agosctp: improve stopping of timers
Michael Tuexen [Tue, 19 Apr 2022 19:29:41 +0000 (21:29 +0200)]
sctp: improve stopping of timers

Reported by: syzbot+c9c70062320aaad19de7@syzkaller.appspotmail.com
MFC after: 3 days

(cherry picked from commit 868868f14efcd7e127dae6e87550357c6cdb9c6d)

19 months agosctp: hold the inp lock while calling ip6_output
Michael Tuexen [Tue, 19 Apr 2022 11:03:08 +0000 (13:03 +0200)]
sctp: hold the inp lock while calling ip6_output

This fixes an issue with handling IPPROTO_IPV6 level socket
options.

Reported by: syzbot+66ede232c3d1271c6226@syzkaller.appspotmail.com
MFC after: 3 days

(cherry picked from commit a12d89332efe0b02307c580a6f3025652374cd47)

19 months agoif_vtnet: improve dumping a kernel
Michael Tuexen [Mon, 18 Apr 2022 22:40:31 +0000 (00:40 +0200)]
if_vtnet: improve dumping a kernel

Disable software LRO during kernel dumping, because having it enabled
requires to be in a network epoch, which might or might not be the
case depending on the code path resulting in the panic.

Reviewed by: markj
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D34787

(cherry picked from commit 53236f905dbf4f3d58b1d5eff5c9b14f100d0c5d)

19 months agosctp: cleanup
Michael Tuexen [Sat, 16 Apr 2022 19:03:16 +0000 (21:03 +0200)]
sctp: cleanup

(cherry picked from commit bbf3bf32116b0b1ff28a19ec0bc2dbcf23b6a94c)

19 months agosctp: fix typo introcuded in last commit
Michael Tuexen [Sat, 16 Apr 2022 17:55:33 +0000 (19:55 +0200)]
sctp: fix typo introcuded in last commit

(cherry picked from commit 5fbf11f70390a043cba06ba893c897f32d005f5d)

19 months agosctp: don't wakeup 1-to-1 listening sockets for data or notifications
Michael Tuexen [Sat, 16 Apr 2022 17:42:27 +0000 (19:42 +0200)]
sctp: don't wakeup 1-to-1 listening sockets for data or notifications

Reported by: syzbot+ec9279d306a4ff0215f8@syzkaller.appspotmail.com
Reported by: syzbot+31d54f6d486333493dd4@syzkaller.appspotmail.com

(cherry picked from commit 3dc57df91e65acf9abfbb437110845f380a8b312)

19 months agosctp: don't keep a pointer to a freed stcb around
Michael Tuexen [Fri, 15 Apr 2022 12:00:00 +0000 (14:00 +0200)]
sctp: don't keep a pointer to a freed stcb around

Reported by: syzbot+b9ef06efdae7cb9ee414@syzkaller.appspotmail.com
Reported by: syzbot+b1e4793e0e6b25b0d510@syzkaller.appspotmail.com

(cherry picked from commit eeba222172170c380450004fdceac80c3612b1e8)

19 months agosctp: improve locking
Michael Tuexen [Fri, 15 Apr 2022 11:58:45 +0000 (13:58 +0200)]
sctp: improve locking

Hold a refcount while giving up an stcp lock. This issue was
found by running syzkaller.

(cherry picked from commit e0127ea4c6b50a5bf239482d8a99ae418174aee5)

19 months agosctp: cleanup
Michael Tuexen [Thu, 14 Apr 2022 19:50:10 +0000 (21:50 +0200)]
sctp: cleanup

(cherry picked from commit 2486a7c0c733fb67636c2004aa3300f417eb5cfe)

19 months agosctp: #ifdef INET-only and INET6-only variables.
John Baldwin [Wed, 13 Apr 2022 23:08:21 +0000 (16:08 -0700)]
sctp: #ifdef INET-only and INET6-only variables.

Duplicating the SCTP_PCB_FLAGS_BOUND_V6 check made the #ifdef's
simpler than applying #ifdef's directly to the original code.  Modern
compilers should cache the result rather than testing the flag twice.

(cherry picked from commit 29a843177e108c688d7daaccac6ada4d16f01dca)

19 months agosctp: fix parameter type in NAT status message
Michael Tuexen [Wed, 13 Apr 2022 17:46:28 +0000 (19:46 +0200)]
sctp: fix parameter type in NAT status message

Thanks to Sriram Yagnaraman for providing the patch for the
userland stack.

(cherry picked from commit 595ac4a11893971ba17a51e0477d580e29e1ef7a)

19 months agosctp: remove a mutex not used anymore
Michael Tuexen [Thu, 7 Apr 2022 15:54:57 +0000 (17:54 +0200)]
sctp: remove a mutex not used anymore

(cherry picked from commit d7224a53b392ec6e230749d9fb42d8826d305d08)

19 months agosctp: use variable names in a consistent way
Michael Tuexen [Thu, 7 Apr 2022 15:51:31 +0000 (17:51 +0200)]
sctp: use variable names in a consistent way

No functional change intended.

(cherry picked from commit 3c3d77bdff6bbb71368fd2b34c32b1ef03421000)

19 months agosctp: don't refer to a potentially outdated stream
Michael Tuexen [Sat, 2 Apr 2022 21:26:27 +0000 (23:26 +0200)]
sctp: don't refer to a potentially outdated stream

Reported by: syzbot+1593381019112e5bb35c@syzkaller.appspotmail.com

(cherry picked from commit 52106f072fd06890fd50ce1a232cbf522ae2155c)

19 months agosctp: cleanup, no functional change
Michael Tuexen [Sat, 2 Apr 2022 21:02:16 +0000 (23:02 +0200)]
sctp: cleanup, no functional change

(cherry picked from commit b30b7a140c527c023f97083c256715ea86d4b6f4)

19 months agosctp: remove a test, which isn't safe
Michael Tuexen [Sat, 2 Apr 2022 13:09:50 +0000 (15:09 +0200)]
sctp: remove a test, which isn't safe

 We can't ensure the stcb is still around. This issue was found
 by syzkaller.

(cherry picked from commit 0f316316200386986de7ac72cf717c13b28f387e)

19 months agosctp: clear pointer to stack when returning from function.
Michael Tuexen [Fri, 1 Apr 2022 22:54:49 +0000 (00:54 +0200)]
sctp: clear pointer to stack when returning from function.

Reported by:    syzbot+04cee5d8805dfbb63c06@syzkaller.appspotmail.com
Reported by:    syzbot+71e7e33dfc3cc39a6bd0@syzkaller.appspotmail.com
Reported by:    syzbot+6c36fc3c1bd03ed96107@syzkaller.appspotmail.com
Reported by:    syzbot+198b3751c158181c47de@syzkaller.appspotmail.com

(cherry picked from commit 39a22011bbb820b389ce8ad166f7bdce112a75cc)

19 months agosctp: ensure that ASCONF chunks are not too large
Michael Tuexen [Tue, 29 Mar 2022 23:22:20 +0000 (01:22 +0200)]
sctp: ensure that ASCONF chunks are not too large

(cherry picked from commit 218e463b85c4b78af93583cfc3d95a1cab8408bf)

19 months agosctp: fix typos
Michael Tuexen [Tue, 29 Mar 2022 19:09:51 +0000 (21:09 +0200)]
sctp: fix typos

Thanks to David Sanders for fixing the typos in the userland stack.

(cherry picked from commit e7e65008ffba90dc57c5f2edf5a000d7d1293a47)

19 months agosctp: don't lock an already locked stcb.
Michael Tuexen [Tue, 29 Mar 2022 14:33:53 +0000 (16:33 +0200)]
sctp: don't lock an already locked stcb.

Reported by: syzbot+e8dca84da3b4b82f4400@syzkaller.appspotmail.com

(cherry picked from commit 5d0c76c7302bad0cd0a9f83a30e11d70141adf37)

19 months agosctp: get rid of stcb send lock
Michael Tuexen [Mon, 28 Mar 2022 23:50:17 +0000 (01:50 +0200)]
sctp: get rid of stcb send lock

Just use the stcb lock instead to simplify locking.

Reported by: syzbot+d00b202063150f85b110@syzkaller.appspotmail.com
Reported by: syzbot+87f268a0a6d2d6383306@syzkaller.appspotmail.com

(cherry picked from commit 5ac91821f5d7dd701752ba76041720d240a507c5)

19 months agodtrace: Improve a verifier error message
Domagoj Stolfa [Tue, 24 Jan 2023 14:09:27 +0000 (09:09 -0500)]
dtrace: Improve a verifier error message

Using '%r0' in efunc causes it to parse %r as a 'r' specifier.

This diff just adds a '%' in front of '%r0' in order to create the
correct output.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38176

(cherry picked from commit 7c5bc69a1a33b3a544175ad89c0bba1429491218)

19 months agonetmap: Tell the compiler to avoid reloading ring indices
Mark Johnston [Mon, 23 Jan 2023 19:41:05 +0000 (14:41 -0500)]
netmap: Tell the compiler to avoid reloading ring indices

Per the removed comments these fields should be loaded only once, since
they can in principle be modified concurrently, though this would be a
violation of the userspace contract with netmap.

No functional change intended.

Reviewed by: vmaffione
MFC after: 1 week
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38061

(cherry picked from commit 56c438fcd4a755f0abe8254779c39a0c4b530c75)

19 months agonetmap: Correct a comment
Mark Johnston [Mon, 23 Jan 2023 19:42:19 +0000 (14:42 -0500)]
netmap: Correct a comment

Reviewed by: vmaffione
MFC after: 1 week
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38063

(cherry picked from commit 854b2f302dcc73dfef2e4458d382f8149ce9167c)

19 months agonetmap: Fix a queue length check in the generic port rx path
Mark Johnston [Mon, 23 Jan 2023 19:41:55 +0000 (14:41 -0500)]
netmap: Fix a queue length check in the generic port rx path

The check is ok by default, since the default value of
netmap_generic_ringsize is 1024.  But we should check against the
configured "ring" size.

Reviewed by: vmaffione
MFC after: 1 week
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38062

(cherry picked from commit 539437c8281d24450bacded3734276acd9983e90)

19 months agoipsec: Clear pad bytes in PF_KEY messages
Mark Johnston [Mon, 16 Jan 2023 15:46:20 +0000 (10:46 -0500)]
ipsec: Clear pad bytes in PF_KEY messages

Various handlers for SADB messages will allocate a new mbuf and populate
some structures in it.  Some of these structures, such as struct
sadb_supported, contain small reserved fields that are not initialized
and are thus leaked to userspace.

Fix the problem by adding a helper to allocate zeroed mbufs.  This
reduces code duplication and the overhead of zeroing these messages
isn't harmful.

Reviewed by: zlei, melifaro
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38068

(cherry picked from commit 8a9495517b0ad54da9759a7ba2cc0b56f8e7c8f9)

19 months agousr.bin/stat: Fix error message formatting.
Jamie Landeg-Jones [Sun, 29 Jan 2023 22:37:25 +0000 (14:37 -0800)]
usr.bin/stat: Fix error message formatting.

PR: bin/261657

(cherry picked from commit 37399d5bcf67c6d68e30a34ce2df30e0964d46d9)

19 months agonetwork.subr: Fix infinite loop
Cy Schubert [Wed, 14 Dec 2022 21:41:10 +0000 (13:41 -0800)]
network.subr: Fix infinite loop

When setting up carp tunnel, using a password consisting of only the
characters used as hexadecimal characters, i.e. abc-def, there will be
an infinite loop in the shell function ifalias_af_common_handler().
To circumvent this we test for " pass ".

PR: 268378
Reported by: jyoung15@gmail.com
Differential Revision: https://reviews.freebsd.org/D37748

(cherry picked from commit e3e57edf4aac05d041ca55ff2f008c6109ef88d5)

19 months agonetwork.subr: Replace "\ " with "[[:space:]]"
Cy Schubert [Wed, 21 Dec 2022 16:06:02 +0000 (08:06 -0800)]
network.subr: Replace "\ " with "[[:space:]]"

"[[:space:]]" is easier to read than "\ " and is conisitent with
clone_up().

Reported by: eugen
Differential Revision: https://reviews.freebsd.org/D37748

(cherry picked from commit fef0e429f190d396d5b3228166a012e85dd912f2)

19 months agoNote upgrade to sendmail 8.17.1
Gregory Neil Shapiro [Wed, 1 Feb 2023 02:48:05 +0000 (02:48 +0000)]
Note upgrade to sendmail 8.17.1

19 months agoMFC: Note upgrade to sendmail 8.17.1
Gregory Neil Shapiro [Wed, 1 Feb 2023 02:22:39 +0000 (02:22 +0000)]
MFC: Note upgrade to sendmail 8.17.1

(cherry picked from commit 38c2f8fe6207ec50088f9efc36d66776b0608137)

19 months agoMFC: Minor changes to force commit these files so new freebsd*.cf files are
Gregory Neil Shapiro [Tue, 17 Jan 2023 06:49:49 +0000 (06:49 +0000)]
MFC: Minor changes to force commit these files so new freebsd*.cf files are
built to use the new sendmail-8.17.1/cf tree.

(cherry picked from commit 431d2a81d421d4db7a07833b4fd12015cbae5ee7)

19 months agoMFC: Sync with vendor sendmail 8.17.1 cf/cf/submit.mc
Gregory Neil Shapiro [Tue, 17 Jan 2023 06:49:07 +0000 (06:49 +0000)]
MFC: Sync with vendor sendmail 8.17.1 cf/cf/submit.mc

(cherry picked from commit 021562c5020dd63d6b812369a9020b3b8147bfbd)

19 months agoMFC: sendmail 8.17.1 included this fix, though in a different location so
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:25:39 +0000 (21:25 +0000)]
MFC: sendmail 8.17.1 included this fix, though in a different location so
removing the FreeBSD local code in favor of the vendor branch version

(cherry picked from commit f97a19ecb98541455c6c940f4bab2dc7dc425468)

19 months agoMFC: Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:24:38 +0000 (21:24 +0000)]
MFC: Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds

(cherry picked from commit 3413ee88c39dbfedfa7d00db536a8e8dc073a562)

19 months agoMFC: Update for new library files in sendmail 8.17.1
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:23:27 +0000 (21:23 +0000)]
MFC: Update for new library files in sendmail 8.17.1

(cherry picked from commit d89513ed20502ddb320474a721d872ef32b31402)

19 months agoMerge commit '28fbd2825d216dafca4d991ad96d05b312f4f9a3'
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:20:22 +0000 (21:20 +0000)]
Merge commit '28fbd2825d216dafca4d991ad96d05b312f4f9a3'

Merge vendor sendmail 8.17.1 into HEAD

(cherry picked from commit 2fb4f839f3fc72ce2bab12f9ba4760f97f73e97f)

19 months agoMakefile.inc1: Print the right PATH for missing install tool error
Jessica Clarke [Sun, 29 Jan 2023 23:45:49 +0000 (23:45 +0000)]
Makefile.inc1: Print the right PATH for missing install tool error

We override PATH for which but then go and print the non-overridden
PATH, which leads to rather confusing messages.

Fixes: 5bb9250e0af4 ("Add necessary Makefile.inc1 infrastructure for building on non-FreeBSD")
(cherry picked from commit 4ebd18cf357af71941675ff3ae7fb3bf56a37e0e)

19 months agoBring our tzcode up to date.
Dag-Erling Smørgrav [Tue, 10 Jan 2023 15:14:27 +0000 (16:14 +0100)]
Bring our tzcode up to date.

* Replay 2010[acflm] which had been merged but not recorded.
* Merge 2010n.
* Reorganize (unsplit) the code to match the upstream layout.
* Merge 2022[cdefg].

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

(cherry picked from commit bc42155199b5b0b479311e05b07aee7f6f9c5172)

tzcode: Address some compiler warnings.

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

(cherry picked from commit d5c85ac6526dcd0ac25ebdb71969c8c788d5e13b)

tzcode: Move configuration into separate header.

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

(cherry picked from commit 394cf6719a3c665eabe24d96669409e0c5a78076)

tzcode: Remove access() again, cf. 02ba1d993fa9.

Reported by: Coverity (CID 1250126)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38035

(cherry picked from commit 3e2e5eebfaa0aebb2790bbde7f35d4c6c52e2596)

tzcode: Avoid memory leak if pthread_setspecific() fails.

Reported by: Coverity (CID 10184721018474)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38036

(cherry picked from commit 96e68c393f65046c0cf69d29f89efcfee949e5de)

tzcode: Fully initialize structs before use.

Reported by: Coverity (CID 15025421502548)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38037

(cherry picked from commit 55572cff58c4208a9e532356a245676b8eed6a3e)

tzcode: Silence warnings.

* Ignore failure to remove our temp file.
* Avoid a minor memory leak in the -D case.

Reported by: Coverity (CID 150253415025351502538)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38038

(cherry picked from commit 2aad7570f4e11ac94bb06c44cdc83ad1962fb97e)

depend-cleanup.sh: handle zic moving one level up.

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

(cherry picked from commit 4a158fc030b5a31efdbad8b30c9a859df553ae3c)

libc: Update mktime(3) / timegm(3) tests.

Sponsored by: Klara, Inc.
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D38177

(cherry picked from commit d8c9f80891872a54d0b21933136644d915096fe3)

zoneinfo: On amd64, include 32-bit data.

While there, drop the unnecessary posixrules option.

Sponsored by: Klara, Inc.
Reviewed by: imp, allanjude
Differential Revision: https://reviews.freebsd.org/D38142

(cherry picked from commit 783c318fd1181d46554c31a5039db10e7f5eef49)

tzcode: Document zic's -D option.

Sponsored by: Klara, Inc.
Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D38141

(cherry picked from commit a7b1b73935f21a3dcd6fc8d86a37b92f0c9ba93f)

zoneinfo: Always produce fat zoneinfo files.

These aren't just needed for compatibility with i386 binaries (which need
the 32-bit section), but potentially also for compatibility with older
binaries on all platforms.

Sponsored by: Klara, Inc.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38194

(cherry picked from commit f1021d27f73efb821213a973e1ab9366278c78f1)

Fix cross-build from STABLE or older CURRENT.

Previously, zic and tzsetup were both listed as install tools and basic
bootstrap tools.  Actually, tzsetup is an install tool while zic is a
non-basic bootstrap tool.

Fixes: 783c318fd118
Sponsored by: Klara, Inc.
Reviewed by: jrtc27, emaste
Differential Revision: https://reviews.freebsd.org/D38195

(cherry picked from commit 7a4a520064cb7fbff79560113682d6fe1a1ae9ee)

Makefile.inc1: Restore adding tzsetup to _basic_bootstrap_tools

ITOOLS is only the list of programs to make a copy of during install, it
doesn't cause anything to be bootstrapped. Thus, by removing tzsetup
from _basic_bootstrap_tools, we end up without it on non-FreeBSD, and so
we error out trying to copy it to INSTALLTMP.

Note that _basic_bootstrap_tools is only used for BOOTSTRAP_ALL_TOOLS
(which is why zic was moved away from it). Should tzsetup evolve such
that the host version is insufficient on older FreeBSD it can be moved
to be more like zic, but that seems unnecessary for what is likely to
remain a simple tool.

This partially reverts commit 7a4a520064cb7fbff79560113682d6fe1a1ae9ee.

Fixes: 7a4a520064cb ("Fix cross-build from STABLE or older CURRENT.")
(cherry picked from commit d4fdfd3f9077216e52f38f7364974959c9e43168)

19 months agotzcode: Implement timezone change detection
Edward Tomasz Napierala [Sun, 12 Sep 2021 03:07:26 +0000 (03:07 +0000)]
tzcode: Implement timezone change detection

Implement optional timezone change detection for local time libc
functions.  This is disabled by default; set WITH_DETECT_TZ_CHANGES
to build it.

Reviewed By: imp
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
X-NetApp-PR: #47
Differential Revision: https://reviews.freebsd.org/D30183

(cherry picked from commit ddedf2a11eb20af1ee52cb3da70a57c21904af8f)

tzcode: Fix operation without WITH_DETECT_TZ_CHANGES

Reviewed By: bdrewery, kevans, cy
Reported By: lwhsu, bdrewery
Fixes: ddedf2a11eb
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31961

(cherry picked from commit 6f43f86bf36dba158355593bab5f81a7f8e2773c)

tzcode: fix tz change detection logic

clock_gettime() returns 0 if it succeeds, so don't capture that into the
fail logic.  With this, WITH_DETECT_TZ_CHANGES successfully detects a
change after 61 seconds.

Reviewed by: imp, trasz
Differential Revision: https://reviews.freebsd.org/D33494

(cherry picked from commit a2c51da6581dbc38c60c9fc41d1b624ff2c8de97)

19 months agopfctl: rule.label is a two-dimensional array
Kristof Provost [Tue, 24 Jan 2023 06:46:46 +0000 (07:46 +0100)]
pfctl: rule.label is a two-dimensional array

Fix checking for a non-empty first string.

PR: 269075
MFC after: 1 week
Reported by: nreilly@blackberry.com

(cherry picked from commit cd80c52cade3e38d273eecec6f9b0a7cba23bcc8)

19 months agogoldfish_rtc: Fix handling a local time RTC
Jessica Clarke [Sun, 14 Aug 2022 18:50:22 +0000 (19:50 +0100)]
goldfish_rtc: Fix handling a local time RTC

The default QEMU config is to have the RTC in UTC. However, if run with
-rtc base=localtime (and wall_cmos_clock is set to match), the driver
fails to account for adjkerntz due to the use of CLOCKF_SETTIME_NO_ADJ.
Copy the same code used by other CLOCKF_SETTIME_NO_ADJ-using drivers
to fix this, namely manually subtracting utc_offset().

Fixes: d63a631e7244 ("Add Goldfish RTC device driver for RISC-V")
MFC after: 1 week

(cherry picked from commit 762dcf10641251c55dda2e6950fef8bb698027ad)

19 months agolibcrypto: Work around strict aliasing violations in bn_nist.c
Jessica Clarke [Mon, 25 Jul 2022 17:17:50 +0000 (18:17 +0100)]
libcrypto: Work around strict aliasing violations in bn_nist.c

This file is full of strict aliasing violations. Previously it was only
optimised in ways that broke the code by CHERI LLVM, but now it appears
that the in-tree LLVM also breaks it for RISC-V, resulting in broken
ECDSA signature validation with error messages like the following:

  root@unmatched:/usr/src # ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key
  /etc/ssh/ssh_host_ecdsa_key is not a key file.
  root@unmatched:/usr/src # git fetch
  fatal: unable to access 'https://git.FreeBSD.org/src.git/': error:1012606B:elliptic curve routines:EC_POINT_set_affine_coordinates:point is not on curve

Reviewed by: dim, jkim
Obtained from: CheriBSD
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35885

(cherry picked from commit 3b41ae32124ad7b61b2297b2e7f3aa5d76b30c53)

19 months agomips: Fix sendsig for stack layout randomisation
Jessica Clarke [Tue, 31 Jan 2023 01:27:50 +0000 (01:27 +0000)]
mips: Fix sendsig for stack layout randomisation

PS_STRINGS doesn't account for the stack gap, we need to use the new
PROC_PS_STRINGS macro to correctly point at the trampoline.

This is a direct commit to stable/13 as mips no longer exists in main.

Fixes: d247611467e0 ("exec: Introduce the PROC_PS_STRINGS() macro")

19 months agolibc: Fix longjmp/_longjmp(buf, 0) for MIPS
Jessica Clarke [Mon, 30 Jan 2023 23:55:03 +0000 (23:55 +0000)]
libc: Fix longjmp/_longjmp(buf, 0) for MIPS

Like AArch64 and RISC-V in the past, MIPS fails to handle this special
case, and will cause the corresponding setjmp/_setjmp to return 0 rather
than 1. Fix this so the newly-added regression tests pass.

This is a direct commit to stable/13 as mips no longer exists in main.

Reviewed by: arichardson, jhb
Differential Revision: https://reviews.freebsd.org/D29363

19 months agolibc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-V
Jessica Clarke [Mon, 9 Jan 2023 18:34:43 +0000 (18:34 +0000)]
libc: Fix longjmp/_longjmp(buf, 0) for AArch64 and RISC-V

These architectures fail to handle this special case, and will cause the
corresponding setjmp/_setjmp to return 0 rather than 1. Fix this and add
regression tests (also committed upstream).

PR: 268684
Reviewed by: arichardson, jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29363

(cherry picked from commit 9fb118bebced1452a46756a13be0161021b10905)

19 months agoMakefile: Avoid sanitizing PATH on non-FreeBSD systems
Jake Freeland [Thu, 19 Jan 2023 22:24:44 +0000 (22:24 +0000)]
Makefile: Avoid sanitizing PATH on non-FreeBSD systems

Allow the build process to find host binaries during the host-symlinks target when
cross-building on non-FreeBSD systems. Whilst most non-FreeBSD systems have all
the needed tools in /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin (the final
path added by host-symlinks itself), Homebrew for macOS on Arm defaults to
/opt/homebrew/bin, other more niche systems may also deviate and users may
expect tools in a customised PATH to be picked up, unlike on FreeBSD where we
want to ensure everything comes from base. In particular, (un)xz are needed
from Homebrew on macOS, and thus cannot be found on Arm without this.

Note that non-FreeBSD builds enforce BUILD_WITH_STRICT_TMPPATH, and so the
actual main build steps will still use a sanitised PATH.

Reviewed by: jrtc27, arichardson
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37991

(cherry picked from commit 16fbf0191243e7c9dff6615b1424b5d39186b36c)

19 months agostrfmon(3): Match the return type
Jose Luis Duran [Tue, 8 Nov 2022 20:16:49 +0000 (17:16 -0300)]
strfmon(3): Match the return type

(cherry picked from commit f5924ad8fde4d5e9c233b821cb6097c6a46740b5)

19 months agostrfmon(3): Wording improvements
Jose Luis Duran [Tue, 8 Nov 2022 20:53:17 +0000 (17:53 -0300)]
strfmon(3): Wording improvements

(cherry picked from commit 59cc636d94a6c9b28147304fa59351224f801e92)

19 months agostrfmon(3): Add an EXAMPLES section
Jose Luis Duran [Tue, 8 Nov 2022 20:36:57 +0000 (17:36 -0300)]
strfmon(3): Add an EXAMPLES section

(cherry picked from commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de)

19 months agolibcxx: add comment explaining why umtx is only used for 64bits
Konstantin Belousov [Tue, 24 Jan 2023 15:36:24 +0000 (17:36 +0200)]
libcxx: add comment explaining why umtx is only used for 64bits

(cherry picked from commit 4c4a29267cbdd05471322e03bfd5eff8eb68e750)

19 months agolibcxx: use __SIZEOF_LONG__ == 8 instead of __LP64__
Konstantin Belousov [Tue, 24 Jan 2023 10:03:45 +0000 (12:03 +0200)]
libcxx: use __SIZEOF_LONG__ == 8 instead of __LP64__

For MFC, 64bit mips is excluded from the new mode of wait/wake, because
it uses 32bit __cxx_contention_t, as noted by jrtc27.

(cherry picked from commit 25b18d8935a5ee933d5465f5db41ad58c26590f9)

19 months agolibcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches
Konstantin Belousov [Fri, 20 Jan 2023 02:57:26 +0000 (04:57 +0200)]
libcxx: Implement atomic::wait/notify using _umtx_op(2) for 64bit arches

(cherry picked from commit 9c996882b0ed279ca314d995f2eb1d538b94e3f8)

19 months agofreebsd32: Make sendmsg match native ABI for unpadded final control message
Jessica Clarke [Thu, 15 Sep 2022 16:16:22 +0000 (17:16 +0100)]
freebsd32: Make sendmsg match native ABI for unpadded final control message

The API says that CMSG_SPACE should be used for msg_controllen, but in
practice the native ABI allows you to only use CMSG_LEN for the final
(typically only) control message, and real-world software does this,
including Wayland. For freebsd32, this is in practice mostly harmless,
since control messages are generally used to carry file descriptors,
which are already 4 bytes in size and thus no padding is needed, but
they can carry other quantities that may not result in an aligned
length. This was discovered after CheriBSD's freebsd64 equivalent was
updated to match the freebsd32 implementation, as that uses 8 byte
alignment which does break the file descriptor use case, and thus
Wayland.

This used to be addressed by aligning buflen before the first iteration,
but that allowed unwanted invalid inputs and was lost in 1b1428dcc82b,
with no safer equivalent put in its place.

Reviewed by: brooks, kib, markj
Obtained from: CheriBSD
Fixes: 1b1428dcc82b ("Fix a TOCTOU vulnerability in freebsd32_copyin_control().")
Differential Revision: https://reviews.freebsd.org/D36554

(cherry picked from commit 7b673a2c73d0577e2c006aeb110295a522b98135)

19 months agofreebsd32_sendmsg: fix control message ABI
Brooks Davis [Wed, 24 Aug 2022 17:34:39 +0000 (18:34 +0100)]
freebsd32_sendmsg: fix control message ABI

When a freebsd32 caller uses all or most allowed space for control
messages (MCLBYTES == 2K) then the message may no longer fit when
the messages are padded for 64-bit alignment.  Historically we've just
shrugged and said there is no ABI guarantee.  We ran into this on
CheriBSD where a capsicumized 64-bit nm would fail when called with more
than 64 files.

Fix this by not gratutiously capping size of mbuf data we'll allocate
to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger).
Instead of hard-coding a length check, let m_get2 do it and check for a
NULL return.

Reviewed by: markj, jhb, emaste
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D36322

(cherry picked from commit c46697b9cb97a14f61ac0a58758aab081b9e48c5)

19 months agokvmclock: Fix initialization when EARLY_AP_STARTUP is not defined
Mark Johnston [Fri, 13 Jan 2023 15:01:00 +0000 (10:01 -0500)]
kvmclock: Fix initialization when EARLY_AP_STARTUP is not defined

To attach to the hypervisor, kvmclock needs to write a per-CPU MSR.
When EARLY_AP_STARTUP is not defined, device attach happens too early:
APs are not yet spun up, so smp_rendezvous only runs the callback on the
local CPU.  As a result, the timecounter only gets initialized on the
BSP, and then timekeeping is broken on SMP systems.

Implement handling for !EARLY_AP_STARTUP kernels: keep track of the CPU
on which device attach ran, and then use a SI_SUB_SMP SYSINIT to
register the rest of the CPUs with the hypervisor.

Reported by: Shrikanth R Kamath <kshrikanth@juniper.net>
Reviewed by: kib, jhb (earlier versions)
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D37705

(cherry picked from commit 568f552b0410f4f72db9ce710f7803acca23f79f)

19 months agoAdd kf_file_nlink field to kf_file and populate it
Jiajie Chen [Mon, 23 Jan 2023 16:36:59 +0000 (00:36 +0800)]
Add kf_file_nlink field to kf_file and populate it

This will allow user-space programs (e.g. lsof) to locate deleted files
whose nlink equals zero. Prior to this commit, programs has to use
stat(kf_path) to get nlink, but that will fail if the file is deleted.

[mjg: s/fail/file in the commit message]

Reviewed by: mjg
Differential Revision:  https://reviews.freebsd.org/D38169

(cherry picked from commit dec7db49602df75119f6b57d32f1eb58e0040abc)

19 months agonetpfil tests: improve pfsync_defer.py
Kajetan Staszkiewicz [Fri, 20 Jan 2023 09:43:02 +0000 (10:43 +0100)]
netpfil tests: improve pfsync_defer.py

Return different exit code depending on which failure was encountered.
The pfsync test expect a very particular failure, not just any.

MFC after: 1 week
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D38123

(cherry picked from commit 06012728beff45e94d58410eae7cda2ea980ef77)

19 months agonetpfil tests: improve pft_ping.py
Kajetan Staszkiewicz [Sat, 21 Jan 2023 02:44:52 +0000 (03:44 +0100)]
netpfil tests: improve pft_ping.py

Multiple improvements to pft_ping.py:

* Automatically use IPv6 when IPv6 addresses are used, --ip6 is not needed.
* Building of ping requests and parsing of ping replies is done layer by
  layer. This way most arguments are available both for IPv6 and IPv4,
  for ICMP and TCP.
* Use argument groups for improved readability.
* Change ToS and TTL argument name to TC and HL to reflect the modern
  IPv6 nomenclature. The argument still set related IPv4 header fields
  properly.
* Instead of sniffing for the very specific case of duplicated packets,
  allow for sniffing on multiple interfaces.
* Report which sniffer has failed by setting bits of error code.
* Raise meaningful exceptions when irrecoverable errors happen.
* Make IPv4 fragmentation flags configurable.
* Make IPv6 HL / IPv4 TTL configurable.
* Make TCP MSS configurable.
* Make TCP sequence number configurable.
* Make ICMP payload size configurable.
* Add debug output.
* Move command line argument parsing out of network functions.
* Make the code somehow PEP-8 compliant.

MFC after: 1 week
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D38122

(cherry picked from commit f57218e469a7b1ab40521ea75ebfd45b493851ca)

19 months agonetpfil tests: improve sniffer.py
Kajetan Staszkiewicz [Fri, 20 Jan 2023 01:40:34 +0000 (02:40 +0100)]
netpfil tests: improve sniffer.py

Multiple improvements to sniffer.py:

* Remove ambiguity of configuring recvif, it must be now explicitly specified.
* Don't catch exceptions around creating the sniffer, let it properly
  fail and display the whole stack trace.
* Count correct packets so that duplicates can be found.

MFC after: 1 week
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D38120

(cherry picked from commit a39dedeb31052ec74b0cd394d56f8d7cc8534645)

19 months agonfsserver: Fix handling of SP4_NONE
Rick Macklem [Sun, 15 Jan 2023 22:07:40 +0000 (14:07 -0800)]
nfsserver: Fix handling of SP4_NONE

For NFSv4.1/4.2, when the client specifies SP4_NONE for
state protection in the ExchangeID operation arguments,
the server MUST allow the state management operations for
any user credentials.  (I misread the RFC and thought that
SP4_NONE meant "at the server's discression" and not MUST
be allowed.)

This means that the "sec=XXX" field of the "V4:" exports(5)
line only applies to NFSv4.0.

This patch fixes the server to always allow state management
operations for SP4_NONE, which is the only state management
option currently supported. (I have patches that add support
for SP4_MACH_CRED to the server. These will be in a future commit.)

In practice, this bug does not seem to have caused
interoperability problems.

(cherry picked from commit 5a0050e68a54353af53ac28df90854797ebbef16)

19 months agogrep: properly switch EOL indicator with -z
Kyle Evans [Wed, 4 Jan 2023 05:21:10 +0000 (23:21 -0600)]
grep: properly switch EOL indicator with -z

-z is supposed to use only the NUL byte as EOL, but we were
inadvertently using both newline and NUL due to REG_NEWLINE in cflags.

The odds of anyone relying on this bsdgrep-specific bug are quite low,
so let's just fix it.  At least one port in the wild has been reported
to expect the intended behavior.

Reported by: Hill Ma <maahiuzeon@gmail.com>
Triaged by: the self-proclaimed peanut gallery on Discord

(cherry picked from commit e898a3af97f97f74c0fb22032bbd163f7cc92a05)

19 months agopf tests: test fast port re-use with syncookies
Kristof Provost [Sat, 31 Dec 2022 18:23:15 +0000 (19:23 +0100)]
pf tests: test fast port re-use with syncookies

When a src/dst ip/port tuple is re-used before the pf state fully
expires we clean up the state and create a new one, unless syncookies
are enabled.

Test this, by running two back-to-back nc sessions, with a fixed source
port. Move the interface and IP to a different (vnet) jail, to trick the
network stack into letting us do this.

MFC after:      2 weeks
Event:          Aberdeen hackathon 2022
Differential Revision:  https://reviews.freebsd.org/D36886

(cherry picked from commit dc698b2cd59ebc08b05a261dbba8ee5707450d28)