All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf 0/3] Misc BPF fixes
@ 2017-12-12  1:25 Daniel Borkmann
  2017-12-12  1:25 ` [PATCH bpf 1/3] bpf: fix corruption on concurrent perf_event_output calls Daniel Borkmann
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-12-12  1:25 UTC (permalink / raw)
  To: ast; +Cc: netdev, Daniel Borkmann

Couple of outstanding fixes for BPF tree: 1) fixes a perf RB
corruption, 2) and 3) fixes a few build issues from the recent
bpf_perf_event.h uapi corrections. Thanks!

Daniel Borkmann (3):
  bpf: fix corruption on concurrent perf_event_output calls
  bpf: fix build issues on um due to mising bpf_perf_event.h
  bpf: fix broken BPF selftest build

 arch/um/include/asm/Kbuild              |  1 +
 kernel/trace/bpf_trace.c                | 19 ++++++++++++-------
 tools/include/uapi/asm/bpf_perf_event.h |  7 +++++++
 tools/testing/selftests/bpf/Makefile    | 13 +------------
 4 files changed, 21 insertions(+), 19 deletions(-)
 create mode 100644 tools/include/uapi/asm/bpf_perf_event.h

-- 
2.9.5

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH bpf 1/3] bpf: fix corruption on concurrent perf_event_output calls
  2017-12-12  1:25 [PATCH bpf 0/3] Misc BPF fixes Daniel Borkmann
@ 2017-12-12  1:25 ` Daniel Borkmann
  2017-12-12  1:25 ` [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h Daniel Borkmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-12-12  1:25 UTC (permalink / raw)
  To: ast; +Cc: netdev, Daniel Borkmann

When tracing and networking programs are both attached in the
system and both use event-output helpers that eventually call
into perf_event_output(), then we could end up in a situation
where the tracing attached program runs in user context while
a cls_bpf program is triggered on that same CPU out of softirq
context.

Since both rely on the same per-cpu perf_sample_data, we could
potentially corrupt it. This can only ever happen in a combination
of the two types; all tracing programs use a bpf_prog_active
counter to bail out in case a program is already running on
that CPU out of a different context. XDP and cls_bpf programs
by themselves don't have this issue as they run in the same
context only. Therefore, split both perf_sample_data so they
cannot be accessed from each other.

Fixes: 20b9d7ac4852 ("bpf: avoid excessive stack usage for perf_sample_data")
Reported-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Song Liu <songliubraving@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 kernel/trace/bpf_trace.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 0ce99c3..40207c2 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -343,14 +343,13 @@ static const struct bpf_func_proto bpf_perf_event_read_value_proto = {
 	.arg4_type	= ARG_CONST_SIZE,
 };
 
-static DEFINE_PER_CPU(struct perf_sample_data, bpf_sd);
+static DEFINE_PER_CPU(struct perf_sample_data, bpf_trace_sd);
 
 static __always_inline u64
 __bpf_perf_event_output(struct pt_regs *regs, struct bpf_map *map,
-			u64 flags, struct perf_raw_record *raw)
+			u64 flags, struct perf_sample_data *sd)
 {
 	struct bpf_array *array = container_of(map, struct bpf_array, map);
-	struct perf_sample_data *sd = this_cpu_ptr(&bpf_sd);
 	unsigned int cpu = smp_processor_id();
 	u64 index = flags & BPF_F_INDEX_MASK;
 	struct bpf_event_entry *ee;
@@ -373,8 +372,6 @@ __bpf_perf_event_output(struct pt_regs *regs, struct bpf_map *map,
 	if (unlikely(event->oncpu != cpu))
 		return -EOPNOTSUPP;
 
-	perf_sample_data_init(sd, 0, 0);
-	sd->raw = raw;
 	perf_event_output(event, sd, regs);
 	return 0;
 }
@@ -382,6 +379,7 @@ __bpf_perf_event_output(struct pt_regs *regs, struct bpf_map *map,
 BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
 	   u64, flags, void *, data, u64, size)
 {
+	struct perf_sample_data *sd = this_cpu_ptr(&bpf_trace_sd);
 	struct perf_raw_record raw = {
 		.frag = {
 			.size = size,
@@ -392,7 +390,10 @@ BPF_CALL_5(bpf_perf_event_output, struct pt_regs *, regs, struct bpf_map *, map,
 	if (unlikely(flags & ~(BPF_F_INDEX_MASK)))
 		return -EINVAL;
 
-	return __bpf_perf_event_output(regs, map, flags, &raw);
+	perf_sample_data_init(sd, 0, 0);
+	sd->raw = &raw;
+
+	return __bpf_perf_event_output(regs, map, flags, sd);
 }
 
 static const struct bpf_func_proto bpf_perf_event_output_proto = {
@@ -407,10 +408,12 @@ static const struct bpf_func_proto bpf_perf_event_output_proto = {
 };
 
 static DEFINE_PER_CPU(struct pt_regs, bpf_pt_regs);
+static DEFINE_PER_CPU(struct perf_sample_data, bpf_misc_sd);
 
 u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
 		     void *ctx, u64 ctx_size, bpf_ctx_copy_t ctx_copy)
 {
+	struct perf_sample_data *sd = this_cpu_ptr(&bpf_misc_sd);
 	struct pt_regs *regs = this_cpu_ptr(&bpf_pt_regs);
 	struct perf_raw_frag frag = {
 		.copy		= ctx_copy,
@@ -428,8 +431,10 @@ u64 bpf_event_output(struct bpf_map *map, u64 flags, void *meta, u64 meta_size,
 	};
 
 	perf_fetch_caller_regs(regs);
+	perf_sample_data_init(sd, 0, 0);
+	sd->raw = &raw;
 
-	return __bpf_perf_event_output(regs, map, flags, &raw);
+	return __bpf_perf_event_output(regs, map, flags, sd);
 }
 
 BPF_CALL_0(bpf_get_current_task)
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h
  2017-12-12  1:25 [PATCH bpf 0/3] Misc BPF fixes Daniel Borkmann
  2017-12-12  1:25 ` [PATCH bpf 1/3] bpf: fix corruption on concurrent perf_event_output calls Daniel Borkmann
@ 2017-12-12  1:25 ` Daniel Borkmann
  2017-12-12  7:55   ` Richard Weinberger
  2017-12-12  1:25 ` [PATCH bpf 3/3] bpf: fix broken BPF selftest build Daniel Borkmann
  2017-12-12 18:07 ` [PATCH bpf 0/3] Misc BPF fixes Alexei Starovoitov
  3 siblings, 1 reply; 8+ messages in thread
From: Daniel Borkmann @ 2017-12-12  1:25 UTC (permalink / raw)
  To: ast; +Cc: netdev, Daniel Borkmann, Hendrik Brueckner, Richard Weinberger

Since c895f6f703ad ("bpf: correct broken uapi for
BPF_PROG_TYPE_PERF_EVENT program type") um (uml) won't build
on i386 or x86_64:

  [...]
    CC      init/main.o
  In file included from ../include/linux/perf_event.h:18:0,
                   from ../include/linux/trace_events.h:10,
                   from ../include/trace/syscall.h:7,
                   from ../include/linux/syscalls.h:82,
                   from ../init/main.c:20:
  ../include/uapi/linux/bpf_perf_event.h:11:32: fatal error:
  asm/bpf_perf_event.h: No such file or directory #include
  <asm/bpf_perf_event.h>
  [...]

Lets add missing bpf_perf_event.h also to um arch. This seems
to be the only one still missing.

Fixes: c895f6f703ad ("bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Suggested-by: Richard Weinberger <richard@sigma-star.at>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Richard Weinberger <richard@sigma-star.at>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 arch/um/include/asm/Kbuild | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index 50a32c3..73c57f6 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -1,4 +1,5 @@
 generic-y += barrier.h
+generic-y += bpf_perf_event.h
 generic-y += bug.h
 generic-y += clkdev.h
 generic-y += current.h
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH bpf 3/3] bpf: fix broken BPF selftest build
  2017-12-12  1:25 [PATCH bpf 0/3] Misc BPF fixes Daniel Borkmann
  2017-12-12  1:25 ` [PATCH bpf 1/3] bpf: fix corruption on concurrent perf_event_output calls Daniel Borkmann
  2017-12-12  1:25 ` [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h Daniel Borkmann
@ 2017-12-12  1:25 ` Daniel Borkmann
  2017-12-18  9:28   ` Hendrik Brueckner
  2017-12-12 18:07 ` [PATCH bpf 0/3] Misc BPF fixes Alexei Starovoitov
  3 siblings, 1 reply; 8+ messages in thread
From: Daniel Borkmann @ 2017-12-12  1:25 UTC (permalink / raw)
  To: ast; +Cc: netdev, Daniel Borkmann, Hendrik Brueckner, Arnaldo Carvalho de Melo

At least on x86_64, the kernel's BPF selftests seemed to have stopped
to build due to 618e165b2a8e ("selftests/bpf: sync kernel headers and
introduce arch support in Makefile"):

  [...]
  In file included from test_verifier.c:29:0:
  ../../../include/uapi/linux/bpf_perf_event.h:11:32:
     fatal error: asm/bpf_perf_event.h: No such file or directory
   #include <asm/bpf_perf_event.h>
                                ^
  compilation terminated.
  [...]

While pulling in tools/arch/*/include/uapi/asm/bpf_perf_event.h seems
to work fine, there's no automated fall-back logic right now that would
do the same out of tools/include/uapi/asm-generic/bpf_perf_event.h. The
usual convention today is to add a include/[uapi/]asm/ equivalent that
would pull in the correct arch header or generic one as fall-back, all
ifdef'ed based on compiler target definition. It's similarly done also
in other cases such as tools/include/asm/barrier.h, thus adapt the same
here.

Fixes: 618e165b2a8e ("selftests/bpf: sync kernel headers and introduce arch support in Makefile")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/include/uapi/asm/bpf_perf_event.h |  7 +++++++
 tools/testing/selftests/bpf/Makefile    | 13 +------------
 2 files changed, 8 insertions(+), 12 deletions(-)
 create mode 100644 tools/include/uapi/asm/bpf_perf_event.h

diff --git a/tools/include/uapi/asm/bpf_perf_event.h b/tools/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 0000000..13a5853
--- /dev/null
+++ b/tools/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,7 @@
+#if defined(__aarch64__)
+#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h"
+#elif defined(__s390__)
+#include "../../arch/s390/include/uapi/asm/bpf_perf_event.h"
+#else
+#include <uapi/asm-generic/bpf_perf_event.h>
+#endif
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 21a2d76..792af7c 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -1,19 +1,8 @@
 # SPDX-License-Identifier: GPL-2.0
 
-ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-endif
-include $(srctree)/tools/scripts/Makefile.arch
-
-$(call detected_var,SRCARCH)
-
 LIBDIR := ../../../lib
 BPFDIR := $(LIBDIR)/bpf
 APIDIR := ../../../include/uapi
-ASMDIR:= ../../../arch/$(ARCH)/include/uapi
 GENDIR := ../../../../include/generated
 GENHDR := $(GENDIR)/autoconf.h
 
@@ -21,7 +10,7 @@ ifneq ($(wildcard $(GENHDR)),)
   GENFLAGS := -DHAVE_GENHDR
 endif
 
-CFLAGS += -Wall -O2 -I$(APIDIR) -I$(ASMDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
+CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
 LDLIBS += -lcap -lelf
 
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h
  2017-12-12  1:25 ` [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h Daniel Borkmann
@ 2017-12-12  7:55   ` Richard Weinberger
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Weinberger @ 2017-12-12  7:55 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: ast, netdev, Hendrik Brueckner

Am Dienstag, 12. Dezember 2017, 02:25:31 CET schrieb Daniel Borkmann:
> Since c895f6f703ad ("bpf: correct broken uapi for
> BPF_PROG_TYPE_PERF_EVENT program type") um (uml) won't build
> on i386 or x86_64:
> 
>   [...]
>     CC      init/main.o
>   In file included from ../include/linux/perf_event.h:18:0,
>                    from ../include/linux/trace_events.h:10,
>                    from ../include/trace/syscall.h:7,
>                    from ../include/linux/syscalls.h:82,
>                    from ../init/main.c:20:
>   ../include/uapi/linux/bpf_perf_event.h:11:32: fatal error:
>   asm/bpf_perf_event.h: No such file or directory #include
>   <asm/bpf_perf_event.h>
>   [...]
> 
> Lets add missing bpf_perf_event.h also to um arch. This seems
> to be the only one still missing.
> 
> Fixes: c895f6f703ad ("bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT
> program type") Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Suggested-by: Richard Weinberger <richard@sigma-star.at>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Tested-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
> Cc: Richard Weinberger <richard@sigma-star.at>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> ---
>  arch/um/include/asm/Kbuild | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
> index 50a32c3..73c57f6 100644
> --- a/arch/um/include/asm/Kbuild
> +++ b/arch/um/include/asm/Kbuild
> @@ -1,4 +1,5 @@
>  generic-y += barrier.h
> +generic-y += bpf_perf_event.h
>  generic-y += bug.h
>  generic-y += clkdev.h
>  generic-y += current.h

Acked-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

-- 
sigma star gmbh - Eduard-Bodem-Gasse 6 - 6020 Innsbruck - Austria
ATU66964118 - FN 374287y

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf 0/3] Misc BPF fixes
  2017-12-12  1:25 [PATCH bpf 0/3] Misc BPF fixes Daniel Borkmann
                   ` (2 preceding siblings ...)
  2017-12-12  1:25 ` [PATCH bpf 3/3] bpf: fix broken BPF selftest build Daniel Borkmann
@ 2017-12-12 18:07 ` Alexei Starovoitov
  3 siblings, 0 replies; 8+ messages in thread
From: Alexei Starovoitov @ 2017-12-12 18:07 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: ast, netdev

On Tue, Dec 12, 2017 at 02:25:29AM +0100, Daniel Borkmann wrote:
> Couple of outstanding fixes for BPF tree: 1) fixes a perf RB
> corruption, 2) and 3) fixes a few build issues from the recent
> bpf_perf_event.h uapi corrections. Thanks!

Applied, thanks Daniel!

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf 3/3] bpf: fix broken BPF selftest build
  2017-12-12  1:25 ` [PATCH bpf 3/3] bpf: fix broken BPF selftest build Daniel Borkmann
@ 2017-12-18  9:28   ` Hendrik Brueckner
  2017-12-18 10:50     ` Daniel Borkmann
  0 siblings, 1 reply; 8+ messages in thread
From: Hendrik Brueckner @ 2017-12-18  9:28 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: ast, netdev, Hendrik Brueckner, Arnaldo Carvalho de Melo, linux-s390

Hi Daniel,

On Tue, Dec 12, 2017 at 02:25:32AM +0100, Daniel Borkmann wrote:
> At least on x86_64, the kernel's BPF selftests seemed to have stopped
> to build due to 618e165b2a8e ("selftests/bpf: sync kernel headers and
> introduce arch support in Makefile"):
> 
>   [...]
>   In file included from test_verifier.c:29:0:
>   ../../../include/uapi/linux/bpf_perf_event.h:11:32:
>      fatal error: asm/bpf_perf_event.h: No such file or directory
>    #include <asm/bpf_perf_event.h>
>                                 ^
>   compilation terminated.
>   [...]
> 
> While pulling in tools/arch/*/include/uapi/asm/bpf_perf_event.h seems
> to work fine, there's no automated fall-back logic right now that would
> do the same out of tools/include/uapi/asm-generic/bpf_perf_event.h. The
> usual convention today is to add a include/[uapi/]asm/ equivalent that
> would pull in the correct arch header or generic one as fall-back, all
> ifdef'ed based on compiler target definition. It's similarly done also
> in other cases such as tools/include/asm/barrier.h, thus adapt the same
> here.
> 
> Fixes: 618e165b2a8e ("selftests/bpf: sync kernel headers and introduce arch support in Makefile")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> ---
>  tools/include/uapi/asm/bpf_perf_event.h |  7 +++++++
>  tools/testing/selftests/bpf/Makefile    | 13 +------------
>  2 files changed, 8 insertions(+), 12 deletions(-)
>  create mode 100644 tools/include/uapi/asm/bpf_perf_event.h
> 
> diff --git a/tools/include/uapi/asm/bpf_perf_event.h b/tools/include/uapi/asm/bpf_perf_event.h
> new file mode 100644
> index 0000000..13a5853
> --- /dev/null
> +++ b/tools/include/uapi/asm/bpf_perf_event.h
> @@ -0,0 +1,7 @@
> +#if defined(__aarch64__)
> +#include "../../arch/arm64/include/uapi/asm/bpf_perf_event.h"
> +#elif defined(__s390__)
> +#include "../../arch/s390/include/uapi/asm/bpf_perf_event.h"
> +#else
> +#include <uapi/asm-generic/bpf_perf_event.h>
> +#endif
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 21a2d76..792af7c 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -1,19 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
> 
> -ifeq ($(srctree),)
> -srctree := $(patsubst %/,%,$(dir $(CURDIR)))
> -srctree := $(patsubst %/,%,$(dir $(srctree)))
> -srctree := $(patsubst %/,%,$(dir $(srctree)))
> -srctree := $(patsubst %/,%,$(dir $(srctree)))
> -endif
> -include $(srctree)/tools/scripts/Makefile.arch
> -
> -$(call detected_var,SRCARCH)
> -
>  LIBDIR := ../../../lib
>  BPFDIR := $(LIBDIR)/bpf
>  APIDIR := ../../../include/uapi
> -ASMDIR:= ../../../arch/$(ARCH)/include/uapi

This is actually necessary on s390:

cc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../../include/generated  -I../../../include    test_verifier.c /root/git/linux/tools/testing/selftests/bpf/libbpf.a /root/git/linux/tools/testing/selftests/bpf/cgroup_helpers.c -lcap -lelf -o /root/git/linux/tools/testing/selftests/bpf/test_verifier
In file included from ../../../include/uapi/asm/bpf_perf_event.h:4:0,
                 from ../../../include/uapi/linux/bpf_perf_event.h:11,
                 from test_verifier.c:29:
../../../include/uapi/../../arch/s390/include/uapi/asm/bpf_perf_event.h:7:9: error: unknown type name 'user_pt_regs'
 typedef user_pt_regs bpf_user_pt_regs_t;
         ^~~~~~~~~~~~
make: *** [../lib.mk:109: /root/git/linux/tools/testing/selftests/bpf/test_verifier] Error 1


The s390 bpf_perf_event.h header file contains an #include for asm/ptrace.h
that defines the user_pt_regs (introduce with my patch set).  For building,
the ptrace.h header file from the tooling must be used, not the local
installed version.

Including the ptrace.h header file directly solves the issue.  Feel free to
merge below snippet into your patch.

Thanks and kind regards,
  Hendrik

---
diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
index cefe7c7cd4f6..0a8e37a519f2 100644
--- a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
+++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -2,7 +2,7 @@
 #ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
 #define _UAPI__ASM_BPF_PERF_EVENT_H__
 
-#include <asm/ptrace.h>
+#include "ptrace.h"
 
 typedef user_pt_regs bpf_user_pt_regs_t;
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf 3/3] bpf: fix broken BPF selftest build
  2017-12-18  9:28   ` Hendrik Brueckner
@ 2017-12-18 10:50     ` Daniel Borkmann
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-12-18 10:50 UTC (permalink / raw)
  To: Hendrik Brueckner; +Cc: ast, netdev, Arnaldo Carvalho de Melo, linux-s390

On 12/18/2017 10:28 AM, Hendrik Brueckner wrote:
[...]
> This is actually necessary on s390:
> 
> cc -Wall -O2 -I../../../include/uapi -I../../../lib -I../../../../include/generated  -I../../../include    test_verifier.c /root/git/linux/tools/testing/selftests/bpf/libbpf.a /root/git/linux/tools/testing/selftests/bpf/cgroup_helpers.c -lcap -lelf -o /root/git/linux/tools/testing/selftests/bpf/test_verifier
> In file included from ../../../include/uapi/asm/bpf_perf_event.h:4:0,
>                  from ../../../include/uapi/linux/bpf_perf_event.h:11,
>                  from test_verifier.c:29:
> ../../../include/uapi/../../arch/s390/include/uapi/asm/bpf_perf_event.h:7:9: error: unknown type name 'user_pt_regs'
>  typedef user_pt_regs bpf_user_pt_regs_t;
>          ^~~~~~~~~~~~
> make: *** [../lib.mk:109: /root/git/linux/tools/testing/selftests/bpf/test_verifier] Error 1
> 
> The s390 bpf_perf_event.h header file contains an #include for asm/ptrace.h
> that defines the user_pt_regs (introduce with my patch set).  For building,
> the ptrace.h header file from the tooling must be used, not the local
> installed version.
> 
> Including the ptrace.h header file directly solves the issue.  Feel free to
> merge below snippet into your patch.

Argh, fwiw, I tested on x86 and arm64. :/ Given it already landed in Linus'
tree, could you send me the below as an official patch and I'll take it via
bpf? I think the below is minimal enough, and should then hopefully be the
last remaining fallout on this uapi issue. I think it's fine to do it this
way. The other option would be to pull in ptrace.h for all the others as well
and map it similarly as with bpf_perf_event.h, but that gets out of hand very
quickly (plus we could not have a default fallback include since it would
otherwise be recursive). Anyway, could you add a comment over the include
below stating that this is necessary to include this way? Just to make sure
it doesn't accidentally get changed back until we have a proper framework
in tools/ for dealing with asm includes.

Thanks a lot,
Daniel

> Thanks and kind regards,
>   Hendrik
> 
> ---
> diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
> index cefe7c7cd4f6..0a8e37a519f2 100644
> --- a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
> +++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
> @@ -2,7 +2,7 @@
>  #ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
>  #define _UAPI__ASM_BPF_PERF_EVENT_H__
>  
> -#include <asm/ptrace.h>
> +#include "ptrace.h"
>  
>  typedef user_pt_regs bpf_user_pt_regs_t;
>  
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-18 10:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12  1:25 [PATCH bpf 0/3] Misc BPF fixes Daniel Borkmann
2017-12-12  1:25 ` [PATCH bpf 1/3] bpf: fix corruption on concurrent perf_event_output calls Daniel Borkmann
2017-12-12  1:25 ` [PATCH bpf 2/3] bpf: fix build issues on um due to mising bpf_perf_event.h Daniel Borkmann
2017-12-12  7:55   ` Richard Weinberger
2017-12-12  1:25 ` [PATCH bpf 3/3] bpf: fix broken BPF selftest build Daniel Borkmann
2017-12-18  9:28   ` Hendrik Brueckner
2017-12-18 10:50     ` Daniel Borkmann
2017-12-12 18:07 ` [PATCH bpf 0/3] Misc BPF fixes Alexei Starovoitov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.