This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Drop S_ISUID and S_ISGID bits
AbandonedPublic

Authored by MaskRay on Feb 8 2021, 2:10 PM.

Details

Summary

This addresses a vulnerability introduced in D62718.

chmod u+s,g+s,o+x a
sudo llvm-strip a
// a should not have set-user-ID or set-group-ID bits

No test because it is not testable on all file systems.

Diff Detail

Event Timeline

MaskRay created this revision.Feb 8 2021, 2:10 PM
MaskRay requested review of this revision.Feb 8 2021, 2:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2021, 2:10 PM
manojgupta requested changes to this revision.Feb 8 2021, 2:18 PM

This change make further deviation from GNU tools. Lets wait for resolution of D93881. This will not be needed if D93881 is merged.

This revision now requires changes to proceed.Feb 8 2021, 2:18 PM
MaskRay added a comment.EditedFeb 8 2021, 3:46 PM

This address llvm-strip exe and llvm-strip exe -o out.

https://sourceware.org/pipermail/binutils/2021-February/115282.html binutils is move to conditional in-place overwrite. I can sign up the work for llvm-objcopy.

jcai19 added a subscriber: jcai19.Feb 9 2021, 10:46 AM

This change make further deviation from GNU tools. Lets wait for resolution of D93881. This will not be needed if D93881 is merged.

This change actually makes our behavior consistent with current GNU strip/objcopy. GNU strip/objcopy does not copy S_ISUID and S_ISGID bits.

chmod u+s,g+s,o+x a
sudo llvm-strip a -o b

Currently b has S_ISUID and S_ISGID bits.

This change make further deviation from GNU tools. Lets wait for resolution of D93881. This will not be needed if D93881 is merged.

This change actually makes our behavior consistent with current GNU strip/objcopy. GNU strip/objcopy does not copy S_ISUID and S_ISGID bits.

chmod u+s,g+s,o+x a
sudo llvm-strip a -o b

Currently b has S_ISUID and S_ISGID bits.

Thanks @MaskRay for the example.
I agree that for the case of Output != Input, S_ISUID and S_ISGID bits should not be copied. The bits should be kept only when Output == Input .

MaskRay abandoned this revision.Feb 22 2021, 9:36 PM

I investigated the old and new binutils behaviors a bit. I think we need to do D97253: If input=output, preserve umask bits, otherwise drop S_ISUID/S_ISGID bits

chmod u+s,g+s,o+x a
sudo llvm-strip a -o b

is still a case that we want to change to match cp