Re: [PATCH bpf-next v4 00/12] bpf: Support dumping kfunc prototypes from BTF

2024-06-08 Thread Daniel Xu
On Sat, Jun 08, 2024 at 03:15:56PM GMT, Daniel Xu wrote: > This patchset enables both detecting as well as dumping compilable > prototypes for kfuncs. > > The first commit instructs pahole to DECL_TAG kfuncs when available. > This requires v1.27 or newer. v1.27 is nearing release at time of > writ

[PATCH bpf-next v4 11/12] bpf: selftests: xfrm: Opt out of using generated kfunc prototypes

2024-06-08 Thread Daniel Xu
The xfrm_info selftest locally defines an aliased type such that folks with CONFIG_XFRM_INTERFACE=m/n configs can still build the selftests. See commit aa67961f3243 ("selftests/bpf: Allow building bpf tests with CONFIG_XFRM_INTERFACE=[m|n]"). Thus, it is simpler if this selftest opts out of using

[PATCH bpf-next v4 10/12] bpf: selftests: nf: Opt out of using generated kfunc prototypes

2024-06-08 Thread Daniel Xu
The bpf-nf selftests play various games with aliased types such that folks with CONFIG_NF_CONNTRACK=m/n configs can still build the selftests. See commits: 1058b6a78db2 ("selftests/bpf: Do not fail build if CONFIG_NF_CONNTRACK=m/n") 92afc5329a5b ("selftests/bpf: Fix build errors if CONFIG_NF_CONNT

[PATCH bpf-next v4 09/12] bpf: treewide: Align kfunc signatures to prog point-of-view

2024-06-08 Thread Daniel Xu
Previously, kfunc declarations in bpf_kfuncs.h (and others) used "user facing" types for kfuncs prototypes while the actual kfunc definitions used "kernel facing" types. More specifically: bpf_dynptr vs bpf_dynptr_kern, __sk_buff vs sk_buff, and xdp_md vs xdp_buff. It wasn't an issue before, as th

[PATCH bpf-next v4 07/12] bpf: selftests: Namespace struct_opt callbacks in bpf_dctcp

2024-06-08 Thread Daniel Xu
With generated kfunc prototypes, the existing callback names will conflict. Fix by namespacing with a bpf_ prefix. Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/progs/bpf_dctcp.c | 36 +-- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/testing/se

[PATCH bpf-next v4 06/12] bpf: selftests: Fix bpf_session_cookie() kfunc prototype

2024-06-08 Thread Daniel Xu
The prototype defined in bpf_kfuncs.h was not in line with how the actual kfunc was defined. This causes compilation errors when kfunc prototypes are generated from BTF. Fix by aligning with actual kfunc definition. Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/bpf_kfuncs.h

[PATCH bpf-next v4 05/12] bpf: selftests: Fix bpf_map_sum_elem_count() kfunc prototype

2024-06-08 Thread Daniel Xu
The prototype in progs/map_percpu_stats.c is not in line with how the actual kfuncs are defined in kernel/bpf/map_iter.c. This causes compilation errors when kfunc prototypes are generated from BTF. Fix by aligning with actual kfunc definitions. Signed-off-by: Daniel Xu --- tools/testing/selfte

[PATCH bpf-next v4 04/12] bpf: selftests: Fix bpf_cpumask_first_zero() kfunc prototype

2024-06-08 Thread Daniel Xu
The prototype in progs/nested_trust_common.h is not in line with how the actual kfuncs are defined in kernel/bpf/cpumask.c. This causes compilation errors when kfunc prototypes are generated from BTF. Fix by aligning with actual kfunc definitions. Signed-off-by: Daniel Xu --- tools/testing/self

[PATCH bpf-next v4 03/12] bpf: selftests: Fix fentry test kfunc prototypes

2024-06-08 Thread Daniel Xu
The prototypes in progs/get_func_ip_test.c were not in line with how the actual kfuncs are defined in net/bpf/test_run.c. This causes compilation errors when kfunc prototypes are generated from BTF. Fix by aligning with actual kfunc definitions. Signed-off-by: Daniel Xu --- .../testing/selftest

[PATCH bpf-next v4 02/12] bpf: selftests: Fix bpf_iter_task_vma_new() prototype

2024-06-08 Thread Daniel Xu
bpf_iter_task_vma_new() is defined as taking a u64 as its 3rd argument. u64 is a unsigned long long. bpf_experimental.h was defining the prototype as unsigned long. Fix by using __u64. Signed-off-by: Daniel Xu --- tools/testing/selftests/bpf/bpf_experimental.h | 2 +- 1 file changed, 1 insertio

[PATCH bpf-next v4 00/12] bpf: Support dumping kfunc prototypes from BTF

2024-06-08 Thread Daniel Xu
This patchset enables both detecting as well as dumping compilable prototypes for kfuncs. The first commit instructs pahole to DECL_TAG kfuncs when available. This requires v1.27 or newer. v1.27 is nearing release at time of writing. Following this, users will be able to look at BTF inside vmlinux

Re: [PATCH bpf-next v3 01/11] bpf, lsm: Annotate lsm hook return value range

2024-06-08 Thread Alexei Starovoitov
On Sat, Jun 8, 2024 at 1:04 AM Xu Kuohai wrote: > > On 6/7/2024 5:53 AM, Paul Moore wrote: > > On Thu, Apr 11, 2024 at 8:24 AM Xu Kuohai wrote: > >> > >> From: Xu Kuohai > >> > >> Add macro LSM_RET_INT to annotate lsm hook return integer type and the > >> default return value, and the expected r

Re: [PATCH v3] selftests/mm: use asm volatile to not optimize mmap read variable

2024-06-08 Thread Pankaj Raghav (Samsung)
On Fri, Jun 07, 2024 at 09:39:36PM -0700, Andrew Morton wrote: > On Thu, 6 Jun 2024 20:36:19 + "Pankaj Raghav (Samsung)" > wrote: > > > From: Pankaj Raghav > > > > create_pagecache_thp_and_fd() in split_huge_page_test.c used the > > variable dummy to perform mmap read. > > > > However, t

Re: [PATCH 5/5] kunit: Merge assertion test into kunit-test.c

2024-06-08 Thread David Gow
On Tue, 4 Jun 2024 at 20:32, Ivan Orlov wrote: > > Since assert_test covers the part of the KUnit core (the assertion > formatting functions), I believe it would be better to have it merged > into kunit-test (as it is done for other tests for the KUnit core). > > Signed-off-by: Ivan Orlov > ---

Re: [PATCH 4/5] kunit: assert: export non-static functions

2024-06-08 Thread David Gow
On Tue, 4 Jun 2024 at 20:32, Ivan Orlov wrote: > > Export non-static functions from the assert.c file into the KUnit > namespace in order to be able to access them from the tests if > they are compiled as modules. > > Signed-off-by: Ivan Orlov > --- I think this could be merged with patch 5, as

Re: [PATCH 3/5] kunit: string-stream-test: Make it a separate module

2024-06-08 Thread David Gow
On Tue, 4 Jun 2024 at 20:32, Ivan Orlov wrote: > > Currently, the only way to build string-stream-test is by setting > CONFIG_KUNIT_TEST=y. However, CONFIG_KUNIT_TEST is a config option for > a different test (`kunit-test.c`). > > Introduce a new Kconfig entry in order to be able to build the > st

Re: [PATCH 2/5] kunit: kunit-test: Remove stub for log tests

2024-06-08 Thread David Gow
On Tue, 4 Jun 2024 at 20:32, Ivan Orlov wrote: > > Since now we are exporting string-stream functions into the KUnit > namespace, we can safely use them in kunit-test when it is compiled as > a module as well. So, remove the stubs used when kunit-test is compiled > as a module. Import the KUnit na

Re: [PATCH 1/5] kunit: string-stream: export non-static functions

2024-06-08 Thread David Gow
On Tue, 4 Jun 2024 at 20:32, Ivan Orlov wrote: > > Export non-static functions from the string-stream.c file into the KUnit > namespace in order to be able to access them from the KUnit core tests > (when they are loaded as modules). > > Signed-off-by: Ivan Orlov > --- Looks good to me, thanks.

[PATCH HID v3 16/16] HID: bpf: make part of struct hid_device writable

2024-06-08 Thread Benjamin Tissoires
It is useful to change the name, the phys and/or the uniq of a struct hid_device during .rdesc_fixup(). For example, hid-uclogic.ko changes the uniq to store the firmware version to differentiate between 2 devices sharing the same PID. In the same way, changing the device name is useful when the d

[PATCH HID v3 15/16] HID: bpf: rework hid_bpf_ops_btf_struct_access

2024-06-08 Thread Benjamin Tissoires
The idea is to provide a list of stucts and their editable fields. Currently no functional changes are introduced here, we will add some more writeable fields in the next patch. Signed-off-by: Benjamin Tissoires --- changes in v3: - rewrote WRITE_RANGE macro to not deal with offset from the ca

[PATCH HID v3 14/16] bpf: allow bpf helpers to be used into HID-BPF struct_ops

2024-06-08 Thread Benjamin Tissoires
Without this helpers like bpf_printk() or bpf_map_update() are not available, making anything but change of bytes impossible to do. Signed-off-by: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/hid/bpf/hid_bpf_struct_ops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dri

[PATCH HID v3 13/16] HID: bpf: error on warnings when compiling bpf objects

2024-06-08 Thread Benjamin Tissoires
There is no real reasons to paper over warnings for such small programs. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/bpf/progs/Makefile b/drivers/hid/

[PATCH HID v3 12/16] HID: bpf: Artist24: remove unused variable

2024-06-08 Thread Benjamin Tissoires
warning: unused variable ‘tilt’ [-Wunused-variable] Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/XPPen__Artist24.bpf.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/bpf/progs/XPPen__Artist24.b

[PATCH HID v3 11/16] Documentation: HID: add a small blurb on udev-hid-bpf

2024-06-08 Thread Benjamin Tissoires
This is the current decision we took: we don't provide automatic loading of HID-BPF by the kernel directly, but rely on an external tool for it. This tool is currently udev-hid-bpf, so let's make people aware of it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 ---

[PATCH HID v3 10/16] Documentation: HID: amend HID-BPF for struct_ops

2024-06-08 Thread Benjamin Tissoires
Now that we are using struct_ops, the docs need to be changed. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2 - use BPF_F_BEFORE --- Documentation/hid/hid-bpf.rst | 156 +++--- include/linux/hid_bpf.h | 8 +-- 2 files changed,

[PATCH HID v3 09/16] selftests/hid: add subprog call test

2024-06-08 Thread Benjamin Tissoires
I got a weird verifier error with a subprog once, so let's have a test for it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- tools/testing/selftests/hid/hid_bpf.c | 41 + tools/testing/selftests/hid/progs/hid.c | 24 +

[PATCH HID v3 08/16] HID: bpf: remove tracing HID-BPF capability

2024-06-08 Thread Benjamin Tissoires
We can now rely on struct_ops as we cleared the users in-tree. Signed-off-by: Benjamin Tissoires --- no changes in v3 changes in v2: - remove now unused enum hid_bpf_attach_flags --- drivers/hid/bpf/Makefile| 2 +- drivers/hid/bpf/entrypoints/Makefile| 9

[PATCH HID v3 07/16] HID: bpf: convert in-tree fixes into struct_ops

2024-06-08 Thread Benjamin Tissoires
Very mechanical: - Change HID_BPF_DEVICE_EVENT and HID_BPF_RDESC_FIXUP #defines - add a matching SEC(".struct_ops.link") - in ArtistPro16Gen2 make the 2 functions static and have a new one calling them Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/b

[PATCH HID v3 06/16] HID: bpf: add defines for HID-BPF SEC in in-tree bpf fixes

2024-06-08 Thread Benjamin Tissoires
We are going to switch over struct_ops, so instead of having to manually replace all fields one by one, let's have a common place to change it. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/progs/FR-TEC__Raptor-Mach-2.bpf.c | 4 ++-- drivers/h

[PATCH HID v3 05/16] HID: samples: convert the 2 HID-BPF samples into struct_ops

2024-06-08 Thread Benjamin Tissoires
This is mostly mechanical: attach_prog is dropped, and the SEC are converted into struct_ops. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 but the commit message. --- samples/hid/Makefile | 5 ++-- samples/hid/hid_bpf_attach.bpf.c | 18 -

[PATCH HID v3 04/16] selftests/hid: convert the hid_bpf selftests with struct_ops

2024-06-08 Thread Benjamin Tissoires
We drop the need for the attach() bpf syscall, but we need to set up the hid_id field before calling __load(). The .bpf.c part is mechanical: we create one struct_ops per HID-BPF program, as all the tests are for one program at a time. Signed-off-by: Benjamin Tissoires --- no changes in v3 ch

[PATCH HID v3 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
We do this implementation in several steps to not have the CI failing: - first (this patch), we add struct_ops while keeping the existing infra available - then we change the selftests, the examples and the existing in-tree HID-BPF programs - then we remove the existing trace points making old

[PATCH HID v3 02/16] HID: bpf: add hid_get/put_device() helpers

2024-06-08 Thread Benjamin Tissoires
no code change, but this way we reduce code duplication and we can export it later. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 47 ++ 1 file changed, 27 insertions(+), 20 deletions(-) di

[PATCH HID v3 01/16] HID: rename struct hid_bpf_ops into hid_ops

2024-06-08 Thread Benjamin Tissoires
Those operations are the ones from HID, not HID-BPF, and I'd like to reuse hid_bpf_ops as the user facing struct_ops API. Signed-off-by: Benjamin Tissoires --- no changes in v3 no changes in v2 --- drivers/hid/bpf/hid_bpf_dispatch.c | 22 +++--- drivers/hid/hid-core.c

[PATCH HID v3 00/16] HID: convert HID-BPF into using bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
The purpose of this series is to rethink how HID-BPF is invoked. Currently it implies a jmp table, a prog fd bpf_map, a preloaded tracing bpf program and a lot of manual work for handling the bpf program lifetime and addition/removal. OTOH, bpf_struct_ops take care of most of the bpf handling leav

Re: [PATCH 1/2] kunit: test: Add vm_mmap() allocation resource manager

2024-06-08 Thread David Gow
On Mon, 20 May 2024 at 03:12, Kees Cook wrote: > > For tests that need to allocate using vm_mmap() (e.g. usercopy and > execve), provide the interface to have the allocation tracked by KUnit > itself. This requires bringing up a placeholder userspace mm. > > This combines my earlier attempt at thi

Re: [PATCH 2/2] usercopy: Convert test_user_copy to KUnit test

2024-06-08 Thread David Gow
On Mon, 20 May 2024 at 03:12, Kees Cook wrote: > > Convert the runtime tests of hardened usercopy to standard KUnit tests. > > Co-developed-by: Vitor Massaru Iha > Signed-off-by: Vitor Massaru Iha > Link: https://lore.kernel.org/r/20200721174654.72132-1-vi...@massaru.org > Signed-off-by: Kees Co

Re: [PATCH bpf-next v3 01/11] bpf, lsm: Annotate lsm hook return value range

2024-06-08 Thread Xu Kuohai
On 6/7/2024 5:53 AM, Paul Moore wrote: On Thu, Apr 11, 2024 at 8:24 AM Xu Kuohai wrote: From: Xu Kuohai Add macro LSM_RET_INT to annotate lsm hook return integer type and the default return value, and the expected return range. The LSM_RET_INT is declared as: LSM_RET_INT(defval, min, max)

Re: [PATCH HID v2 03/16] HID: bpf: implement HID-BPF through bpf_struct_ops

2024-06-08 Thread Benjamin Tissoires
On Jun 07 2024, Alexei Starovoitov wrote: > On Fri, Jun 7, 2024 at 8:28 AM Benjamin Tissoires wrote: > > +struct hid_bpf_ops { > > + /* hid_id needs to stay first so we can easily change it > > +* from userspace. > > +*/ > > + int hid_id; > > +