apache / apache/nuttx

signal handler is called within "kernel"

Open
#10,326 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

nuttx, at least w/o CONFIG_LIB_SYSCALL, calls user-specified signal hander within the "kernel" part of the code directly.
it isn't safe because user handler can call system calls.

in the extreme case, the user handler escapes with a `longjmp`. it likely crashes the kernel later.
unfortunately it's somehow common for apps for posix environment to use longjmp within a signal handler.

while CONFIG_LIB_SYSCALL seems to defer signal delivery as expected (i haven't tested this. just glancing the code)
it isn't always desirable because:
* it has considerable overhead like linking otherwise unused system calls
* you need to write arch-dependent code (eg. sim doesn't have an implementation right now)

i guess a lighter-weight fix is nicer to have. eg. making every syscall-type functions call, say,`enter_kernel`/`leave_kernel`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.