From: Nathan Chancellor <nathan@kernel.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Kees Cook <keescook@chromium.org>, Guo Ren <guoren@kernel.org>,
Deepak Gupta <debug@rivosinc.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Fangrui Song <maskray@google.com>,
linux-riscv@lists.infradead.org, llvm@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/5] riscv: SCS support
Date: Mon, 14 Aug 2023 10:59:28 -0700 [thread overview]
Message-ID: <20230814175928.GA1028706@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230811233556.97161-7-samitolvanen@google.com>
Hi Sami,
On Fri, Aug 11, 2023 at 11:35:57PM +0000, Sami Tolvanen wrote:
> Hi folks,
>
> This series adds Shadow Call Stack (SCS) support for RISC-V. SCS
> uses compiler instrumentation to store return addresses in a
> separate shadow stack to protect them against accidental or
> malicious overwrites. More information about SCS can be found
> here:
>
> https://clang.llvm.org/docs/ShadowCallStack.html
>
> Patch 1 is from Deepak, and it simplifies VMAP_STACK overflow
> handling by adding support for accessing per-CPU variables
> directly in assembly. The patch is included in this series to
> make IRQ stack switching cleaner with SCS, and I've simply
> rebased it. Patch 2 uses this functionality to clean up the stack
> switching by moving duplicate code into a single function. On
> RISC-V, the compiler uses the gp register for storing the current
> shadow call stack pointer, which is incompatible with global
> pointer relaxation. Patch 3 moves global pointer loading into a
> macro that can be easily disabled with SCS. Patch 4 implements
> SCS register loading and switching, and allows the feature to be
> enabled, and patch 5 adds separate per-CPU IRQ shadow call stacks
> when CONFIG_IRQ_STACKS is enabled.
>
> Note that this series requires Clang 17. Earlier Clang versions
> support SCS on RISC-V, but use the x18 register instead of gp,
> which isn't ideal. gcc has SCS support for arm64, but I'm not
> aware of plans to support RISC-V. Once the Zicfiss extension is
> ratified, it's probably preferable to use hardware-backed shadow
> stacks instead of SCS on hardware that supports the extension,
> and we may want to consider implementing CONFIG_DYNAMIC_SCS to
> patch between the implementation at runtime (similarly to the
> arm64 implementation, which switches to SCS when hardware PAC
> support isn't available).
I took this series for a spin on top of 6.5-rc6 with both LLVM 18 (built
within the past couple of days) and LLVM 17.0.0-rc2 but it seems that
the CFI_BACKWARDS LKDTM test does not pass with
CONFIG_SHADOW_CALL_STACK=y.
[ 73.324652] lkdtm: Performing direct entry CFI_BACKWARD
[ 73.324900] lkdtm: Attempting unchecked stack return address redirection ...
[ 73.325178] lkdtm: Eek: return address mismatch! 0000000000000002 != ffffffff80614982
[ 73.325478] lkdtm: FAIL: stack return address manipulation failed!
Does the test need to be adjusted or is there some other issue?
Cheers,
Nathan
next prev parent reply other threads:[~2023-08-14 17:59 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 23:35 [PATCH 0/5] riscv: SCS support Sami Tolvanen
2023-08-11 23:35 ` [PATCH 1/5] riscv: VMAP_STACK overflow detection thread-safe Sami Tolvanen
2023-08-12 14:35 ` kernel test robot
2023-08-13 1:25 ` Guo Ren
2023-08-14 15:34 ` Sami Tolvanen
2023-08-11 23:35 ` [PATCH 2/5] riscv: Deduplicate IRQ stack switching Sami Tolvanen
2023-08-11 23:36 ` [PATCH 3/5] riscv: Move global pointer loading to a macro Sami Tolvanen
2023-08-11 23:36 ` [PATCH 4/5] riscv: Implement Shadow Call Stack Sami Tolvanen
2023-08-11 23:36 ` [PATCH 5/5] riscv: Use separate IRQ shadow call stacks Sami Tolvanen
2023-08-14 17:59 ` Nathan Chancellor [this message]
2023-08-14 18:33 ` [PATCH 0/5] riscv: SCS support Kees Cook
2023-08-14 18:57 ` Sami Tolvanen
2023-08-14 20:18 ` Sami Tolvanen
2023-08-14 21:09 ` Kees Cook
2023-08-14 18:33 ` Sami Tolvanen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230814175928.GA1028706@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=debug@rivosinc.com \
--cc=guoren@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=maskray@google.com \
--cc=ndesaulniers@google.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox