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
net: Fix SIOCSIFDESCR fallthrough bug in ifioctl()
* Add the missing 'break' to SIOCSIFDESCR to fix the fallthrough bug.
* Remove the redundant ifnet_lock()/unlock() pair.
* Clean up the code a bit by rearranging the local variables.
net: Fix ifnet_mtx deadlock in ifioctl()
Several error paths in ifioctl()'s switch (SIOCGIFGROUP, SIOCAIFGROUP,
SIOCDIFGROUP, SIOCSIFDESCR) return directly instead of break, bypassing
the ifnet_unlock() at the end of the function. As a result, ifnet_mtx
is held across the switch and will block any future ifnet_lock() calls,
which basically breaks the network subsystem.
What makes matter worse is that SIOCGIFGROUP has no caps check, so
any local user can trigger such a deadlock in the network subsystem.
GitHub-PR: #47
Assisted-with: Zhipu GLM-5.2
net: Fix ifnet_mtx deadlock in ifioctl()
Several error paths in ifioctl()'s switch (SIOCGIFGROUP, SIOCAIFGROUP,
SIOCDIFGROUP, SIOCSIFDESCR) return directly instead of break, bypassing
the ifnet_unlock() at the end of the function. As a result, ifnet_mtx
is held across the switch and will block any future ifnet_lock() calls,
which basically breaks the network subsystem.
What makes matter worse is that SIOCGIFGROUP has no caps check, so
any local user can trigger such a deadlock in the network subsystem.
GitHub-PR: #47
Assisted-with: Zhipu GLM-5.2
net: Fix SIOCSIFDESCR fallthrough bug in ifioctl()
* Add the missing 'break' to SIOCSIFDESCR to fix the fallthrough bug.
* Remove the redundant ifnet_lock()/unlock() pair.
* Clean up the code a bit by rearranging the local variables.
isa: allow the ISA PnP isolation scan to be skipped
The scan probes several read-data ports, each running the full
isolation protocol with mandatory DELAY()s; with no PnP cards present
it finds nothing yet costs several seconds of boot time. Add a
hw.isa.pnp_disabled tunable (default 0) so systems known to have no
ISA PnP hardware - virtual machines in particular - can skip it.
NetBSD skips its isapnp probe automatically when SMBIOS slot tables
report no ISA slots, but that data is absent on typical VMs (and
NetBSD/OpenBSD do not compile ISA PnP into amd64 kernels at all), so
an explicit tunable serves the VM case better.
sys/kern: make the interrupt-config-hook settle delay tunable
After the interrupt-driven config hooks have finished, the kernel
lingers for a hardcoded 5 seconds before proceeding to the root mount,
to give USB a chance to enumerate (else a USB root device might not be
seen). On systems that cannot boot from USB - virtual machines in
particular - this is 5 seconds of pure boot-time waste.
Replace the hardcoded 5*hz with a kern.intr_config_hook_delay_ms
tunable (default 5000, preserving current behavior).
virtio_mmio(4): Add a manual page for the virtio-mmio transport driver
Document the legacy (v1) virtio-mmio transport and, in particular, the
hw.virtio.mmio.device[_N] kenv variables it uses for device discovery
and their <size>@<baseaddr>:<irq>[:<unit>] grammar.
virtual: virtio-mmio (legacy v1) transport driver
Import and x86-adapt FreeBSD's virtio-mmio transport driver.
The driver speaks the legacy (v1) virtio-mmio register layout and
discovers devices from the "hw.virtio.mmio.device" kenv
(<size>@<base>:<irq>[:<unit>]) rather than FDT/ACPI, attaching on
nexus.
Reviewed-by: @ivadasz
sys/kern: Replace vfs.root.wakedelay with millisecond-based wakedelay_ms
The seconds-based vfs.root.wakedelay tunable is too coarse for non-CAM
kern confs that only need a short settle delay before mounting root.
Replace it with vfs.root.wakedelay_ms, which specifies the delay in
milliseconds and defaults to 2000 (the previous 2 second default).
Update loader.8 and loader.conf accordingly.
apple_smc: add thermal governor and PROCHOT override
When the SMC asserts PROCHOT# due to disconnected sensors or absent
battery, the driver now detects this at attach, clears BD_PROCHOT in
MSR 0x1FC, and takes over fan control from the SMC failsafe. A kernel
thread implements a linear fan curve between configurable temperature
thresholds with hysteresis and rate-limited ramp-down.
New sysctls expose scheduled wake time (CLWK), S5 power-on timer
(G3AO/G3WD), AC wake delay (AUWT), display brightness (DPBR),
chassis state (ENV0), and software thermal throttle disable (STFD).
The raw key interface is no longer gated behind APPLE_SMC_DEBUG.
Temperature description table expanded to ~170 entries.
reboot(8): Fix openlog(3) calls
LOG_CONS was OR'd into the facility argument instead of logopt, leaving
logopt as 0. The correct call is openlog(ident, LOG_CONS, LOG_AUTH),
as shutdown(8) and init(8) already do.
Signed-off-by: Ricardo Branco <rbranco at suse.de>
GitHub-PR: #37
reboot(8): Fix openlog(3) calls
LOG_CONS was OR'd into the facility argument instead of logopt, leaving
logopt as 0. The correct call is openlog(ident, LOG_CONS, LOG_AUTH),
as shutdown(8) and init(8) already do.
Signed-off-by: Ricardo Branco <rbranco at suse.de>
GitHub-PR: #37
libthread_xu: Link with '-z nodelete'; unloading it is unsafe
Loading libthread_xu has irreversible process-wide effects:
* rtld lazily rebinds libc weak pthread stubs (e.g. _spinlock) to
the strong definitions in this library. There is no mechanism to
undo GOT bindings on dlclose(), so after an unload libc keeps
calling into the unmapped region.
* __isthreaded stays set -- the library cannot prove that no other
threads exist, so it cannot safely clear it -- which keeps the
libc malloc on the locked path through the dangling _spinlock
pointer.
* _thr_signal_init() installs signal handlers pointing into the
library, and _thr_signal_deinit() is empty, so signal delivery
after an unload also jumps into unmapped memory.
Consequently a program that dlopen()s a dependency chain pulling in
[42 lines not shown]
contrib/bmake: Adjust documentation of our custom variables
* Improve the markup styles a bit.
* Move the postition to the end of bmake builtin variables.
make(1): Refactor Makefile
* Include ${srcdir}/VERSION for _MAKE_VERSION instead of hardcoding it.
* Clean up CFLAGS; remove unused ones.
* Move a few variables from CFLAGS to COPTS.main.c where they're only
used.
* Remove other obsolete COPTS.*.
make(1): Undefine USE_EMALLOC to avoid libutil dependency
With USE_EMALLOC undefined, util.h becomes unused and thus remove it.
This improves the zrj's commit ee2cba8aae8c6b2ce0b6c6fc150e61c1736c64e8.
make(1): Directly install vendor's make.1
The vendor's bmake.1 man page intends for the portable bmake
distribution. So just install the vendor's make.1 instead of using
bmake.1.
contrib/bmake: Remove obsolete custom variable '.MAKE.BUILT.BY'
This custom variable was initially added in commit 673bdc16bff3eec8 to
help resolve a C++ ABI change between gcc47 and gcc50. Since the
removal of gcc47 (commit 0f44b32a8fb34e5f), this variable became
obsolete and unused.
vendor/bmake: Add back LICENSE and VERSION
* Keep LICENSE for vendor software, keeping consistent with other vendor
softwares.
* VERSION can be included in the Makefile to avoid hardcoding the
version there.