Skip to content

mm/ubsan: add missing handlers and never report recursively - #22279

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
huojianchaoyy:nx-mm-ubsan-fixes-v1
Nov 25, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
huojianchaoyy:nx-mm-ubsan-fixes-v1

Conversation

@huojianchaoyy

Copy link
Copy Markdown

Note: Please adhere to Contributing Guidelines.

Summary

UBSAN changes from Xiaomi Vela, split out of #22206 as asked in its review.

  • mm/ubsan: Supplementing missing interfaces for ubsan: __ubsan_handle_vla_bound_not_positive() and __ubsan_handle_nonnull_return_v1(), which code built with -fsanitize=vla-bound or -fsanitize=returns-nonnull-attribute calls, and their empty versions for CONFIG_MM_UBSAN_DUMMY.
  • mm/ubsan: never report recursively: printing a report goes through syslog(); when that trips another check (seen early in boot on x86_64), the handler was re-entered until the stack overflowed. A nested report now returns without printing.

Impact

  • New UBSAN handlers. A check that fails while a report is being printed is not reported.

Testing

Host: Ubuntu 22.04 x86_64, GCC 13.4.0, CMake 3.23 + Ninja 1.10. Base: master 25b649e.

./tools/checkpatch.sh -c -u -m -g HEAD~2..HEAD passes.

sim:ostest (KASAN and UBSAN): a 320 s run completes one ostest pass with no KASAN/UBSAN report; apart from the delays printed by hrtimer_test, the output is the same as master's.

Not tested: the x86_64 boot case, real hardware.

zhangyu981027 and others added 2 commits November 24, 2026 20:05
Add __ubsan_handle_vla_bound_not_positive() and
__ubsan_handle_nonnull_return_v1(), which code built with
-fsanitize=vla-bound or -fsanitize=returns-nonnull-attribute calls,
and their empty versions for CONFIG_MM_UBSAN_DUMMY.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
Printing a report goes through syslog(), which touches the TLS task
info. Early in boot on x86_64 that access itself trips a type-mismatch
check, the handler is re-entered from inside ubsan_prologue(), and the
recursion continues until the stack is exhausted (77k frames observed).

Track an in-progress report and make ubsan_prologue() refuse a nested
one, so the handlers return without printing.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
@github-actions github-actions Bot added Area: Memory Management Memory Management issues Size: S The size of the change in this PR is small labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown

@xiaoxiang781216
xiaoxiang781216 merged commit 9893ef9 into apache:master Nov 25, 2026
58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Memory Management Memory Management issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants