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: <CACPK8Xcm2SeSStk2EBEcUoyiUc0=d6ce_MfnP=ce3z6MMXyuiw@mail.gmail.com>
Date: Tue, 4 Nov 2025 17:42:04 +1030
From: Joel Stanley <joel@....id.au>
To: debug@...osinc.com
Cc: Paul Walmsley <paul.walmsley@...ive.com>, Palmer Dabbelt <palmer@...belt.com>, 
	Albert Ou <aou@...s.berkeley.edu>, Conor Dooley <conor@...nel.org>, Arnd Bergmann <arnd@...db.de>, 
	Peter Zijlstra <peterz@...radead.org>, Kees Cook <kees@...nel.org>, linux-kernel@...r.kernel.org, 
	linux-riscv@...ts.infradead.org, linux-kselftest@...r.kernel.org, 
	alistair.francis@....com, richard.henderson@...aro.org, jim.shu@...ive.com, 
	andybnac@...il.com, kito.cheng@...ive.com, charlie@...osinc.com, 
	atishp@...osinc.com, evan@...osinc.com, cleger@...osinc.com, 
	alexghiti@...osinc.com, Michael Ellerman <mpe@...storrent.com>
Subject: Re: [PATCH v22 28/28] kselftest/riscv: kselftest for user mode cfi

On Fri, 24 Oct 2025 at 03:33, Deepak Gupta via B4 Relay
<devnull+debug.rivosinc.com@...nel.org> wrote:

> diff --git a/tools/testing/selftests/riscv/cfi/Makefile b/tools/testing/selftests/riscv/cfi/Makefile
> new file mode 100644
> index 000000000000..55165a93845f
> --- /dev/null
> +++ b/tools/testing/selftests/riscv/cfi/Makefile
> @@ -0,0 +1,16 @@
> +CFLAGS += -I$(top_srcdir)/tools/include
> +
> +CFLAGS += -march=rv64gc_zicfilp_zicfiss -fcf-protection=full
> +
> +ifeq ($(shell $(CC) $(CFLAGS) -nostdlib -xc /dev/null -o /dev/null > /dev/null 2>&1; echo $$?),0)
> +TEST_GEN_PROGS := cfitests|

I hacked this up a bit to get it working for me.

I added this at the top to use the local headers from a `make
headers`. Without this the selftest lacked the required ptrace
changes:

+CFLAGS += $(KHDR_INCLUDES)

I needed this before the ifeq so it used the cross compiler to perform
the test, otherwise the test was always false:

+# Check for zicfli* extensions needs cross compiler
+# which is not set until lib.mk is included
+ifeq ($(LLVM)$(CC),cc)
+CC := $(CROSS_COMPILE)gcc
+endif
+#nedif

Findally, a cosmetic one. If we set the name of the main test file to
be the same as the test, the rule from lib.mk will give us neat
output:

     make[2]: Entering directory 'tools/testing/selftests/riscv/cfi'
       CC       cfitests

--- a/tools/testing/selftests/riscv/cfi/Makefile
+++ b/tools/testing/selftests/riscv/cfi/Makefile
@@ -12,12 +12,11 @@ endif
 ifeq ($(shell $(CC) $(CFLAGS) -nostdlib -xc /dev/null -o /dev/null >
/dev/null 2>&1; echo $$?),0)
 TEST_GEN_PROGS := cfitests

-include ../../lib.mk
+$(OUTPUT)/cfitests: cfitests.c shadowstack.c

-$(OUTPUT)/cfitests: riscv_cfi_test.c shadowstack.c
-       $(CC) -o$@ $(CFLAGS) $(LDFLAGS) $^
 else
-include ../../lib.mk

 $(shell echo "Toolchain doesn't support CFI, skipping CFI kselftest." >&2)
 endif
+
+include ../../lib.mk

I can push up a branch with my changes if you'd like.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ