[BinaryFormat] Fix UBSan negative-shift in identify_magic Mach-O path (#204122)
`identify_magic()` read the Mach-O filetype field at offset 12 by
left-shifting four bytes of the input StringRef:
```
type = Magic[12] << 24 | Magic[13] << 12 | Magic[14] << 8 | Magic[15];
```
`StringRef::operator[]` returns a `signed char`. When a header byte has
its
high bit set (e.g. 0xFA == -6 after promotion to int), the expression
"-6 << 24" is undefined behavior; even positive bytes like 0xFF promote
to a value whose "<< 24" overflows a signed int. UBSan trapped this on a
crafted input found by lldb-target-fuzzer:
```
Magic.cpp:177:26: runtime error: left shift of negative value -6
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
libFuzzer: deadly signal
```
[26 lines not shown]
AMDGPU: Teach disassembler to produce target id directives (#203979)
Inspect the binary's e_flags to reproduce the .amdgcn_target directive.
This is a step towards round-trip disassembly without depending
on command line state specifying the subtarget. I wasn't sure
where to put the emission to ensure it is always emitted. I
also do not know why it's OK to just write to outs(), but that's
what the other directives here were doing.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
[lldb][test] Skip watchpoint and expression tests on WebAssembly (#204235)
WebAssembly has no watchpoint support (Process/wasm reports no
watchpoints; the stop reason comes back as a plain signal) and cannot
JIT or interpret expressions (ProcessWasm sets CanJIT to false). Teach
the existing per-platform category checks about wasm so the whole
"watchpoint" and "expression" categories are skipped, rather than
decorating each test individually.
api2: fix FTP default import and skip boot attach/replace/detach test
test_200_ftp: FTPModel moved to ftp.config submodule when the plugin
was converted to the typesafe pattern; update the generated script's
import accordingly.
test_boot_attach_replace_detach: skip until IT can provide larger
disks; current disks lack space for the required boot partitions.
[RFC][CodeGen] Add generic target feature checks for intrinsics
This PR adds target-independent infrastructure for annotating LLVM intrinsics
with required subtarget feature expressions.
It introduces a TargetFeatures string field to intrinsic TableGen records.
TableGen emits an intrinsic-to-feature mapping table.
Both SelectionDAG and GlobalISel now perform this check before lowering target
intrinsics. This allows targets to opt in by annotating intrinsic definitions
directly, rather than adding custom checks during lowering, legalization, or
instruction selection.
This PR uses one AMDGPU intrinsic as an example.
NAS-141383 / 26.0.0-RC.1 / Fix a few API tests (by anodos325) (#19134)
* Reporting realtime shows stats on boot pool and so we should expect
it.
* pam / auth stack now properly reports in *audit* messages why the
authentication failed (minimally including PAM error code).
* harden our webshell tests
Original PR: https://github.com/truenas/middleware/pull/19133
Co-authored-by: Andrew Walker <andrew.walker at truenas.com>
[RFC][CodeGen] Add generic target feature checks for intrinsics
This PR adds target-independent infrastructure for annotating LLVM intrinsics
with required subtarget feature expressions.
It introduces a TargetFeatures string field to intrinsic TableGen records.
TableGen emits an intrinsic-to-feature mapping table.
Both SelectionDAG and GlobalISel now perform this check before lowering target
intrinsics. This allows targets to opt in by annotating intrinsic definitions
directly, rather than adding custom checks during lowering, legalization, or
instruction selection.
This PR uses one AMDGPU intrinsic as an example.
sh: Improve function documentation
* Mention that the function body can be in parentheses. It is already
implied since the function body can be any valid statement, but it may
not be obvious to a reader who has only ever seen functions that used
curly brackets and assumes that they are part of the function syntax.
* Remove the incorrect claim that a local statement may only occur at
the top of a function.
* Show that a value may be assigned to a variable in a local statement.
* While here, replace unpaired double quotes with \(dq to avoid
confusing syntax highlighters.
PR: 296050
MFC after: 1 week
Reviewed by: ziaee, jilles
Differential Revision: https://reviews.freebsd.org/D57596
pfctl: pfctl_get_astats() doesn't set errno
After commit 08f54dfca197 pfctl_get_astats() doesn't set errno anymore,
except in one place. Fix up that one place and adjust callers
appropriately.
Reviewed by: kp
Fixes: 08f54dfca197 ("pf: convert DIOCRGETASTATS to netlink")
Differential Revision: https://reviews.freebsd.org/D57608
AMDGPU: Refactor AMDGPUTargetID to not store MCSubtargetInfo
Store the triple string and GPUKind instead. The dependence
on checking AMDHSA seems like an anti-feature, but maintain the
behavior of not printing the modifiers for other OSes. Start
parsing the target ID instead of performing a direct string
comparison. Also improve test coverage for the treatment of the
environment component of the triple. The main behavioral change
is this will now produce normalized triples in the output and
diagnostics. Practially, this means all of the places that
currently emit "--" will be expanded into "-unknown-".
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
AMDGPU: Teach disassembler to produce target id directives
Inspect the binary's e_flags to reproduce the .amdgcn_target directive.
This is a step towards round-trip disassembly without depending
on command line state specifying the subtarget. I wasn't sure
where to put the emission to ensure it is always emitted. I
also do not know why it's OK to just write to outs(), but that's
what the other directives here were doing.
Co-Authored-By: Claude Opus 4.6 <noreply at anthropic.com>
[AMDGPU] Add flag to control VGPR pressure limits (#203797)
The RP trackers don't accurately measure the RA problem, and can
underestimate the number of registers required. Currently, for VGPR
pressure, we account for these inaccuracies using VGPRLimitBias, and
ErrorMargin. These are used to reduce the VGPRCriticalLimit /
VGPRExcessLimit . During scheduling, we check RP against these limits,
and if we start to see RP exceeding these limits, we will trigger RP
reduction heuristics (when deciding which instructions to schedule
next). Thus VGPRLimitBias + ErrorMargin effectively reduce the amount of
allowable RP during scheduling, as a means to compensate for RP tracker
inaccuracies. Currently, ErrorMargin is set to 3, and VGPRLimitBias is
set to 0.
However, the degree of inaccuracy tends to scale with the number of
registers we have available for allocation. In other words, the RP
trackers inaccuracy is better expressed as a percent of the register
budget, rather than some literal value. This PR adds some functionality
to express this inaccuracy compensation is a percent - and exposes a
[7 lines not shown]
[AMDGPU] NFC: Obviously show isVALU includes LDSDMA instructions (#203548)
In https://reviews.llvm.org/D124472 we started labelling LDSDMA as VALU
-- this was due to SPG stating that these instructions act as both
memory + VALU instructions.
This is buried in the isVALU methods - I'd argue that most users without
knowledge of this characteristic would not expect this behavior, and
looking at the implementation of these methods, there is nothing that
would suggest this behavior. This PR forces users to confront this
characteristic and decide if that is what they want to do for their
usecase.
I've personally seen at least two bugs in upstream code caused by this,
and have seen it cause problems a dozen + times in downstream code / in
WIP things.
Fix missing 2FA account flag and re-enable STIG tests
AccountFlag.TWOFACTOR was set in _get_user_obj() based on
self.twofactor_user, which only becomes true after the PAM OATH
conversation runs -- i.e. it was always false at that point. As a
result 2FA web sessions never carried the '2FA' flag and
validate_stig() rejected every credential, blocking STIG
enablement. This is why the suite had been failing for months.
Set TWOFACTOR in authenticate_oath() on success instead, where
the second factor has actually been verified, mirroring how OTPW
is recorded. Drop the now-dead check from _get_user_obj().
Re-enable tests/stig test_01 and test_02 and restore the conftest
server setup. test_03 stays skipped: its auditd-event checks need
the auditd daemon (Debian auditd.service + tnaudit), which is
managed outside middleware.
[SandboxVec][DAG] Implement UnscheduledPreds API (#201240)
Mirroring UnscheduledSuccs, this patch adds an UnscheduledPreds DAG node
counter that counts how many predecessors are not scheduled yet.
It also renames the existing ready() to readyBottomUp() to help us
differentiate between the two variants that are now available.
sysutils/boxrun: Update to 0.4.3
ChangeLog:
- support for VNET/epair networking
- support for devfs, and mountpoints
- several security improvements
- bugfixes
MFH: 2026Q2
(cherry picked from commit 1f686502344979246e35b30a6972388660bc672b)
[MCJIT] Fix frem.ll test failure with LLVM_ENABLE_RPMALLOC on Windows (#200319)
When compiled with `LLVM_ENABLE_RPMALLOC`, `lli.exe` links statically to
the runtime. With `LLVM_EXPORT_SYMBOLS_FOR_PLUGINS` enabled, `lli.exe`
exports a subset of symbols from the runtime library, but not all. In
particular, `printf()` is exported from the application binary, but
`fflush()` and `exit()` are not. For a JITted module, unresolved
external symbols are loaded either from the application or dynamic
libraries, in this case, from `msvcrt.dll`. The `MCJIT/frem.ll` test
attempts to flush the output, but because the functions resolve to
different CRT instances, the output data is lost.
The patch avoids the test failure by disabling exporting symbols from
`lli.exe` when it is linked with the static runtime library.
sysutils/boxrun: Update to 0.4.3
ChangeLog:
- support for VNET/epair networking
- support for devfs, and mountpoints
- several security improvements
- bugfixes
MFH: 2026Q2