DragonFlyBSD/src 6856d6bshare/mk bsd.crunchgen.mk

bsd.crunchgen.mk: Minor cleanups
DeltaFile
+13-15share/mk/bsd.crunchgen.mk
+13-151 files

DragonFlyBSD/src 52ff205initrd/rescue Makefile, share/mk bsd.crunchgen.mk

bsd.crunchgen.mk: Add CRUNCH_HOSTPROGS_${P} and fix awk in rescue

The usr.bin/awk consists of two subdirs: (1) 'awk' the actual program;
(2) 'maketab' a host program to help generate additional source.
Previously, the initrd/rescue/Makefile pointed the awk source to
'usr.bin/awk', and that caused the following warning:

```
crunchgen: rescue.conf: awk: warning: could not find any .o files
```

And pointing the source to 'usr.bin/awk/awk' couldn't fix it because the
required 'maketab' program would be unavailable.

To fix the problem as well as to extend the crunchgen framework, add the
CRUNCH_HOSTPROGS_${P} variable to specify the host programs required by
the build.  Implement the rules and specify the dependencies to build
the host programs.


    [2 lines not shown]
DeltaFile
+20-0share/mk/bsd.crunchgen.mk
+3-0initrd/rescue/Makefile
+23-02 files

DragonFlyBSD/src 250a8b4. Makefile_upgrade.inc, initrd Makefile

initrd: Merge rescue.libcrypto into rescue

After the last commit fixed the 'crc32' symbol conflict between
libhammer and libz, the merge of rescue.libcrypto and rescue only had
one conflict symbol: tilde_expand() from libprivate_ssh and
libprivate_edit.  Work around this symbol conflict by setting
libprivate_ssh an internal library for ssh/scp.

This merge reduces the rescue binaries size by ~1.1MB, from 12.1MB
(rescue 5.3MB + rescue.libcrypto 6.8MB) to 11MB.
DeltaFile
+106-53initrd/rescue/Makefile
+0-80initrd/rescue.libcrypto/Makefile
+1-1initrd/Makefile
+1-0Makefile_upgrade.inc
+108-1344 files

DragonFlyBSD/src 8cb3695lib/libhammer Makefile

libhammer(3): Exclude crc32.c and icrc32.c from sys/libkern

The user hammer(8) already includes these sources from sys/libkern, so
don't need to provide them in this library. More importantly, this
avoids the 'crc32' symbol conflict with libz.
DeltaFile
+4-7lib/libhammer/Makefile
+4-71 files

DragonFlyBSD/src addc09einitrd/rescue Makefile, initrd/rescue.libcrypto Makefile

crunchgen(1): Improve the handling of internal libraries

Previously, the `libs_int` and `special lib_int` commands specified the
internal libraries by their full paths, following the way of handling of
the shared libraries by `libs_so` and `special lib_so`. However, this
was actually a mistake because the internal libraries require building.
So it was lucky/hacky that rescue/rescue.libcrypto specified the
internal libraries with a combination of source directory and the
library name, e.g.,

```
CRUNCH_INTLIB_grep= ${CRUNCH_PATH_grep}/grep/libgreputils/libgreputils.a
CRUNCH_INTLIB_telnet= ${.CURDIR}/../../lib/libtelnet/libtelnet.a
```

To actually properly support internal libraries, we must explicitly the
source directories, as well as support build options.  To this end,
change the `libs_int` and `special lib_int` commands to only specify the
libraries names, and then extend the `special srcdir` to explicitly the

    [10 lines not shown]
DeltaFile
+153-51usr.bin/crunch/crunchgen/crunchgen.c
+69-18usr.bin/crunch/crunchgen/crunchgen.1
+40-28share/mk/bsd.crunchgen.mk
+2-1initrd/rescue/Makefile
+2-1initrd/rescue.libcrypto/Makefile
+266-995 files

DragonFlyBSD/src cc3bf8ashare/mk bsd.crunchgen.mk

bsd.crunchgen.mk: Minor cleanups
DeltaFile
+13-15share/mk/bsd.crunchgen.mk
+13-151 files

DragonFlyBSD/src 6e9501binitrd/rescue Makefile, share/mk bsd.crunchgen.mk

bsd.crunchgen.mk: Add CRUNCH_HOSTPROGS_${P} and fix awk in rescue

The usr.bin/awk consists of two subdirs: (1) 'awk' the actual program;
(2) 'maketab' a host program to help generate additional source.
Previously, the initrd/rescue/Makefile pointed the awk source to
'usr.bin/awk', and that caused the following warning:

```
crunchgen: rescue.conf: awk: warning: could not find any .o files
```

And pointing the source to 'usr.bin/awk/awk' couldn't fix it because the
required 'maketab' program would be unavailable.

To fix the problem as well as to extend the crunchgen framework, add the
CRUNCH_HOSTPROGS_${P} variable to specify the host programs required by
the build.  Implement the rules and specify the dependencies to build
the host programs.


    [2 lines not shown]
DeltaFile
+20-0share/mk/bsd.crunchgen.mk
+3-0initrd/rescue/Makefile
+23-02 files

DragonFlyBSD/src 8410ea0usr.bin/crunch/crunchgen crunchgen.c, usr.bin/crunch/crunchide crunchide.c

crunchgen(1): Remove the unneeded '-dc' linker flag

crunchide(1) does not hide symbols by making them local for many years.
We've also been using '-fno-common' compiler flag for a long time. So
the '-dc' linker flag is obsolete. Just remove it.

Obtained-from: FreeBSD (https://reviews.freebsd.org/D34215)
DeltaFile
+2-4usr.bin/crunch/crunchide/crunchide.c
+1-2usr.bin/crunch/crunchgen/crunchgen.c
+3-62 files

DragonFlyBSD/src 5fd9458usr.bin/crunch/crunchgen crunchgen.1 crunchgen.c

crunchgen(1): Enhance the '-q' (quiet) option to control warnings

Only suppress the warning messages about the component program when the
'-q' option is specified twice.

For example, now the following suppressed warning in crunching
initrd/rescue is shown:
```
crunchgen: rescue.conf: awk: warning: could not find any .o files
```

This also reveals a real problem in the 'awk' component, and I've
created a bug to track it:
https://bugs.dragonflybsd.org/issues/3414
DeltaFile
+7-7usr.bin/crunch/crunchgen/crunchgen.c
+2-1usr.bin/crunch/crunchgen/crunchgen.1
+9-82 files

DragonFlyBSD/src 9dd2293usr.bin/crunch/crunchgen crunchgen.c crunchgen.1

crunchgen(1): Update usage() text and sort options

* Add the missing '-l' option to the usage text.
* Sort the options in the usage text and in the man page.
DeltaFile
+7-9usr.bin/crunch/crunchgen/crunchgen.1
+4-4usr.bin/crunch/crunchgen/crunchgen.c
+11-132 files

DragonFlyBSD/src 4c33bcausr.bin/crunch/crunchgen crunchgen.c

crunchgen(1): Clean up and improve the makefile writeout code

No functional changes.
DeltaFile
+43-47usr.bin/crunch/crunchgen/crunchgen.c
+43-471 files

DragonFlyBSD/src da4731fusr.bin/crunch/crunchgen crunchgen.c

crunchgen(1): Fix a repeated word in comment and fix styles
DeltaFile
+5-3usr.bin/crunch/crunchgen/crunchgen.c
+5-31 files

DragonFlyBSD/src 6f7f058usr.bin/crunch/crunchgen crunchgen.c

crunchgen(1): Clean up intlib_makefile_rules() a bit

While there, apply minor style fixes.
DeltaFile
+7-12usr.bin/crunch/crunchgen/crunchgen.c
+7-121 files

DragonFlyBSD/src 366bf19lib/libnvmm libnvmm_x86.c, sys/dev/virtual/nvmm/x86 nvmm_x86.h nvmm_x86_svm.c

nvmm: Fully sync with master version
DeltaFile
+402-307lib/libnvmm/libnvmm_x86.c
+483-0sys/dev/virtual/nvmm/x86/nvmm_x86_internal.h
+365-64test/testcases/libnvmm/h_mem_assist.c
+338-90sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+393-0test/testcases/libnvmm/h_misc.c
+24-256sys/dev/virtual/nvmm/x86/nvmm_x86.h
+2,005-71726 files not shown
+2,780-1,17432 files

DragonFlyBSD/src 068147cshare/man/man9 atomic.9, sys/cpu/x86_64/include atomic.h

atomic(9): Add relaxed load/store variants from FreeBSD

Obtained from FreeBSD.  However, the original atomic_store_ptr() macro
was causing '-Wcast-qual' warnings, so I changed it based on the
NetBSD's atomic_store_relaxed().

Actually, I found NetBSD's version more clean, but we import the FreeBSD
version to help import code/drivers in the future.

Discussed-with: dillon
DeltaFile
+131-0sys/sys/atomic_common.h
+14-13share/man/man9/atomic.9
+1-2sys/cpu/x86_64/include/atomic.h
+146-153 files

DragonFlyBSD/src ae3845csys/dev/virtual/nvmm nvmm_os.h, sys/sys bitops.h

<sys/bitops.h>: Import ilog2(n) from NetBSD

And thus remove the local define from 'nvmm_os.h'.
DeltaFile
+79-0sys/sys/bitops.h
+0-1sys/dev/virtual/nvmm/nvmm_os.h
+79-12 files

DragonFlyBSD/src b0913e3sys/vfs/hammer2 hammer2_vfsops.c

hammer2: Disable debug v/f-chain dumps on unmounting

The two dumps were added to track down the HAMMER2-msg leak reported by
malloc_uninit() and would always print the following logs at shutdown:

```
v-chain 0xfffff8008e6204c0 volume.0   0000000000000010 0000000000000000/0  mir=00000000000
00140
      [00002000] (?) refs=1
f-chain 0xfffff8008e620640 freemap.0   0000000000000010 0000000000000000/0  mir=0000000000
000140
      [00002000] (?) refs=1
```

Given that the memory leak has been fixed in commit
bfcedfb468d712f29cadb491bec0928ad4279bad, disable these two debug dumps
now.

ok by dillon.
DeltaFile
+10-5sys/vfs/hammer2/hammer2_vfsops.c
+10-51 files

DragonFlyBSD/src 40e5c56sys/vfs/hammer2 hammer2_vfsops.c

hammer2: Disable debug v/f-chain dumps on unmounting

The two dumps were added to track down the HAMMER2-msg leak reported by
malloc_uninit() and would always print the following logs at shutdown:

```
v-chain 0xfffff8008e6204c0 volume.0   0000000000000010 0000000000000000/0  mir=00000000000
00140
      [00002000] (?) refs=1
f-chain 0xfffff8008e620640 freemap.0   0000000000000010 0000000000000000/0  mir=0000000000
000140
      [00002000] (?) refs=1
```

Given that the memory leak has been fixed in commit
bfcedfb468d712f29cadb491bec0928ad4279bad, disable these two debug dumps
now.

ok by dillon.
DeltaFile
+10-5sys/vfs/hammer2/hammer2_vfsops.c
+10-51 files

DragonFlyBSD/src b243cfcsys/kern kern_dmsg.c

kern: Fix memory leak in kdmsg_iocom_uninit()

When kdmsg_iocom_uninit() is called but no connection was ever
established (no reader/writer threads), a PING message was allocated and
queued but never freed. This caused a 120-byte leak from the HAMMER2-msg
allocator on shutdown.

Fix this by calling kdmsg_drain_msgq() to clean up any queued messages.

This fixes the 'malloc_uninit: 120 bytes of HAMMER2-msg still allocated'
warning.  Note that this warning already disappeared after fixing the
hammer2_ioctl_recluster() bug in commit
c5cc81fefa166cc45657541c155797f0cff88c62.

Bug: https://bugs.dragonflybsd.org/issues/3385
DeltaFile
+7-1sys/kern/kern_dmsg.c
+7-11 files

DragonFlyBSD/src 5531067sys/kern kern_slaballoc.c

kern: Clean up malloc_uninit()

* Correct the diagnostic log message by omitting the CPU id, which
  doesn't apply here. The unfreed bytes must be summed from all CPUs.

* Clean up excess INVARIANTS ifdef's by using '__debugvar' instead.
DeltaFile
+3-9sys/kern/kern_slaballoc.c
+3-91 files

DragonFlyBSD/src 57fb4c1sys/dev/drm linux_kobject.c

drm: Fix kobject_release() to free kobj->name

While there, adjust kvasprintf() in kobject_init_and_add() to use
'GFP_KERNEL' for consistency.
DeltaFile
+5-1sys/dev/drm/linux_kobject.c
+5-11 files

DragonFlyBSD/src ff5e130gnu/usr.bin/mpc Makefile

mpc: Fix inclusion paths to correctly include its own 'config.h'

It wrongly included the GMP's 'config.h', as the '../gmp/' directory has
both 'gmp.h' and 'config.h'.
DeltaFile
+2-1gnu/usr.bin/mpc/Makefile
+2-11 files

DragonFlyBSD/src 28b9924contrib/binutils-2.34 README.DRAGONFLY, contrib/binutils-2.34/binutils readelf.c

binutils234: Patch readelf(1) to recognize DragonFly-specific notes

* Define NT_DRAGONFLY_ABI and NT_DRAGONFLY_NOINIT in
  'include/elf/common.h' according to 'lib/csu/common/notes.h'.
* Add process_dragonfly_elf_note() to readelf.c to decode
  DragonFly-specific notes.

Before:
```
% readelf -n /bin/sh

Displaying notes found in: .note.tag
  Owner                Data size        Description
  DragonFly            0x00000004       NT_VERSION (version)
   description data: c8 29 09 00
  DragonFly            0x00000004       Unknown note type: (0x00000020)
   description data: 00 00 00 00
```


    [10 lines not shown]
DeltaFile
+47-0contrib/binutils-2.34/binutils/readelf.c
+5-0contrib/binutils-2.34/include/elf/common.h
+2-0contrib/binutils-2.34/README.DRAGONFLY
+54-03 files

DragonFlyBSD/src d014692sys/kern subr_diskgpt.c

kernel: Fix two bugs in gptinit()

* Fix the wrong type for 'table_lba'; should be 'uint64_t' instead of
  'uint32_t', and fix the read to use le64toh().

* Allow the partition table has entries more than 128 (MAX_GPT_ENTRIES).
  The UEFI specification basically has no upper limit, but we limit to
  parsing the first 128 (MAX_GPT_ENTRIES) entries.

  This actually happens with a Proxmox v9.2 ISO, which uses GPT and
  allocates 44 blocks for the partition table, so there are 176 entries.

  For example, here is the gpt(8) of a USB stick written with this ISO:

  ```
  Disk da8: 57.3GB (120225792 512-byte sectors)
      Start    Sectors    Size  Index  Contents
          0          1    512B      -  PMBR
          1          1    512B      -  Primary GPT header

    [13 lines not shown]
DeltaFile
+18-10sys/kern/subr_diskgpt.c
+18-101 files

DragonFlyBSD/src bb51ebelib/libc/sys mincore.2, sys/vm vm_mmap.c

mincore(2): Add 'vm.mincore_mapped' sysctl to control reporting

Add the 'vm.mincore_mapped' (default ON!) to control whether to report
only the mapping status (if set to a non-zero value) or the physical
residency (if set to a zero value; the old behavior).

The idea of implementing this and enabling it by default is to help
mitigate page cache attacks [1].

[1] Page Cache Attacks: https://arxiv.org/abs/1901.01161

Obtain-from: FreeBSD (https://reviews.freebsd.org/D18764)
DeltaFile
+16-3lib/libc/sys/mincore.2
+7-3sys/vm/vm_mmap.c
+23-62 files

DragonFlyBSD/src dfe3e28lib/libc/sys mincore.2, sys/vm vm_mmap.c

mincore(2): Fix several bugs

* Return ENOMEN when the requested range is not fully mapped.
  (obtained from FreeBSD: 455dd7d4c79bc7bef5401721f617e64eca7ef422)

  This change should fix a crash in Mesa where it calls mincore() to
  determine whether a protocol field is a valid pointer in order to
  keep compatible with an old protocol version.

* Fix an off-by-one error in filling the skipped entries.  lastvecindex
  refers to the last valid byte, so the new bytes should come after it.
  (obtained from FreeBSD: 6a87d217e2da2a63d4431aeb871783e1dd7349ae)

* Fix the calculation of the 'end' boundary.
  (obtained from FreeBSD: d0c9294b810f8b42b7ac27a46db44b94ddca3160)

* Update the man page.

Reported-by: peeterm
DeltaFile
+46-14lib/libc/sys/mincore.2
+28-14sys/vm/vm_mmap.c
+74-282 files

DragonFlyBSD/src d28806asys/kern kern_jail.c

jail: Fix potential buffer overflow in sysctl_jail_list()

sysctl_jail_list() allocates a buffer of size = count*1024, and then
uses ksnprintf() to format the jail information and advance the write
position. However, ksnprintf() returns the would-be length (i.e., the
number of bytes would be written if the buffer is big enough). So a jail
that has a very long path and/or many IPs would overflow the allocated
buffer.

Fix the bug by correctly handling the return value of ksnprintf().

GitHub-PR: #45
Reported-by: Nathan Sapwell (jewbird)
DeltaFile
+6-6sys/kern/kern_jail.c
+6-61 files

DragonFlyBSD/src 0118d21sys/vm device_pager.c

vm: Remove duplicate reference in cdev_pager_allocate()

The code was updated in 2013 [1] to bring in various changes from
FreeBSD, but left this duplicate reference.  Remove the erroneous
vm_object_reference_locked() call.

[1] kernel: Port new device_pager interface from FreeBSD
    commit f2c2051ee473577d22178d55f782ceebbd88d58f

GitHub-PR: #49
Credit: LI Leding
DeltaFile
+0-4sys/vm/device_pager.c
+0-41 files

DragonFlyBSD/src a7cf60fusr.bin/rpcinfo rpcinfo.c

rpcinfo(8): Fix stack buffer overflow in rpcbdump()

The function previously used unbounded sprintf() and strcat() to format
the info into a fixed 256-byte stack buffer.  A malicious or compromised
rpcbind endpoint that returns enough distinct version numbers for a
single program (roughly 24 maximum-width decimal values plus separators)
can overflow this buffer.

CVE: CVE-2026-16461
Openwall: CVE-2026-16277 & CVE-2026-16461: buffer overflows in rpcinfo
        (https://www.openwall.com/lists/oss-security/2026/07/23/8)
DeltaFile
+16-7usr.bin/rpcinfo/rpcinfo.c
+16-71 files

DragonFlyBSD/src f7502a8usr.bin/rpcinfo rpcinfo.c

rpcinfo(8): Fix stack buffer overflow in rpcbaddrlist()

rpcinfo's rpcbaddrlist() formats two server-controlled, unbounded XDR
strings into a fixed 128-byte stack buffer with sprintf(). A malicious
or on-path rpcbind server overflows it when a user runs:
$ rpcinfo -l <host> <prognum> <versnum>

Obtained-from: https://git.linux-nfs.org/?p=steved/rpcbind.git;a=commitdiff;h=bb9bb7286a4c345442946dc2ce3c9e7f67e96d4d
CVE: CVE-2026-16277
Openwall: CVE-2026-16277 & CVE-2026-16461: buffer overflows in rpcinfo
        (https://www.openwall.com/lists/oss-security/2026/07/23/8)
DeltaFile
+1-1usr.bin/rpcinfo/rpcinfo.c
+1-11 files