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: <CAO-hwJ+23HWjRHx8463uL5hA1HMYcmPD2=63Fv=J__x7zvmLjg@mail.gmail.com>
Date:   Wed, 13 Jul 2022 13:36:22 +0200
From:   Benjamin Tissoires <benjamin.tissoires@...hat.com>
To:     Quentin Monnet <quentin@...valent.com>
Cc:     Greg KH <gregkh@...uxfoundation.org>,
        Jiri Kosina <jikos@...nel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, Shuah Khan <shuah@...nel.org>,
        Dave Marchevsky <davemarchevsky@...com>,
        Joe Stringer <joe@...ium.io>, Jonathan Corbet <corbet@....net>,
        Tero Kristo <tero.kristo@...ux.intel.com>,
        lkml <linux-kernel@...r.kernel.org>,
        "open list:HID CORE LAYER" <linux-input@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        Linux Doc Mailing List <linux-doc@...r.kernel.org>,
        Pu Lehui <pulehui@...wei.com>
Subject: Re: [PATCH bpf-next v6 12/23] HID: initial BPF implementation

On Wed, Jul 13, 2022 at 10:48 AM Quentin Monnet <quentin@...valent.com> wrote:
>
> On 12/07/2022 15:58, Benjamin Tissoires wrote:
[...]
> > diff --git a/drivers/hid/bpf/entrypoints/Makefile b/drivers/hid/bpf/entrypoints/Makefile
> > new file mode 100644
> > index 000000000000..dd60a460c6c4
> > --- /dev/null
> > +++ b/drivers/hid/bpf/entrypoints/Makefile
> > @@ -0,0 +1,88 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +OUTPUT := .output
> > +abs_out := $(abspath $(OUTPUT))
> > +
> > +CLANG ?= clang
> > +LLC ?= llc
> > +LLVM_STRIP ?= llvm-strip
> > +
> > +TOOLS_PATH := $(abspath ../../../../tools)
> > +BPFTOOL_SRC := $(TOOLS_PATH)/bpf/bpftool
> > +BPFTOOL_OUTPUT := $(abs_out)/bpftool
> > +DEFAULT_BPFTOOL := $(OUTPUT)/sbin/bpftool
> > +BPFTOOL ?= $(DEFAULT_BPFTOOL)
> > +
> > +LIBBPF_SRC := $(TOOLS_PATH)/lib/bpf
> > +LIBBPF_OUTPUT := $(abs_out)/libbpf
> > +LIBBPF_DESTDIR := $(LIBBPF_OUTPUT)
> > +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include
> > +BPFOBJ := $(LIBBPF_OUTPUT)/libbpf.a
> > +
> > +INCLUDES := -I$(OUTPUT) -I$(LIBBPF_INCLUDE) -I$(TOOLS_PATH)/include/uapi
> > +CFLAGS := -g -Wall
> > +
> > +VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux)                         \
> > +                  $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux)    \
> > +                  ../../../../vmlinux                                \
> > +                  /sys/kernel/btf/vmlinux                            \
> > +                  /boot/vmlinux-$(shell uname -r)
> > +VMLINUX_BTF ?= $(abspath $(firstword $(wildcard $(VMLINUX_BTF_PATHS))))
> > +ifeq ($(VMLINUX_BTF),)
> > +$(error Cannot find a vmlinux for VMLINUX_BTF at any of "$(VMLINUX_BTF_PATHS)")
> > +endif
> > +
> > +ifeq ($(V),1)
> > +Q =
> > +msg =
> > +else
> > +Q = @
> > +msg = @printf '  %-8s %s%s\n' "$(1)" "$(notdir $(2))" "$(if $(3), $(3))";
> > +MAKEFLAGS += --no-print-directory
> > +submake_extras := feature_display=0
> > +endif
> > +
> > +.DELETE_ON_ERROR:
> > +
> > +.PHONY: all clean
> > +
> > +all: entrypoints.lskel.h
> > +
> > +clean:
> > +     $(call msg,CLEAN)
> > +     $(Q)rm -rf $(OUTPUT) entrypoints
> > +
> > +entrypoints.lskel.h: $(OUTPUT)/entrypoints.bpf.o | $(BPFTOOL)
> > +     $(call msg,GEN-SKEL,$@)
> > +     $(Q)$(BPFTOOL) gen skeleton -L $< > $@
> > +
> > +
> > +$(OUTPUT)/entrypoints.bpf.o: entrypoints.bpf.c $(OUTPUT)/vmlinux.h $(BPFOBJ) | $(OUTPUT)
> > +     $(call msg,BPF,$@)
> > +     $(Q)$(CLANG) -g -O2 -target bpf $(INCLUDES)                           \
> > +              -c $(filter %.c,$^) -o $@ &&                                 \
> > +     $(LLVM_STRIP) -g $@
> > +
> > +$(OUTPUT)/vmlinux.h: $(VMLINUX_BTF) $(BPFTOOL) | $(INCLUDE_DIR)
> > +ifeq ($(VMLINUX_H),)
> > +     $(call msg,GEN,,$@)
> > +     $(Q)$(BPFTOOL) btf dump file $(VMLINUX_BTF) format c > $@
> > +else
> > +     $(call msg,CP,,$@)
> > +     $(Q)cp "$(VMLINUX_H)" $@
> > +endif
> > +
> > +$(OUTPUT) $(LIBBPF_OUTPUT) $(BPFTOOL_OUTPUT):
> > +     $(call msg,MKDIR,$@)
> > +     $(Q)mkdir -p $@
> > +
> > +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OUTPUT)
> > +     $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC)                         \
> > +                 OUTPUT=$(abspath $(dir $@))/ prefix=                       \
> > +                 DESTDIR=$(LIBBPF_DESTDIR) $(abspath $@) install_headers
> > +
> > +$(DEFAULT_BPFTOOL): $(BPFOBJ) | $(BPFTOOL_OUTPUT)
> > +     $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOL_SRC)                        \
> > +                 OUTPUT=$(BPFTOOL_OUTPUT)/                                  \
> > +                 LIBBPF_OUTPUT=$(LIBBPF_OUTPUT)/                            \
> > +                 LIBBPF_DESTDIR=$(LIBBPF_DESTDIR)/                          \
> > +                 prefix= DESTDIR=$(abs_out)/ install-bin
>
> Hi Benjamin,
>
> Note that, at other locations where bpftool is needed to generate the
> vmlinux.h or the skeletons, there is some work in progress to use only
> the "bootstrap" version of bpftool (the intermediary bpftool binary used
> to generate skeletons required for the final bpftool binary) [0]. This
> is enough to generate these objects, it makes compiling the bpftool
> binary faster, and solves some issues related to cross-compilation. It's
> probably worth exploring in your case (or as a follow-up) as well.
>

Hi Quentin,

Indeed, I applied a similar patch to [1] (the 3/3 in the series you
mentioned) and I have the exact same light skeleton.
I have stashed the changes locally for a future revision (I doubt
everything will go through in this version ;-P ).

Cheers,
Benjamin

> Quentin
>
> [0]
> https://lore.kernel.org/all/20220712030813.865410-1-pulehui@huawei.com/t/#u
>
[1] https://lore.kernel.org/all/20220712030813.865410-4-pulehui@huawei.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ