Skip to content

UBSan - #26

Merged
d-tatianin merged 9 commits into
masterfrom
sanitizers
Sep 28, 2026
Merged

d-tatianin merged 9 commits into
masterfrom
sanitizers

Conversation

@d-tatianin

Copy link
Copy Markdown
Member

No description provided.

Latest GCC & Binutils + a few nice fixes.

While at it, unhardcode the CI GCC version so it is fetched dynamically.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
The shift in BIT_OF_TYPE() promotes any type narrower than int to int,
so BIT_U8() and BIT_U16() produced a signed int, which BIT_FIELD_READ()
then rejects as a field mask. Cast the result back to the requested
type.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Lets code that serializes itself against other callers, such as the
console flush, get out of the panic path's way.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
A print from inside a flush, e.g. a WARN() in a console driver or an
interrupt that logs mid write, flushed again and clobbered the static
buffers the outer flush was still using. Registering a console flushed
the same way with no protection at all.

Let only one caller flush at a time. A nested caller leaves its record
in the ring and marks the flush pending for the owner to pick up. A
panic flushes regardless, since the flush it interrupted never resumes.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
A reader that knows an unpublished record will never be finished, e.g.
one printing a panic, needs a way to get to the records after it. Add
log_ring_read_with_flags() and LOG_RING_READ_SKIP_UNPUBLISHED for that,
log_ring_read() stays the plain form. The newest record is never skipped
since its writer may still be running.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
A panic that interrupts a print between reserving its record and
publishing it, e.g. from an interrupt handler, leaves that record
unpublished forever. The flush stopped there, so none of the panic
output ever reached a console. Skip such records while a panic is in
progress.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
Other reporters of non-fatal kernel problems should end their report
the same way a WARN() does, so panic_on_warn applies to them too.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
It lets a helper called from any subdirectory set source file properties
on the kernel objects via set_property(SOURCE ... TARGET_DIRECTORY).

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
@d-tatianin
d-tatianin force-pushed the sanitizers branch 2 times, most recently from 419ed73 to cbc86c8 Compare September 28, 2026 21:31
UBSAN support for both the GCC and Clang toolchains, behind a config
option in the debug sub-menu, opt-in support per architecture.

The one quirk is that only Clang supports relative report locations via
"-fsanitize-undefined-strip-path-components=", while GCC has no such
option, so we just keep absolute paths there.

Enum checks are left out since neither compiler instruments them for C.
Division by zero is GCC only, clang treats the code after its handler
as unreachable, so a report that returns runs off the function.

Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
@d-tatianin
d-tatianin merged commit 6550a7d into master Sep 28, 2026
4 checks passed
@d-tatianin
d-tatianin deleted the sanitizers branch September 28, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant