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

   ## Summary
   
   Three small signal fixes, stacked on #21831 (that PR must merge first; this 
branch is based on its tip):
   
   1. **Fix the same TOCTOU race in nxsig_clockwait()** —
      nxsig_clockwait() re-checks the pending set for a caller that has
      already published its sigwaitmask (nxsig_timedwait()).  That check has
      the same SMP race that was fixed in nxsig_timedwait(): the snapshot
      from nxsig_pendingset() is taken under tg_lock, but
      nxsig_remove_pendingsignal() re-acquires the lock, and another CPU may
      consume the signal in that window, making remove() return NULL and the
      DEBUGASSERT fire (or memcpy dereference NULL in release builds).
      Retry the same way nxsig_timedwait() now does.
   
   2. **Zero-initialize the SIGCHLD siginfo in task_exithook()** —
      The SIGCHLD siginfo built in nxtask_sigchild() was only partially
      initialized: the si_user field, which only the sigaction queue path
      assigns, kept its stack garbage.  The entry is memcpy'd into the
      pending queue and handed back to a wait() consumer.  Zero the whole
      structure first, like kill() and tgkill() already do (previous PR).
   
   3. **Inline suitable small functions** —
      nxsig_lowest(), nxsig_cleanup() and nxsig_nanosleep() are tiny helpers
      called from several translation units; keeping them out of line pulls
      whole extra files into every build.  Move them into the headers as
      static inline and drop the out-of-line copies.  sig_cleanup.c and
      sig_nanosleep.c keep their remaining functions; only sig_lowest.c
      consisted of a single inlined function and is removed.
   
   ## Impact
   
   - Is new feature added?  No, bugfix + size reduction.
   - Is existing feature changed?  No behavior change is intended; the
     clockwait retry only adds robustness on SMP.
   - Impact on user (ABI)?  The public header gains a `static inline`
     nxsig_nanosleep() and now includes <time.h> — no ABI change.
   - Impact on documentation?  None.
   - Impact on security?  Fixes a potential NULL dereference (release
     builds) and an uninitialized pointer handoff.
   - Anything special to consider?  Stacked on #21831 (the timedwait
     TOCTOU fix and kill/tgkill zero-init land first); rebase freely if
     that merges first.
   
   ## Testing
   
   sim:nsh — builds clean, boots to nsh.
   
   sim:ostest — full run (7242 lines), zero assertions, zero FAILED:
   
       user_main: Exiting
       ostest_main: Exiting with status 0
   
   qemu-armv8a:nsh_smp (SMP, 4 cores) — ostest completes with zero
   failures:
   
       ostest_main: Exiting with status 0
   
   smartl-c906:knsh (kernel build, riscv64) — links clean in the CI
   container:
   
       Memory region         Used Size      Region Size    %age Used
           progmem:      109624 B           1 MB          10.45%
           sram:          10624 B           1 MB          1.01%
   
   checkpatch (CI params: -c -u -m -g): All checks pass.
   


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