fix(caps): correct capability v3 byte order and lock securebits#88
Draft
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
Draft
fix(caps): correct capability v3 byte order and lock securebits#88noeljackson wants to merge 1 commit intoedera-dev:mainfrom
noeljackson wants to merge 1 commit intoedera-dev:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two bugs in the Linux capability v3 handling:
1. Swapped data[0]/data[1] in capget/capset
Per the kernel capability v3 ABI, the
__user_cap_data_structarray uses:data[0]= capabilities 0-31 (low 32 bits)data[1]= capabilities 32+ (high 32 bits)The previous code had these reversed in
get_caps(),set_caps(), and the error path ofcapset(). This caused capabilities above 31 (e.g. CAP_MAC_OVERRIDE=32) to be placed in the wrong position and capabilities 0-31 to be shifted up, making capset(2) fail or silently apply wrong capability masks.2. Unlocked securebits in set_keep_caps()
set_keep_caps()only setSECBIT_NO_SETUID_FIXUP(bit 4) without locking it. A process could clear the securebit before the capability drop sequence completes, defeating the purpose of preserving caps across UID changes.Now sets
SECBIT_NO_SETUID_FIXUP | SECBIT_NO_SETUID_FIXUP_LOCKED | SECBIT_KEEP_CAPS_LOCKED(4 | 8 | 32 = 44) to make the securebits immutable.