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
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
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
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>
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
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
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
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
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]
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.
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)
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>
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
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)
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
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)
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
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>
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.