Commit graph

136647 commits

Author SHA1 Message Date
Kristof Provost
b8b6ee3554 pf: Fix parsing of long table names
When parsing the nvlist for a struct pf_addr_wrap we unconditionally
tried to parse "ifname". This broke for PF_ADDR_TABLE when the table
name was longer than IFNAMSIZ. PF_TABLE_NAME_SIZE is longer than
IFNAMSIZ, so this is a valid configuration.

Only parse (or return) ifname or tblname for the corresponding
pf_addr_wrap type.

This manifested as a failure to set rules such as these, where the pfctl
optimiser generated an automatic table:

	pass in proto tcp to 192.168.0.1 port ssh
	pass in proto tcp to 192.168.0.2 port ssh
	pass in proto tcp to 192.168.0.3 port ssh
	pass in proto tcp to 192.168.0.4 port ssh
	pass in proto tcp to 192.168.0.5 port ssh
	pass in proto tcp to 192.168.0.6 port ssh
	pass in proto tcp to 192.168.0.7 port ssh

Reported by:	Florian Smeets
Tested by:	Florian Smeets
Reviewed by:	donner
X-MFC-With:	5c11c5a365
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29962

(cherry picked from commit 402dfb0a8d)
2021-05-10 21:45:56 +02:00
Rick Macklem
8f81f190a6 param.h: Bump __FreeBSD_version to 1300505 for 272f399422
Commit 272f399422 changed the internal KAPI between the
nscl.ko and nfscommon.ko modules, so they both need to be
rebuilt from sources.
2021-05-10 08:14:57 -07:00
Rick Macklem
272f399422 nfsd: fix the slot sequence# when a callback fails
Commit 4281bfec36 patched the server so that the
callback session slot would be free'd for reuse when
a callback attempt fails.
However, this can often result in the sequence# for
the session slot to be advanced such that the client
end will reply NFSERR_SEQMISORDERED.

To avoid the NFSERR_SEQMISORDERED client reply,
this patch negates the sequence# advance for the
case where the callback has failed.
The common case is a failed back channel, where
the callback cannot be sent to the client, and
not advancing the sequence# is correct for this
case.  For the uncommon case where the client's
reply to the callback is lost, not advancing the
sequence# will indicate to the client that the
next callback is a retry and not a new callback.
But, since the FreeBSD server always sets "csa_cachethis"
false in the callback sequence operation, a retry
and a new callback should be handled the same way
by the client, so this should not matter.

Until you have this patch in your NFSv4.1/4.2 server,
you should consider avoiding the use of delegations.
Even with this patch, interoperation with the
Linux NFSv4.1/4.2 client in kernel versions prior
to 5.3 can result in frequent 15second delays if
delegations are enabled.  This occurs because, for
kernels prior to 5.3, the Linux client does a TCP
reconnect every time it sees multiple concurrent
callbacks and then it takes 15seconds to recover
the back channel after doing so.

(cherry picked from commit 8759773148)
2021-05-10 08:01:42 -07:00
Rick Macklem
5e1753891a nfsd: fix session slot handling for failed callbacks
When the NFSv4.1/4.2 server does a callback to a client
on the back channel, it will use a session slot in the
back channel session. If the back channel has failed,
the callback will fail and, without this patch, the
session slot will not be released.
As more callbacks are attempted, all session slots
can become busy and then the nfsd thread gets stuck
waiting for a back channel session slot.

This patch frees the session slot upon callback
failure to avoid this problem.

Without this patch, the problem can be avoided by leaving
delegations disabled in the NFS server.

(cherry picked from commit 4281bfec36)
2021-05-10 07:57:51 -07:00
Hans Petter Selasky
b7622437f5 net: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros
Introduce convenience macros to retrieve the DSCP, ECN or traffic class
bits from an IPv6 header.

Use them where appropriate.

Reviewed by:	ae (previous version), rscheff, tuexen, rgrimes
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29056

(cherry picked from commit bb4a7d94b9)
2021-05-10 16:30:44 +02:00
Hans Petter Selasky
a122a5ebde Add more USB quirks for Garmin devices.
Sort the Garmin products while at it.

PR:		254664
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 28af0c4814)
2021-05-10 16:11:19 +02:00
Hans Petter Selasky
0d1e6e9413 Remove USB device ID added by SVN r150701 in the CDC USB ethernet driver.
Since then, the FreeBSD USB stack has got proper USB RNDIS support.

PR:		254345
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit d2c8714064)
2021-05-10 16:11:19 +02:00
Hans Petter Selasky
74ef3f740d Add more USB quirks for Kingston devices.
PR:		253855
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 47bc8fc9ae)
2021-05-10 16:11:19 +02:00
Hans Petter Selasky
30c20249b9 Fix build of stand/usb .
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 7497dd5889)
2021-05-10 16:11:19 +02:00
Hans Petter Selasky
9312bcb2e9 if_smsc: Add the ability to disable "turbo_mode", also called RX frame batching,
similarly to the Linux driver, by a tunable read only sysctl.

Submitted by:	Oleg Sidorkin <osidorkin@gmail.com>
PR:		254884
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 5a3426f453)
2021-05-10 16:11:19 +02:00
Elliott Mitchell
8a4f990338 kern/intr: declare interrupt vectors unsigned
These should never get values large enough for sign to matter, but one
of them becoming negative could cause problems.

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

(cherry picked from commit a3c7da3d08)
2021-05-10 09:36:20 -04:00
Mark Johnston
eafeee082c divert: Fix mbuf ownership confusion in div_output()
div_output_outbound() and div_output_inbound() relied on the caller to
free the mbuf if an error occurred.  However, this is contrary to the
semantics of their callees, ip_output(), ip6_output() and
netisr_queue_src(), which always consume the mbuf.  So, if one of these
functions returned an error, that would get propagated up to
div_output(), resulting in a double free.

Fix the problem by making div_output_outbound() and div_output_inbound()
responsible for freeing the mbuf in all cases.

Reported by:	Michael Schmiedgen <schmiedgen@gmx.net>
Tested by:	Michael Schmiedgen
Reviewed by:	donner
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30129

(cherry picked from commit a1fadf7de2)
2021-05-10 09:36:08 -04:00
Mark Johnston
44d26e9e78 smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry()
Otherwise, if !smp_started is true, then smp_rendezvous_cpus_done() will
harmlessly perform an atomic RMW on an uninitialized variable.

Reported by:	KMSAN
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cdfcfc607a)
2021-05-10 09:35:53 -04:00
Konstantin Belousov
51af250608 Add ptrace(PT_COREDUMP)
(cherry picked from commit 87a64872cd)
2021-05-10 04:03:06 +03:00
Konstantin Belousov
2b348ecde1 ptracestop: mark threads suspended there with the new TDB_SSWITCH flag
(cherry picked from commit 68d311b666)
2021-05-10 04:03:00 +03:00
Konstantin Belousov
4495cd6e7e ptrace: do not allow for parallel ptrace requests
(cherry picked from commit 9ebf9100ba)
2021-05-10 04:02:47 +03:00
Konstantin Belousov
57d7b30ea8 kern_ptrace(): extract code to determine ptrace eligibility into helper
(cherry picked from commit 54c8baa021)
2021-05-10 04:02:40 +03:00
Konstantin Belousov
b35e4edc97 kern_ptrace: change type of proctree_locked to bool
(cherry picked from commit 2bd0506c8d)
2021-05-10 04:02:36 +03:00
Konstantin Belousov
8e1c74210c Add thread_run_flash() helper
(cherry picked from commit af928fded0)
2021-05-10 04:02:28 +03:00
Konstantin Belousov
5771601bf4 Add sleepq_remove_nested()
(cherry picked from commit 15465a2c25)
2021-05-10 04:02:23 +03:00
Konstantin Belousov
969dcc5f49 ELF coredump: define several useful flags for the coredump operations
(cherry picked from commit 86ffb3d1a0)
2021-05-10 04:02:16 +03:00
Konstantin Belousov
69130fd57a imgact_elf: consistently pass flags from coredump down to helper functions
(cherry picked from commit 5bc3c61780)
2021-05-10 04:02:10 +03:00
Jose Luis Duran
b316c016e1 Add Apollo Lake SIO/LPSS UARTs PCI IDs
PR:	255556

(cherry picked from commit 8f1562430f)
2021-05-10 03:50:08 +03:00
Jose Luis Duran
2fb889b520 uart_bus_pci.c: Style
PR:	255556

(cherry picked from commit 5b8b6b26e4)
2021-05-10 03:50:02 +03:00
Jose Luis Duran
e0c2f8156c ifconfig: Minor documentation fix
PR:	255557

(cherry picked from commit 0ea8a7f36d)
2021-05-10 03:48:05 +03:00
Konstantin Belousov
fbf613c93f filt_timerexpire: do not iterate over the interval
(cherry picked from commit 7cb40543e9)
2021-05-10 03:47:35 +03:00
Lutz Donnerhacke
2b3074de33 netgraph/ng_base: Allow larger BINARY2ASCII conversions
Allocate the necessary memory for the conversion dynamically starting
with a value which is sufficient for almost all normal cases.

PR:		187835
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D23840

(cherry picked from commit 45d75e3ac3)
2021-05-09 15:25:05 +02:00
Rick Macklem
69aed9987e nfscl: fix delegation recall when the file is not open
Without this patch, if a NFSv4 server recalled a
delegation when the file is not open, the renew
thread would block in the NFS VOP_INACTIVE()
trying to acquire the client state lock that it
already holds.

This patch fixes the problem by delaying the
vrele() call until after the client state
lock is released.

This bug has been in the NFSv4 client for
a long time, but since it only affects
delegation when recalled due to another
client opening the file, it got missed
during previous testing.

Until you have this patch in your client,
you should avoid the use of delegations.

(cherry picked from commit 02695ea890)
2021-05-08 19:55:16 -07:00
Kristof Provost
70e8fe5eee pf: Fix IP checksum on reassembly
If we reassemble a packet we modify the IP header (to set the length and
remove the fragment offset information), but we failed to update the
checksum. On certain setups (mostly where we did not re-fragment again
afterwards) this could lead to us sending out packets with incorrect
checksums.

PR:		255432
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30026

(cherry picked from commit 055c55abef)
2021-05-07 10:16:02 +02:00
Kristof Provost
326f189d5b pf: PFRULE_REFS should not be user-visible
Split the PFRULE_REFS flag from the rule_flag field. PFRULE_REFS is a
kernel-internal flag and should not be exposed to or read from
userspace.

MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29778

(cherry picked from commit 4f1f67e888)
2021-05-07 10:15:43 +02:00
Kristof Provost
7b15ca116c pf: Ensure that we don't use kif passed to pfi_kkif_attach()
Once a kif is passed to pfi_kkif_attach() we must ensure we never re-use
it for anything else.
Set the kif to NULL afterwards to guarantee this.

Reported-by: syzbot+be5d4f4a7a4c295e659a@syzkaller.appspotmail.com
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5e98cae661)
2021-05-07 10:15:42 +02:00
Kristof Provost
c3f3f53771 pf: Move prototypes for userspace functions to userspace header
These functions no longer exist in the kernel, so there's no reason to
keep the prototypes in a kernel header. Move them to pfctl where they're
actually implemented.

Reviewed by:	glebius
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29643

(cherry picked from commit a9b338b260)
2021-05-07 10:15:42 +02:00
Kristof Provost
a3e4fd8b33 pf: Implement nvlist variant of DIOCGETRULE
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29559

(cherry picked from commit d710367d11)
2021-05-07 10:15:41 +02:00
Kristof Provost
f9b057eaf6 pf: Introduce nvlist variant of DIOCADDRULE
This will make future extensions of the API much easier.
The intent is to remove support for DIOCADDRULE in FreeBSD 14.

Reviewed by:	markj (previous version), glebius (previous version)
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29557

(cherry picked from commit 5c62eded5a)
2021-05-07 10:15:41 +02:00
Kristof Provost
95a06e369e pf: Remove unused variable rt_listid from struct pf_krule
Reviewed by:	donner
MFC after:	4 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D29639

(cherry picked from commit 4967f672ef)
2021-05-07 10:15:40 +02:00
Alfredo Dal'Ava Junior
dca829138c opal_console: fix serial console output corruption on powerpc64
Adds OPAL_CONSOLE_WRITE error handling and implements a call to
OPAL_CONSOLE_WRITE_BUFFER_SPACE to verify if there's enough space
before writing to console.

This fixes serial port output getting corrupted on fast writes, like
on "dmesg" output.

Tested on Raptor Blackbird running powerpc64 BE kernel

Reviewed by:	luporl
Sponsored by:	Eldorado Reserach Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D29063

(cherry picked from commit b8bc6b7954)
2021-05-07 02:33:39 -03:00
Alfredo Dal'Ava Junior
8d58984588 powerpc: implement bus_map_resource and bus_unmap_resource DEVMETHODs
Implements bus_map_resource and bus_unmap_resource DEVMETHODs to be
used by powerpc targets. This is identical to the amd64 code.

Required by virtio-modern.

Reviewed by:	bryanv
Sponsored by:	Eldorado Research Institute (eldorado.org.br)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D28012

(cherry picked from commit befb0817bd)
2021-05-07 02:32:50 -03:00
Konstantin Belousov
aa21554a8b ioccom: define ioctl cmd value that can never be valid
(cherry picked from commit 619fe09586)
2021-05-07 03:36:00 +03:00
Konstantin Belousov
af861a369e amd64: invalidate TLB between page table update and access
(cherry picked from commit 21fc6a2a10)
2021-05-07 03:35:54 +03:00
Tai-hwa Liang
5fcae41665 fwip(4): fixing kernel panic when receiving unicast packet
Wrapping fwip_unicast_input() with NET_EPOCH_{ENTER,EXIT} to avoid a
NET_EPOCH_ASSERT() in netisr_dispatch().

Reviewed by:	hselasky
MFC after:	2 weeks

(cherry picked from commit bdf316e892)
2021-05-06 13:23:00 +00:00
Alexander Motin
22efcea413 Introduce "soft" serseq variant.
With new ZFS prefetcher improvements it is no longer needed to fully
serialize reads to reach decent prediction hit rate.  Softer variant
only creates small time window to reduce races instead of completely
blocking following reads while previous is running.  It much less
hurts the performance in case of prediction miss.

MFC after:	1 month

(cherry picked from commit ac503c194c)
2021-05-05 23:18:38 -04:00
Mark Johnston
9d45365e33 pipe: Avoid calling selrecord() on a closing pipe
pipe_poll() may add the calling thread to the selinfo lists of both ends
of a pipe.  It is ok to do this for the local end, since we know we hold
a reference on the file and so the local end is not closed.  It is not
ok to do this for the remote end, which may already be closed and have
called seldrain().  In this scenario, when the polling thread wakes up,
it may end up referencing a freed selinfo.

Guard the selrecord() call appropriately.

Reviewed by:	kib
Reported by:	syzkaller+KASAN
Differential Revision:	https://reviews.freebsd.org/D30016

(cherry picked from commit d1e9441583)
2021-05-05 11:01:43 -04:00
Piotr Pawel Stefaniak
6ac7b0221f Balance parentheses in sysctl descriptions
(cherry picked from commit a212f56d10)
2021-05-05 13:04:58 +02:00
Xin LI
2941198570 arcmsr(4): Fix SCSI command timeout on ARC-1886.
Many thanks to Areca for continuing to support FreeBSD.

Submitted by:	黃清隆 <ching2048 areca com tw>

(cherry picked from commit 438b553207)
2021-05-04 22:03:22 -07:00
Alexander Motin
22b9f618e8 Set PCIe device's Max_Payload_Size to match PCIe root's.
Usually on boot the MPS is already configured by BIOS.  But we've
found that on hot-plug it is not true at least for our Supermicro
X11 boards.  As result, mismatch between root's configuration of
256 bytes and device's default of 128 bytes cause problems for some
devices, while others seem to work fine.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.

(cherry picked from commit 5a898b2b78)
2021-05-04 20:53:55 -04:00
Alexander V. Chernikov
972fcfb34b [fib algo] Update fib_gen counter under FIB_MOD_LOCK.
MFC after:	3 days

(cherry picked from commit 41ce0e34ea)
2021-05-04 21:31:36 +00:00
Alexander V. Chernikov
939c41f3b8 Fix drace CTF for the rib_head.
33cb3cb2e3 introduced an `rib_head` structure field under the
FIB_ALGO define. This may be problematic for the CTF, as some
 of the files including `route_var.h` do not have `fib_algo`
 defined.

Make dtrace happy by making the field unconditional.

Suggested by:	markj

(cherry picked from commit bc5ef45aec)
2021-05-04 21:31:25 +00:00
Alexander V. Chernikov
d0666c8718 Add rib_walk_from() wrapper for selective rib tree traversal.
Provide wrapper for the rnh_walktree_from() rib callback.
As currently `struct rib_head` is considered internal to the
 routing subsystem, this wrapper is necessary to maintain isolation
 from the external code.

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

(cherry picked from commit f9668e42b4)
2021-05-04 21:30:35 +00:00
Alexander V. Chernikov
83add84c00 [fib algo] Delay algo init at fib growth to to allow to reliably use rib KPI.
Currently, most of the rib(9) KPI does not use rnh pointers, using
 fibnum and family parameters to determine the rib pointer instead.
This works well except for the case when we initialize new rib pointers
 during fib growth.
In that case, there is no mapping between fib/family and the new rib,
 as an entirely new rib pointer array is populated.

Address this by delaying fib algo initialization till after switching
 to the new pointer array and updating the number of fibs.
Set datapath pointer to the dummy function, so the potential callers
 won't crash the kernel in the brief moment when the rib exists, but
 no fib algo is attached.

This change allows to avoid creating duplicates of existing rib functions,
 with altered signature.

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

(cherry picked from commit 8a0d57baec)
2021-05-04 21:30:35 +00:00
Alexander V. Chernikov
3fd9848f15 [rtsock] Enforce netmask/RTF_HOST consistency.
Traditionally we had 2 sources of information whether the
 added/delete route request targets network or a host route:
netmask (RTA_NETMASK) and RTF_HOST flag.

The former one is tricky: netmask can be empty or can explicitly
 specify the host netmask. Parsing netmask sockaddr requires per-family
 parsing and that's what rtsock code traditionally avoided. As a result,
 consistency was not enforced and it was possible to specify network with
 the RTF_HOST flag and vice versa.

Continue normalization efforts from D29826 and D29826 and ensure that
 RTF_HOST flag always reflects host/network data from netmask field.

Differential Revision: https://reviews.freebsd.org/D29958
MFC after:	2 days

(cherry picked from commit 5d1403a79a)
2021-05-04 21:29:36 +00:00