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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 May 2018 12:12:05 -0700
From:   Y Song <ys114321@...il.com>
To:     Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        oss-drivers@...ronome.com, netdev <netdev@...r.kernel.org>,
        Björn Töpel <bjorn.topel@...il.com>
Subject: Re: [PATCH bpf-next 3/4] samples: bpf: fix build after move to
 compiling full libbpf.a

On Fri, May 11, 2018 at 5:17 PM, Jakub Kicinski
<jakub.kicinski@...ronome.com> wrote:
> There are many ways users may compile samples, some of them got
> broken by commit 5f9380572b4b ("samples: bpf: compile and link
> against full libbpf").  Improve path resolution and make libbpf
> building a dependency of source files to force its build.
>
> Samples should now again build with any of:
>  cd samples/bpf; make
>  make samples/bpf
>  make -C samples/bpf
>  cd samples/bpf; make O=builddir
>  make samples/bpf O=builddir
>  make -C samples/bpf O=builddir

I typically built samples/bpf/ this way:
    export KBUILD_OUTPUT=/home/yhs/linux-bld
at linux source directory:
    make defconfig
in /home/yhs/linux-bld,
    make -j100 && make headers_install && make samples/bpf/

With this patch, the build for samples/bpf/ still failed.

-bash-4.2$ make samples/bpf/
  CHK     include/config/kernel.release
  Using /data/users/yhs/work/net-next as source for kernel
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    /data/users/yhs/work/net-next/scripts/checksyscalls.sh
  DESCEND  objtool
  CHK     scripts/mod/devicetable-offsets.h
scripts/Makefile.host:106: target
`samples/bpf//data/users/yhs/work/net-next/samples/bpf/../../tools/lib/bpf/libbpf.a'
doesn't match the target pattern
make -C /data/users/yhs/work/net-next/samples/bpf/../../tools/lib/bpf/
O= srctree=/data/users/yhs/work/net-next/samples/bpf/../../

Auto-detecting system features:
...                        libelf: [ OFF ]
...                           bpf: [ OFF ]

No libelf found
make[4]: *** [elfdep] Error 1
make[3]: *** [/data/users/yhs/work/net-next/samples/bpf/../../tools/lib/bpf/libbpf.a]
Error 2
make[2]: *** [samples/bpf/] Error 2
make[1]: *** [sub-make] Error 2
make: *** [__sub-make] Error 2
-bash-4.2$

I noticied that I might use BPF_SAMPLES_PATH variable to tell where is
the samples/bpf source.
Below is what I did:
-bash-4.2$ BPF_SAMPLES_PATH=../../../net-next/samples/bpf make
samples/bpf/
  CHK     include/config/kernel.release
  Using /data/users/yhs/work/net-next as source for kernel
  GEN     ./Makefile
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    /data/users/yhs/work/net-next/scripts/checksyscalls.sh
  DESCEND  objtool
  CHK     scripts/mod/devicetable-offsets.h
scripts/Makefile.host:106: target
`samples/bpf/../../../net-next/samples/bpf/../../tools/lib/bpf/libbpf.a'
doesn't match the target pattern
  CHK     samples/bpf/syscall_nrs.h
  HOSTCC  samples/bpf/../../../net-next/samples/bpf/../../tools/lib/bpf/libbpf.a
gcc: fatal error: no input files
compilation terminated.
make[3]: *** [samples/bpf/../../../net-next/samples/bpf/../../tools/lib/bpf/libbpf.a]
Error 4
make[2]: *** [samples/bpf/] Error 2
make[1]: *** [sub-make] Error 2
make: *** [__sub-make] Error 2
-bash-4.2$

-bash-4.2$ pwd
/home/yhs/work
-bash-4.2$ ls
linux-bld  net-next
-bash-4.2$

>
> Fixes: 5f9380572b4b ("samples: bpf: compile and link against full libbpf")
> Reported-by: Björn Töpel <bjorn.topel@...il.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
> ---
>  samples/bpf/Makefile | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 9e255ca4059a..bed205ab1f81 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -1,4 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
> +
> +BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
> +TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
> +
>  # List of programs to build
>  hostprogs-y := test_lru_dist
>  hostprogs-y += sock_example
> @@ -49,7 +53,8 @@ hostprogs-y += xdpsock
>  hostprogs-y += xdp_fwd
>
>  # Libbpf dependencies
> -LIBBPF := ../../tools/lib/bpf/libbpf.a
> +LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
> +
>  CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
>  TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
>
> @@ -233,15 +238,15 @@ CLANG_ARCH_ARGS = -target $(ARCH)
>  endif
>
>  # Trick to allow make to be run from this directory
> -all: $(LIBBPF)
> -       $(MAKE) -C ../../ $(CURDIR)/
> +all:
> +       $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
>
>  clean:
>         $(MAKE) -C ../../ M=$(CURDIR) clean
>         @rm -f *~
>
>  $(LIBBPF): FORCE
> -       $(MAKE) -C $(dir $@)
> +       $(MAKE) -C $(dir $@) O= srctree=$(BPF_SAMPLES_PATH)/../../
>
>  $(obj)/syscall_nrs.s:  $(src)/syscall_nrs.c
>         $(call if_changed_dep,cc_s_c)
> @@ -272,7 +277,8 @@ verify_target_bpf: verify_cmds
>                 exit 2; \
>         else true; fi
>
> -$(src)/*.c: verify_target_bpf
> +$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
> +$(src)/*.c: verify_target_bpf $(LIBBPF)
>
>  $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
>
> --
> 2.17.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ