Skip to content
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

Add more negative unmarshaling tests #591

Merged
merged 7 commits into from
Feb 28, 2024
Merged

Add more negative unmarshaling tests #591

merged 7 commits into from
Feb 28, 2024

Conversation

dthaler
Copy link
Contributor

@dthaler dthaler commented Feb 21, 2024

This change is table-based, using a table of all instructions based on the table in the BPF ISA specification.
It implements an algorithm to walk the table and test invalid variations of such instructions, thus catching more cases that were not previously validated.

A few things that were validated but gave inconsistent error messages for different opcodes are updated to be consistent throughout.

Instructions that are only defined where 0 is in some field are no longer treated as part of the same instruction, since there could be other instructions in the future that use other values. For example, "nonzero src for register" used to be shown as the error when passing src > 0 for some opcodes that are only defined for src = 0, which is now a "bad instruction" since it's available for use by a new separate instruction, per the ISA spec.

@coveralls
Copy link

coveralls commented Feb 21, 2024

Coverage Status

coverage: 90.234% (+0.06%) from 90.171%
when pulling 4dc72eb on dthaler:negative
into ec074df on vbpf:main.

@elazarg
Copy link
Collaborator

elazarg commented Feb 21, 2024

Does this need a rebase now?

@dthaler
Copy link
Contributor Author

dthaler commented Feb 21, 2024

Does this need a rebase now?

Done, just in case.

Copy link
Collaborator

@elazarg elazarg left a comment

Choose a reason for hiding this comment

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

LGTM in general; see some style comments below.

Other style points:

  • This is an opportunity to have uniform capitalization too. I suggest all-lowercase.
  • .c_str() is never needed here. We can also use std::format() for simplification, either now or in a future PR.

src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
src/test/test_marshal.cpp Outdated Show resolved Hide resolved
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
Signed-off-by: Dave Thaler <[email protected]>
@dthaler
Copy link
Contributor Author

dthaler commented Feb 28, 2024

  • .c_str() is never needed here. We can also use std::format() for simplification, either now or in a future PR.

Github's "ubuntu-latest" runner supports clang 15.
Clang 15 support for std::format is experimental, disabled by default, and may have breaking changes to it.
Hence it turns out we need to punt using std::format to a future PR.

@dthaler
Copy link
Contributor Author

dthaler commented Feb 28, 2024

  • This is an opportunity to have uniform capitalization too. I suggest all-lowercase.

Done

Signed-off-by: Dave Thaler <[email protected]>
@elazarg elazarg merged commit e0c25fc into vbpf:main Feb 28, 2024
13 checks passed
@dthaler dthaler deleted the negative branch February 28, 2024 17:41
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