Commit graph

149134 commits

Author SHA1 Message Date
Mark Johnston
3e53fec002 fb: Explicitly handle errors when getting or setting a colour palette
In the VESA driver, simply ignore errors.  It is not clear to me how to
return them to userspace.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after:	1 week

(cherry picked from commit ddc8576d297937a1395f47550a8f5b1fac79afc2)
2024-01-04 08:42:13 -05:00
Mark Johnston
0328de3def linux: Check for copyout errors in ioctl handlers
In preparation for annotating copyin() and friends with
__result_use_check.

Reviewed by:	dchagin
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43199

(cherry picked from commit b9924c202fc34004d4164cdc50f88d8fcef26279)
2024-01-04 08:42:13 -05:00
John Baldwin
8247b328ef riscv nexus: Sort bus_set_resource in DEVMETHOD table
(cherry picked from commit 7bf9223ca958aed45a998890f351afaae67550fe)
2024-01-03 12:48:50 -08:00
John Baldwin
c24913c904 riscv nexus: Use bus_generic_rman_*_resource
Custom activate/deactivate_resource methods are still needed to handle
IRQ resources.

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

(cherry picked from commit f8709c826be977471df5663833f291f43d93d54c)
2024-01-03 12:48:42 -08:00
John Baldwin
efdbdfa9fd aarch64 nexus: Fix a mismerge in nexus_activate_resource
Fixes:		658501d25930 aarch64 nexus: Use bus_generic_rman_*_resource
(cherry picked from commit 5622f52c98cda7df1faef11d847e04500158e107)
2024-01-03 12:48:35 -08:00
John Baldwin
25d378703a aarch64 nexus: Use bus_generic_rman_*_resource
Custom activate/deactivate_resource methods are still needed to handle
IRQ resources.

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

(cherry picked from commit 658501d25930bcf24839f3308ee1da971145c018)
2024-01-03 12:48:28 -08:00
John Baldwin
9d2b2ab93c x86 nexus: Use bus_generic_rman_*_resource
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42740

(cherry picked from commit a03a335a801246dfb95ccf35ec3f64b9fe968874)
2024-01-03 12:48:20 -08:00
John Baldwin
92991e8f8d new-bus: Disable assertions for rman mismatches for activate/deactivate
Bus drivers which use an rman to sub-divide a resource allocated from
a parent bus should handle mapping requests (and activate/deactivate
requests) for those sub-allocated resources by doing a subset mapping
of the resource allocated from the parent (and then using this to
handle activate/deactivate requests).

However, not all bus drivers which use internal rmans (such as acpi(4)
and pci_pci(4)) do that since not all nexus drivers support
bus_map/unmap.  Eventually bus drivers should be updated to do this
properly at which point these assertions can be reenabled.

Reported by:	delphij, kib

(cherry picked from commit ed88eef140a1c3d57d546f409c216806dd3da809)
2024-01-03 12:47:24 -08:00
John Baldwin
0c7aa9afb1 new-bus: Add comments for resource_*_map_request*
Requested by:	mhorne

(cherry picked from commit 46971d38de334a9418e2b66b37cea7d051b6731a)
2024-01-03 12:47:18 -08:00
John Baldwin
0962b9d086 newbus: Add a set of bus resource helpers for nexus-like devices
These routines can be used to implement
bus_alloc/adjust/activate/deactive/release_resource on bus drivers
which suballocate resources from rman(9) resource managers.

These methods require a new bus_get_rman method in the bus driver to
return the suitable rman for a given resource type.  The
activate/deactivate helpers also require the bus to implement the
bus_map/ummap_resource methods.

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

(cherry picked from commit 751615c538446ea0384f8faa9cb2508670c3799a)
2024-01-03 12:47:08 -08:00
John Baldwin
a6d562d415 new-bus: Add a comment for bus_generic_get_domain
(cherry picked from commit 00b3cde596dd3945d56aa12f2a4957b2910e1ee3)
2024-01-03 12:47:02 -08:00
John Baldwin
dfa6fdec56 ehci_ps3: Remove unused struct definition.
(cherry picked from commit 3578000a6f505148c5e0ecf5be9d644ed07a81bc)
2024-01-03 12:34:35 -08:00
John Baldwin
19cfade3f3 arm64/riscv nexus: Implement bus_unmap_resource
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42725

(cherry picked from commit 71cfd330fc008187ff41db795ae5e6372bf802ab)
2024-01-03 12:34:28 -08:00
John Baldwin
3125b3e82c nexus: Use resource_validate_map_request
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42724

(cherry picked from commit b887b665ebc044f246d261e8af543765b846ed38)
2024-01-03 12:34:20 -08:00
John Baldwin
d9c1d04ad5 new-bus: Add resource_validate_map_request function
This helper function for BUS_MAP_RESOURCE performs common argument
validation.

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

(cherry picked from commit 19f073c612afa0111d216e5ccab9525bfc97ec32)
2024-01-03 12:34:11 -08:00
John Baldwin
30ead05708 arm64/amd64/riscv nexus: Use bus_generic_rl_*
Reviewed by:	mhorne, imp
Differential Revision:	https://reviews.freebsd.org/D42716

(cherry picked from commit ecf2106c0701e522b8c643f8ea37550b3e58ba57)
2024-01-03 12:33:59 -08:00
John Baldwin
a4c3fdf96d gpiobus: Use bus_generic_rl_* methods
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42715

(cherry picked from commit a19ed3495d5556281ea39995d962b93a637183f0)
2024-01-03 12:33:51 -08:00
John Baldwin
b636e35bb7 vfs mount: Consistently use ENODEV internally for an invalid fstype
Change vfs_byname_kld to always return an error value of ENODEV to
indicate an unsupported fstype leaving ENOENT to indicate errors such
as a missing mount point or invalid path.  This allows nmount(2) to
better distinguish these cases and avoid treating a missing device
node as an invalid fstype after commit 6e8272f317.

While here, change mount(2) to return EINVAL instead of ENODEV for an
invalid fstype to match nmount(2).

PR:		274600
Reviewed by:	pstef, markj
Differential Revision:	https://reviews.freebsd.org/D42327

(cherry picked from commit 3eed4803f943e2937325e81140b88e2e8eea8deb)
2024-01-03 12:18:44 -08:00
John Baldwin
bf63f0e7e3 qlnx: Fix a couple of type mismatches in function declarations
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42586

(cherry picked from commit be909a79a8e2506b49ed81f9bd8115512dd613a4)
2024-01-03 09:43:48 -08:00
John Baldwin
fd3190c2da sys: Disable -Walloc-size-larger-than for GCC 9+
By default this warns about sizes larger than PTRDIFF_MAX passed to
malloc (rather than SIZE_MAX).  This doesn't trigger
deterministically, but it does trigger for kmalloc() of struct_size()
in iwlwifi's iwl_configure_rxq even when struct_size() is changed to
use PTRDIFF_MAX.  NB: struct_size() in Linux caps the size at
SIZE_MAX, not PTRDIFF_MAX via size_mul().

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

(cherry picked from commit ede077bf2a259c23923d1ab1231dc8c4577e6672)
2024-01-03 09:43:48 -08:00
John Baldwin
df8d325b8d ocs: Fix a couple of type mismatches in function prototypes
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42585

(cherry picked from commit 7aa5b2a9e7f5f3cd33e72cb1e95790fe7637f10f)
2024-01-03 09:43:48 -08:00
John Baldwin
6a1b9033d8 ath_hal: Fix a couple of type mismatches in function prototypes
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42584

(cherry picked from commit 1e65df68403acac2231dda161fd12e62f888a031)
2024-01-03 09:43:48 -08:00
Alexander Motin
78c98588c9 nvme: Add some bits from NVMe 2.0c spec.
MFC after:	1 week

(cherry picked from commit b46c7b1ed4e5307c689df72ea8a0b69e02456905)
2024-01-02 20:40:31 -05:00
Rick Macklem
2f3ff6fe1a vfs_vnops.c: Fix vn_generic_copy_file_range() for truncation
When copy_file_range(2) was first being developed,
*inoffp + len had to be <= infile_size or an error was
returned. This semantic (as defined by Linux) changed
to allow *inoffp + len to be greater than infile_size and
the copy would end at *inoffp + infile_size.

Unfortunately, the code that decided if the outfd should
be truncated in length did not get updated for this
semantics change.
As such, if a copy_file_range(2) is done, where infile_size - *inoffp
is less that outfile_size but len is large, the outfd file is truncated
when it should not be. (The semantics for this for Linux is to not
truncate outfd in this case.)

This patch fixes the problem. I believe the calculation is safe
for all non-negative values of outsize, *outoffp, *inoffp and insize,
which should be ok, since they are all guaranteed to be non-negative.

Note that this bug is not observed over NFSv4.2, since it truncates
len to infile_size - *inoffp.

PR:	276045

(cherry picked from commit 2319ca6a01816f7fc85d623097c639f239e18c6a)
2024-01-02 17:22:26 -08:00
John Baldwin
e74b03451f abort2: Generate a core dump
Call sigexit rather than exit1 so that a core is generated.

If running the SIGABRT handler is desired, this would need to use
kern_psignal() instead.  In that case a userspace wrapper in libc
would be needed to force an exit if the handler doesn't exit.  Given
that abort2(2)'s intended use case is when userland is in a
sufficiently bad state such that it can't safely call syslog(3) before
abort(3), a userspace abort2(3) wrapper in libc might be dubious.

Reviewed by:	Olivier Certner <olce.freebsd@certner.fr>, emaste
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D42163

(cherry picked from commit 9b57e30cf5b6036263a1a2551df8574571c6f5a4)
2024-01-02 11:20:37 -08:00
John Baldwin
950162c4d3 ctl: Use ctl_io_sbuf in ctl_process_done
This reduces a second copy of (mostly) the same code.

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42210

(cherry picked from commit e846a3e0168f9188a6eccedd52707c63fd83cba2)
2024-01-02 11:20:37 -08:00
John Baldwin
dba59c3567 ctl: Make ctl_private.h more self-contained
Include <sys/sysctl.h> for sysctl context types.

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42209

(cherry picked from commit fc8cf0a8deb8908fb17acc56e96f3f700c05136d)
2024-01-02 11:20:37 -08:00
John Baldwin
2996e219e4 ctl: Make ctl_ha.h more self-contained
Include <sys/queue.h> for queue macros

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42208

(cherry picked from commit 10b1a66934b0c1b252369c496952974f980441a4)
2024-01-02 11:20:37 -08:00
John Baldwin
15601268b9 ctl: Make ctl_io.h more self-contained
Include <cam/scsi/scsi_all.h> for struct scsi_sense_data.
Include <sys/queue.h> for queue macros.

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42207

(cherry picked from commit 4efebb3de39a2694169d3032fb6ca567409c2bcb)
2024-01-02 11:20:37 -08:00
John Baldwin
46b03fd898 ctl: Make ctl.h more self-contained
Make MALLOC_DECLARE conditional on <sys/malloc.h> and forward declare
several types.

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42206

(cherry picked from commit 55231cd180692c7299bff65e608dba20013ec0f7)
2024-01-02 11:20:37 -08:00
John Baldwin
2cad2d1a2a cam: Make <cam/scsi/scsi_all.h> more self-contained
Include <sys/malloc.h> in the kernel for struct malloc_type.

Reviewed by:	ken, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D42205

(cherry picked from commit 2e539c6f5aba657c69790d91130ceceeb0b8c38e)
2024-01-02 11:20:36 -08:00
Gleb Smirnoff
943814893b tcp: always set tcp_tun_port to a correct value
The tcp_tun_port field that is used to pass port value between UDP
and TCP in case of tunneling is a generic field that used to pass
data between network layers.  It can be contaminated on entry, e.g.
by a VLAN tag set by a NIC driver.  Explicily set it, so that it
is zeroed out in a normal not-tunneled TCP.  If it contains garbage,
tcp_twcheck() later can enter wrong block of code and treat the packet
as incorrectly tunneled one.  On main and stable/14 that will end up
with sending incorrect responses, but on stable/13 with ipfw(8) and
pcb-matching rules it may end up in a panic.

This is a minimal conservative patch to be merged to stable branches.
Later we may redesign this.

PR:			275169
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43065

(cherry picked from commit 513f2e2e7180202167ca2963d815d2a4c3ac0af9)
2024-01-02 11:06:31 -08:00
Rick Macklem
dabf1797a7 nfscl: Fix handling of expired Kerberos credentials (NFSv4.1/4.2)
If the NFS server detects that the Kerberos credentials provided
by a NFSv4.1/4.2 mount using sec=krb5[ip] have expired, the NFS
server replies with a krpc layer error of RPC_AUTHERROR.
When this happened, the client erroneously left the NFSv4.1/4.2
session slot busy, so that it could not be used by other RPCs.
If this happened for all session slots, the mount point would
hang.

This patch fixes the problem by releasing the session slot
and resetting its sequence# upon receiving a RPC_AUTHERROR
reply.

This bug only affects NFSv4.1/4.2 mounts using sec=krb5[ip],
but has existed since NFSv4.1 client support was added to
FreeBSD.

So, why has the bug remained undetected for so long?
I cannot be sure, but I suspect that, often, the client detected
the Kerberos credential expiration before attempting the RPC.
For this case, the client would not do the RPC and, as such,
there would be no busy session slot.  Also, no hang would
occur until all session slots are busied (64 for a FreeBSD
client/server), so many cases of the bug probably went undetected?
Also, use of sec=krb5[ip] mounts are not that common.

PR:	275905

(cherry picked from commit a558130881e9d574dc5f37827fe2284667d5aba8)
2024-01-01 17:20:17 -08:00
Konstantin Belousov
27acf8db5b Convert fsidcmp(9) from macro to inline function
(cherry picked from commit 3334a537ed385e487a47208dab8f36b25643bcdb)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
aaa4654adc iommu_gas_remove(): consolidate places where decision is made to keep the entry
(cherry picked from commit c0047e7c356953d138194ff71cc510ffe85425f0)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
8019d103e0 iommu_gas: make placeholder entry at the start of the GAS zero size
(cherry picked from commit f59128775636846574e092c68e849a56f74577e6)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
264e49515f iommu: add iommu_gas_remove_locked()
(cherry picked from commit 273b4de3462d7825ebe4ace7a1930f098311287f)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
5dcf0d72f6 IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE
(cherry picked from commit a59c252903e81f46c74903ce5b1cf0960927dbcc)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
edaece2f7e iommu_gas: zero fake on-stack map entry used in iommu_gas_remove_clip_left()
(cherry picked from commit cb1d664b0073232173072231cb386f0216ee596b)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
b86d839af9 iommu_gas: print entries flags and domains if an overlap detected
(cherry picked from commit 733da1eb947688210bc152656357ecafbd172bb7)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
43ccf1cf37 DMAR: add knob to disable RMRR entries installation into domains
(cherry picked from commit 24e38af60a637073b5164837959098acaa3d8daa)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
1bb758df1a iommu_gas: add ddb 'show iommu_domain' command
(cherry picked from commit 30ce85ca11433ba05cdbab8aedceaa15a93bd97a)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
eb0d8cb121 iommu_gas_match_one(): check for underflow
(cherry picked from commit a869643e184a73382ef7939b465fd42785e096d1)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
056e270e26 dmar(9): style, fix indent
(cherry picked from commit 7153d5e4bc67732f8258d50ffffa42a09a19b427)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
d60d1d5840 iommu: remove leftover sys/cdefs.h includes
(cherry picked from commit 6afa2333d2e42e1df67a0fab20f0ede76dff516d)
2024-01-02 02:41:38 +02:00
Mark Johnston
266eefe7f4 vmm: Fix handling of errors from subyte()
subyte() returns -1 upon an error, not an errno value.

MFC after:	1 week
Fixes:	e17eca3276 ("vmm: Avoid embedding cpuset_t ioctl ABIs")

(cherry picked from commit 6adf554abd1c848d2c9ab7ea8a7fb7dd20a0c186)
2024-01-01 19:30:00 -05:00
Mark Johnston
fecd8e111a compat_freebsd4: Fix handling of errors from subyte()
Upon failure, subyte() returns -1, not an errno value.

MFC after:	1 week

(cherry picked from commit c38df501ce2ed7da128448f815ec627c39fd3bad)
2024-01-01 19:30:00 -05:00
Mark Johnston
9b28f3f032 iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()
Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43148

(cherry picked from commit 74e713804fa4767991c5f20e6b85da4235107122)
2024-01-01 19:29:59 -05:00
Mark Johnston
7bc713a5a5 nmount: Ignore errors when copying out an error string
In general we copy error strings as part of reporting an error from
lower layers, so if the copyout() fails there's nothing to do since we'd
prefer to preserve the original error.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	olce, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43147

(cherry picked from commit 099d25c354d93d9cd9c9cd261428f5ab0547a194)
2024-01-01 19:29:58 -05:00
Mark Johnston
bd287fa8bc geom: Report copyout() errors in g_ctl_ioctl_ctl()
Despite the name, req->serror is used in some cases to copy non-error
messages to userspace.  So, report errors when copying out so long as
they don't clobber an earlier error.

Reviewed by:	mav, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43146

(cherry picked from commit bbf221e3e822d15dafb37bd8e200a9864f2636b4)
2024-01-01 19:29:57 -05:00