vendor/ncurses: Add a trailing nul for magic-string in putwin.
This was flagged by GCC 12.5's -Wstringop-overread.
Patch is from upstream, therefore fixing on the vendor branch.
initrd/mkinitrd.sh: Force strip the binaries to fix size exceeding
A user may set DEBUG_FLAGS in /etc/make.conf to retain debug symbols
during the installation phase, so the copied /rescue tools containing
the debug symbols would exceed the allowed maximum initrd image (current
15MB) and then break the installworld phase.
This issue was introduced by my commit 9d10863cc2df1e9077eb6405dd8572c243ba94d7
that removed the hardcoded 'strip' invocation from crunchgen(1)-
generated makefiles.
Now we force strip the binaries after copying them to the initrd build
directory.
Reported-by: swildner
Discussed-with: swildner
initrd/oinit: Implement login_tty() to avoid depending on libutil
Copy the login_tty() from libutil and thus remove the dependency on
libutil. However, this doesn't reduce the final binary size...
Meanwhile, remove unnecessary header inclusions.
initrd: Exclude 'oinit' from rescue tools
oinit is a stripped-down init(8), so it's only useful on an initrd
image. Move it from ${RESCUE_SUBDIRS} to ${INITRD_SUBDIRS} and remove
the existing /rescue/oinit. Adjust the makefiles to simplify the
installation logic.
initrd/mkinitrd.sh: Actually use check_initrd() and small changes
* The check_initrd() was not used. Now use it before making the image.
* Simplify the awk command to be bc(1) to round up the image size.
* Shell syntax and style cleanups.
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
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)
kernel: Refactor newvers.sh script
* Require and directly use 'KERN_IDENT' from the environment. This
avoids the 'make -V KERN_IDENT' command and thus fix the following
warning from bmake since the last upgrade to 20260619:
```
make[3]: warning: Invalid internal option "-J" in "/usr/obj/usr/src/sys/ALY"; see the manual page
```
* Leverage the new tools/gencopyright.sh script to generate the
copyright header.
* Simplify the awk command that extracts '__DragonFly_version' from
<sys/param.h> (referred to FreeBSD).
* Clean up code and styles.
include: Rewrite generation of <osreldate.h>
* Add the new tools/gencopyright.sh script to generate the copyright
header. Prefer the copyright year extracted from top-level COPYRIGHT,
similar to FreeBSD's.
* Directly extract the __DragonFly_version from <sys/param.h> as RELDATE
instead of calling newvers.sh. As a result, no need to clean up the
extra-generated files: version, vers.c and vers.txt.
By the way, this also avoids a few bmake warnings appeared after the
recent bmake upgrade (to 20260619):
```
make[2]: warning: Invalid internal option "-J" in "/usr/src"; see the manual page
make[2]: warning: Invalid internal option "-J" in "/usr/src"; see the manual page
make[2]: warning: Invalid internal option "-J" in "/usr/src"; see the manual page
make[5]: warning: Invalid internal option "-J" in "/usr/obj/usr/src/world_x86_64/usr/src/include"; see the manual page
make[2]: warning: Invalid internal option "-J" in "/usr/src"; see the manual page
make[2]: warning: Invalid internal option "-J" in "/usr/src"; see the manual page
[4 lines not shown]
kernel: Change ip6_sprintf() not to use static buffers
Now the caller must pass a buffer of size at least INET6_ADDRSTRLEN.
Derived-from: FreeBSD (commit 1d54aa3ba94f4d9883b0746ce45123d5b5be773b)
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)
kernel: Add WARNS_AUDIT for the kernel.
Analogous to world. If specified, any warning options that we normally
disable in buildkernel using -Wno-* will be active.
While here, move -Wold-style-declaration from CFLAGS to CWARNFLAGS.