casaroli opened a new pull request, #20638: URL: https://github.com/apache/nuttx/pull/20638
## Summary In a kernel build, the kernel allocates from the user heap through `kumm_*()`. It does this also while the address environment of another process is selected: `up_create_stack()` allocates the stack of a new process in the heap of that process. When that heap cannot grow, `sbrk()` and `memalign()` set `errno`. `errno` is in the TLS of the calling thread, at a user address that is not mapped in the new process. The kernel then takes a data abort, or writes into the memory of the new process. This PR does not set `errno` in the kernel copy of the user heap, as `kmm_*()` already does. The callers in the kernel use the returned NULL or -1. The first commit only fixes the nxstyle errors in `umm_zalloc.c`. ## Impact Kernel builds (`!CONFIG_BUILD_FLAT` and `__KERNEL__`) only. User code and flat builds still get `errno` set, as before. ## Testing `qemu-armv8a:knsh` with 4 CPUs, with this change on a larger local branch, and page allocation failures injected after boot (1 in 101 `sbrk()` page allocations, plus fork and exec failures). A stress test runs `fork()` and `exec()` from 4 workers. - Before: data abort at `0xc020008c` in `sbrk()`, from `up_create_stack()`. - After: 4 of 4 runs complete; 23 `sbrk()` failures were injected and none caused an abort. Build: `qemu-armv8a:nsh`, `qemu-armv8a:knsh` and `lm3s6965-ek:qemu-protected`, no warnings. `tools/checkpatch.sh -c -u -m -g` passes. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
