Commit graph

277284 commits

Author SHA1 Message Date
Kristof Provost 248da7940a if_ovpn tests: Test using a TCP socket for DCO
This used to trigger panics, so try to reproduce it.
Create an if_ovpn interface, set a new peer on it with a TCP fd (as
opposed to the expected UDP) and ensure that this is rejected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-08-11 10:40:03 +02:00
Kristof Provost fd6b3bede5 if_ovpn: reject non-UDP sockets
We must ensure that the fd provided by userspace is really for a UDP
socket. If it's not we'll panic in udp_set_kernel_tunneling().

Reported by:	Gert Doering <gert@greenie.muc.de>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-08-11 10:40:03 +02:00
Søren Schmidt 0b6d133c08 Add RockChip RK356X support to existing RockChip thermal driver. 2022-08-11 08:26:39 +00:00
Peter Holm 64f923959a stress2: Added a regression test 2022-08-11 09:42:02 +02:00
Ganbold Tsagaankhuu ace8bb34ce Add support for RK3568 to RockChip GRF and SPI drivers.
Partially from https://reviews.freebsd.org/D36027

Submitted by:	sos
2022-08-11 05:32:48 +00:00
Warner Losh 39fdad34e2 stand: impose 510,000 byte limit for /boot/loader and /boot/pxeldr
The BIOS method of booting imposes an absolute limit of 640k for the
size of the program being run due to btx. In practice, this means that
programs larger than about 500kiB will fail in odd ways as the stack /
heap will overflow.

Pick 510,000 as the cutoff line semi-arbitrarily. loader_lua is now
almost too big and we want to break the build when it crosses this
threshold. In my experience, below 500,000 always works, above 520,000
always seems to fail with things getting bad somewhere between 512,000
to 515,000. 510,000 is as close to the line as I think we can go, though
experience may dictate we need to lower this in the future.

This is at-best a stop-breakage until we have a better way to subset the
boot loader for BIOS booting to allow better, more fined-tuned
/boot/loaders for the many different environments they have to run
in. This likely means we'll have a graphical loader than understands a
few filesystmes for installation, and a non-graphical loader that
understands the most filesystems possible for everything else in the
future. Our build infrastructure needs some work before we can do that,
however.

At this late date, it likely isn't worth the efforts to move parts of
the loader into high memory. There's a number of assumptions about where
the stack is, where buffers reside, etc that are fulfilled when it lives
in the first 640k that would need bounce buffers and/or other counter
measures if we were to split it up. All BIOS calls are done in 16-bit
mode with SEG:OFF addresses, requiring them to be in the first 640k of
RAM. And nearly all machines in the last decade can boot with UEFI
(though there's some exceptions, so it isn't worth killing outright
yet).

Sponsored by:		Netflix
Reviewed by:		kevans
Differential Revision:	https://reviews.freebsd.org/D36129
2022-08-10 21:29:20 -06:00
Warner Losh e2295b9117 stand: i386/amd64: Always use elf format for /boot/loader and pxeldr
The first level boot blocks have understood how to load ELF code since
1999. Switch /boot/loader and /boot/pxeldr over to being ELF format so
that in-tree tools can examine them more closely. In addition, one
could, in theory, now have a 'lo-mem' and a 'hi-mem' segment (though a
lot of work would need to be done with bounce buffers, btx, code segment
marking, etc for an arrangement like that to work).

As far as I can tell, this is the last a.out binary in the tree. There
are several raw binaries left, but everything else is ELF.

Reviewed by:		emaste, kevans
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D36130
2022-08-10 21:28:22 -06:00
Philip Paeps 9f9fc6bb80 contrib/tzdata: import tzdata 2022b
Changes: https://github.com/eggert/tz/blob/2022b/NEWS

MFC after:	3 days
2022-08-11 10:48:24 +08:00
Philip Paeps 79499b48c8 Import tzdata 2022b 2022-08-11 10:23:48 +08:00
Ed Maste 0fd8d3589a acpi: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by:	jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36096
2022-08-10 17:17:33 -04:00
Alexander V. Chernikov 685866bbe1 routing: fix build without ROUTE_MPATH
MFC after:	1 month
2022-08-10 20:45:22 +00:00
Emmanuel Vadot 348164aa9e sdio: Add CCCR speed defines
Those are the defines needed to change speed on a SDIO card.
2022-08-10 22:07:24 +02:00
Emmanuel Vadot 49da0242e7 sdio: Do not allow setting a block size if function doesn't support it 2022-08-10 22:07:24 +02:00
Emmanuel Vadot 1ee7a80492 sdio: Always use increment address for read/write_4
SDIO CMD53 (RW Extented) can either write to the same address (useful for FIFO)
or auto increment the destination address (to write to multiple registers).
It is more logical to have read/write_4 to use incremental mode and make other
helper function for writing to a FIFO destination especially since most FIFO
write/read will be 8bits based and not 32bits based.
2022-08-10 22:07:23 +02:00
Emmanuel Vadot b9db5e0a8f sdio: Change the sdio helper name and arg order
Do not use b/l but _1/_4 also address comes first and then data.
This makes them closer to something like bus_space_{read,write}
We have no users in the tree.
2022-08-10 22:07:23 +02:00
Ed Maste 3471fcf3a4 opencrypto: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-08-10 15:35:29 -04:00
Alexander V. Chernikov 102e6817f0 devd: move all devd notification logic to a separate file.
Currently, subr_bus.c shares logic for (a) maintaining all HW devices
 (e.g. discovery/attach/detach logic) and (b) generic devctl notification
 layer for devices/PMU/GEOM/interfaces/etc).
These two subsystems share really tiny interaction interface, composed of 3
 notification functions. With that in mind, move devctl layer to a
 separate file, establishing a clear notification interface between the
 sub.c bus layer and the provider (devctl).

The primary driver of this change is netlink implementation (D36002).
The idea is to propagate device-level events to netlink as well, so all
 netlink customers can subscribe to these changes.
The long-term goal is to deprecate devctl and to use netlink as the
 kernel<> userland transport provided netlink gets enough traction.

Reviewed by:	imp, markj
Differential Revision: https://reviews.freebsd.org/D36091
MFC after:	1 month
2022-08-10 18:56:01 +00:00
Alexander V. Chernikov 5c4d2252d7 routing: move rtentry and subscription code out of route_ctl.c
route_ctl.c size has grown considerably since initial introduction.
Factor out non-relevant parts:
* all rtentry logic, such as creation/destruction and accessors
 goes to net/route/route_rtentry.c
* all rtable subscription logic goes to net/route/route_subscription.c

Differential Revision: https://reviews.freebsd.org/D36074
MFC after:	1 month
2022-08-10 18:56:01 +00:00
Alexander V. Chernikov 2ce553854c routing: add rib_<add|del>_route_px() functions operating with nexthops.
This change adds public KPI to work with routes using pre-created
 nexthops, instead of using data from addrinfo structures. These
 functions will be later used for adding/deleting kernel-originated
 routes and upcoming netlink protocol.

As a part of providing this KPI, low-level route addition code has been
 reworked to provide more control over route creation or change.
 Specifically, a number of operation flags
 (RTM_F_<CREATE|EXCL|REPLACE|APPEND>) have been added, defining the
 desired behaviour the the route already exists (or not exists). This
 change required some changes in the multipath addition code, resulting
 in moving this code to route_ctl.c, rendering mpath_ctl.c empty.

Differential Revision: https://reviews.freebsd.org/D36073
MFC after:	1 month
2022-08-10 18:56:01 +00:00
Alexander V. Chernikov 66230639ce routing: split nexthop creation and rtentry creation.
This change is required for the upcoming introduction of the next
 nexhop-based operations KPI, as it will create rtentry and nexthops
 at different stages of route table modification.

Differential Revision: https://reviews.freebsd.org/D36072
MFC after:	2 weeks
2022-08-10 18:27:13 +00:00
Alexander V. Chernikov dedeec1143 routing: refactor #2
* Use same filter func (rib_filter_f_t) for nexhtop groups to
 simplify callbacks.
* simplify conditional route deletion & remove the need to pass
 rt_addrinfo to the low-level deletion functions
* speedup rib_walk_del() by removing an additional per-prefix lookup

Differential Revision: https://reviews.freebsd.org/D36071
MFC after:	1 month
2022-08-10 18:20:21 +00:00
Alexander V. Chernikov 0d60e88b41 routing: refactor control cmds #1
This and the follow-up routing-related changes target to remove or
 reduce `struct rt_addrinfo` usage and use recently-landed nhop(9)
 KPI instead.
Traditionally `rt_addrinfo` structure has been used to propagate all necessary
information between the protocol/rtsock and a routing layer. Many
functions inside routing subsystem uses it internally. However, using
this structure became somewhat complicated, as there are too many ways
of specifying a single state and verifying data consistency is hard.
For example, arerouting flgs consistent with mask/gateway sockaddr pointers?
Is mask really a host mask? Are sockaddr "valid" (e.g. properly zeroed, masked,
have proper length)? Are they mutable? Is the suggested interface specified
 by the interface index embedded into the sockadd_dl gateway, or passed
 as RTAX_IFP parameter, or directly provided by rti_ifp or it needs to
 be derived from the ifa?
These (and other similar) questions have to be considered every time when
 a function has `rt_addrinfo` pointer as an argument.

The new approach is to bring more control back to the protocols and
construct the desired routing objects themselves - in the end, it's the
protocol/subsystem who knows the desired outcome.

This specific diff changes the following:
* add explicit basic low-level radix operations:
 add_route() (renamed from add_route_nhop())
 delete_route() (factored from change_route_nhop())
 change_route() (renamed from change_route_nhop)
* remove "info" parameter from change_route_conditional() as a part
 of reducing rt_addrinfo usage in the internal KPIs
* add lookup_prefix_rt() wrapper for doing re-lookups after
 RIB lock/unlock

Differential Revision: https://reviews.freebsd.org/D36070
MFC after:	2 weeks
2022-08-10 18:20:20 +00:00
Gleb Smirnoff 07285bb4c2 tcp: utilize new solisten_clone() and solisten_enqueue()
This streamlines cloning of a socket from a listener.  Now we do not
drop the inpcb lock during creation of a new socket, do not do useless
state transitions, and put a fully initialized socket+inpcb+tcpcb into
the listen queue.

Before this change, first we would allocate the socket and inpcb+tcpcb via
tcp_usr_attach() as TCPS_CLOSED, link them into global list of pcbs, unlock
pcb and put this onto incomplete queue (see 6f3caa6d81).  Then, after
sonewconn() we would lock it again, transition into TCPS_SYN_RECEIVED,
insert into inpcb hash, finalize initialization of tcpcb.  And then, in
call into tcp_do_segment() and upon transition to TCPS_ESTABLISHED call
soisconnected().  This call would lock the listening socket once again
with a LOR protection sequence and then we would relocate the socket onto
the complete queue and only now it is ready for accept(2).

Reviewed by:		rrs, tuexen
Differential revision:	https://reviews.freebsd.org/D36064
2022-08-10 11:09:34 -07:00
Gleb Smirnoff 8f5a0a2e4f sockets: provide solisten_clone(), solisten_enqueue()
as alternative KPI to sonewconn().  The latter has three stages:
- check the listening socket queue limits
- allocate a new socket
- call into protocol attach method
- link the new socket into the listen queue of the listening socket

The attach method, originally designed for a creation of socket by the
socket(2) syscall has slightly different semantics than attach of a socket
cloned by listener.  Make it possible for protocols to call into the
first stage, then perform a different attach, and then call into the
final stage.  The first stage, that checks limits and clones a socket
is called solisten_clone(), and the function that enqueues the socket
is solisten_enqueue().

Reviewed by:		tuexen
Differential revision:	https://reviews.freebsd.org/D36063
2022-08-10 11:09:34 -07:00
Gleb Smirnoff c7a62c925c inpcb: gather v4/v6 handling code into in_pcballoc() from protocols
Reviewed by:		rrs, tuexen
Differential revision:	https://reviews.freebsd.org/D36062
2022-08-10 11:09:34 -07:00
Emmanuel Vadot d38a784b61 modules: if_awg: Add miibus_if.h to the source
Needed by the module.
2022-08-10 19:25:31 +02:00
Emmanuel Vadot fbc50a6954 modules: aw_mmc: Add mmc_pwrseq_if to the source
Needed by the module.
2022-08-10 19:25:29 +02:00
Emmanuel Vadot 87f642ac03 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.
2022-08-10 19:22:31 +02:00
Andrew Turner abc7a4a0c1 Simplify setting a non-4k PAGE_SIZE on arm64
Define PAGE_SIZE and PAGE_MASK based on PAGE_SHIFT. With this we only
need to set one value to change one value to change the page size.

While here remove the unused PAGE_MASK_* macros.

Sponsored by:	The FreeBSD Foundation
2022-08-10 17:02:00 +01:00
Ed Maste 7dc4d5118c gpio: mark INVARIANTS variables as __diagused
Fixes INVARIANTS build with Clang 15, which previously failed due to
set-but-not-used variable warnings.

Reviewed by:	dim
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36097
2022-08-10 10:39:58 -04:00
Gleb Smirnoff d88eb4654f tcp: address a wire level race with 2 ACKs at the end of TCP handshake
Imagine we are in SYN-RCVD state and two ACKs arrive at the same time,
both valid, e.g. coming from the same host and with valid sequence.

First packet would locate the listening socket in the inpcb database,
write-lock it and start expanding the syncache entry into a socket.
Meanwhile second packet would wait on the write lock of the listening
socket.  First packet will create a new ESTABLISHED socket, free the
syncache entry and unlock the listening socket.  Second packet would
call into syncache_expand(), but this time it will fail as there
is no syncache entry.  Second packet would generate RST, effectively
resetting the remote connection.

It seems to me, that it is impossible to solve this problem with
just rearranging locks, as the race happens at a wire level.

To solve the problem, for an ACK packet arrived on a listening socket,
that failed syncache lookup, perform a second non-wildcard lookup right
away.  That lookup may find the new born socket.  Otherwise, we indeed
send RST.

Tested by:		kp
Reviewed by:		tuexen, rrs
PR:			265154
Differential revision:	https://reviews.freebsd.org/D36066
2022-08-10 07:32:37 -07:00
Alexander V. Chernikov f998535a66 netinet6: allow ND entries creation for all directly-reachable
destinations.

The current assumption is that kernel-handled rtadv prefixes along with
 the interface address prefixes are the only prefixes considered in
 the ND neighbor eligibility code.
Change this by allowing any non-gatewaye routes to be eligible. This
 will allow DHCPv6-controlled routes to be correctly handled by
 the ND code.
Refactor nd6_is_new_addr_neighbor() to enable more deterministic
 performance in "found" case and remove non-needed
 V_rt_add_addr_allfibs handling logic.

Reviewed By: kbowling
Differential Revision: https://reviews.freebsd.org/D23695
MFC after:	1 month
2022-08-10 14:19:19 +00:00
Emmanuel Vadot 8d6b3a8570 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
2022-08-10 15:47:22 +02:00
Emmanuel Vadot c9ccf3a32d Import device-tree files from Linux 5.18
Sponsored by:   Beckhoff Automation GmbH & Co. KG
2022-08-10 14:32:46 +02:00
Emmanuel Vadot 9066e824ca Import device-tree files from Linux 5.18 2022-08-10 14:31:09 +02:00
Emmanuel Vadot e67e85659c Import device-tree files from Linux 5.17
Sponsored by:   Beckhoff Automation GmbH & Co. KG
2022-08-10 14:29:43 +02:00
Emmanuel Vadot b7d8b5635a Import device-tree files from Linux 5.17 2022-08-10 14:28:38 +02:00
Emmanuel Vadot 8cc087a1ee Import device-tree files from Linux 5.16
Sponsored by:   Beckhoff Automation GmbH & Co. KG
2022-08-10 14:27:16 +02:00
Emmanuel Vadot dec44e532c Import device-tree files from Linux 5.16 2022-08-10 14:25:35 +02:00
Emmanuel Vadot 354d7675fe Import device-tree files from Linux 5.15
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-08-10 14:21:52 +02:00
Emmanuel Vadot 1769b8f3a9 Import device-tree files from Linux 5.15 2022-08-10 14:20:33 +02:00
Emmanuel Vadot 5956d97f4b Import device-tree files from Linux 5.14 2022-08-10 14:12:15 +02:00
Emmanuel Vadot 17bac45f17 Import device-tree files from Linux 5.14 2022-08-10 14:05:33 +02:00
Michael Tuexen bd30a1216e 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
2022-08-08 13:07:10 +02:00
Michael Tuexen bb995f2ef0 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
MFC after:	1 week
2022-08-08 12:53:42 +02:00
Xin LI e9a2e4d1d2 arc4random(3): Reduce diff with OpenBSD.
The main change was v1.57 by djm@:

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

Reviewed by:	csprng (markm, cem)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D36088
2022-08-09 17:27:55 -07:00
Mark Johnston 1dfa8b73f6 tests: Add more shared shadow regression tests
The new tests exercise simulated COW that occurs when the protections on
a wired, copy-on-write mapping are changed from read-only to read-write.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35636
2022-08-09 18:34:01 -04:00
Mark Johnston 2bed73739a atomic: Add plain atomic_load/store_bool()
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36078
2022-08-09 18:34:01 -04:00
Mark Johnston 3ba8e9dc4a dtrace/amd64: Implement emulation of call instructions
Here, the provider is responsible for updating the trapframe to redirect
control flow and for computing the return address.  Once software-saved
registers are restored, the emulation shifts the remaining context down
on the stack to make space for the return address, then copies the
address provided by the invop handler.  dtrace_invop() is modified to
allocate temporary storage space on the stack for use by the provider to
return the return address.

This is to support a new provider for amd64 which can instrument
arbitrary instructions, not just function entry and exit instructions as
FBT does.

In collaboration with:	christos
Sponsored by:	Google, Inc. (GSoC 2022)
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2022-08-09 18:34:01 -04:00
Mark Johnston a7aa3d4d75 fbt/x86: Extract arg1 for return probes from the trapframe
dtrace invop handlers have access to the whole trapframe, just use that
to extract %rax/%eax for return probes instead of relying on an
additional parameter to the handler.  No functional change intended.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-08-09 18:34:01 -04:00