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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)