fs/binfmt: close symlink TOCTOU and harden setuid/setgid exec hygiene - #19585
fs/binfmt: close symlink TOCTOU and harden setuid/setgid exec hygiene#19585Abhishekmishra2808 wants to merge 2 commits into
Conversation
Perform pseudo-filesystem permission checks inside inode_reserve() and inode_remove() while the inode tree lock is held, and hold that lock across pseudorename mutations so symlink swaps cannot bypass directory checks. On setuid/setgid exec, update saved set-IDs, mark the task group secure, sanitize dangerous environment variables, clear debug/dumpable flags, and add issetugid(), secure_getenv(), and PR_SET/GET_DUMPABLE support. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
cb067ec to
5576e21
Compare
Gate PR_SET/GET_DUMPABLE on CONFIG_SCHED_USER_IDENTITY, restore rename source-parent permission checks under the inode lock, hold a read lock around pseudo-fs open permission checks, and provide issetugid() stubs when user identity is disabled. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
5576e21 to
633e7d8
Compare
|
|
Hi, the build is failing in mainline. @casaroli, please help us to add AVX512 vector sources in the sim/CMake LAME build. Thanks! @xiaoxiang781216 and @acassis PTAL. |
I can fix the cmake file again, however the root problem is that lame revision is not pinned: So when they update, sometimes it breaks: I believe our options are:
I think 3 is bad decision I recommend we do (1) -> (4); or (2) -> (4) What do you think? Ref: https://sourceforge.net/p/lame/svn/HEAD/log/?path=/trunk/lame/libmp3lame/vector |
|
Agreed. Pinning to a known revision and updating both Make and CMake to match it (option 2) is the better approach (IMO). Keeping CMake in sync with trunk all the time isn't sustainable. |
Summary
This change closes a symlink TOCTOU race in the pseudo-filesystem and hardens setuid/setgid exec identity handling. Parent-directory permission checks are performed inside inode_reserve() and inode_remove() while the inode tree lock is held, and that lock is kept across pseudorename, so a symlink cannot be swapped between the check and the mutation. On setuid/setgid exec, saved set-IDs are updated, the task group is marked secure, unsafe environment variables are sanitized, and debug/dumpable state is cleared. Support is also added for issetugid(), secure_getenv(), and PR_SET_DUMPABLE / PR_GET_DUMPABLE, gated on CONFIG_SCHED_USER_IDENTITY.
Impact
Configs that enable CONFIG_FS_PERMISSION and CONFIG_PSEUDOFS_SOFTLINKS now enforce directory permissions under the inode lock, which closes the previous check-then-act window around symlink targets. Configs with CONFIG_SCHED_USER_IDENTITY get stricter setuid/setgid exec behavior, including saved-ID updates, environment sanitization, and dumpable/secure flag handling. When those options are disabled there is no intended behavior change, and stock sim:nsh still builds. Applications that previously relied on inheriting variables such as PATH or LD_* across a setuid exec may see those cleared; that is intentional.
Testing
multiuser_test completed with 0 failures, covering UID/GID switching, saved-set child semantics, pseudoFS and tmpfs permission enforcement, and passwd lookup after credential drop. Full ostest exited with status 0.