This series adds an Ultravisor(UV) device letting the userspace send some
Ultravisor calls to the UV. Currently two calls are supported.
Query Ultravisor Information (QUI) and
Receive Attestation Measurement (Attest[ation]).
The UV device is implemented as a miscdevice accepting only IOCTLs.
The IOCTL cmd specifies the UV call and the IOCTL arg the request
and response data depending on the UV call.
The device driver writes the UV response in the ioctl argument data.
The 'uvdevice' does no checks on the request beside faulty userspace
addresses, if sizes are in a sane range before allocating in kernel space,
and other tests that prevent the system from corruption.
Especially, no checks are made, that will be performed by the UV anyway
(E.g. 'invalid command' in case of attestation on unsupported hardware).
These errors are reported back to Userspace using the UV return code
field.
The first two patches introduce the new device as a module configured to be
compiled directly into the kernel (y) similar to the s390 SCLP and CHSH
miscdevice modules. Patch 3&4 introduce Kselftests which verify error
paths of the ioctl.
v2->v3:
The main change is that QUI is now introduced after Attestation as we
might not want pick it. Also the Kselftest patch is splitted into
Attestation and QUI so that they can be picked without requiring
QUI support of the uvdevice.
* dropped the Kconfig dependency
* reorganized the series:
- Patch 1 now covers the introduction of the uvdevice and Attestation
- Patch 2 adds QUI to uvdevice
- Patch 3/4 add Kselftests for Attestation and QUI
* fixed some nits
* added some comments
v1->v2:
* ioctl returns -ENOIOCTLCMD in case of a invalid ioctl command
* streamlined reserved field test
* default Kconfig is y instead of m
* improved selftest documentation
Steffen Eiden (4):
drivers/s390/char: Add Ultravisor io device
drivers/s390/char: Add Query Ultravisor Information to uvdevice
selftests: drivers/s390x: Add uvdevice tests
selftests: drivers/s390x: Add uvdevice QUI tests
MAINTAINERS | 3 +
arch/s390/include/asm/uv.h | 23 +-
arch/s390/include/uapi/asm/uvdevice.h | 53 +++
drivers/s390/char/Kconfig | 10 +
drivers/s390/char/Makefile | 1 +
drivers/s390/char/uvdevice.c | 320 ++++++++++++++++++
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/drivers/.gitignore | 1 +
.../selftests/drivers/s390x/uvdevice/Makefile | 22 ++
.../selftests/drivers/s390x/uvdevice/config | 1 +
.../drivers/s390x/uvdevice/test_uvdevice.c | 281 +++++++++++++++
11 files changed, 715 insertions(+), 1 deletion(-)
create mode 100644 arch/s390/include/uapi/asm/uvdevice.h
create mode 100644 drivers/s390/char/uvdevice.c
create mode 100644 tools/testing/selftests/drivers/s390x/uvdevice/Makefile
create mode 100644 tools/testing/selftests/drivers/s390x/uvdevice/config
create mode 100644 tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c
--
2.25.1
There is a spelling mistake in a message. Fix it.
Signed-off-by: Colin Ian King <colin.i.king(a)gmail.com>
---
tools/testing/selftests/sched/cs_prctl_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c
index 8109b17dc764..62b579b601bf 100644
--- a/tools/testing/selftests/sched/cs_prctl_test.c
+++ b/tools/testing/selftests/sched/cs_prctl_test.c
@@ -267,7 +267,7 @@ int main(int argc, char *argv[])
if (setpgid(0, 0) != 0)
handle_error("process group");
- printf("\n## Create a thread/process/process group hiearchy\n");
+ printf("\n## Create a thread/process/process group hierarchy\n");
create_processes(num_processes, num_threads, procs);
need_cleanup = 1;
disp_processes(num_processes, procs);
--
2.35.1
Hi,
This is a followup of my v1 at [0].
The short summary of the previous cover letter and discussions is that
HID could benefit from BPF for the following use cases:
- simple fixup of report descriptor:
benefits are faster development time and testing, with the produced
bpf program being shipped in the kernel directly (the shipping part
is *not* addressed here).
- Universal Stylus Interface:
allows a user-space program to define its own kernel interface
- Surface Dial:
somehow similar to the previous one except that userspace can decide
to change the shape of the exported device
- firewall:
still partly missing there, there is not yet interception of hidraw
calls, but it's coming in a followup series, I promise
- tracing:
well, tracing.
I tried to address as many comments as I could and here is the short log
of changes:
v2:
===
- split the series by subsystem (bpf, HID, libbpf, selftests and
samples)
- Added an extra patch at the beginning to not require CAP_NET_ADMIN for
BPF_PROG_TYPE_LIRC_MODE2 (please shout if this is wrong)
- made the bpf context attached to HID program of dynamic size:
* the first 1 kB will be able to be addressed directly
* the rest can be retrieved through bpf_hid_{set|get}_data
(note that I am definitivey not happy with that API, because there
is part of it in bits and other in bytes. ouch)
- added an extra patch to prevent non GPL HID bpf programs to be loaded
of type BPF_PROG_TYPE_HID
* same here, not really happy but I don't know where to put that check
in verifier.c
- added a new flag BPF_F_INSERT_HEAD for BPF_LINK_CREATE syscall when in
used with HID program types.
* this flag is used for tracing, to be able to load a program before
any others that might already have been inserted and that might
change the data stream.
Cheers,
Benjamin
[0] https://lore.kernel.org/linux-input/20220224110828.2168231-1-benjamin.tisso…
Benjamin Tissoires (28):
bpf: add new is_sys_admin_prog_type() helper
bpf: introduce hid program type
HID: hook up with bpf
libbpf: add HID program type and API
selftests/bpf: add tests for the HID-bpf initial implementation
samples/bpf: add new hid_mouse example
bpf/hid: add a new attach type to change the report descriptor
HID: allow to change the report descriptor from an eBPF program
libbpf: add new attach type BPF_HID_RDESC_FIXUP
selftests/bpf: add report descriptor fixup tests
samples/bpf: add a report descriptor fixup
bpf/hid: add hid_{get|set}_data helpers
HID: bpf: implement hid_bpf_get|set_data
selftests/bpf: add tests for hid_{get|set}_data helpers
bpf/hid: add new BPF type to trigger commands from userspace
libbpf: add new attach type BPF_HID_USER_EVENT
selftests/bpf: add test for user call of HID bpf programs
selftests/bpf: hid: rely on uhid event to know if a test device is
ready
bpf/hid: add bpf_hid_raw_request helper function
HID: add implementation of bpf_hid_raw_request
selftests/bpf: add tests for bpf_hid_hw_request
bpf/verifier: prevent non GPL programs to be loaded against HID
HID: bpf: compute only the required buffer size for the device
HID: bpf: only call hid_bpf_raw_event() if a ctx is available
bpf/hid: Add a flag to add the program at the beginning of the list
libbpf: add handling for BPF_F_INSERT_HEAD in HID programs
selftests/bpf: Add a test for BPF_F_INSERT_HEAD
samples/bpf: fix bpf_program__attach_hid() api change
drivers/hid/Makefile | 1 +
drivers/hid/hid-bpf.c | 361 +++++++++
drivers/hid/hid-core.c | 34 +-
include/linux/bpf-hid.h | 129 +++
include/linux/bpf_types.h | 4 +
include/linux/hid.h | 25 +
include/uapi/linux/bpf.h | 59 ++
include/uapi/linux/bpf_hid.h | 50 ++
kernel/bpf/Makefile | 3 +
kernel/bpf/hid.c | 652 +++++++++++++++
kernel/bpf/syscall.c | 26 +-
kernel/bpf/verifier.c | 7 +
samples/bpf/.gitignore | 1 +
samples/bpf/Makefile | 4 +
samples/bpf/hid_mouse_kern.c | 91 +++
samples/bpf/hid_mouse_user.c | 129 +++
tools/include/uapi/linux/bpf.h | 59 ++
tools/lib/bpf/libbpf.c | 22 +-
tools/lib/bpf/libbpf.h | 2 +
tools/lib/bpf/libbpf.map | 1 +
tools/testing/selftests/bpf/prog_tests/hid.c | 788 +++++++++++++++++++
tools/testing/selftests/bpf/progs/hid.c | 216 +++++
22 files changed, 2649 insertions(+), 15 deletions(-)
create mode 100644 drivers/hid/hid-bpf.c
create mode 100644 include/linux/bpf-hid.h
create mode 100644 include/uapi/linux/bpf_hid.h
create mode 100644 kernel/bpf/hid.c
create mode 100644 samples/bpf/hid_mouse_kern.c
create mode 100644 samples/bpf/hid_mouse_user.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/hid.c
create mode 100644 tools/testing/selftests/bpf/progs/hid.c
--
2.35.1
This script uses bash specific syntax. make it more specific by
declaring it to be used via bash rather than /bin/sh which could
be non-bash.
Signed-off-by: Dirk Müller <dmueller(a)suse.de>
---
tools/testing/selftests/vm/charge_reserved_hugetlb.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh
index a5cb4b09a46c..751d20a2eea8 100644
--- a/tools/testing/selftests/vm/charge_reserved_hugetlb.sh
+++ b/tools/testing/selftests/vm/charge_reserved_hugetlb.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Kselftest framework requirement - SKIP code is 4.
--
2.35.1
The first patch of this series is an improvement to the existing
syncookie BPF helper. The second patch is a documentation fix.
The third patch allows BPF helpers to accept memory regions of fixed
size without doing runtime size checks.
The two last patches add new functionality that allows XDP to
accelerate iptables synproxy.
v1 of this series [1] used to include a patch that exposed conntrack
lookup to BPF using stable helpers. It was superseded by series [2] by
Kumar Kartikeya Dwivedi, which implements this functionality using
unstable helpers.
The fourth patch adds new helpers to issue and check SYN cookies without
binding to a socket, which is useful in the synproxy scenario.
The fifth patch adds a selftest, which consists of a script, an XDP
program and a userspace control application. The XDP program uses
socketless SYN cookie helpers and queries conntrack status instead of
socket status. The userspace control application allows to tune
parameters of the XDP program. This program also serves as a minimal
example of usage of the new functionality.
The draft of the new functionality was presented on Netdev 0x15 [3].
v2 changes:
Split into two series, submitted bugfixes to bpf, dropped the conntrack
patches, implemented the timestamp cookie in BPF using bpf_loop, dropped
the timestamp cookie patch.
v3 changes:
Moved some patches from bpf to bpf-next, dropped the patch that changed
error codes, split the new helpers into IPv4/IPv6, added verifier
functionality to accept memory regions of fixed size.
[1]: https://lore.kernel.org/bpf/20211020095815.GJ28644@breakpoint.cc/t/
[2]: https://lore.kernel.org/bpf/20220114163953.1455836-1-memxor@gmail.com/
[3]: https://netdevconf.info/0x15/session.html?Accelerating-synproxy-with-XDP
Maxim Mikityanskiy (5):
bpf: Use ipv6_only_sock in bpf_tcp_gen_syncookie
bpf: Fix documentation of th_len in bpf_tcp_{gen,check}_syncookie
bpf: Allow helpers to accept pointers with a fixed size
bpf: Add helpers to issue and check SYN cookies in XDP
bpf: Add selftests for raw syncookie helpers
include/linux/bpf.h | 10 +
include/net/tcp.h | 1 +
include/uapi/linux/bpf.h | 100 ++-
kernel/bpf/verifier.c | 26 +-
net/core/filter.c | 128 ++-
net/ipv4/tcp_input.c | 3 +-
scripts/bpf_doc.py | 4 +
tools/include/uapi/linux/bpf.h | 100 ++-
tools/testing/selftests/bpf/.gitignore | 1 +
tools/testing/selftests/bpf/Makefile | 5 +-
.../selftests/bpf/progs/xdp_synproxy_kern.c | 750 ++++++++++++++++++
.../selftests/bpf/test_xdp_synproxy.sh | 71 ++
tools/testing/selftests/bpf/xdp_synproxy.c | 418 ++++++++++
13 files changed, 1594 insertions(+), 23 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c
create mode 100755 tools/testing/selftests/bpf/test_xdp_synproxy.sh
create mode 100644 tools/testing/selftests/bpf/xdp_synproxy.c
--
2.30.2
The $(CC) variable used in Makefiles could contain several arguments
such as "ccache gcc". These need to be passed as a single string to
check_cc.sh, otherwise only the first argument will be used as the
compiler command. Without quotes, the $(CC) variable is passed as
distinct arguments which causes the script to fail to build trivial
programs.
Fix this by adding quotes around $(CC) when calling check_cc.sh to
pass the whole string as a single argument to the script even if it
has several words such as "ccache gcc".
Fixes: e9886ace222e ("selftests, x86: Rework x86 target architecture detection")
Tested-by: "kernelci.org bot" <bot(a)kernelci.org>
Signed-off-by: Guillaume Tucker <guillaume.tucker(a)collabora.com>
---
Notes:
v2: rebase and drop changes in check_cc.sh
tools/testing/selftests/vm/Makefile | 6 +++---
tools/testing/selftests/x86/Makefile | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index fbccdda93629..213f6a57d7f6 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -54,9 +54,9 @@ TEST_GEN_FILES += split_huge_page_test
TEST_GEN_FILES += ksm_tests
ifeq ($(MACHINE),x86_64)
-CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_program.c -m32)
-CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c)
-CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie)
+CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32)
+CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c)
+CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_program.c -no-pie)
override TARGETS := protection_keys
BINARIES_32 := $(TARGETS:%=%_32)
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile
index 8a1f62ab3c8e..53df7d3893d3 100644
--- a/tools/testing/selftests/x86/Makefile
+++ b/tools/testing/selftests/x86/Makefile
@@ -6,9 +6,9 @@ include ../lib.mk
.PHONY: all all_32 all_64 warn_32bit_failure clean
UNAME_M := $(shell uname -m)
-CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32)
-CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c)
-CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie)
+CAN_BUILD_I386 := $(shell ./check_cc.sh "$(CC)" trivial_32bit_program.c -m32)
+CAN_BUILD_X86_64 := $(shell ./check_cc.sh "$(CC)" trivial_64bit_program.c)
+CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh "$(CC)" trivial_program.c -no-pie)
TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \
check_initial_reg_state sigreturn iopl ioperm \
--
2.30.2
Hi Team,
I need a clarification the function "tap_timeout" which is being used in the runner.sh , the one will give the result format in the TAP 13 protocol. Below I am giving the function.
tap_timeout()
{
# Make sure tests will time out if utility is available.
if [ -x /usr/bin/timeout ] ; then
/usr/bin/timeout --foreground "$kselftest_timeout" "$1"
else
"$1"
fi
}
Need a clarification why we are using the function "tap_timout" and why the "kselftest_timeout" variable declared as 45 seconds by default. It will be very helpful if you are clarifying these things for me.
Regards
Sarath PT