link_elf: bounds-check the DT_HASH offset
parse_dynamic() builds the symbol hash table at ef->address + d_ptr
without checking that d_ptr lies within the mapped image, so a crafted
DT_HASH entry causes an out-of-bounds read of the hash header. Reject
the object with ENOEXEC when the header does not fit in the image.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61323
link_elf_obj: validate section name offsets
A section name offset (sh_name) indexes the section name string table
without being checked against shstrcnt, and the result is passed to
strcmp(), so a corrupt object causes an out-of-bounds read. Check that
the table is NUL-terminated and that every sh_name lies within it, in
both the preload and file paths, and reject the object with ENOEXEC.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61338
link_elf_obj: validate symbol name offsets
A symbol name offset (st_name) indexes the string table in several
places without being checked against ddbstrcnt, so a corrupt object
causes an out-of-bounds read. Check that the string table is
NUL-terminated and that every st_name lies within it, in both the
preload and file paths, and reject the object with ENOEXEC.
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61322
link_elf_obj: bounds-check e_shstrndx in link_elf_load_file()
e_shstrndx is used to index the section header array after only being
checked against zero, so a malformed object can make the linker read up
to about 64K entries past the end of shdr[]. Reject such a file with
ENOEXEC, as link_elf_link_preload() already does.
Reported by: llm-postcr
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61321
[mlir][XeGPU] Retry smaller inst_data when picking subgroup layouts (#239888)
Subgroup layout propagation always used the largest hardware block as
`inst_data`. When each subgroup's tile is smaller than that block, no
layout was found and propagation failed. For example, `64x16xf32` over
32 subgroups gives each subgroup `2x16`, which is smaller than the
`8x16` block.
This PR retries with smaller blocks until a subgroup layout fits:
- store_nd / prefetch_nd: try smaller block sizes.
- dpas / dpas_mx: try smaller M.
The largest block is still tried first, so existing results don't
change.
assisted-by-claude
---------
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MC][MachO] Add an option to relocate cross-section offsets in DWARF (#239793)
Mach-O objects store references from one DWARF section into another as
bare offsets rather than relocations. For comparison in ELF, DWARF
references are relocations against sections that start at address 0.
Because of this Mach-O DWARF sections cannot be concatenated by tools
such as ld -r. However, this would be useful for some niche use-cases
such as doing an incremental (ld -r) link and then creating a static
archive that is then distributed to another machine.
This patch adds MCTargetOptions::MachORelocatableDwarf and a
-macho-relocatable-dwarf flag, which sets
DwarfUsesRelocationsAcrossSections for Darwin targets. When it is set,
every __DWARF section is also assigned address 0, like in ELF.
Assisted-by: Claude
sysutils/bsdisks: refresh TimeMediaDetected on media change
TimeMediaDetected was only set when the drive appeared, so a card
inserted into a card reader that was already plugged in, or a disc
inserted into an optical drive, got a stale time and gvfs would not
automount it. Update it on devd MEDIACHANGE and send
PropertiesChanged so gvfs picks up the new value.
Use read-only accessors for TimeDetected and TimeMediaDetected,
matching the other Drive properties.
Revert "[test][llvm-strings] Use printf for interpreting octal of echo -e" (#240613)
Reverts llvm/llvm-project#240529
Apparently this breaks things for z/OS. Not that it's easy to tell given
there's no upstream CI for z/OS as far as I can tell.
Co-authored-by: Jackson Stogel <jtstogel at gmail.com>
SystemZ: Lower sub-word atomicrmw during type legalization (#238532)
Produce the ATOMIC_LOADW_* nodes when replacing the illegal i8/i16
results, instead of custom lowering the promoted node later. This
removes the no-op custom type legalization case.
Constants are now any-extended, so one test materializes an immediate
with llill instead of lhi.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
ipfilter: Remove erroneous ntohs()
The original commit was wrong. ipf_nat_builddivertmp() builds the UDP
template with the length in host byte order
M_DUP() copies that value unchanged. The old code was therefore correct.
It added fin_plen in host order and then did a single htons().
The original patch was discussed with Co-Pilot, which pointed out the
original bug. claude-opus-5-5 discovered the ntohs() error that
co-pilot suggested.
Interestingly this code had been running here for a couple of months.
Reported by: llm-postcr
Fixes: 72cc9e3766f4
[LV] Expand alias-mask pointer bounds after the SCEV checks. (#240556)
materializeAliasMask expanded the diff-check pointer bounds via
VPExpandSCEVRecipes in the entry block, before the SCEV checks. The
bounds come from LAA's SCEVs, which are computed under LAA's predicates
(e.g. versioned strides), so they are only valid if the predicates hold.
For example a bound could become%n /u (%y + 1) after versioning
%stride == 1, which divides by zero for %y == -1 and %stride != 1,
while the original loop is well defined.
Expand the bounds directly in the alias-mask check block using
VPSCEVExpander, which is dominated by the SCEV checks.
[Clang][OBT] Diagnose overflow handlers in local class member functions
The overflow handler diagnostics skipped any body finished while another
function scope was active, so that a lambda is diagnosed with its
enclosing function. That also skipped member functions of local classes,
which the enclosing walk does not visit, so they were never diagnosed.
Skip only nested lambdas. A local class member function is a separate
function, so it can warn under -Woverflow-behavior-no-handler but never
under -Woverflow-behavior-unreachable-handler.
Also inline the three single-use diagnostic groups, and use %enum_select
for the lambda or block in -Woverflow-behavior-unreachable-handler.
Signed-off-by: Justin Stitt <justinstitt at google.com>
[libc][stdfix][NFC] Use cpp::numeric_limits<T>::digits in divifx (#239900)
Use `cpp::numeric_limits<T>::digits` in `divifx` to count value bits
instead of `sizeof(IntType) * 8 - cpp::is_signed_v<IntType>`.
Also compare `INTERMEDIATE_BITS` against
`cpp::numeric_limits<int64_t>::digits` (63) instead of `64` for signed
types, since `INTERMEDIATE_BITS` excludes the sign bit.
Follows
https://github.com/llvm/llvm-project/pull/235602#issuecomment-6417638445.
[libc][math][c++23] Add log10p1bf16 math function (#235343)
This PR adds the `log10p1bf16` math function to LLVM libc for the
`bfloat16` type. It computes `log10(1 + x)` and handles special cases
like NaN, infinity, zero, and the domain boundary at `x = -1`.
The implementation uses a polynomial approximation for small inputs and
range reduction with a lookup table for other inputs. Special cases are
handled to maintain the expected floating-point behavior, including
exception behavior.
Added unit tests for accuracy, special values, and exception handling,
along with smoke tests. Updated the relevant libc entrypoint lists,
CMake files, and Bazel build files to integrate the function into both
build systems.
Validated the implementation using the available CMake and Bazel build
and test targets.
[4 lines not shown]
zdb: borrow only the length read in the --anyraid-map dump
vdev_anyraid_read_map() reads each tile map chunk at its rounded
length, not as a full 16 MiB buffer, but print_anyraid_mapping()
borrows and returns SPA_MAXBLOCKSIZE bytes of each buffer. Debug
builds abort on 'zdb --anyraid-map -vv' and higher: "VERIFY3U(
abd->abd_size, >=, n) failed (512 >= 16777216)" in abd_borrow_buf().
Borrow and return the size of each buffer.
Also free the two arrays that zdb_print_anyraid_tile_layout()
allocates for its separator lines, which valgrind reports as lost
with any --anyraid-map -v level.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Paul Dagnelie <paul.dagnelie at klarasystems.com>
Signed-off-by: Tigerblue77 <37409593+tigerblue77 at users.noreply.github.com>
Closes #19728
anyraid: write the last tile's entries when a map chunk fills
vdev_anyraid_write_map_sync() issues each 16 MiB chunk of the tile map
as soon as an entry fills it, but when that entry belongs to the last
tile it stops and leaves the chunk to the final write. If the entry
was the skip entry before that tile, or the location of one of its
copies but not the last, the remaining entries of the tile are never
written: once the vdev is opened again, the map has lost that tile or
some of its copies.
Stop only when the entry that filled the chunk is the last one, and
otherwise issue the chunk and go on. Found from reading, as was the
read of a full last chunk: a chunk holds 4194304 entries, and this was
not reproduced.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Paul Dagnelie <paul.dagnelie at klarasystems.com>
Signed-off-by: Tigerblue77 <37409593+tigerblue77 at users.noreply.github.com>
Closes #19728
anyraid: read a full last map chunk when the map fills it
vdev_anyraid_read_map() takes the length of the last tile map chunk as
map_length % SPA_MAXBLOCKSIZE, which is 0 when the map length is a
multiple of 16 MiB. That chunk is then read as a single sector while
its checksum covers 16 MiB, so every copy of such a map fails its
checksum and the vdev cannot be opened.
Take the length left in the map, at most SPA_MAXBLOCKSIZE, as the
parsing loop of anyraid_open_existing() already does. Found
from reading: such a map has about 4 million entries, and this was
not reproduced.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Paul Dagnelie <paul.dagnelie at klarasystems.com>
Signed-off-by: Tigerblue77 <37409593+tigerblue77 at users.noreply.github.com>
Closes #19728
anyraid: write the tile map at the vdev's ashift
map_write_issue() rounds each tile map chunk up to the ashift of the
leaf it writes to, while vdev_anyraid_read_map() reads and checks it
rounded up to the ashift of the anyraid vdev. When a leaf's ashift is
smaller than the vdev's, the checksum of every map copy covers fewer
bytes than the read, every copy fails it, and the vdev cannot be
opened: the pool cannot be imported again after an export or a
reboot. This is the case of 512e disks, which report 512-byte logical
and 4 KiB physical sectors, when the pool's ashift is not set: the
vdev takes the physical ashift and its leaves the logical one. A pool
created with -o ashift=12 is not affected, since zpool then sets that
ashift on every leaf too.
Round the write up to the vdev's ashift, as the read and the map
header already do. Maps written with mismatched ashifts since
816804dfdd stay unreadable; no release carries that code.
anyraid_import_ashift makes file vdevs report 4 KiB physical sectors
[7 lines not shown]
Add cross/mingw-w64-i686-*-crtdll
This allows compiling for Win32s / Win95 without msvcrt. However, C++
requires the _w* functions that are only in msvcrt and newer *and*
require Windows NT, so C++ is disabled for now.
build: skip script installation hook without userspace
The common.sh install hook runs even when CONFIG_USER is disabled.
With --with-config=kernel, no scripts create its destination directory,
so the shell redirection fails and make ignores the error.
Guard the hook with CONFIG_USER, like the scripts that use common.sh.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Giuseppe Piscitelli <ooonea at gmail.com>
Assisted-by: OpenAI Codex
Closes #19760
libspl: remove unused Solaris disk headers
We only use a few things in a single source file, so just move them
there and delete the rest.
Sponsored-by: TrueNAS
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Rob Norris <rob.norris at truenas.com>
Closes #19785
[test][llvm-strings] Use printf for interpreting octal of echo -e (#240529)
`echo -e` may not interpret `\NNN` as octal with certain system shells.
LLVM-lit uses its internal shell by default now
(https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179),
so it's perfectly fine and correct to rely system-dependent behavior.
However, some downstream consumers (Google) are still migrating to use
the internal shell. Given that s/echo/printf/g is minor, sending this PR
for broader compatibility in the meantime. Happy to revert if there is
an objection to making changes like this during lit internal shell
migration.