DescriptionDecouple CodeGen from ErrorCode
CodeGen's only dependency on ErrorCode was one MakeInstruction()
overload, which can be removed by making the caller responsible for
converting the ErrorCode to a BPF_RET'able value. Fortunately, there
are only two uses of this function:
1. SandboxBPF::RetExpression() which is easily fixed by simply calling
ErrorCode::err() to get the ErrorCode's error value.
2. codegen_unittest.cc which is merely testing the BPF code generator,
and so any return values will do: no need to be seccomp-bpf return
values... so just replace them with simple integer values. (While
here, change a few bare "BPF_RET" arguments to "BPF_RET + BPF_K" just
to be consistent.)
After this CL, CodeGen focuses solely on assembling programs for the
abstract BPF machine, while higher-level abstractions (primarily
SandboxBPF) are responsible for using it in a way that's semantically
meaningful for seccomp-bpf.
BUG=414363
Committed: https://crrev.com/a5f2064030a34e71157085175b7ae93242509173
Cr-Commit-Position: refs/heads/master@{#295192}
Patch Set 1 #
Total comments: 6
Patch Set 2 : Respond to rickyz@ feedback #Patch Set 3 : Sync and fix comment #
Messages
Total messages: 13 (2 generated)
|