ebpf-verifier icon indicating copy to clipboard operation
ebpf-verifier copied to clipboard

Add more negative unmarshaling tests

Open dthaler opened this issue 1 year ago • 5 comments

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.

dthaler avatar Feb 21 '24 01:02 dthaler

Coverage Status

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

coveralls avatar Feb 21 '24 01:02 coveralls

Does this need a rebase now?

elazarg avatar Feb 21 '24 18:02 elazarg

Does this need a rebase now?

Done, just in case.

dthaler avatar Feb 21 '24 19:02 dthaler

  • .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 avatar Feb 28 '24 00:02 dthaler

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

Done

dthaler avatar Feb 28 '24 00:02 dthaler