xdr_mbuf.c: Add a check for the return value for xdrmbuf_getbytes()
The xdrmbuf_getlong() function failed to check for the return
value from xdrmbuf_getbytes(). This could have resulted in
a failure during NFS RPC message processing.
(cherry picked from commit cf59649539e653db8285996af2b161be9693a49d)
rpc.tlsservd.c: Check the malloc return
The NULL return is used by the following memcpy()
call. Fail the request instead.
Unlikely to happen in practice, since the rpc.tlsservd
daemon runs as root and does not allocate a lot or memory.
(cherry picked from commit 6d705f2bf17f2c221ffd0d9b0824ba0fb429392e)
xdr_mbuf.c: Add a check for the return value for xdrmbuf_getbytes()
The xdrmbuf_getlong() function failed to check for the return
value from xdrmbuf_getbytes(). This could have resulted in
a failure during NFS RPC message processing.
(cherry picked from commit cf59649539e653db8285996af2b161be9693a49d)
[CSKY][MC] Use CoerceFromRegClass for FPR64 and GPRPair operands (#241449)
The 64-bit FP registers share assembly names with the 32-bit ones, and
`GPRPair` registers are named after their first `GPR`, so the parser
always produces an `FPR32` or `GPR` register and
`validateTargetOperandClass` rewrote it in-place, even when the
instruction being tried did not end up being selected.
We can set `CoerceFromRegClass` to have tablegen emit the coercion
automatically to stop mutating operands in `validateTargetOperandClass`,
which now only keeps the out-of-range diagnostic for `fr16`-`fr31`.
Assisted-by: AI tooling
[TableGen][AsmMatcher] Support custom RenderMethod on RegisterClass (#242126)
Allow `RegisterClass` definitions to specify a custom `RenderMethod`
(defaulting to `addRegOperands`, including per-`HwMode` dispatch for
`RegClassByHwMode`).
This is need for the final few targets to make the arguments to
`validateTargetOperandClass` const.
Assisted-by: AI tooling
[RISC-V] Group vector register groups by LMUL in the register enum. NFC (#242124)
The `V*M2`/`V*M4`/`V*M8` registers were interleaved in the register enum
(`V0M2`, `V0M4`, `V0M8`, `V10M2`, ...) since registers are sorted by
name.
Set `PositionOrder` per LMUL so that each group is contiguous. This
allows
the generated `CoerceFromRegClass` conversions for `VRM2` and `VRM4` to
use simple arithmetic instead of a switch.
This doesn't have a huge impact since Clang already lowered the switches
to a lookup table, so the resulting code only shrinks by a few bytes.
It does make the generated code a bit more readable though.
Also update the TableGen test to use the same approach for its
`VRM2`/`VRM4` classes so the generated strides are easier to follow.
Since this removes the accidental coverage of the switch fallback and
of differing source and destination strides, add dedicated register
classes for both.
Assisted-by: AI tooling
[TableGen][AsmMatcher] Diagnose invalid CoerceFromRegClass (#242123)
With `AllowDuplicateRegisterNames`, `MatchRegisterName` returns the
first
register in enum order for each assembly name, so registers that share a
name with an earlier register are never produced by the parser. Coercing
from such a register silently never fires, so report an error instead.
RISC-V already has a similar static_assert in `matchRegisterNameHelper`.
Change motivated by Craig's comment here:
https://github.com/llvm/llvm-project/pull/241023#discussion_r4556363273
Assisted-by: AI tooling
vm_page_unwire_unmanaged(): fix a double free of the page
The function decided to free the page when vm_page_unwire_noq() reported
that the last wiring was released and a separate load of ref_count then
returned zero. For a page that belongs to an object, the object can drop
its VPRC_OBJREF reference between the decrement and the load. The load
then sees zero, and both threads free the page, which ends up on the
free lists twice and is later handed out to two owners.
Decide from the value returned by our own atomic decrement instead.
Reported by: alc
Reviewed by: alc
Fixes: fee2a2fa3983 ("Change synchonization rules for vm_page reference counting.")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61860
graphics/blender: fix build with onetbb 2023.2
onetbb 2023.2 calls the parallel_sort comparator with const values,
so the non-const lambda in MOD_grease_pencil_build.cc no longer
compiles. Make it take const references.
[lldb-dap] Remove debug type from startDebugging reverse request (#244816)
According to [DAP
specification](https://microsoft.github.io/debug-adapter-protocol/specification#Reverse_Requests_StartDebugging):
```
interface StartDebuggingRequestArguments {
/**
* Arguments passed to the new debug session. The arguments must only contain
* properties understood by the `launch` or `attach` requests of the debug
* adapter and they must not contain any client-specific properties (e.g.
* `type`) or client-specific features (e.g. substitutable 'variables').
*/
configuration: { [key: string]: any; };
```
The adapter shouldn't send the debug type. Also VSCode platform will
ignore the type sent and set it to parent's:
```
const config = {
[5 lines not shown]
kern/kern_descrip.c: do not leak ctty/textvp/tracevp use counts
If the export of one of the special process vnodes failed, the
references on the remaining ones leaked, since export_vnode_to_sb() was
not called for them.
Each reference is now taken just before its export, with the process
held in between.
Read the session's ctty vnode and take its reference under the session lock.
Reviewed by: markj
Fixes: 36bd49ac4db8 ("fd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61859
execve(): unshare pwd
Ensure that pwd is not shared when execing into any ABI, so rforked
siblings are not affected. The altroot changes made during exec, by
linux_on_exec() and by the setuid altroot clear, affected rforked
siblings sharing the pwd.
Remove now always no-op pdunshare() call next to fdunshare().
Reviewed by: markj
Fixes: fd745e1db6b5 ("linux(4): Use pwd_altroot() to tell namei() about ABI root path")
Fixes: 2137bad49a6f ("exec_new_vmspace(): drop altroot for native processes if setuid")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61858
kern/kern_descrip.c: avoid leaking vnode use count hold when vnode export fails
export_vnode_to_sb() returns on remainder == 0 without calling
export_vnode_to_kinfo(), which vrele()s it.
Reviewed by: markj
Fixes: fe52cf547580 ("Re-factor the code to provide kern_proc_filedesc_out(), kern_proc_out(), and kern_proc_vmmap_out() functions ...")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61859
linux: harden the linux_pwd_onexec() altroot entry
Do not take the native altroot into account when looking up
linux_emul_path.
Reported by: llm-postcr
Reviewed by: markj
Fixes: 9757c0cf98e4 ("chaltroot(2) and fchaltroot(2): new syscalls")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61858
kern/kern_descrip.c: avoid leaking pwd hold when vnode export fails
kern_proc_filedesc_out() gotos around the pwd_drop() call on errors from
export_vnode_to_sb(), leaking the hold.
Reported by: llm-postcr
Reviewed by: markj
Fixes: 36bd49ac4db8 ("fd: Avoid truncating output buffers for KERN_PROC_{CWD,FILEDESC}")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61859