lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190518004639.20648-4-mcroce@redhat.com>
Date:   Sat, 18 May 2019 02:46:38 +0200
From:   Matteo Croce <mcroce@...hat.com>
To:     xdp-newbies@...r.kernel.org, bpf@...r.kernel.org
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>
Subject: [PATCH 4/5] samples/bpf: fix tracex5_user build error

Add missing symbols to tools/include/linux/filter.h to fix a build failure:

make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
  HOSTCC  samples/bpf/tracex5_user.o
samples/bpf/tracex5_user.c: In function ‘install_accept_all_seccomp’:
samples/bpf/tracex5_user.c:17:21: error: array type has incomplete element type ‘struct sock_filter’
   17 |  struct sock_filter filter[] = {
      |                     ^~~~~~
samples/bpf/tracex5_user.c:18:3: warning: implicit declaration of function ‘BPF_STMT’; did you mean ‘BPF_STX’? [-Wimplicit-function-declaration]
   18 |   BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
      |   ^~~~~~~~
      |   BPF_STX
samples/bpf/tracex5_user.c:20:9: error: variable ‘prog’ has initializer but incomplete type
   20 |  struct sock_fprog prog = {
      |         ^~~~~~~~~~
samples/bpf/tracex5_user.c:21:4: error: ‘struct sock_fprog’ has no member named ‘len’
   21 |   .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
      |    ^~~
samples/bpf/tracex5_user.c:21:10: warning: excess elements in struct initializer
   21 |   .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
      |          ^
samples/bpf/tracex5_user.c:21:10: note: (near initialization for ‘prog’)
samples/bpf/tracex5_user.c:22:4: error: ‘struct sock_fprog’ has no member named ‘filter’
   22 |   .filter = filter,
      |    ^~~~~~
samples/bpf/tracex5_user.c:22:13: warning: excess elements in struct initializer
   22 |   .filter = filter,
      |             ^~~~~~
samples/bpf/tracex5_user.c:22:13: note: (near initialization for ‘prog’)
samples/bpf/tracex5_user.c:20:20: error: storage size of ‘prog’ isn’t known
   20 |  struct sock_fprog prog = {
      |                    ^~~~
samples/bpf/tracex5_user.c:20:20: warning: unused variable ‘prog’ [-Wunused-variable]
samples/bpf/tracex5_user.c:17:21: warning: unused variable ‘filter’ [-Wunused-variable]
   17 |  struct sock_filter filter[] = {
      |                     ^~~~~~
make[2]: *** [scripts/Makefile.host:109: samples/bpf/tracex5_user.o] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2

Signed-off-by: Matteo Croce <mcroce@...hat.com>
---
 tools/include/linux/filter.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/tools/include/linux/filter.h b/tools/include/linux/filter.h
index ca28b6ab8db7..6b2ed7eccfa5 100644
--- a/tools/include/linux/filter.h
+++ b/tools/include/linux/filter.h
@@ -7,6 +7,33 @@
 
 #include <linux/bpf.h>
 
+/*
+ *	Try and keep these values and structures similar to BSD, especially
+ *	the BPF code definitions which need to match so you can share filters
+ */
+
+struct sock_filter {	/* Filter block */
+	__u16	code;   /* Actual filter code */
+	__u8	jt;	/* Jump true */
+	__u8	jf;	/* Jump false */
+	__u32	k;      /* Generic multiuse field */
+};
+
+struct sock_fprog {	/* Required for SO_ATTACH_FILTER. */
+	unsigned short		len;	/* Number of filter blocks */
+	struct sock_filter __user *filter;
+};
+
+/*
+ * Macros for filter block array initializers.
+ */
+#ifndef BPF_STMT
+#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
+#endif
+#ifndef BPF_JUMP
+#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
+#endif
+
 /* ArgX, context and stack frame pointer register positions. Note,
  * Arg1, Arg2, Arg3, etc are used as argument mappings of function
  * calls in BPF_CALL instruction.
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ