asm: allow negative constants for builtin function calls#1806
Merged
lmb merged 1 commit intocilium:mainfrom Jun 24, 2025
Merged
asm: allow negative constants for builtin function calls#1806lmb merged 1 commit intocilium:mainfrom
lmb merged 1 commit intocilium:mainfrom
Conversation
Contributor
Author
dylandreimerink
approved these changes
Jun 20, 2025
Member
dylandreimerink
left a comment
There was a problem hiding this comment.
That is an easier fix than I thought. The builtin function call numbers can never get that high anyway.
Seems like we do have to adjust TestConstant so it iterates only over 0 to int32_max instead of 0 to uint32_max
ti-mo
approved these changes
Jun 23, 2025
The work to encode a platform into various constant types made it
so that decoding a call to a builtin helper with a negative value
fails with
decoding instructions for section <sectionname>:
offset <offset>: invalid constant 0xffffffff
for a BPF instruction of "call -1". This is because we can't
represent -1 as a tagged platform constant.
Allow negative constants by not transforming them into a platform
constant at all. Adjust the platform tag size so that we never
generate a platform constant with the high bit set. This avoids
confusing it with a negative number when reinterpreting it as a
signed number and ensures that trying to marshal such an
instruction gives an error.
Fixes: cilium#1797
Signed-off-by: Lorenz Bauer <[email protected]>
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.
The work to encode a platform into various constant types made it so that decoding a call to a builtin helper with a negative value fails with
for a BPF instruction of "call -1". This is because we can't represent -1 as a tagged platform constant.
Allow negative constants by not transforming them into a platform constant at all. Adjust the platform tag size so that we never generate a platform constant with the high bit set. This avoids confusing it with a negative number when reinterpreting it as a signed number and ensures that trying to marshal such an instruction gives an error.
Fixes: #1797