aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/seccomp/Makefile12
-rw-r--r--samples/seccomp/bpf-direct.c18
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.
2obj- := dummy.o 2obj- := dummy.o
3 3
4hostprogs-$(CONFIG_SECCOMP) := bpf-fancy dropper 4hostprogs-$(CONFIG_SECCOMP_FILTER) := bpf-fancy dropper bpf-direct
5bpf-fancy-objs := bpf-fancy.o bpf-helper.o
6 5
7HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include 6HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
8HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include 7HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include
9HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include 8HOSTCFLAGS_bpf-helper.o += -I$(objtree)/usr/include
10HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include 9HOSTCFLAGS_bpf-helper.o += -idirafter $(objtree)/include
10bpf-fancy-objs := bpf-fancy.o bpf-helper.o
11 11
12HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include 12HOSTCFLAGS_dropper.o += -I$(objtree)/usr/include
13HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include 13HOSTCFLAGS_dropper.o += -idirafter $(objtree)/include
14dropper-objs := dropper.o 14dropper-objs := dropper.o
15 15
16# bpf-direct.c is x86-only.
17ifeq ($(SRCARCH),x86)
18# List of programs to build
19hostprogs-$(CONFIG_SECCOMP) += bpf-direct
20bpf-direct-objs := bpf-direct.o
21endif
22
23HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include 16HOSTCFLAGS_bpf-direct.o += -I$(objtree)/usr/include
24HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include 17HOSTCFLAGS_bpf-direct.o += -idirafter $(objtree)/include
18bpf-direct-objs := bpf-direct.o
25 19
26# Try to match the kernel target. 20# Try to match the kernel target.
27ifeq ($(CONFIG_64BIT),) 21ifeq ($(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 */
186int main(void)
187{
188 return 1;
189}
190#endif /* SUPPORTED_ARCH */