diff options
author | Jorge Lucangeli Obes <jorgelo@google.com> | 2019-06-12 14:45:06 -0400 |
---|---|---|
committer | Jorge Lucangeli Obes <jorgelo@google.com> | 2019-06-24 10:02:41 -0400 |
commit | 32201f8a02ad582aa08b8a71ff2938dc7bc038d1 (patch) | |
tree | ca5061c1290ac2d7df69c09959d70040cbcc8e01 /syscall_filter_unittest_macros.h | |
parent | e1a868923c2daf9a7ed3b9300f5e18ca295bf0e8 (diff) | |
download | minijail-32201f8a02ad582aa08b8a71ff2938dc7bc038d1.tar.gz |
Add support for SECCOMP_RET_LOG.
Detect at runtime whether SECCOMP_RET_LOG is available and use that for
logging.
Bug: chromium:934859
Test: New unit tests.
Test: On 4.14 device, minijail0 -S -L test/seccomp.policy -- /bin/true.
Test: audit.log shows failing syscall, binary exits successfully.
Test: On <4.14 device, behaves as before.
Change-Id: Ic9da1b5dae2b4b1df50e9d3e6f18c816e93bff87
Diffstat (limited to 'syscall_filter_unittest_macros.h')
-rw-r--r-- | syscall_filter_unittest_macros.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/syscall_filter_unittest_macros.h b/syscall_filter_unittest_macros.h index 4923fc4..3972cb4 100644 --- a/syscall_filter_unittest_macros.h +++ b/syscall_filter_unittest_macros.h @@ -3,6 +3,11 @@ * found in the LICENSE file. */ +#ifndef SYSCALL_FILTER_UNITTEST_MACROS_H +#define SYSCALL_FILTER_UNITTEST_MACROS_H + +#include "bpf.h" + /* BPF testing macros. */ #define EXPECT_EQ_BLOCK(_block, _code, _k, _jt, _jf) \ do { \ @@ -76,6 +81,13 @@ do { \ BPF_RET+BPF_K, SECCOMP_RET_TRAP); \ } while (0) +#define EXPECT_LOG(_block) \ +do { \ + EXPECT_EQ((_block)->len, 1U); \ + EXPECT_EQ_STMT((_block)->instrs, \ + BPF_RET+BPF_K, SECCOMP_RET_LOG); \ +} while (0) + #define EXPECT_ALLOW(_block) \ do { \ EXPECT_EQ((_block)->len, 2U); \ @@ -107,3 +119,5 @@ do { \ EXPECT_EQ_BLOCK(&(_filter)[1], \ BPF_JMP+BPF_JA, (_id), (_jt), (_jf)); \ } while (0) + +#endif // SYSCALL_FILTER_UNITTEST_MACROS_H |