Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Unified Diff: sandbox/linux/seccomp-bpf/syscall_unittest.cc

Issue 588143007: sandbox: Convert remaining legacy tests to use policy classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another style fix (grr clang-format) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf/syscall_unittest.cc
diff --git a/sandbox/linux/seccomp-bpf/syscall_unittest.cc b/sandbox/linux/seccomp-bpf/syscall_unittest.cc
index 54e1dda254f55d37b2195fd17697ae867d60933f..2014b6b7a8a765450afffa41a1d374e36b07060f 100644
--- a/sandbox/linux/seccomp-bpf/syscall_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/syscall_unittest.cc
@@ -99,18 +99,26 @@ intptr_t CopySyscallArgsToAux(const struct arch_seccomp_data& args, void* aux) {
return -ENOMEM;
}
-ErrorCode CopyAllArgsOnUnamePolicy(SandboxBPF* sandbox,
- int sysno,
- std::vector<uint64_t>* aux) {
- if (!SandboxBPF::IsValidSyscallNumber(sysno)) {
- return ErrorCode(ENOSYS);
+class CopyAllArgsOnUnamePolicy : public SandboxBPFPolicy {
+ public:
+ CopyAllArgsOnUnamePolicy(std::vector<uint64_t>* aux) : aux_(aux) {}
jln (very slow on Chromium) 2014/09/23 18:42:06 bit: explicit
mdempsky 2014/09/23 18:50:20 Done.
+ virtual ~CopyAllArgsOnUnamePolicy() {}
+
+ virtual ErrorCode EvaluateSyscall(SandboxBPF* sandbox,
+ int sysno) const OVERRIDE {
+ DCHECK(SandboxBPF::IsValidSyscallNumber(sysno));
+ if (sysno == __NR_uname) {
+ return sandbox->Trap(CopySyscallArgsToAux, aux_);
+ } else {
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
+ }
}
- if (sysno == __NR_uname) {
- return sandbox->Trap(CopySyscallArgsToAux, aux);
- } else {
- return ErrorCode(ErrorCode::ERR_ALLOWED);
- }
-}
+
+ private:
+ std::vector<uint64_t>* aux_;
+
+ DISALLOW_COPY_AND_ASSIGN(CopyAllArgsOnUnamePolicy);
+};
// We are testing Syscall::Call() by making use of a BPF filter that
// allows us

Powered by Google App Engine
This is Rietveld 408576698