Page MenuHomeFreeBSD

Indicate issetugid in AT_BSDFLAGS
AbandonedPublic

Authored by mjg on Feb 21 2020, 12:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 9, 8:24 PM
Unknown Object (File)
Mar 5 2024, 9:59 AM
Unknown Object (File)
Feb 12 2024, 4:04 AM
Unknown Object (File)
Jan 20 2024, 10:36 AM
Unknown Object (File)
Jan 12 2024, 9:04 AM
Unknown Object (File)
Dec 31 2023, 8:15 AM
Unknown Object (File)
Dec 28 2023, 7:09 AM
Unknown Object (File)
Dec 22 2023, 9:12 AM
Subscribers

Details

Reviewers
kib
Summary

This saves one issetugid for every exec. Note there is another call coming from something deeper which probably cannot be easily taken care of in the same manner.

Test Plan

Verified with debug printfs that trust is NOT set when running 'su' et al and is set otherwise.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

libexec/rtld-elf/rtld.c
454

If you allocate one more flag in bsdflags. used to indicate support for BSDF_ISSETUGID, you do not need to rely on osreldate() which is better IMO. Check the new flag, and if set, ELF_BSDF_ISSETUGID presence is equal to trust. Also right now you rely on bsdflags presence, adding that flag would make zero initialization of bsdflags do the right thing.

Another option is to allocate new auxv entry with the value indicating issetugid, but flags are fine since they are already there.

sys/kern/kern_prot.c
1233

!= 0

  • use an extra flag instead of reldate
kib added inline comments.
sys/sys/elf_common.h
1461

_VALID instead of _PASSED ?

This revision is now accepted and ready to land.Feb 21 2020, 12:46 PM
mjg planned changes to this revision.Feb 21 2020, 3:07 PM

Upon further testing this is buggy - sometimes the passed down value disagrees with what the syscall returns later as setugid call on exec happens only after copyout.

In D23779#522553, @mjg wrote:

Upon further testing this is buggy - sometimes the passed down value disagrees with what the syscall returns later as setugid call on exec happens only after copyout.

You should directly pass result of calculation with credential_changing in imgparam.