Re: [PATCH] test coverage for dup_fd() failure handling in unshare_fd()

2024-08-21 Thread Shuah Khan
On 8/21/24 22:39, Al Viro wrote: At some point there'd been a dumb braino during the dup_fd() calling conventions change; caught by smatch and immediately fixed. The trouble is, there had been no test coverage for the dup_fd() failure handling - neither in kselftests nor in LTP. Fortunat

Re: [PATCH 3/3] kunit: Improve format of the KUNIT_EXPECT_EQ assertion

2024-08-21 Thread David Gow
On Thu, 22 Aug 2024 at 03:15, Michal Wajdeczko wrote: > > Diagnostic message for failed KUNIT_ASSERT|EXPECT_EQ shows in > case of integers only raw values, like for this example: > > bool flag; > KUNIT_EXPECT_EQ(test, 0, kstrtobool("dunno", &flag)); > > we will get: > > [ ] Expected 0 == kst

Re: [PATCH 2/3] kunit: Improve format of the PTR_EQ|NE|NULL assertion

2024-08-21 Thread David Gow
On Thu, 22 Aug 2024 at 03:15, Michal Wajdeczko wrote: > > Diagnostic message for failed KUNIT_ASSERT|EXPECT_PTR_EQ|NE|NULL > shows only raw pointer value, like for this example: > > void *ptr1 = ERR_PTR(-ENOMEM); > void *ptr2 = NULL; > KUNIT_EXPECT_PTR_EQ(test, ptr1, ptr2); > KUNIT_EXPECT_

Re: [PATCH 1/3] kunit: Improve format of the NOT_ERR_OR_NULL assertion

2024-08-21 Thread David Gow
On Thu, 22 Aug 2024 at 03:15, Michal Wajdeczko wrote: > > Diagnostic message for failed KUNIT_ASSERT|EXPECT_NOT_ERR_OR_NULL > shows only raw error code, like for this example: > > void *myptr = ERR_PTR(-ENOMEM); > KUNIT_EXPECT_NOT_ERR_OR_NULL(test, myptr); > > we will get: > > [ ] Expected m

Re: [PATCH v1] selftests:tdx:Use min macro

2024-08-21 Thread Shuah Khan
On 8/21/24 22:46, Yan Zhen wrote: Using the min macro is usually more intuitive and readable. How did you find this problem? Signed-off-by: Yan Zhen --- tools/testing/selftests/tdx/tdx_guest_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftest

Re: [PATCH 4/4] kunit: Add example with alternate function redirection method

2024-08-21 Thread David Gow
On Wed, 21 Aug 2024 at 22:43, Michal Wajdeczko wrote: > > Add example how to use KUNIT_FIXED_STUB_REDIRECT and compare its > usage with the KUNIT_STATIC_STUB_REDIRECT. Also show how the > DECLARE_IF_KUNIT macro could be helpful in declaring test data in > the non-test data structures. > > Signed-o

Re: [PATCH 3/4] kunit: Allow function redirection outside of the KUnit thread

2024-08-21 Thread David Gow
On Wed, 21 Aug 2024 at 22:43, Michal Wajdeczko wrote: > > Currently, the 'static stub' API only allows function redirection > for calls made from the kthread of the current test, which prevents > the use of this functionalty when the tested code is also used by > other threads, outside of the KUni

Re: [PATCH 2/4] kunit: Add macro to conditionally expose declarations to tests

2024-08-21 Thread David Gow
On Wed, 21 Aug 2024 at 22:43, Michal Wajdeczko wrote: > > The DECLARE_IF_KUNIT macro will introduces identifiers only if > CONFIG_KUNIT is enabled. Otherwise if CONFIG_KUNIT is not enabled > no identifiers from the param list will be defined. > > Signed-off-by: Michal Wajdeczko > --- > Cc: Rae Mo

Re: [PATCH 1/4] kunit: Introduce kunit_is_running()

2024-08-21 Thread David Gow
On Wed, 21 Aug 2024 at 22:43, Michal Wajdeczko wrote: > > Wrap uses of the static key 'kunit_running' into a helper macro > to allow future checks to be placed in the code residing outside > of the CONFIG_KUNIT. We will start using this in upcoming patch. > > Signed-off-by: Michal Wajdeczko > ---

Re: [PATCH 0/3] selftests: Fix cpuid / vendor checking build issues

2024-08-21 Thread Muhammad Usama Anjum
On 8/21/24 11:30 AM, Shuah Khan wrote: > On 8/13/24 04:45, Ilpo Järvinen wrote: >> First, generalize resctrl selftest non-contiguous CAT check to not >> assume non-AMD vendor implies Intel. Second, improve kselftest common >> parts and resctrl selftest such that the use of __cpuid_count() does >> n

Re: [RFC PATCH 3/3] kselftest: Provide __cpuid_count() stub on non-x86 archs

2024-08-21 Thread Muhammad Usama Anjum
On 8/13/24 3:45 PM, Ilpo Järvinen wrote: > Building resctrl selftest fails on ARM because it uses __cpuid_count() > that fails the build with error: > > CC resctrl_tests > In file included from resctrl.h:24, > from cat_test.c:11: > In function 'arch_supports_noncont_cat',

[PATCH v1] selftests:tdx:Use min macro

2024-08-21 Thread Yan Zhen
Using the min macro is usually more intuitive and readable. Signed-off-by: Yan Zhen --- tools/testing/selftests/tdx/tdx_guest_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/tdx/tdx_guest_test.c b/tools/testing/selftests/tdx/tdx_guest_test.c in

Re: [PATCH 2/3] selftests/resctrl: Always initialize ecx to avoid build warnings

2024-08-21 Thread Muhammad Usama Anjum
On 8/13/24 3:45 PM, Ilpo Järvinen wrote: > To avoid warnings when __cpuid_count() is an empty stub, always > initialize ecx because it is used in the return statement. > > Signed-off-by: Ilpo Järvinen Reviewed-by: Muhammad Usama Anjum > --- > tools/testing/selftests/resctrl/cat_test.c | 2 +- >

Re: [PATCH 1/3] selftests/resctrl: Generalize non-contiguous CAT check

2024-08-21 Thread Muhammad Usama Anjum
On 8/13/24 3:45 PM, Ilpo Järvinen wrote: > arch_supports_noncont_cat() checks if vendor is ARCH_AMD and if that is > not true, ARCH_INTEL is assumed which might not be true either because > get_vendor() can also return zero if neither AMD nor Intel is detected. > > Generalize the vendor check usin

[PATCH] test coverage for dup_fd() failure handling in unshare_fd()

2024-08-21 Thread Al Viro
At some point there'd been a dumb braino during the dup_fd() calling conventions change; caught by smatch and immediately fixed. The trouble is, there had been no test coverage for the dup_fd() failure handling - neither in kselftests nor in LTP. Fortunately, it can be triggered on stock k

Re: [PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler

2024-08-21 Thread Shuah Khan
On 8/21/24 13:09, Steven Rostedt wrote: From: Steven Rostedt Masami reported a bug when running function graph tracing then the function profiler. The following commands would cause a kernel crash: # cd /sys/kernel/tracing/ # echo function_graph > current_tracer # echo 1 > function_pr

Re: [PATCH v5 1/2] selftests: Rename sigaltstack to generic signal

2024-08-21 Thread Shuah Khan
On 8/21/24 00:15, Dev Jain wrote: Rename sigaltstack to signal, and rename the existing test to sigaltstack.c. Can you elaborate on the benefits if renaming the test? Also you have such a good information in the cover-letter for this patch - it would be good to include it in the change log for

Re: [PATCH v1] tools:mm:Check mmap based on return values

2024-08-21 Thread Shuah Khan
On 8/20/24 21:50, Yang Ruibin wrote: To correctly detect whether mmap is successful, must use if (map_ptr == MAP_FAILED)to avoid incorrectly handling a valid mapping. Add "Fix mmap() error paths to check for MAP_FAILED" at the end of the changelog Change short log to say "selftests:mm: Fix mma

Re: [PATCH v3 1/3] riscv: mm: Use hint address in mmap if available

2024-08-21 Thread Yangyu Chen
> On Aug 22, 2024, at 06:17, Palmer Dabbelt wrote: > > On Mon, 19 Aug 2024 18:58:18 PDT (-0700), rsworkt...@outlook.com wrote: >> On 2024-08-20 01:00, Charlie Jenkins wrote: >>> On Mon, Aug 19, 2024 at 01:55:57PM +0800, Levi Zim wrote: On 2024-03-22 22:06, Palmer Dabbelt wrote: > On T

Re: [PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-21 Thread Alexei Starovoitov
On Wed, Aug 21, 2024 at 2:10 AM Tony Ambardar wrote: > > > +static inline void bpf_insn_bswap(struct bpf_insn *insn) > +{ > + /* dst_reg & src_reg nibbles */ > + __u8 *regs = (__u8 *)insn + offsetofend(struct bpf_insn, code); > + > + *regs = (*regs >> 4) | (*regs << 4); > +

[PATCH v11 39/39] KVM: selftests: arm64: Add GCS registers to get-reg-list

2024-08-21 Thread Mark Brown
GCS adds new registers GCSCR_EL1, GCSCRE0_EL1, GCSPR_EL1 and GCSPR_EL0. Add these to those validated by get-reg-list. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 28 ++ 1 file changed, 28 insertions(+)

[PATCH v11 38/39] kselftest/arm64: Enable GCS for the FP stress tests

2024-08-21 Thread Mark Brown
While it's a bit off topic for them the floating point stress tests do give us some coverage of context thrashing cases, and also of active signal delivery separate to the relatively complicated framework in the actual signals tests. Have the tests enable GCS on startup, ignoring failures so they c

[PATCH v11 37/39] kselftest/arm64: Add a GCS stress test

2024-08-21 Thread Mark Brown
Add a stress test which runs one more process than we have CPUs spinning through a very recursive function with frequent syscalls immediately prior to return and signals being injected every 100ms. The goal is to flag up any scheduling related issues, for example failure to ensure that barriers are

[PATCH v11 36/39] kselftest/arm64: Add GCS signal tests

2024-08-21 Thread Mark Brown
Do some testing of the signal handling for GCS, checking that a GCS frame has the expected information in it and that the expected signals are delivered with invalid operations. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/.gitignore|

[PATCH v11 35/39] kselftest/arm64: Add test coverage for GCS mode locking

2024-08-21 Thread Mark Brown
Verify that we can lock individual GCS mode bits, that other modes aren't affected and as a side effect also that every combination of modes can be enabled. Normally the inability to reenable GCS after disabling it would be an issue with testing but fortunately the kselftest_harness runs each test

[PATCH v11 34/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-08-21 Thread Mark Brown
There are things like threads which nolibc struggles with which we want to add coverage for, and the ABI allows us to test most of these even if libc itself does not understand GCS so add a test application built using the system libc. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown

[PATCH v11 33/39] kselftest/arm64: Add very basic GCS test program

2024-08-21 Thread Mark Brown
This test program just covers the basic GCS ABI, covering aspects of the ABI as standalone features without attempting to integrate things. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/Makefile| 2 +- tools/testing/selftests/arm64/gcs/

[PATCH v11 32/39] kselftest/arm64: Always run signals tests with GCS enabled

2024-08-21 Thread Mark Brown
Since it is not possible to return from the function that enabled GCS without disabling GCS it is very inconvenient to use the signal handling tests to cover GCS when GCS is not enabled by the toolchain and runtime, something that no current distribution does. Since none of the testcases do anythin

[PATCH v11 31/39] kselftest/arm64: Allow signals tests to specify an expected si_code

2024-08-21 Thread Mark Brown
Currently we ignore si_code unless the expected signal is a SIGSEGV, in which case we enforce it being SEGV_ACCERR. Allow test cases to specify exactly which si_code should be generated so we can validate this, and test for other segfault codes. Reviewed-by: Thiago Jung Bauermann Signed-off-by: M

[PATCH v11 30/39] kselftest/arm64: Add framework support for GCS to signal handling tests

2024-08-21 Thread Mark Brown
Teach the framework about the GCS signal context, avoiding warnings on the unknown context. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/testcases/testcases.c | 7 +++ tools/testing/selftests/arm64/signal/testcases/testcases.h | 1 +

[PATCH v11 29/39] kselftest/arm64: Add GCS as a detected feature in the signal tests

2024-08-21 Thread Mark Brown
In preparation for testing GCS related signal handling add it as a feature we check for in the signal handling support code. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/signal/test_signals.h | 2 ++ tools/testing/selftests/arm64/signal/te

[PATCH v11 28/39] kselftest/arm64: Verify the GCS hwcap

2024-08-21 Thread Mark Brown
Add coverage of the GCS hwcap to the hwcap selftest, using a read of GCSPR_EL0 to generate SIGILL without having to worry about enabling GCS. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- tools/testing/selftests/arm64/abi/hwcap.c | 19 +++ 1 file changed, 19 i

[PATCH v11 27/39] arm64: Add Kconfig for Guarded Control Stack (GCS)

2024-08-21 Thread Mark Brown
Provide a Kconfig option allowing the user to select if GCS support is built into the kernel. Reviewed-by: Thiago Jung Bauermann Reviewed-by: Catalin Marinas Signed-off-by: Mark Brown --- arch/arm64/Kconfig | 20 1 file changed, 20 insertions(+) diff --git a/arch/arm64/Kc

[PATCH v11 26/39] arm64/ptrace: Expose GCS via ptrace and core files

2024-08-21 Thread Mark Brown
Provide a new register type NT_ARM_GCS reporting the current GCS mode and pointer for EL0. Due to the interactions with allocation and deallocation of Guarded Control Stacks we do not permit any changes to the GCS mode via ptrace, only GCSPR_EL0 may be changed. Reviewed-by: Thiago Jung Bauermann

[PATCH v11 25/39] arm64/signal: Expose GCS state in signal frames

2024-08-21 Thread Mark Brown
Add a context for the GCS state and include it in the signal context when running on a system that supports GCS. We reuse the same flags that the prctl() uses to specify which GCS features are enabled and also provide the current GCS pointer. We do not support enabling GCS via signal return, there

[PATCH v11 24/39] arm64/signal: Set up and restore the GCS context for signal handlers

2024-08-21 Thread Mark Brown
When invoking a signal handler we use the GCS configuration and stack for the current thread. Since we implement signal return by calling the signal handler with a return address set up pointing to a trampoline in the vDSO we need to also configure any active GCS for this by pushing a frame for th

[PATCH v11 23/39] arm64/mm: Implement map_shadow_stack()

2024-08-21 Thread Mark Brown
As discussed extensively in the changelog for the addition of this syscall on x86 ("x86/shstk: Introduce map_shadow_stack syscall") the existing mmap() and madvise() syscalls do not map entirely well onto the security requirements for guarded control stacks since they lead to windows where memory i

[PATCH v11 22/39] arm64/gcs: Implement shadow stack prctl() interface

2024-08-21 Thread Mark Brown
Implement the architecture neutral prctl() interface for setting the shadow stack status, this supports setting and reading the current GCS configuration for the current thread. Userspace can enable basic GCS functionality and additionally also support for GCS pushes and arbitrary GCS stores. It

[PATCH v11 21/39] arm64/gcs: Ensure that new threads have a GCS

2024-08-21 Thread Mark Brown
When a new thread is created by a thread with GCS enabled the GCS needs to be specified along with the regular stack. Unfortunately plain clone() is not extensible and existing clone3() users will not specify a stack so all existing code would be broken if we mandated specifying the stack explicit

[PATCH v11 20/39] arm64/gcs: Context switch GCS state for EL0

2024-08-21 Thread Mark Brown
There are two registers controlling the GCS state of EL0, GCSPR_EL0 which is the current GCS pointer and GCSCRE0_EL1 which has enable bits for the specific GCS functionality enabled for EL0. Manage these on context switch and process lifetime events, GCS is reset on exec(). Also ensure that any ch

[PATCH v11 19/39] arm64/mm: Handle GCS data aborts

2024-08-21 Thread Mark Brown
All GCS operations at EL0 must happen on a page which is marked as having UnprivGCS access, including read operations. If a GCS operation attempts to access a page without this then it will generate a data abort with the GCS bit set in ESR_EL1.ISS2. EL0 may validly generate such faults, for examp

[PATCH v11 18/39] arm64/traps: Handle GCS exceptions

2024-08-21 Thread Mark Brown
A new exception code is defined for GCS specific faults other than standard load/store faults, for example GCS token validation failures, add handling for this. These faults are reported to userspace as segfaults with code SEGV_CPERR (protection error), mirroring the reporting for x86 shadow stack

[PATCH v11 17/39] arm64/hwcap: Add hwcap for GCS

2024-08-21 Thread Mark Brown
Provide a hwcap to enable userspace to detect support for GCS. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- Documentation/arch/arm64/elf_hwcaps.rst | 2 ++ arch/arm64/include/asm/hwcap.h | 1 + arch/arm64/include/uapi/asm/hwcap.h | 1 + arch/arm64/kernel/cpufeat

[PATCH v11 16/39] arm64/idreg: Add overrride for GCS

2024-08-21 Thread Mark Brown
Hook up an override for GCS, allowing it to be disabled from the command line by specifying arm64.nogcs in case there are problems. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- Documentation/admin-guide/kernel-parameters.txt | 3 +++ arch/arm64/kernel/pi/idreg-override.c

[PATCH v11 15/39] KVM: arm64: Manage GCS access and registers for guests

2024-08-21 Thread Mark Brown
GCS introduces a number of system registers for EL1 and EL0, on systems with GCS we need to context switch them and expose them to VMMs to allow guests to use GCS. In order to allow guests to use GCS we also need to configure HCRX_EL2.GCSEn, if this is not set GCS instructions will be noops and CH

[PATCH v11 14/39] arm64/mm: Map pages for guarded control stack

2024-08-21 Thread Mark Brown
Map pages flagged as being part of a GCS as such rather than using the full set of generic VM flags. This is done using a conditional rather than extending the size of protection_map since that would make for a very sparse array. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown ---

[PATCH v11 13/39] mm: Define VM_SHADOW_STACK for arm64 when we support GCS

2024-08-21 Thread Mark Brown
Use VM_HIGH_ARCH_5 for guarded control stack pages. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- Documentation/filesystems/proc.rst | 2 +- include/linux/mm.h | 12 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Documentation/fi

[PATCH v11 12/39] arm64/mm: Allocate PIE slots for EL0 guarded control stack

2024-08-21 Thread Mark Brown
Pages used for guarded control stacks need to be described to the hardware using the Permission Indirection Extension, GCS is not supported without PIE. In order to support copy on write for guarded stacks we allocate two values, one for active GCSs and one for GCS pages marked as read only prior t

[PATCH v11 11/39] arm64/cpufeature: Runtime detection of Guarded Control Stack (GCS)

2024-08-21 Thread Mark Brown
Add a cpufeature for GCS, allowing other code to conditionally support it at runtime. Reviewed-by: Thiago Jung Bauermann Reviewed-by: Catalin Marinas Signed-off-by: Mark Brown --- arch/arm64/include/asm/cpufeature.h | 6 ++ arch/arm64/kernel/cpufeature.c | 9 + arch/arm64/tool

[PATCH v11 10/39] arm64/gcs: Provide basic EL2 setup to allow GCS usage at EL0 and EL1

2024-08-21 Thread Mark Brown
There is a control HCRX_EL2.GCSEn which must be set to allow GCS features to take effect at lower ELs and also fine grained traps for GCS usage at EL0 and EL1. Configure all these to allow GCS usage by EL0 and EL1. We also initialise GCSCR_EL1 and GCSCRE0_EL1 to ensure that we can execute functio

[PATCH v11 09/39] arm64/gcs: Provide put_user_gcs()

2024-08-21 Thread Mark Brown
In order for EL1 to write to an EL0 GCS it must use the GCSSTTR instruction rather than a normal STTR. Provide a put_user_gcs() which does this. Reviewed-by: Thiago Jung Bauermann Reviewed-by: Catalin Marinas Signed-off-by: Mark Brown --- arch/arm64/include/asm/uaccess.h | 18 +

[PATCH v11 08/39] arm64/gcs: Add manual encodings of GCS instructions

2024-08-21 Thread Mark Brown
Define C callable functions for GCS instructions used by the kernel. In order to avoid ambitious toolchain requirements for GCS support these are manually encoded, this means we have fixed register numbers which will be a bit limiting for the compiler but none of these should be used in sufficientl

[PATCH v11 07/39] arm64/sysreg: Add definitions for architected GCS caps

2024-08-21 Thread Mark Brown
The architecture defines a format for guarded control stack caps, used to mark the top of an unused GCS in order to limit the potential for exploitation via stack switching. Add definitions associated with these. Reviewed-by: Thiago Jung Bauermann Acked-by: Catalin Marinas Signed-off-by: Mark Br

[PATCH v11 06/39] arm64/gcs: Document the ABI for Guarded Control Stacks

2024-08-21 Thread Mark Brown
Add some documentation of the userspace ABI for Guarded Control Stacks. Reviewed-by: Thiago Jung Bauermann Signed-off-by: Mark Brown --- Documentation/arch/arm64/gcs.rst | 230 + Documentation/arch/arm64/index.rst | 1 + 2 files changed, 231 insertions(+)

[PATCH v11 05/39] arm64: Document boot requirements for Guarded Control Stacks

2024-08-21 Thread Mark Brown
FEAT_GCS introduces a number of new system registers, we require that access to these registers is not trapped when we identify that the feature is present. There is also a HCRX_EL2 control to make GCS operations functional. Since if GCS is enabled any function call instruction will cause a fault

[PATCH v11 04/39] mman: Add map_shadow_stack() flags

2024-08-21 Thread Mark Brown
In preparation for adding arm64 GCS support make the map_shadow_stack() SHADOW_STACK_SET_TOKEN flag generic and add _SET_MARKER. The existing flag indicates that a token usable for stack switch should be added to the top of the newly mapped GCS region while the new flag indicates that a top of stac

[PATCH v11 03/39] prctl: arch-agnostic prctl for shadow stack

2024-08-21 Thread Mark Brown
Three architectures (x86, aarch64, riscv) have announced support for shadow stacks with fairly similar functionality. While x86 is using arch_prctl() to control the functionality neither arm64 nor riscv uses that interface so this patch adds arch-agnostic prctl() support to get and set status of s

[PATCH v11 02/39] arm64/mm: Restructure arch_validate_flags() for extensibility

2024-08-21 Thread Mark Brown
Currently arch_validate_flags() is written in a very non-extensible fashion, returning immediately if MTE is not supported and writing the MTE check as a direct return. Since we will want to add more checks for GCS refactor the existing code to be more extensible, no functional change intended. Re

[PATCH v11 01/39] mm: Introduce ARCH_HAS_USER_SHADOW_STACK

2024-08-21 Thread Mark Brown
Since multiple architectures have support for shadow stacks and we need to select support for this feature in several places in the generic code provide a generic config option that the architectures can select. Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Reviewed-by: Deepak Gupt

[PATCH v11 00/39] arm64/gcs: Provide support for GCS in userspace

2024-08-21 Thread Mark Brown
The arm64 Guarded Control Stack (GCS) feature provides support for hardware protected stacks of return addresses, intended to provide hardening against return oriented programming (ROP) attacks and to make it easier to gather call stacks for applications such as profiling. When GCS is active a sec

Re: [PATCH 1/1] Improve missing mods error message and make shell script executable

2024-08-21 Thread Jakub Kicinski
On Tue, 20 Aug 2024 16:21:16 -0400 David Hunter wrote: > Subject: [PATCH 1/1] Improve missing mods error message and make shell script > executable Would be good to add a prefix to the subject: selftests: net: > Make the test executable. Currently, tests in this shell script are not > executabl

Re: [PATCH net] selftests: mlxsw: ethtool_lanes: Source ethtool lib from correct path

2024-08-21 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net.git (main) by Jakub Kicinski : On Tue, 20 Aug 2024 12:53:47 +0200 you wrote: > From: Ido Schimmel > > Source the ethtool library from the correct path and avoid the following > error: > > ./ethtool_lanes.sh: line 14: ./../../../net/forwarding/ethtool

Re: [PATCH net-next v6] net: netconsole: selftests: Create a new netconsole selftest

2024-08-21 Thread Jakub Kicinski
On Wed, 21 Aug 2024 11:50:40 +0200 Matthieu Baerts wrote: > > + echo "SKIP: IPs already in use. Skippig it" >&2 > > Skippig: is it because netconsole is vegetarian? Let's do one more rev :) -- pw-bot: cr

Re: [PATCH v3 7/7] selftests/mm: add more mseal traversal tests

2024-08-21 Thread Pedro Falcato
Andrew, please squash this small patch with this one. It directly addresses a problem found in review. (I was told this is the preferred way to send small fixups, and I don't think anyone wants a v4 over this trivial issue) Thank you! 8< >From 614e5dc27073c39579c863ebdff4396948e28e03 Mon

Re: [PATCH 3/4] kunit: Allow function redirection outside of the KUnit thread

2024-08-21 Thread Michal Wajdeczko
On 21.08.2024 23:38, Lucas De Marchi wrote: > On Wed, Aug 21, 2024 at 04:43:04PM GMT, Michal Wajdeczko wrote: >> Currently, the 'static stub' API only allows function redirection >> for calls made from the kthread of the current test, which prevents >> the use of this functionalty when the teste

Re: [PATCH] selftests/bpf: Fix incorrect parameters in NULL pointer checking

2024-08-21 Thread Dan Carpenter
On Wed, Aug 21, 2024 at 03:07:27PM -0700, Alexei Starovoitov wrote: > On Wed, Aug 21, 2024 at 2:50 PM Dan Carpenter > wrote: > > > > On Wed, Aug 21, 2024 at 02:03:17PM -0700, Yonghong Song wrote: > > > > > > On 8/19/24 7:34 PM, Hao Ge wrote: > > > > From: Hao Ge > > > > > > > > Smatch reported t

Re: [PATCH net-next v19 03/13] netdev: support binding dma-buf to netdevice

2024-08-21 Thread Jakub Kicinski
On Wed, 21 Aug 2024 11:36:31 -0400 Mina Almasry wrote: > Additionally I'm wondering if we should disable adding mp-bound > devices as slaves completely, regardless of xdp. My concern is that if > the lower device is using unreadable memory, then the upper device may > see unreadable memory in its c

Re: [PATCH v3 1/3] riscv: mm: Use hint address in mmap if available

2024-08-21 Thread Palmer Dabbelt
On Mon, 19 Aug 2024 18:58:18 PDT (-0700), rsworkt...@outlook.com wrote: On 2024-08-20 01:00, Charlie Jenkins wrote: On Mon, Aug 19, 2024 at 01:55:57PM +0800, Levi Zim wrote: On 2024-03-22 22:06, Palmer Dabbelt wrote: On Thu, 01 Feb 2024 18:28:06 PST (-0800), Charlie Jenkins wrote: On Wed, Jan

Re: [PATCH] selftests/bpf: Fix incorrect parameters in NULL pointer checking

2024-08-21 Thread Alexei Starovoitov
On Wed, Aug 21, 2024 at 2:50 PM Dan Carpenter wrote: > > On Wed, Aug 21, 2024 at 02:03:17PM -0700, Yonghong Song wrote: > > > > On 8/19/24 7:34 PM, Hao Ge wrote: > > > From: Hao Ge > > > > > > Smatch reported the following warning: > > > ./tools/testing/selftests/bpf/testing_helpers.c:455 >

Re: [PATCH 4/4] kunit: Add example with alternate function redirection method

2024-08-21 Thread Michal Wajdeczko
On 21.08.2024 23:22, Rae Moar wrote: > On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko > wrote: >> >> Add example how to use KUNIT_FIXED_STUB_REDIRECT and compare its >> usage with the KUNIT_STATIC_STUB_REDIRECT. Also show how the >> DECLARE_IF_KUNIT macro could be helpful in declaring test d

Re: [PATCH] selftests/bpf: Fix incorrect parameters in NULL pointer checking

2024-08-21 Thread Dan Carpenter
On Wed, Aug 21, 2024 at 02:03:17PM -0700, Yonghong Song wrote: > > On 8/19/24 7:34 PM, Hao Ge wrote: > > From: Hao Ge > > > > Smatch reported the following warning: > > ./tools/testing/selftests/bpf/testing_helpers.c:455 > > get_xlated_program() > > warn: variable dereferenced before

Re: [PATCH 3/4] kunit: Allow function redirection outside of the KUnit thread

2024-08-21 Thread Michal Wajdeczko
On 21.08.2024 23:32, Rae Moar wrote: > On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko > wrote: >> > Hello! > > This is looking good and seems to be working well. I just had some > questions below. > > Thanks! > -Rae > >> Currently, the 'static stub' API only allows function redirection >>

Re: [PATCH net-next v3 4/8] selftests/net: Open /proc/thread-self in open_netns()

2024-08-21 Thread Dmitry Safonov
On Wed, 21 Aug 2024 at 20:11, Simon Horman wrote: > > On Thu, Aug 15, 2024 at 10:32:29PM +0100, Dmitry Safonov via B4 Relay wrote: > > From: Dmitry Safonov <0x7f454...@gmail.com> > > > > It turns to be that open_netns() is called rarely from the child-thread > > and more often from parent-thread.

Re: [PATCH 3/4] kunit: Allow function redirection outside of the KUnit thread

2024-08-21 Thread Lucas De Marchi
On Wed, Aug 21, 2024 at 04:43:04PM GMT, Michal Wajdeczko wrote: Currently, the 'static stub' API only allows function redirection for calls made from the kthread of the current test, which prevents the use of this functionalty when the tested code is also used by other threads, outside of the KUn

Re: [PATCH net-next v3 2/8] selftests/net: Provide test_snprintf() helper

2024-08-21 Thread Dmitry Safonov
Hi Simon, On Wed, 21 Aug 2024 at 20:10, Simon Horman wrote: > > On Thu, Aug 15, 2024 at 10:32:27PM +0100, Dmitry Safonov via B4 Relay wrote: > > From: Dmitry Safonov <0x7f454...@gmail.com> > > > > Instead of pre-allocating a fixed-sized buffer of TEST_MSG_BUFFER_SIZE > > and printing into it, cal

Re: [PATCH 3/4] kunit: Allow function redirection outside of the KUnit thread

2024-08-21 Thread Rae Moar
On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko wrote: > Hello! This is looking good and seems to be working well. I just had some questions below. Thanks! -Rae > Currently, the 'static stub' API only allows function redirection > for calls made from the kthread of the current test, which pre

Re: [PATCH 1/4] kunit: Introduce kunit_is_running()

2024-08-21 Thread Lucas De Marchi
On Wed, Aug 21, 2024 at 04:43:02PM GMT, Michal Wajdeczko wrote: Wrap uses of the static key 'kunit_running' into a helper macro to allow future checks to be placed in the code residing outside of the CONFIG_KUNIT. We will start using this in upcoming patch. Signed-off-by: Michal Wajdeczko Re

Re: [PATCH 4/4] kunit: Add example with alternate function redirection method

2024-08-21 Thread Rae Moar
On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko wrote: > > Add example how to use KUNIT_FIXED_STUB_REDIRECT and compare its > usage with the KUNIT_STATIC_STUB_REDIRECT. Also show how the > DECLARE_IF_KUNIT macro could be helpful in declaring test data in > the non-test data structures. > > Signe

Re: [PATCH 2/4] kunit: Add macro to conditionally expose declarations to tests

2024-08-21 Thread Rae Moar
On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko wrote: > > The DECLARE_IF_KUNIT macro will introduces identifiers only if > CONFIG_KUNIT is enabled. Otherwise if CONFIG_KUNIT is not enabled > no identifiers from the param list will be defined. > > Signed-off-by: Michal Wajdeczko Hello! I like

Re: [PATCH 1/4] kunit: Introduce kunit_is_running()

2024-08-21 Thread Rae Moar
On Wed, Aug 21, 2024 at 10:43 AM Michal Wajdeczko wrote: > > Wrap uses of the static key 'kunit_running' into a helper macro > to allow future checks to be placed in the code residing outside > of the CONFIG_KUNIT. We will start using this in upcoming patch. > > Signed-off-by: Michal Wajdeczko H

Re: [PATCH] selftests/bpf: Fix incorrect parameters in NULL pointer checking

2024-08-21 Thread Yonghong Song
On 8/19/24 7:34 PM, Hao Ge wrote: From: Hao Ge Smatch reported the following warning: ./tools/testing/selftests/bpf/testing_helpers.c:455 get_xlated_program() warn: variable dereferenced before check 'buf' (see line 454) It seems correct,so let's modify it based on it's suggestion.

Re: [PATCH bpf-next v4 2/2] selftests/bpf: Add mptcp subflow subtest

2024-08-21 Thread Manu Bretelle
> On Aug 13, 2024, at 6:12 PM, Martin KaFai Lau wrote: > > > > On 8/5/24 2:52 AM, Matthieu Baerts (NGI0) wrote: >> +static int endpoint_init(char *flags) >> +{ >> + SYS(fail, "ip -net %s link add veth1 type veth peer name veth2", NS_TEST); >> + SYS(fail, "ip -net %s addr add %s/24 dev veth1",

Re: [PATCH bpf-next v2 2/2] selftests/bpf: Add mptcp subflow subtest

2024-08-21 Thread Manu Bretelle
> On May 10, 2024, at 12:21 PM, Manu Bretelle wrote: > > > > On 5/10/24, 7:06 AM, "Alexei Starovoitov" > wrote: > > > > > > On Thu, May 9, 2024 at 11:31 AM Matthieu Baerts > wrote: >> >> Hello, >> >> On 09/05/2024 17:49

[PATCH RFT v10 8/8] selftests/clone3: Test shadow stack support

2024-08-21 Thread Mark Brown
Add basic test coverage for specifying the shadow stack for a newly created thread via clone3(), including coverage of the newly extended argument structure. We check that a user specified shadow stack can be provided, and that invalid combinations of parameters are rejected. In order to facilita

[PATCH RFT v10 7/8] selftests/clone3: Allow tests to flag if -E2BIG is a valid error code

2024-08-21 Thread Mark Brown
The clone_args structure is extensible, with the syscall passing in the length of the structure. Inside the kernel we use copy_struct_from_user() to read the struct but this has the unfortunate side effect of silently accepting some overrun in the structure size providing the extra data is all zero

[PATCH RFT v10 6/8] selftests/clone3: Factor more of main loop into test_clone3()

2024-08-21 Thread Mark Brown
In order to make it easier to add more configuration for the tests and more support for runtime detection of when tests can be run pass the structure describing the tests into test_clone3() rather than picking the arguments out of it and have that function do all the per-test work. No functional c

[PATCH RFT v10 5/8] selftests/clone3: Remove redundant flushes of output streams

2024-08-21 Thread Mark Brown
Since there were widespread issues with output not being flushed the kselftest framework was modified to explicitly set the output streams unbuffered in commit 58e2847ad2e6 ("selftests: line buffer test program's stdout") so there is no need to explicitly flush in the clone3 tests. Reviewed-by: Ke

[PATCH RFT v10 4/8] fork: Add shadow stack support to clone3()

2024-08-21 Thread Mark Brown
Unlike with the normal stack there is no API for configuring the the shadow stack for a new thread, instead the kernel will dynamically allocate a new shadow stack with the same size as the normal stack. This appears to be due to the shadow stack series having been in development since before the m

[PATCH RFT v10 3/8] mm: Introduce ARCH_HAS_USER_SHADOW_STACK

2024-08-21 Thread Mark Brown
Since multiple architectures have support for shadow stacks and we need to select support for this feature in several places in the generic code provide a generic config option that the architectures can select. Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Reviewed-by: Deepak Gupt

[PATCH RFT v10 2/8] selftests: Provide helper header for shadow stack testing

2024-08-21 Thread Mark Brown
While almost all users of shadow stacks should be relying on the dynamic linker and libc to enable the feature there are several low level test programs where it is useful to enable without any libc support, allowing testing without full system enablement. This low level testing is helpful during b

[PATCH RFT v10 1/8] Documentation: userspace-api: Add shadow stack API documentation

2024-08-21 Thread Mark Brown
There are a number of architectures with shadow stack features which we are presenting to userspace with as consistent an API as we can (though there are some architecture specifics). Especially given that there are some important considerations for userspace code interacting directly with the feat

[PATCH RFT v10 0/8] fork: Support shadow stacks in clone3()

2024-08-21 Thread Mark Brown
The kernel has recently added support for shadow stacks, currently x86 only using their CET feature but both arm64 and RISC-V have equivalent features (GCS and Zicfiss respectively), I am actively working on GCS[1]. With shadow stacks the hardware maintains an additional stack containing only the

[PATCH 3/3] kunit: Improve format of the KUNIT_EXPECT_EQ assertion

2024-08-21 Thread Michal Wajdeczko
Diagnostic message for failed KUNIT_ASSERT|EXPECT_EQ shows in case of integers only raw values, like for this example: bool flag; KUNIT_EXPECT_EQ(test, 0, kstrtobool("dunno", &flag)); we will get: [ ] Expected 0 == kstrtobool("dunno", &flag), but [ ] kstrtobool("dunno", &flag) == -22

[PATCH 2/3] kunit: Improve format of the PTR_EQ|NE|NULL assertion

2024-08-21 Thread Michal Wajdeczko
Diagnostic message for failed KUNIT_ASSERT|EXPECT_PTR_EQ|NE|NULL shows only raw pointer value, like for this example: void *ptr1 = ERR_PTR(-ENOMEM); void *ptr2 = NULL; KUNIT_EXPECT_PTR_EQ(test, ptr1, ptr2); KUNIT_EXPECT_NULL(test, ptr1); we will get: [ ] Expected ptr1 == ptr2, but [

[PATCH 0/3] kunit: Improve format of some assertion messages

2024-08-21 Thread Michal Wajdeczko
This is mostly a re-post of a series [1] that was apparently lost last year. [1] https://lore.kernel.org/all/20230928133821.1467-1-michal.wajdec...@intel.com/ Cc: David Gow Cc: Rae Moar Michal Wajdeczko (3): kunit: Improve format of the NOT_ERR_OR_NULL assertion kunit: Improve format of t

[PATCH 1/3] kunit: Improve format of the NOT_ERR_OR_NULL assertion

2024-08-21 Thread Michal Wajdeczko
Diagnostic message for failed KUNIT_ASSERT|EXPECT_NOT_ERR_OR_NULL shows only raw error code, like for this example: void *myptr = ERR_PTR(-ENOMEM); KUNIT_EXPECT_NOT_ERR_OR_NULL(test, myptr); we will get: [ ] Expected myptr is not error, but is: -12 but we can improve it by using more frie

Re: [PATCH net-next v3 4/8] selftests/net: Open /proc/thread-self in open_netns()

2024-08-21 Thread Simon Horman
On Thu, Aug 15, 2024 at 10:32:29PM +0100, Dmitry Safonov via B4 Relay wrote: > From: Dmitry Safonov <0x7f454...@gmail.com> > > It turns to be that open_netns() is called rarely from the child-thread > and more often from parent-thread. Yet, on initialization of kconfig > checks, either of threads

Re: [PATCH net-next v3 2/8] selftests/net: Provide test_snprintf() helper

2024-08-21 Thread Simon Horman
On Thu, Aug 15, 2024 at 10:32:27PM +0100, Dmitry Safonov via B4 Relay wrote: > From: Dmitry Safonov <0x7f454...@gmail.com> > > Instead of pre-allocating a fixed-sized buffer of TEST_MSG_BUFFER_SIZE > and printing into it, call vsnprintf() with str = NULL, which will > return the needed size of the

[PATCH] ftrace/selftest: Test combination of function_graph tracer and function profiler

2024-08-21 Thread Steven Rostedt
From: Steven Rostedt Masami reported a bug when running function graph tracing then the function profiler. The following commands would cause a kernel crash: # cd /sys/kernel/tracing/ # echo function_graph > current_tracer # echo 1 > function_profile_enabled In that order. Create a test t

Re: [PATCH RESEND v5] rust: str: Use `core::CStr`, remove the custom `CStr` implementation

2024-08-21 Thread Benno Lossin
On 21.08.24 14:08, Alice Ryhl wrote: > On Mon, Aug 19, 2024 at 5:39 PM Michal Rostecki wrote: >> >> From: Michal Rostecki >> >> `CStr` became a part of `core` library in Rust 1.75. This change replaces >> the custom `CStr` implementation with the one from `core`. >> >> `core::CStr` behaves genera

  1   2   >