Skip to content

Validate instructions #593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 29, 2024
Merged

Conversation

Alan-Jowett
Copy link
Collaborator

This pull request includes several changes to the ubpf library, focusing on instruction validation and updating the build configuration. The most important changes include adding a new source file to the build, introducing a function to validate instructions, and integrating this validation into the instruction validation process.

Build Configuration:

Instruction Validation:

  • vm/ubpf_int.h: Introduced the ubpf_is_valid_instruction function to check if an instruction is supported and provide an error message if it is not.
  • vm/ubpf_vm.c: Integrated the ubpf_is_valid_instruction function into the existing instruction validation process to ensure unsupported instructions are caught and reported.

Alan Jowett added 4 commits October 29, 2024 12:42
Signed-off-by: Alan Jowett <[email protected]>
Signed-off-by: Alan Jowett <[email protected]>
Signed-off-by: Alan Jowett <[email protected]>
@coveralls
Copy link

Coverage Status

coverage: 79.201% (-0.05%) from 79.25%
when pulling dce3d66 on Alan-Jowett:validate_instructions
into e6bf9d4 on iovisor:main.

@Alan-Jowett Alan-Jowett merged commit 3c639e6 into iovisor:main Oct 29, 2024
51 checks passed
.destination_lower_bound = BPF_REG_0,
.destination_upper_bound = BPF_REG_9,
.immediate_lower_bound = 0,
.immediate_upper_bound = 64,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem to handle the upper limit, but according to the spec, not every value between 0 and 64 is valid. Only the values 16, 32, and 64 are allowed (https://www.ietf.org/archive/id/draft-ietf-bpf-isa-04.html#section-4.2-5). Does the filter technique here handle that?

*errmsg = ubpf_error("Invalid offset value %d for opcode %2X.", insts.offset, insts.opcode);
return false;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we able to validate things that are within the opcode and need to have specific values? In particular, the ALU64 endianness instruction is defined such that source operand field is 0: https://www.ietf.org/archive/id/draft-ietf-bpf-isa-04.html#section-4.2-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants