libbpf-rs: Fix BTF int offset extraction from aux word#1367
Open
cuiweixie wants to merge 1 commit intolibbpf:masterfrom
Open
libbpf-rs: Fix BTF int offset extraction from aux word#1367cuiweixie wants to merge 1 commit intolibbpf:masterfrom
cuiweixie wants to merge 1 commit intolibbpf:masterfrom
Conversation
The auxiliary u32 for BTF_KIND_INT packs several fields; the offset lives in bits 16–23 (see BTF_INT_ENCODING in the kernel UAPI). After masking with 0x00_ff_00_00, shifting by 24 decodes the wrong bit range, so Int::offset was effectively wrong. Shift by 16 to align the mask with the documented layout.
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.
What
Correct the shift applied after masking bits 16–23 of the BTF
KIND_INTauxiliaryu32when buildingInt::offset. The mask0x00_ff_00_00must be paired with a shift of 16, not 24, so the field matches the layout used byBTF_INT_ENCODINGin the kernel UAPI.Why
With shift 24, the masked value was decoded from the wrong bit positions, so
Int::offsetdid not reflect the encoded offset.