diff options
-rw-r--r-- | samples/seccomp/Makefile | 12 | ||||
-rw-r--r-- | samples/seccomp/bpf-direct.c | 18 |
2 files changed, 19 insertions, 11 deletions
diff --git a/samples/seccomp/Makefile b/samples/seccomp/Makefile index e8fe0f57b68f..16aa2d424985 100644 --- a/samples/seccomp/Makefile +++ b/samples/seccomp/Makefile | |||
@@ -1,27 +1,21 @@ | |||
1 | # kbuild trick to avoid linker error. Can be omitted if a module is built. | 1 | # kbuild trick to avoid linker error. Can be omitted if a module is built. |
2 | obj- := dummy.o | 2 | obj- := dummy.o |
3 | 3 | ||
4 | hostprogs-$(CONFIG_SECCOMP) := bpf-fancy dropper | 4 | hostprogs-$(CONFIG_SECCOMP_FILTER) := bpf-fancy dropper bpf-direct |
5 | bpf-fancy-objs := bpf-fancy.o bpf-helper.o | ||
6 | 5 | ||
7 | HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include | 6 | HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include |
8 | HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include | 7 | HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include |
9 | HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include | 8 | HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include |
10 | HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include | 9 | HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include |
10 | bpf-fancy-objs := bpf-fancy.o bpf-helper.o | ||
11 | 11 | ||
12 | HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include | 12 | HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include |
13 | HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include | 13 | HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include |
14 | dropper-objs := dropper.o | 14 | dropper-objs := dropper.o |
15 | 15 | ||
16 | # bpf-direct.c is x86-only. | ||
17 | ifeq ($(SRCARCH),x86) | ||
18 | # List of programs to build | ||
19 | hostprogs-$(CONFIG_SECCOMP) += bpf-direct | ||
20 | bpf-direct-objs := bpf-direct.o | ||
21 | endif | ||
22 | |||
23 | HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include | 16 | HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include |
24 | HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include | 17 | HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include |
18 | bpf-direct-objs := bpf-direct.o | ||
25 | 19 | ||
26 | # Try to match the kernel target. | 20 | # Try to match the kernel target. |
27 | ifeq ($(CONFIG_64BIT),) | 21 | ifeq ($(CONFIG_64BIT),) |
diff --git a/samples/seccomp/bpf-direct.c b/samples/seccomp/bpf-direct.c index 26f523e6ed74..151ec3f52189 100644 --- a/samples/seccomp/bpf-direct.c +++ b/samples/seccomp/bpf-direct.c | |||
@@ -8,6 +8,11 @@ | |||
8 | * and can serve as a starting point for developing | 8 | * and can serve as a starting point for developing |
9 | * applications using prctl(PR_SET_SECCOMP, 2, ...). | 9 | * applications using prctl(PR_SET_SECCOMP, 2, ...). |
10 | */ | 10 | */ |
11 | #if defined(__i386__) || defined(__x86_64__) | ||
12 | #define SUPPORTED_ARCH 1 | ||
13 | #endif | ||
14 | |||
15 | #if defined(SUPPORTED_ARCH) | ||
11 | #define __USE_GNU 1 | 16 | #define __USE_GNU 1 |
12 | #define _GNU_SOURCE 1 | 17 | #define _GNU_SOURCE 1 |
13 | 18 | ||
@@ -43,8 +48,6 @@ | |||
43 | #define REG_ARG3 REG_R10 | 48 | #define REG_ARG3 REG_R10 |
44 | #define REG_ARG4 REG_R8 | 49 | #define REG_ARG4 REG_R8 |
45 | #define REG_ARG5 REG_R9 | 50 | #define REG_ARG5 REG_R9 |
46 | #else | ||
47 | #error Unsupported platform | ||
48 | #endif | 51 | #endif |
49 | 52 | ||
50 | #ifndef PR_SET_NO_NEW_PRIVS | 53 | #ifndef PR_SET_NO_NEW_PRIVS |
@@ -174,3 +177,14 @@ int main(int argc, char **argv) | |||
174 | payload("Error message going to STDERR\n")); | 177 | payload("Error message going to STDERR\n")); |
175 | return 0; | 178 | return 0; |
176 | } | 179 | } |
180 | #else /* SUPPORTED_ARCH */ | ||
181 | /* | ||
182 | * This sample is x86-only. Since kernel samples are compiled with the | ||
183 | * host toolchain, a non-x86 host will result in using only the main() | ||
184 | * below. | ||
185 | */ | ||
186 | int main(void) | ||
187 | { | ||
188 | return 1; | ||
189 | } | ||
190 | #endif /* SUPPORTED_ARCH */ | ||