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

   ## Summary
   
   setreuid() and setregid() mishandle two cases in sched/group:
   
   - A privileged caller that changes only its real ID (other argument -1) has 
the new real ID copied into both the effective and the saved ID. POSIX requires 
the effective ID to stay unchanged and the saved ID to be refreshed from the 
(unchanged) effective ID.
   - An unprivileged caller that explicitly passes its current real ID is 
rejected with EPERM, although that value is an allowed credential. Supplying 
the real ID, even unchanged, must also refresh the saved set-ID from the 
effective ID.
   
   Route privileged callers through the common update path (keeping the 
permission checks for unprivileged callers), accept the current real ID as a 
valid value, and update the saved set-ID whenever the real ID is explicitly 
supplied or the effective ID moves away from the real ID matching the behavior 
of Linux __sys_setreuid()/__sys_setregid().
   
   Also update Documentation/os/scheduling/user_identity.rst to describe the 
corrected semantics.
   
   ## Impact
   
   - Impact on user: Fixes incorrect credential transitions for the setreuid(2) 
and setregid(2) system calls. No API change.
   - Impact on build: No new files; only sched/group/group_setreuid.c, 
sched/group/group_setregid.c and one documentation file are touched. The libc 
root-only stubs used when CONFIG_SCHED_USER_IDENTITY is disabled are unchanged.
   - Impact on hardware: None.
   - Impact on documentation: user_identity.rst updated to match.
   - Impact on security: Yes — restores correct saved set-ID bookkeeping, which 
is security relevant (the saved ID governs later privilege restoration).
   - Impact on compatibility: Corrects non-conforming behavior; callers relying 
on the old (non-POSIX) privileged behavior are unlikely.
   
   ## Testing
   
   Build host: macOS 26.6.2 ARM64, Apple Clang 21.0.0.
   Target: sim:ostest.
   Build: make completes successfully with LD: nuttx.
   Static checks: nxstyle, checkpatch pass.
   Runtime smoke test: ./nuttx starts and proceeds through enabled OSTest cases 
without an assertion in the observed run.
   
   


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