Repository navigation
sched/signal: validate a sigevent's signal and target thread - #20424
Merged
Merged
Conversation
|
No functional change; the next commit touches both files. Signed-off-by: Royyan Zahir <[email protected]>
royzah
requested review from
Donny9,
GUIDINGLI,
Ouss4 and
jerpelea
as code owners
October 2, 2026 09:52
A SIGEV_SIGNAL | SIGEV_THREAD_ID timer skipped timer_create's signal check, and nxsig_notification honoured any thread ID. Add nxsig_event_valid(): the signal must exist and a SIGEV_THREAD_ID target must be one of the caller's own threads, as on Linux. timer_create, gpio, button and phy_notify call it before storing an event, so the caller gets EINVAL and an expiring timer never fails its DEBUGVERIFY. Signed-off-by: Royyan Zahir <[email protected]>
xiaoxiang781216
approved these changes
Oct 2, 2026
GUIDINGLI
approved these changes
Oct 9, 2026
3 of 5 tasks
royzah
added a commit
to royzah/nuttx
that referenced
this pull request
Oct 24, 2026
Several notification entry points still store caller-supplied signal numbers and SIGEV_THREAD_ID targets without validating them. Delivery later runs in a worker or interrupt context, where the registering caller's thread group can no longer be checked. Use nxsig_event_valid() before saving events, replacing active alarms, binding callbacks, or submitting AIO. Cover joystick, timer, RTC, capture, zero-cross, FT80x, automount, IEEE 802.15.4, legacy ESP32-C3 Wi-Fi, message queue and AIO registration paths. Reject invalid events with EINVAL while preserving disable/unsubscribe handling and LIO_WAIT's ignored event. This follows the registration-time validation added in apache#20424 and uses its existing helper. It does not change delivery-time checks, validate separate PID fields, or address user-pointer access. Tested on Ubuntu 26.04.1 x86_64 with GCC 15.2.0 using an extended sim:ostest configuration and a temporary regression harness. The baseline had 79 failures; the fixed run passed all 153 checks. Seventeen changed files were built; the legacy ESP32-C3 adapter and physical hardware remain untested. Whole-file checkpatch checks pass.
royzah
added a commit
to royzah/nuttx
that referenced
this pull request
Oct 24, 2026
Several notification entry points still store caller-supplied signal numbers and SIGEV_THREAD_ID targets without validating them. Delivery later runs in a worker or interrupt context, where the registering caller's thread group can no longer be checked. Use nxsig_event_valid() before saving events, replacing active alarms, binding callbacks, or submitting AIO. Cover joystick, timer, RTC, capture, zero-cross, FT80x, automount, IEEE 802.15.4, legacy ESP32-C3 Wi-Fi, message queue and AIO registration paths. Reject invalid events with EINVAL while preserving disable/unsubscribe handling and LIO_WAIT's ignored event. This follows the registration-time validation added in apache#20424 and uses its existing helper. It does not change delivery-time checks, validate separate PID fields, or address user-pointer access. Tested on Ubuntu 26.04.1 x86_64 with GCC 15.2.0 using an extended sim:ostest configuration and a temporary regression harness. The baseline had 79 failures; the fixed run passed all 153 checks. Seventeen changed files were built; the legacy ESP32-C3 adapter and physical hardware remain untested. Whole-file checkpatch checks pass. Signed-off-by: Royyan Zahir <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: Please adhere to Contributing Guidelines.
Summary
timer_create()checked the signal number only whensigev_notifywas exactlySIGEV_SIGNAL, soSIGEV_SIGNAL | SIGEV_THREAD_IDlet any number through to dispatch, and an expiring timer then failed itsDEBUGVERIFY.nxsig_notification()also honoured any thread ID, letting a process aim a timer or driver notification at a thread of another process.New
nxsig_event_valid(): the signal must exist, and aSIGEV_THREAD_IDtarget must be one of the caller's own threads, as on Linux. It runs where the event is registered, so the caller getsEINVALup front.sig_notification.c,nuttx/signal.hnxsig_event_valid()timer_create.c,gpio.c,button_upper.c,phy_notify.cgpio.c,button_upper.cThe other drivers that take a sigevent from user space (joystick, rtc, oneshot, aio, ...) follow in a separate PR.
Impact
Every build. A sigevent with a bad signal number, or aimed at another process's thread, is refused with
EINVALwhen registered.Testing
Host: Ubuntu 24.04, x86_64. Builds and QEMU runs in
ghcr.io/apache/nuttx/apache-nuttx-ci-linux(QEMU 6.2, Arm GNU GCC 13.2, xPack RISC-V GCC 14.3).qemu-armv8a:knshostestpasses, its timer tests included;hellorv-virt:knsh64hello;osteststops afterStarted user_main at PID=6, as master doessim:nsh,stm32f103-minimum:buttons,esp32-devkitc:buttons,imxrt1020-evk:netnsh,qemu-armv7a:knshtimer_create()withSIGEV_THREAD_IDat another process's thread:EINVALqemu-armv8a:knsh:hello, thenostestrv-virt:knsh64:hello, thenostest; identical to master'si.MX93, PX4 kernel build, previous revision:
tests isolationtools/checkpatch.sh -c -u -m -gclean.