You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "Jackapyun (via GitHub)" <gi...@apache.org> on 2026/01/20 11:32:08 UTC

[PR] mm/kasan: prevent recursive report overflow [nuttx]

Jackapyun opened a new pull request, #18042:
URL: https://github.com/apache/nuttx/pull/18042

   ## Summary
   
   This PR addresses a critical stack overflow issue in the KASAN (Kernel Address Sanitizer) error reporting mechanism when the report handler recursively triggers additional KASAN checks.
   
   ### Problem
   When `kasan_report()` is executing and calls `_alert()` for error reporting, the logging function may trigger additional memory access operations that can fail KASAN checks. This causes recursive re-entry into the KASAN report handler, leading to stack overflow and suppressing the original error report.
   
   ### Solution
   The fix implements a dual-approach strategy:
   
   1. **Call `kasan_stop()` before reporting**: Halts all KASAN checks when entering the panic path, preventing recursive checks during error message printing
   2. **Reuse `dump_only` flag efficiently**: Consolidates the panic/non-panic decision logic into a single flag, ensuring consistent behavior without additional stack usage
   
   ### Key Changes
   - Extract `dump_only` flag calculation at the beginning of `kasan_report()` 
   - Call `kasan_stop()` only when panic reporting is needed (before `_alert()`)
   - Reuse the flag for both panic decision and stack dump logic
   
   ---
   
   ## Impact
   
   ### Stability
   - ✅ Eliminates stack overflow risk from recursive KASAN reports
   - ✅ Preserves original error reporting despite recursive triggers
   - ✅ Reduces stack memory usage in error paths
   
   ### Compatibility
   - ✅ No breaking API changes
   - ✅ No impact on non-KASAN builds
   - ✅ Maintains existing panic/dump behavior based on configuration
   
   ### Code Quality
   - ✅ Improves code maintainability by eliminating duplicate logic
   - ✅ Reduces code duplication in panic decision handling
   - ✅ Clear separation of concerns in error handling flow
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] mm/kasan: prevent recursive report overflow [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #18042:
URL: https://github.com/apache/nuttx/pull/18042


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org