Re: [PATCH v7 13/39] arm64/mm: Map pages for guarded control stack

2023-12-03 Thread Thiago Jung Bauermann
Hello, Mark Brown writes: > diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c > index 645fe60d000f..605d4e6edc1d 100644 > --- a/arch/arm64/mm/mmap.c > +++ b/arch/arm64/mm/mmap.c > @@ -79,9 +79,20 @@ arch_initcall(adjust_protection_map); > > pgprot_t vm_get_page_prot(unsigned long vm_

Re: [PATCH v7 21/39] arm64/gcs: Allocate a new GCS for threads with GCS enabled

2023-12-06 Thread Thiago Jung Bauermann
Mark Brown writes: > When a new thread is created by a thread with GCS enabled the GCS needs > to be specified along with the regular stack. clone3() has been > extended to support this case, allowing userspace to explicitly request > the size for the GCS to be created, but plain clone() is no

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

2023-12-06 Thread Thiago Jung Bauermann
Mark Brown writes: > Implement the architecture neutral prtctl() 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 pu

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

2023-12-06 Thread Thiago Jung Bauermann
Mark Brown writes: > Since the x86 code has not yet been rebased to v6.5-rc1 this includes > the architecture neutral parts of Rick Edgecmbe's "x86/shstk: Introduce > map_shadow_stack syscall". This paragraph can be dropped now. -- Thiago

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

2023-12-08 Thread Thiago Jung Bauermann
Mark Brown writes: > +static bool gcs_signal_cap_valid(u64 addr, u64 val) > +{ > + /* > + * The top bit should be set, this is an invalid address for > + * EL0 and will only be set for caps created by signals. > + */ > + if (!(val & GCS_SIGNAL_CAP_FLAG)) > + r

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

2023-12-09 Thread Thiago Jung Bauermann
Mark Brown writes: > +static int preserve_gcs_context(struct gcs_context __user *ctx) > +{ > + int err = 0; > + u64 gcspr; > + > + /* > + * We will add a cap token to the frame, include it in the > + * GCSPR_EL0 we report to support stack switching via > + * sigreturn

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

2023-12-09 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. The

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

2023-12-12 Thread Thiago Jung Bauermann
I'm going a bit out-of-order to report a build failure in a test: Mark Brown writes: > +// Recurse x20 times > +.macro recurse id I get an assembler error here: gcc -nostdlib gcs-stress-thread.S -o /home/thiago.bauermann/src/linux/tools/testing/selftests/arm64/gcs/gcs-stress-thread gcs-stre

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

2023-12-14 Thread Thiago Jung Bauermann
Mark Brown writes: > + /* Same thing via process_vm_readv() */ > + local_iov.iov_base = &rval; > + local_iov.iov_len = sizeof(rval); > + remote_iov.iov_base = (void *)gcspr; > + remote_iov.iov_len = sizeof(rval); > + ret = process_vm_writev(child, &local_iov, 1, &remote_

Re: [PATCH v7 36/39] selftests/arm64: Add GCS signal tests

2023-12-16 Thread Thiago Jung Bauermann
Mark Brown writes: > diff --git > a/tools/testing/selftests/arm64/signal/testcases/gcs_exception_fault.c > b/tools/testing/selftests/arm64/signal/testcases/gcs_exception_fault.c > new file mode 100644 > index ..532d533592a1 > --- /dev/null > +++ b/tools/testing/selftests/arm64/sig

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

2023-12-16 Thread Thiago Jung Bauermann
Mark Brown writes: >> Also, it's strange that the tests defined after map_gcs.stack_overflow >> don't run when I execute this test program. I'm doing: > >> $ ./run_kselftest.sh -t arm64:libc-gcs > >> I.e., these tests aren't being run in my FVP: > >> > +FIXTURE_VARIANT_ADD(map_invalid_gcs, too_

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

2023-12-19 Thread Thiago Jung Bauermann
Mark Brown writes: > arm64/mm: Restructure arch_validate_flags() for extensibility > prctl: arch-agnostic prctl for shadow stack > mman: Add map_shadow_stack() flags > arm64: Document boot requirements for Guarded Control Stacks > arm64/gcs: Document the ABI for Gu

Re: [PATCH v8 00/38] arm64/gcs: Provide support for GCS in userspace

2024-02-19 Thread Thiago Jung Bauermann
nto latest clone3() series. > - Link to v7: > https://lore.kernel.org/r/20231122-arm64-gcs-v7-0-201c483bd...@kernel.org Thank you for addressing my comments. I still have a few nets and questions in a few patches, but regardless of them: Reviewed-by: Thiago Jung Bauermann -- Thiago

Re: [PATCH v8 20/38] arm64/gcs: Ensure that new threads have a GCS

2024-02-19 Thread Thiago Jung Bauermann
Mark Brown writes: > When a new thread is created by a thread with GCS enabled the GCS needs > to be specified along with the regular stack. clone3() has been > extended to support this case, allowing userspace to explicitly specify > the size and location of the GCS. The specified GCS must h

Re: [PATCH v8 23/38] arm64/signal: Set up and restore the GCS context for signal handlers

2024-02-19 Thread Thiago Jung Bauermann
Mark Brown writes: > +#ifdef CONFIG_ARM64_GCS > +static int gcs_restore_signal(void) > +{ > + u64 gcspr_el0, cap; > + int ret; > + > + if (!system_supports_gcs()) > + return 0; > + > + if (!(current->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE)) > + retu

Re: [PATCH v8 33/38] kselftest/arm64: Add a GCS test program built with the system libc

2024-02-19 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. > > Signed-off-by: Mark Brown >

Re: [PATCH v8 35/38] selftests/arm64: Add GCS signal tests

2024-02-19 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. > > Signed-off-by: Mark Brown > --- > tools/testing/selftests/arm64/signal/.gitignore|

Re: [PATCH v8 33/38] kselftest/arm64: Add a GCS test program built with the system libc

2024-02-22 Thread Thiago Jung Bauermann
Mark Brown writes: > On Mon, Feb 19, 2024 at 11:15:57PM -0300, Thiago Jung Bauermann wrote: > >> The only issue as can be seen above is that the can_call_function test >> is failing. The child is getting a GCS Segmentation fault when returning >> from fork(). > >&

Re: [PATCH v8 33/38] kselftest/arm64: Add a GCS test program built with the system libc

2024-02-27 Thread Thiago Jung Bauermann
Mark Brown writes: > [[PGP Signed Part:Undecided]] > On Thu, Feb 22, 2024 at 11:24:59PM -0300, Thiago Jung Bauermann wrote: >> Mark Brown writes: > >> My rootfs is Ubuntu 22.04.3. In case it's useful, my kernel config is >> here: > >> https://peopl

Re: [PATCH v8 33/38] kselftest/arm64: Add a GCS test program built with the system libc

2024-02-29 Thread Thiago Jung Bauermann
Mark Brown writes: > [[PGP Signed Part:Undecided]] > On Thu, Feb 22, 2024 at 11:24:59PM -0300, Thiago Jung Bauermann wrote: >> Mark Brown writes: > >> > I believe based on prior discussions that you're running this using >> > shrinkwrap - can you confir

Re: [PATCH RFT v6 3/9] mm: Introduce ARCH_HAS_USER_SHADOW_STACK

2024-07-15 Thread Thiago Jung Bauermann
Hello, > diff --git a/mm/Kconfig b/mm/Kconfig > index b4cb45255a54..45416916dec1 100644 > --- a/mm/Kconfig > +++ b/mm/Kconfig > @@ -1249,6 +1249,12 @@ config IOMMU_MM_DATA > config EXECMEM > bool > > +config ARCH_HAS_USER_SHADOW_STACK > + bool > + help > + The architecture

Re: [PATCH v9 05/39] arm64/gcs: Document the ABI for Guarded Control Stacks

2024-07-16 Thread Thiago Jung Bauermann
Mark Brown writes: > +3. Allocation of Guarded Control Stacks > + > + > +* When GCS is enabled for a thread a new Guarded Control Stack will be > + allocated for it of size RLIMIT_STACK or 4 gigabytes, whichever is s/4 gigabytes/2 gigabytes/ > + smalle

Re: [PATCH v9 20/39] arm64/gcs: Ensure that new threads have a GCS

2024-07-16 Thread Thiago Jung Bauermann
Mark Brown writes: > diff --git a/arch/arm64/mm/gcs.c b/arch/arm64/mm/gcs.c > index b0a67efc522b..4a3ce8e3bdfb 100644 > --- a/arch/arm64/mm/gcs.c > +++ b/arch/arm64/mm/gcs.c > @@ -8,6 +8,139 @@ > #include > #include > > +static unsigned long alloc_gcs(unsigned long addr, unsigned long size,

Re: [PATCH v9 35/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > 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. > > Review

Re: [PATCH v9 35/39] kselftest/arm64: Add a GCS test program built with the system libc

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > On Thu, Jul 18, 2024 at 01:14:41PM -0300, Thiago Jung Bauermann wrote: > >> In my FVP VM, this test gets a GCS SIGSEGV before running the first test: > > Do you have THP enabled? That still doesn't work (I'm expecting it to > be fixed wit

Re: [PATCH v9 37/39] kselftest/arm64: Add GCS signal tests

2024-07-18 Thread Thiago Jung Bauermann
Mark Brown writes: > 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 >

Re: [PATCH v9 38/39] kselftest/arm64: Add a GCS stress test

2024-07-18 Thread Thiago Jung Bauermann
for example failure to ensure that barriers > are inserted when moving a GCS using task to another CPU. The test runs for > a configurable amount of time, defaulting to 10 seconds. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests

Re: [PATCH v9 38/39] kselftest/arm64: Add a GCS stress test

2024-07-18 Thread Thiago Jung Bauermann
Thiago Jung Bauermann writes: > # # Finishing up... > # # Thread-4030 exited with error code 255 > # not ok 1 Thread-4030 > # # Thread-4031 exited with error code 255 > # not ok 2 Thread-4031 > # # Thread-4032 exited with error code 255 > # not ok 3 Thread-4032 > # #

Re: [PATCH v10 27/40] kselftest/arm64: Verify the GCS hwcap

2024-08-07 Thread Thiago Jung Bauermann
Hello, Mark Brown writes: > 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/selfte

Re: [PATCH v10 29/40] selftests/clone3: Enable arm64 shadow stack testing

2024-08-07 Thread Thiago Jung Bauermann
+++ > 1 file changed, 26 insertions(+) Reviewed-by: Thiago Jung Bauermann The clone3 test passes on my FVP setup: Tested-by: Thiago Jung Bauermann -- Thiago

Re: [PATCH v10 34/40] kselftest/arm64: Add very basic GCS test program

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > 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/

Re: [PATCH v10 35/40] kselftest/arm64: Add a GCS test program built with the system libc

2024-08-07 Thread Thiago Jung Bauermann
> +++ > 4 files changed, 750 insertions(+), 1 deletion(-) The libc-gcs test passes on my FVP setup: Tested-by: Thiago Jung Bauermann -- Thiago

Re: [PATCH v10 36/40] kselftest/arm64: Add test coverage for GCS mode locking

2024-08-07 Thread Thiago Jung Bauermann
toolchains with support for enabling GCS by default we will > need to take care to not do that in the build system but there are no > such toolchains yet so it is not yet an issue. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests/

Re: [PATCH v10 37/40] kselftest/arm64: Add GCS signal tests

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > 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 >

Re: [PATCH v10 38/40] kselftest/arm64: Add a GCS stress test

2024-08-07 Thread Thiago Jung Bauermann
for example failure to ensure that barriers > are inserted when moving a GCS using task to another CPU. The test runs for > a configurable amount of time, defaulting to 10 seconds. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests

Re: [PATCH v10 38/40] kselftest/arm64: Add a GCS stress test

2024-08-07 Thread Thiago Jung Bauermann
Mark Brown writes: > On Wed, Aug 07, 2024 at 07:39:54PM -0300, Thiago Jung Bauermann wrote: > >> # # Thread-4870: Failed to enable GCS > > which is printed if a basic PR_SET_SHADOW_STACK_STATUS fails immediately > the program starts executing: > > function _star

Re: [PATCH v10 39/40] kselftest/arm64: Enable GCS for the FP stress tests

2024-08-07 Thread Thiago Jung Bauermann
sts enable GCS on startup, ignoring failures so > they continue to work as before on systems without GCS. > > Reviewed-by: Thiago Jung Bauermann > Signed-off-by: Mark Brown > --- > tools/testing/selftests/arm64/fp/assembler.h | 15 +++ > tools/testing/selftests/a