Skip to content

nshlib: hard/soft credential drop and sudo via PR_NSHCRED_AUTHSETEID - #3714

Open
Abhishekmishra2808 wants to merge 2 commits into
apache:masterfrom
Abhishekmishra2808:feature/supp-groups-and-sudo
Open

nshlib: hard/soft credential drop and sudo via PR_NSHCRED_AUTHSETEID#3714
Abhishekmishra2808 wants to merge 2 commits into
apache:masterfrom
Abhishekmishra2808:feature/supp-groups-and-sudo

Conversation

@Abhishekmishra2808

Copy link
Copy Markdown
Contributor

Summary

  • Hard-drop non-root NSH logins with setres*(uid,uid,uid); soft-drop from root-originated sessions keeps saved-root.
  • Wire su / sudo to prctl(PR_NSHCRED_AUTHSETEID) for password verify + euid/egid raise; enable the agent with PR_NSHCRED_ENABLE at NSH init.
  • Improve useradd UID allocation (passwd_append next UID ≥ 1000) and expand ostest multiuser coverage for AUTHSETEID / hard-drop paths.
  • Depends on the companion nuttx PR sched: supplementary groups, setresuid/setresgid, and PR_NSHCRED_AUTHSETEID nuttx#19767

Impact

NSH sessions can drop to a real non-root identity and escalate only after an in-kernel passwd check, which is what makes su/sudo usable with hard-dropped logins. Builds without CONFIG_SCHED_USER_IDENTITY are unchanged.

Testing

nsh# useradd testuser UserPass1!
nsh# cat /tmp/passwd
root:$pbkdf2-sha256$10000$uwK3GNfobksYkqa5H9-Rcw$kNsxMZi26PeLxdWKgFjNvZpOoouP_DcHyO2mwyACVc0:0:0:/
testuser:$pbkdf2-sha256$10000$LCsDACzp0RA26xvaHPsY2g$gfCJXfLINNOKNIpVqepoUaYJiMbB8ojezAlosZJnrXY:1000:1000:/
nsh# su testuser
nsh$ id
uid=1000(testuser) suid=0(root) gid=1000 sgid=0(root) groups=1000
nsh$ su root
password: 
nsh# id
uid=0(root) gid=0(root) groups=0(root)
nsh# 

Hard-drop non-root logins with setres*(uid,uid,uid). Soft-drop within
root-originated sessions so in-process su/sudo can restore euid.
Escalate only through prctl(PR_NSHCRED_AUTHSETEID) after password
verification; mark the agent with PR_NSHCRED_ENABLE at NSH init.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Exercise agent-flag gates, wrong/empty/correct AUTHSETEID passwords,
session-persistent su root, and related permission paths. Harden
passwd_append helpers used by the seeded passwd file.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant