This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] If input=output, preserve umask bits, otherwise drop S_ISUID/S_ISGID bits
ClosedPublic

Authored by MaskRay on Feb 22 2021, 9:34 PM.

Details

Summary

This makes the behavior similar to cp

chmod u+s,g+s,o+x a
sudo llvm-strip a -o b
// With this patch, b drops set-user-ID and set-group-ID bits.
// sudo cp a b => b does not have set-user-ID or set-group-ID bits.

This also changes the behavior for the following case:

chmod u+s,g+s,o+x a
llvm-strip a
// a preserves set-user-ID and set-group-ID bits.
// This matches binutils<2.36 and probably >=2.37.  2.36 and 2.36.1 have some compatibility issues.

Diff Detail

Event Timeline

MaskRay created this revision.Feb 22 2021, 9:34 PM
MaskRay requested review of this revision.Feb 22 2021, 9:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 22 2021, 9:34 PM
manojgupta accepted this revision.Feb 23 2021, 8:04 AM

Thanks a lot Fangrui.

This revision is now accepted and ready to land.Feb 23 2021, 8:04 AM

I am not particular up-to-speed on the file permissions stuff, so I'll defer to @manojgupta for the rest of the change.

llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-win.test
35

I don't think this line will work. From the test comment at the top, "Windows has no umask". I don't appear to have it on my machine (which has GnuWin32 installed).

manojgupta added inline comments.Feb 24 2021, 10:57 AM
llvm/test/tools/llvm-objcopy/ELF/mirror-permissions-win.test
35

Yes, this is a good point about windows/umask . @MaskRay please consider removing or adjusting this test.

MaskRay updated this revision to Diff 326148.Feb 24 2021, 11:07 AM
MaskRay edited the summary of this revision. (Show Details)

drop Windows test

This revision was landed with ongoing or failed builds.Feb 24 2021, 11:10 AM
This revision was automatically updated to reflect the committed changes.