diff options
Diffstat (limited to 'samples/seccomp/bpf-helper.h')
-rw-r--r-- | samples/seccomp/bpf-helper.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/samples/seccomp/bpf-helper.h b/samples/seccomp/bpf-helper.h index 643279dd30fb..38ee70f3cd5b 100644 --- a/samples/seccomp/bpf-helper.h +++ b/samples/seccomp/bpf-helper.h | |||
@@ -59,6 +59,16 @@ void seccomp_bpf_print(struct sock_filter *filter, size_t count); | |||
59 | #define FIND_LABEL(labels, label) seccomp_bpf_label((labels), #label) | 59 | #define FIND_LABEL(labels, label) seccomp_bpf_label((labels), #label) |
60 | 60 | ||
61 | #define EXPAND(...) __VA_ARGS__ | 61 | #define EXPAND(...) __VA_ARGS__ |
62 | |||
63 | /* Ensure that we load the logically correct offset. */ | ||
64 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
65 | #define LO_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) | ||
66 | #elif __BYTE_ORDER == __BIG_ENDIAN | ||
67 | #define LO_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) + sizeof(__u32) | ||
68 | #else | ||
69 | #error "Unknown endianness" | ||
70 | #endif | ||
71 | |||
62 | /* Map all width-sensitive operations */ | 72 | /* Map all width-sensitive operations */ |
63 | #if __BITS_PER_LONG == 32 | 73 | #if __BITS_PER_LONG == 32 |
64 | 74 | ||
@@ -70,21 +80,16 @@ void seccomp_bpf_print(struct sock_filter *filter, size_t count); | |||
70 | #define JLE(x, jt) JLE32(x, EXPAND(jt)) | 80 | #define JLE(x, jt) JLE32(x, EXPAND(jt)) |
71 | #define JA(x, jt) JA32(x, EXPAND(jt)) | 81 | #define JA(x, jt) JA32(x, EXPAND(jt)) |
72 | #define ARG(i) ARG_32(i) | 82 | #define ARG(i) ARG_32(i) |
73 | #define LO_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) | ||
74 | 83 | ||
75 | #elif __BITS_PER_LONG == 64 | 84 | #elif __BITS_PER_LONG == 64 |
76 | 85 | ||
77 | /* Ensure that we load the logically correct offset. */ | 86 | /* Ensure that we load the logically correct offset. */ |
78 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 87 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
79 | #define ENDIAN(_lo, _hi) _lo, _hi | 88 | #define ENDIAN(_lo, _hi) _lo, _hi |
80 | #define LO_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) | ||
81 | #define HI_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) + sizeof(__u32) | 89 | #define HI_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) + sizeof(__u32) |
82 | #elif __BYTE_ORDER == __BIG_ENDIAN | 90 | #elif __BYTE_ORDER == __BIG_ENDIAN |
83 | #define ENDIAN(_lo, _hi) _hi, _lo | 91 | #define ENDIAN(_lo, _hi) _hi, _lo |
84 | #define LO_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) + sizeof(__u32) | ||
85 | #define HI_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) | 92 | #define HI_ARG(idx) offsetof(struct seccomp_data, args[(idx)]) |
86 | #else | ||
87 | #error "Unknown endianness" | ||
88 | #endif | 93 | #endif |
89 | 94 | ||
90 | union arg64 { | 95 | union arg64 { |