This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f60a8725841ca05efe75242d9aadc907b7790e77 Author: yushuailong <[email protected]> AuthorDate: Sat Sep 26 15:26:49 2026 +0800 sched/group: Allow unchanged real IDs in setxid calls. Unprivileged setreuid() and setregid() reject requests that explicitly retain the current real ID, even though that value is an allowed credential. Accept the existing real ID and update the saved ID whenever the real ID is explicitly supplied, matching the documented setreuid/setregid behavior. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <[email protected]> --- sched/group/group_setregid.c | 6 +++--- sched/group/group_setreuid.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sched/group/group_setregid.c b/sched/group/group_setregid.c index 9fd21aa10a7..b3856656c1e 100644 --- a/sched/group/group_setregid.c +++ b/sched/group/group_setregid.c @@ -82,7 +82,7 @@ int setregid(gid_t rgid, gid_t egid) if (old_egid != 0) { if (rgid != (gid_t)-1 && - rgid != old_egid && rgid != old_sgid) + rgid != old_rgid && rgid != old_egid && rgid != old_sgid) { set_errno(EPERM); return ERROR; @@ -111,8 +111,8 @@ int setregid(gid_t rgid, gid_t egid) * set-group-ID to the new effective group ID. */ - if ((rgid != (gid_t)-1 && rgroup->tg_gid != old_rgid) || - (egid != (gid_t)-1 && rgroup->tg_egid != old_rgid)) + if (rgid != (gid_t)-1 || + (egid != (gid_t)-1 && egid != old_rgid)) { rgroup->tg_sgid = rgroup->tg_egid; } diff --git a/sched/group/group_setreuid.c b/sched/group/group_setreuid.c index c423ad0489c..19cd6dd9a60 100644 --- a/sched/group/group_setreuid.c +++ b/sched/group/group_setreuid.c @@ -83,7 +83,7 @@ int setreuid(uid_t ruid, uid_t euid) if (old_euid != 0) { if (ruid != (uid_t)-1 && - ruid != old_euid && ruid != old_suid) + ruid != old_ruid && ruid != old_euid && ruid != old_suid) { set_errno(EPERM); return ERROR; @@ -112,8 +112,8 @@ int setreuid(uid_t ruid, uid_t euid) * set-user-ID to the new effective user ID. */ - if ((ruid != (uid_t)-1 && rgroup->tg_uid != old_ruid) || - (euid != (uid_t)-1 && rgroup->tg_euid != old_ruid)) + if (ruid != (uid_t)-1 || + (euid != (uid_t)-1 && euid != old_ruid)) { rgroup->tg_suid = rgroup->tg_euid; }
