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

   ## Summary
   
   Three signal-subsystem fixes, each an independent commit:
   
   * **exit twice**: TCB_FLAG_EXIT_PROCESSING was set by nx_pthread_exit()
     only after the join handshake; during the handshake the exiting thread
     was not yet marked, so a fatal signal handled in that window re-entered
     the exit path through nxsig_abnormal_termination() and terminated the
     thread twice. The flag now moves to the top of nx_pthread_exit(), and
     nxsig_abnormal_termination() returns early when it is already set.
     This also makes the whole exit visible to the existing
     EXIT_PROCESSING checks (nxsig_tcbdispatch, pthread_cancel).
   
   * **signalfd UAF**: the dispatch path ran a per-device SA_KERNELHAND
     callback walking dev->fds[] unprotected; a woken higher-priority
     poller could free the device mid-walk. Poll waiters are now anchored
     on the long-lived task group and notified under
     enter_critical_section(); the waiter array is allocated lazily on
     first signalfd poll and freed at group teardown. This retires the
     SA_KERNELHAND dispatch from the signal path (signalfd was its only
     user; the public macro stays for ABI). A forked child group no longer
     inherits the parent's signalfd wakeups — per-process semantics, as on
     Linux.
   
   * **SIG_IGN pending**: POSIX requires that setting the disposition of a
     pending signal to SIG_IGN discards the pending signal. The old code
     only removed the sigaction container and left matching entries queued
     in the group pending list forever. Entries are now collected under the
     group lock and released after dropping it.
   
   ## Impact
   
   * Is new feature added? Is existing feature changed? NO (bug fixes + POSIX 
compliance)
   * Impact on user (will user need to adapt to change)? NO
   * Impact on build (will build process change)? NO
   * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO 
(arch-independent: sched + fs)
   * Impact on documentation (is update required / provided)? NO
   * Impact on security (any sort of implications)? YES — fixes a 
use-after-free and removes a kernel-context user-callback path from the signal 
dispatch
   * Impact on compatibility (backward/forward/interoperability)? NO 
(SA_KERNELHAND macro retained; no in-tree users remain)
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host(s): Linux x86_64, GCC (host compiler, sim)
   * Target(s): sim (sim:ostest; same config + CONFIG_SIGNAL_FD=y for the 
signalfd changes)
   
   Testing logs (build, sim:ostest + CONFIG_SIGNAL_FD=y):
   
   ```
   CP:  include/nuttx/fs/hostfs.h
   LD:  nuttx
   ```
   
   Testing logs (runtime, sim:ostest full suite, 7185 lines of output, 0 
FAIL/panic/assert):
   
   ```
   user_main: Exiting
   ostest_main: Exiting with status 0
   ```
   
   Signal-relevant suites all pass: nested signal handling, cancellation
   (7 stages), semaphore-interrupted-by-signal, robust mutex, waitpid/waitid.
   


-- 
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]

Reply via email to