The delta operation (c->c_time - ticks) is documented as safe, however it
still can cause overflow in narrow case scenarios.
Try to avoid overflow/underflow or at least make it less frequent with
a direct comparison of c->c_time and tics. Perform the operation of
subtraction only when c->c_time > ticks.
sys/kern/kern_timeout.c:720:9, signed integer overflow: -2147410738 - 72912 cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Patch suggested by <Riastradh>
As discussed on IRC and proposed by dholland@, the existing idiom is
type-sensitive, and will likely fail silently when the flags variable
is a 64-bit type.
No functional change intended. If anything breaks, it was probably
already broken.
Replace unaligned pointer dereference with a more portable construct that
is free from Undefined Behavior semantics.
sys/arch/x86/x86/mpbios.c:308:11, load of misaligned address 0xffff800031c7a413 for type 'const __uint16_t' which requires 2 byte alignment
Detected with Kernel Undefined Behavior Sanitizer
Change the type of IOMAP_INVALOFF to unsigned int.
sys/arch/amd64/amd64/machdep.c:518:42, left shift of 65535 by 16 places cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Kernel Undefined Behavior Sanitizer enforces more warnings in build time.
This makes the build fatal in the drm/i915 code in:
- intel_ddi_put_crtc_pll(),
- intel_ddi_clock_get(),
- intel_ddi_pll_enable(),
- intel_ddi_setup_hw_pll_state().
The error message in all the cases says:
error: case label does not reduce to an integer constant
Set the type of the value left shifted to unsigned.
This change is required to build NetBSD/amd64 with KUBSan.
Do not left shift signed integer in a way that the signedness bit is
changed.
sys/kern/kern_lwp.c:1892:29, left shift of 1 by 31 places cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Reported by <Harry Pantazis>
Do not left shift signed integer in a way that the signedness bit is
changed.
sys/kern/kern_lwp.c:1849:27, left shift of 1 by 31 places cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Reported by <Harry Pantazis>
Do not shift a signed integer causing change of the signed bit.
sys/kern/sys_mqueue.c:881:23, left shift of 1 by 31 places cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Reported by <Harry Pantazis>
Do not shift a signed integer causing change of the signed bit.
sys/kern/sys_mqueue.c:712:24, left shift of 1 by 31 places cannot be represented in type 'int'
Detected with Kernel Undefined Behavior Sanitizer.
Reported by <Harry Pantazis>
Remove a number of commented out pseudodevice lines that are
duplicative with GENERIC.common. Othewise, someone might think it
reasonable to uncomment or add them.
For now, a number of pseudodevices that are not in GENERIC.common
remain, pending comments on the larger-scale rototill.
We do, and packages occasionally expect the long options to exist.
Pointed out while investigating
PR pkg/53425: graphics/py-matplotlib 2.2.2 import fails
(which is not fixed by this commit)
We use MWAIT/MONITOR to hatch secondary CPUs. The errata means that
the wakeup may not happen, so SMP boot fails.
Use wrmsr to disable it in hardware too, for extra paranoia.
PR port-amd64/53420,
also reported on netbsd-users by joern clausen and ssartor.