casaroli opened a new pull request, #20745: URL: https://github.com/apache/nuttx/pull/20745
## Summary POSIX requires the `si_uid` member in `siginfo_t`: the real user ID of the process that sent the signal. NuttX has `si_pid`, but not `si_uid`. This PR adds `si_uid` next to `si_pid`, under the same `CONFIG_SCHED_HAVE_PARENT` condition. - `kill()`, `tgkill()`, `sigqueue()`, `pthread_sigqueue()` and the sigevent notifications set it to the real user ID of the sender. - SIGCHLD and `waitid()` set it to the real user ID of the child when it exited. For `waitid()`, `struct child_status_s` keeps this value in a new `ch_uid` member, only with `CONFIG_SCHED_USER_IDENTITY`. - Without `CONFIG_SCHED_USER_IDENTITY`, the value is always 0. - `signalfd()` now also returns the value in `ssi_uid`. The first commit fixes the indentation in `nxsig_clockwait()` (whitespace only), so that `sig_clockwait.c` passes nxstyle. The last commit updates the `siginfo_t` listing in `Documentation/reference/user/structures.rst`. ## Impact With `CONFIG_SCHED_HAVE_PARENT`, `siginfo_t` is 4 bytes larger on 32-bit targets (8 bytes on 64-bit targets, because of alignment). With `CONFIG_SCHED_USER_IDENTITY` and `CONFIG_SCHED_CHILD_STATUS`, `struct child_status_s` is 4 bytes larger on 32-bit targets (no change on 64-bit targets). A build without `CONFIG_SCHED_HAVE_PARENT` does not change. ## Testing A test program on `qemu-armv8a:knsh` (QEMU 11 with HVF on an Apple M4), in four configurations: the default, `+SCHED_USER_IDENTITY`, `+SCHED_CHILD_STATUS`, and both. The program checks `si_pid` and `si_uid` after `kill()` and `sigqueue()`, and after `waitid()` for a child that calls `setuid(4321)` before it exits. With `SCHED_USER_IDENTITY` it also checks `kill()` after `setuid(1234)`. | Configuration | kill / sigqueue `si_uid` | waitid `si_uid` | kill after `setuid(1234)` | |---|---|---|---| | default | 0 | 0 | (setuid fails) | | `+SCHED_USER_IDENTITY` | 0 | 4321 | 1234 | | `+SCHED_CHILD_STATUS` | 0 | 0 | (setuid fails) | | both | 0 | 4321 | 1234 | All checks pass. On master the program does not compile (no `si_uid`). `ostest` on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` ends with `ostest_main: Exiting with status 0` in all four configurations. `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]
