DragonFlyBSD/src 8958ea9. Makefile_upgrade.inc, initrd/rescue Makefile

initrd: Add diff/sdiff back to rescue and fix build

Update the rescue/Makefile to include the updated diff/sdiff utilities;
however, diff3 is excluded because it's a shell script and relies on
libexec/diff3prog.  As a result, we must remove /rescue/diff3 via
"make upgrade"; otherwise, /rescue/diff3 would become a separate binary
(because of hardlinks) and break initrd build because of exceeded size.

Bug: https://bugs.dragonflybsd.org/issues/3376
DeltaFile
+3-9initrd/rescue/Makefile
+1-0Makefile_upgrade.inc
+4-92 files

DragonFlyBSD/src 48363b6usr.bin/diff3 diff3 diff3.sh

diff3(1): Rewrite Makefile by using SCRIPTS

Meanwhile, rename the script "diff3" to "diff3" to work with SCRIPTS.
DeltaFile
+0-64usr.bin/diff3/diff3
+64-0usr.bin/diff3/diff3.sh
+1-6usr.bin/diff3/Makefile
+65-703 files

DragonFlyBSD/src 7876b5dlibexec/diff3prog Makefile

libexec/diff3prog: Don't duplicate the installation of diff3.1

The diff3.1 man page is already being installed by usr.bin/diff3.
DeltaFile
+1-3libexec/diff3prog/Makefile
+1-31 files

DragonFlyBSD/src a95b5cfusr.bin/diff Makefile

diff(1): Remove unnecessary "-Wall" COPTS

The "-Wall" option is already set by default.
DeltaFile
+0-1usr.bin/diff/Makefile
+0-11 files

DragonFlyBSD/src d775d69usr.bin/sdiff Makefile

sdiff(1): Remove unused stuff from Makefile
DeltaFile
+0-5usr.bin/sdiff/Makefile
+0-51 files

DragonFlyBSD/src f7ba04fusr.bin/sdiff Makefile.depend

sdiff(1): Remove Makefile.depend

That was auto-generated in FreeBSD's code base; we don't need it.
DeltaFile
+0-15usr.bin/sdiff/Makefile.depend
+0-151 files

DragonFlyBSD/src f9dc17eusr.bin/mail main.c extern.h

mail(1): Catch SIGWINCH to adapt to terminal size changes

Turn setscreensize() into a signal handler for SIGWINCH.  This
allows users to resize their terminal and have long subject lines
become visible in "h(eader)" listings without the need to restart
mail(1).

Submit: https://bugs.dragonflybsd.org/issues/3375
DeltaFile
+7-2usr.bin/mail/main.c
+1-1usr.bin/mail/extern.h
+8-32 files

DragonFlyBSD/src 9b7e606usr.bin/mail main.c extern.h

mail(1): Catch SIGWINCH to adapt to terminal size changes

Turn setscreensize() into a signal handler for SIGWINCH.  This
allows users to resize their terminal and have long subject lines
become visible in "h(eader)" listings without the need to restart
mail(1).

Submit: https://bugs.dragonflybsd.org/issues/3375
DeltaFile
+7-2usr.bin/mail/main.c
+1-1usr.bin/mail/extern.h
+8-32 files

DragonFlyBSD/src d5ba4faetc/rc.d dhclient

rc.d: Fix a typo in the comment of dhclient script
DeltaFile
+1-1etc/rc.d/dhclient
+1-11 files

DragonFlyBSD/src ab4c55cusr.bin/dsynth dsynth.c

dsynth - Include "add" in "help" output.

* Include a blurb on the "add" directive in the dsynth help output.

Submitted-by: Pierre-Alain TORET <daftaupe at dragonflybsd.org>
DeltaFile
+2-0usr.bin/dsynth/dsynth.c
+2-01 files

DragonFlyBSD/src fea0a68share/man/man5 rc.conf.5

rc.conf.5: Document the missing dhclient_flags_<interface>

This interface-specific dhclient(8) flags variable is supported by the
rc script, but was missing in the man page.

Obtained-from: FreeBSD
DeltaFile
+9-1share/man/man5/rc.conf.5
+9-11 files

DragonFlyBSD/src 1a7f098etc/rc.d dhclient

rc.d: Improve dhclient script

* Make use of the pid file to check the current status
* Improve the handling of arguments
* Improve error reporting

Obtained-from: FreeBSD
DeltaFile
+27-14etc/rc.d/dhclient
+27-141 files

DragonFlyBSD/src 5eebb8bshare/man/man5 rc.conf.5

rc.conf.5: Document the missing dhclient_flags_<interface>

This interface-specific dhclient(8) flags variable is supported by the
rc script, but was missing in the man page.

Obtained-from: FreeBSD
DeltaFile
+9-1share/man/man5/rc.conf.5
+9-11 files

DragonFlyBSD/src c726e45etc/rc.d nfsd ypbind

rc.d: Fix nfsd/yp* scripts to set ${command_args}

These scripts were failing to set ${command_args} because they set
"command_args=${<name>_flags}" before performing "load_rc_config".
As a result, the "command_args" variable was empty and the "<name>_flags"
settings in rc.conf were effectively ignored.

Fix this issue by moving the "command_args" assignment after calling
"load_rc_config".

Reported-by: kentish (on IRC)
Referred-to: FreeBSD
DeltaFile
+2-1etc/rc.d/nfsd
+2-1etc/rc.d/ypbind
+2-1etc/rc.d/yppasswdd
+2-1etc/rc.d/ypserv
+2-1etc/rc.d/ypset
+2-1etc/rc.d/ypxfrd
+12-66 files

DragonFlyBSD/src bd23261contrib/gcc-8.0/libstdc++-v3/config/locale/dragonfly codecvt_members.cc

libstdc++: Fix unsigned wraparound in codecvt::do_length [PR105857]

When the max argument to std::codecvt<wchar_t, char, mbstate_t>::length
is SIZE_MAX/4+1 or greater the multiplication with sizeof(wchar_t) will
wrap to a small value, and the alloca call will have a buffer that's
smaller than requested. The call to mbsnrtowcs then has a buffer that is
smaller than the value passed as the buffer length. When libstdc++.so is
built with -D_FORTIFY_SOURCE=3 the mismatched buffer and length will get
detected and will abort inside Glibc.

When it doesn't abort, there's no buffer overflow because Glibc's
mbsnrtowcs has the same len * sizeof(wchar_t) calculation to determine
the size of the buffer in bytes, and that will wrap to the same small
number as the alloca argument. So luckily Glibc agrees with the caller
about the real size of the buffer, and won't overflow it.

Even when the max argument isn't large enough to wrap, it can still be
much too large to safely pass to alloca, so we should limit that. We
already have a loop that processes chunks so that we can handle null

    [4 lines not shown]
DeltaFile
+6-3contrib/gcc-8.0/libstdc++-v3/config/locale/dragonfly/codecvt_members.cc
+6-31 files

DragonFlyBSD/src bbd7e13sys/kern kern_sig.c sys_generic.c, sys/sys signal2.h proc.h

kernel - Fix signal / signal-mask-change race

* Fix race between incoming signals and sigsuspend(), ppoll(),
  or pselect() when used to change the signal mask.  A signal can
  be received and queued to a process that is in the middle of
  unmasking said signal without triggering signal processing.

* Our kernel *sleep*() and wakeup functions avoid whole-process
  locks to ensure high thread performance, but this can result in
  a race when a signal cannot be delivered to a thread and gets
  queued to the process instead.

  In order to keep the high-performance sleep, we instead use
  atomic ops and a ref-counter only in code paths related to
  general signal delivery to the process.  Code which changes the
  signal mask then waits for the ref-counter to become zero as
  needed to ensure proper interlocked tests across signal mask
  changes to close the race.
DeltaFile
+50-0sys/sys/signal2.h
+28-6sys/kern/kern_sig.c
+5-0sys/kern/sys_generic.c
+2-1sys/sys/proc.h
+85-74 files

DragonFlyBSD/src a6741f0sbin/hammer2 cmd_snapshot.c

sbin/hammer2/cmd_snapshot.c: Fix error handling

pfs.name is not valid when ioctl(HAMMER2IOC_PFS_GET) failed.
DeltaFile
+1-0sbin/hammer2/cmd_snapshot.c
+1-01 files

DragonFlyBSD/src 6cd7b65sbin/hammer2 main.c

sbin/hammer2: Fix usage()
DeltaFile
+1-1sbin/hammer2/main.c
+1-11 files

DragonFlyBSD/src 84646c2sys/netinet in_pcb.c, sys/netinet6 in6_src.c

kernel - Fix auto port assignment collision in network code

* When the SO_REUSEADDR or SO_REUSEPORT socket option is set on a
  socket undergoing automatic lport assignment, the auto network port
  assignment code in the kernel improperly ignores collisions against
  ports assigned to wildcard sockets and may assign the same port.  This
  causes later connect() calls to fail.

* Can cause gdb services to sometimes fail to connect.

* Fixed by ignoring the options for the purposes of finding an unused
  port.

Reported-by: Sergey Zigachev (servik)
DeltaFile
+10-0sys/netinet6/in6_src.c
+7-0sys/netinet/in_pcb.c
+17-02 files

DragonFlyBSD/src ccab79clibexec/rtld-elf rtld.c rtld.h, libexec/rtld-elf/x86_64 reloc.c

rtld - do not allow both dynamic DTV index and static TLS offset

* If we are allocating static offset for an object with dynamic index,
  return failure. In the opposite case, if dynamic index is requested for
  statically allocated TLS area, directly use the offset instead of
  setting the index.
  Taken from FreeBSD, commit 91880e07f605edb90339685bc934699a4344de3b.

* While there, fix dtv timing race between threads.

Co-authored-by: Matthew Dillon <dillon at apollo.backplane.com>
Reported-by: Stephane Russell <srussell at prodigeinfo.qc.ca>
DeltaFile
+21-5libexec/rtld-elf/rtld.c
+2-2libexec/rtld-elf/x86_64/reloc.c
+2-1libexec/rtld-elf/rtld.h
+1-1libexec/rtld-elf/map_object.c
+26-94 files

DragonFlyBSD/src 11bfc5asbin/ifconfig ifwg.c

ifconfig(8): Improve wg_aip_parse() to validate CIDR prefix length
DeltaFile
+5-3sbin/ifconfig/ifwg.c
+5-31 files

DragonFlyBSD/src d4d5b6bsbin/ifconfig ifwg.c

ifconfig(8): Fix IPv6 CIDR parsing error for wgaip (wg allowed-ip)

The inet_net_pton() is inherited from legacy ISC named code and uses a
legacy IPv6 CIDR format (e.g., 1:2:3:4/64), so it fails to parse some
now valid IPv6 CIDRs (e.g., 1:2:3:4::/64).  This was causing 'wgaip'
option to fail configure some IPv6 allowed-ips/networks.

Given that inet_net_pton() is not standard and behaves differently
across BSDs and Linux, it might be not really useful to fix/improve it
(e.g., by porting OpenBSD's version).  Instead, I chose to write
wg_aip_parse() to manually parse the CIDRs.

Reported-by: Michael Neumann (mneumann) on IRC
DeltaFile
+45-12sbin/ifconfig/ifwg.c
+45-121 files

DragonFlyBSD/src 996ed88sys/kern vfs_syscalls.c kern_sig.c, sys/sys proc.h

kernel - Improve umount -f operation

* Increase the process test/kill retry loop for umount -f from 10
  to 50 (from 2.5 seconds to 12.5 seconds) to give processes more
  time to exit after receiving a KILL signal.

* Make the tsleep() used for the retry delay unconditional to ensure a
  reasonable period of time is allowed to elapse.

* Release the mount structure lock during the 0.25 second tsleep()
  in the retry loop.  This allows processes to unstick during the
  umount -f retry loop.

* Add a P_MUSTKILL flag to the process structure, set if necessary
  during a umount -f.  Process core dumps (which are usually
  uninterruptable) will be aborted if this flag is found to be set.
  Further tests for this flag may be needed.

Reported-by: marino (via loki kernel crash)
DeltaFile
+15-5sys/kern/vfs_syscalls.c
+4-1sys/kern/kern_sig.c
+4-0sys/kern/imgact_elf.c
+1-1sys/sys/proc.h
+24-74 files

DragonFlyBSD/src c87a730sys/kern vfs_syscalls.c

kernel - Fix umount -f related panic

* Adjust umount -f (forced unmount) logic to kill processes which
  still hold references to the mount in question, due to being chrooted
  or jailed in the mount, their current directory being on the mount,
  or having any open file via the mount.

  To be frank, it is hard to find a nice way to rip a mount out from under
  processes as their behavior upon suddenly having file descriptors go bad
  is completely non-deterministic.  A forced unmount is not supposed to be
  kind to the system.  The best solution is to kill the processes.

* Fixes panics related to regular use of umount -f if the operation
  happens to race active operations by processes on the mount.

Reported-by: marino
DeltaFile
+83-7sys/kern/vfs_syscalls.c
+83-71 files

DragonFlyBSD/src b07befasys/kern vfs_syscalls.c kern_sig.c, sys/sys proc.h

kernel - Improve umount -f operation

* Increase the process test/kill retry loop for umount -f from 10
  to 50 (from 2.5 seconds to 12.5 seconds) to give processes more
  time to exit after receiving a KILL signal.

* Make the tsleep() used for the retry delay unconditional to ensure a
  reasonable period of time is allowed to elapse.

* Release the mount structure lock during the 0.25 second tsleep()
  in the retry loop.  This allows processes to unstick during the
  umount -f retry loop.

* Add a P_MUSTKILL flag to the process structure, set if necessary
  during a umount -f.  Process core dumps (which are usually
  uninterruptable) will be aborted if this flag is found to be set.
  Further tests for this flag may be needed.

Reported-by: marino (via loki kernel crash)
DeltaFile
+15-5sys/kern/vfs_syscalls.c
+4-1sys/kern/kern_sig.c
+4-0sys/kern/imgact_elf.c
+1-1sys/sys/proc.h
+24-74 files

DragonFlyBSD/src e436662sbin/fsck_hammer2 test.c

sbin/fsck_hammer2: Fix destination FILE* in print_media()

Also show comp/check in string format.
DeltaFile
+6-4sbin/fsck_hammer2/test.c
+6-41 files

DragonFlyBSD/src cc8e70bsys/kern vfs_vnops.c vfs_syscalls.c, sys/opencrypto cryptodev.c

kern - Make lseek(2) generic

* Extend fileops with fo_seek function allowing pluggable lseek(2)
  implementations. Part of preparation for linux DMA-BUF compat API.

* Move current vnode lseek implementation into vnode and devfs fileops.
  Code is exactly the same in both, note about duplication added.

* Set remaining fileops to badfo_seek.

Mentored-By: dillon
DeltaFile
+64-1sys/kern/vfs_vnops.c
+61-1sys/vfs/devfs/devfs_vnops.c
+1-51sys/kern/vfs_syscalls.c
+8-1sys/kern/kern_descrip.c
+6-0sys/sys/file2.h
+2-1sys/opencrypto/cryptodev.c
+142-555 files not shown
+152-5911 files

DragonFlyBSD/src c973322contrib/diffutils/lib vasnprintf.c regexec.c, contrib/diffutils/src diff3.c

world - Replace gnu diff, diff3, and sdiff with BSD versions

* Replace diff and diff3 with the OpenBSD diff and diff3,
  Replace sdiff with the FreeBSD sdiff,
  Remove the GNU diff, diff3, and sdiff

* Basic testing with dsynth bulk to ensure no significant compatibility
  disruptions.

Submitted-by: Tyler <tyler.clark at foxide.xyz>
DeltaFile
+0-5,621contrib/diffutils/lib/vasnprintf.c
+0-4,334contrib/diffutils/lib/regexec.c
+0-3,946contrib/diffutils/lib/regcomp.c
+0-1,789contrib/diffutils/src/diff3.c
+0-1,746contrib/diffutils/lib/regex_internal.c
+0-1,734gnu/usr.bin/diff/libdiffutils/config.h
+0-19,170257 files not shown
+5,328-66,284263 files

DragonFlyBSD/src 152bbefsbin/fsck_hammer2 test.c

sbin/fsck_hammer2: Remove unused voldata argument
DeltaFile
+68-103sbin/fsck_hammer2/test.c
+68-1031 files

DragonFlyBSD/src 167a410sbin/hammer2 cmd_debug.c

sbin/hammer2/cmd_debug.c: Refactor unreadable cmd_show()

0b7381572b131c74051832dc251604e7f77b5a54 added multi-volumes
support to cmd_show() (entry point of freemap,show,volhdr directives)
with minimum modification using goto, but the code has been not
so readable since then. Rewrite this entry point function.

The output is same except that "Volume %d header %d..."
by default (= when not showing volhdr or bref for all volumes)
appears before printing each volhdr or bref, rather than all
at once in the beginning.
DeltaFile
+67-72sbin/hammer2/cmd_debug.c
+67-721 files