Skip to content

Commit

Permalink
samples/seccomp: Add standalone config option
Browse files Browse the repository at this point in the history
Add a separate Kconfig option for SAMPLES_SECCOMP.

Main reason for this is that, just like other samples, it's forced to
be a module.

Without this, since the sample is a target only controlled by
CONFIG_SECCOMP_FILTER, the samples will be built before include files are
put in place properly. For example, from an arm64 allmodconfig built with
"make -sk -j 32" (without specific target), the following happens:

  samples/seccomp/bpf-fancy.c:13:27: fatal error: linux/seccomp.h: No such file or directory
  samples/seccomp/bpf-helper.h:20:50: fatal error: linux/seccomp.h: No such file or directory
  samples/seccomp/dropper.c:20:27: fatal error: linux/seccomp.h: No such file or directory
  samples/seccomp/bpf-direct.c:21:27: fatal error: linux/seccomp.h: No such file or directory

So, just stick to the same format as other samples.

Signed-off-by: Olof Johansson <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
olofj authored and kees committed Jul 7, 2016
1 parent d011a4d commit f6041c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions samples/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,11 @@ config SAMPLE_CONNECTOR
with it.
See also Documentation/connector/connector.txt

config SAMPLE_SECCOMP
tristate "Build seccomp sample code -- loadable modules only"
depends on SECCOMP_FILTER && m
help
Build samples of seccomp filters using various methods of
BPF filter construction.

endif # SAMPLES
2 changes: 1 addition & 1 deletion samples/seccomp/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# kbuild trick to avoid linker error. Can be omitted if a module is built.
obj- := dummy.o

hostprogs-$(CONFIG_SECCOMP_FILTER) := bpf-fancy dropper bpf-direct
hostprogs-$(CONFIG_SAMPLE_SECCOMP) := bpf-fancy dropper bpf-direct

HOSTCFLAGS_bpf-fancy.o += -I$(objtree)/usr/include
HOSTCFLAGS_bpf-fancy.o += -idirafter $(objtree)/include
Expand Down

0 comments on commit f6041c1

Please sign in to comment.