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

DragonFlyBSD/src bfab99dsys/kern kern_linker.c

kernel/linker: serialize recursive unload

Restore the safe list traversal from commit
e7a2d40362352344eff1c4f395caf0a735e00a3e.

'llf_lock' is now recursive and held through the unload path, so
callbacks and dependency release can recurse without exposing a
partially unloaded file.

GitHub-PR: #50
DeltaFile
+4-8sys/kern/kern_linker.c
+4-81 files

DragonFlyBSD/src e6c9b95sys/kern kern_linker.c

kernel/linker: preserve refs after unload veto

linker_file_unload() used to take a temporary file reference (file->refs)
before notifying modules to unload [1].  Its veto path dropped that
temporary reference before returning the error.

The 2009 linker code sync with FreeBSD [2] removed the temporary
reference but retained the decrement.  Therefore, every failed kldunload
reduced 'file->refs' even though the file remained loaded, allowing
repeated EBUSY returns to drive the count below zero.

Keep the existing reference when a module vetoes unload.  sys_kldunload()
already restores userrefs on error, and a later unload attempt can retry
with both counters unchanged.

[1] Handle recursive situations a bit more robustly ...
    commit e7a2d40362352344eff1c4f395caf0a735e00a3e
[2] modules: pull in most of FreeBSD's module linker changes
    commit 1c0e32863e0583221e430c22c1c68a023fd16195

    [2 lines not shown]
DeltaFile
+0-1sys/kern/kern_linker.c
+0-11 files

DragonFlyBSD/src 19c2bccsys/kern subr_diskslice.c, sys/sys param.h diskslice.h

kernel: Remove DIOCGSLICEINFO and DIOCSYNCSLICEINFO ioctls

The DIOCGSLICEINFO ioctl code had a buffer overflow bug.  The ioctl
declared the parameter to have size of 'struct diskslices', which only
supported MAX_SLICES (i.e., 16) slices.  When try to use this ioctl on a
disk with more slices (e.g., a GPT disk that may have 128
partitions/slices), the bcopy() would overflow the target buffer that
was prepared by mapped_ioctl().

It's actually not easy to properly fix this bug. However, this ioctl was
actually unused. In addition, FreeBSD has removed it in 2003 [1]. So
simply remove it, together with the related DIOCSYNCSLICEINFO.

[1] https://github.com/freebsd/freebsd-src/commit/19f7043db0bba9dd2c333612eff90411339d46de

GitHub-PR: #43
Reported-by: Nathan Sapwell (jewbird)
Discussed-with: swildner
DeltaFile
+0-35sys/kern/subr_diskslice.c
+2-2sys/sys/diskslice.h
+1-1sys/sys/param.h
+3-383 files

DragonFlyBSD/src 7e88ea5sys/net/tun if_tun.c

if_tun: Fix mbuf chain leak in tunwrite()

tunwrite() builds an mbuf chain headed by 'top' in its read loop;
on the final iteration the local 'm' points at the chain tail.
Then the subsequent EAFNOSUPPORT default case of the family switch calls
m_freem(m), freeing only that tail mbuf and leaking the chain head and
all intermediates.

Fix the m_freem() to free from 'top' instead to free the whole mbuf
chain, matching the earlier error path.

While there, fix one indentation. (aly)

GitHub-PR: #39
Assisted-with: Zhipu GLM-5.2
DeltaFile
+2-2sys/net/tun/if_tun.c
+2-21 files

DragonFlyBSD/src 9f24219lib/libnvmm libnvmm_x86.c

libnvmm(3): Remove unused GVA computation artifacts

On single-memory-operand instructions, we use the GPA provided by
the hardware and discard the GVA. The code that calculates the GVA
is therefore effectively unused. Remove it.

Obtained-from: NVMM Reference Implementation
DeltaFile
+34-140lib/libnvmm/libnvmm_x86.c
+34-1401 files

DragonFlyBSD/src 1275f15test/testcases/libnvmm h_mem_assist.c h_mem_assist_asm.S

testcases/libnvmm: Remove the two RIP-relative addressing tests

This reverts commit dea513a396514e21fa2cb677cd1e42929283d797 where I
added these two commits, which only helped validate the instruction
decoder and thus were not important.  Remove them to keep in sync with
the upstream NVMM Reference Implementation.
DeltaFile
+0-66test/testcases/libnvmm/h_mem_assist_asm.S
+0-6test/testcases/libnvmm/h_mem_assist.c
+0-722 files

DragonFlyBSD/src 48d7dfasys/dev/virtual/nvmm/x86 nvmm_x86_svmfunc.S

nvmm(4): Improve HOST_RESTORE_TR to save an unnecessary movzwq

Reviewed-by: dillon
DeltaFile
+3-5sys/dev/virtual/nvmm/x86/nvmm_x86_svmfunc.S
+3-51 files