mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Dave Hansen <dave.hansen@linux.intel.com>, linux-kernel@vger.kernel.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Rick P <rick.p.edgecombe@intel.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	Kees Cook <kees@kernel.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>, Thomas Gleixner <tglx@kernel.org>
Subject: Re: [RFC][PATCH 00/24] x86 Kernel Shadow Stacks
Date: Fri, 23 Oct 2026 03:21:29 +0100	[thread overview]
Message-ID: <c8accd0f-118e-49ae-839d-7474250b14e4@citrix.com> (raw)
In-Reply-To: <20261021195120.E61EC737@davehans-spike.ostc.intel.com>

On 21/10/2026 8:51 pm, Dave Hansen wrote:
> == Warts ==
>
> In order of things I want folks looking at.
>
>  * The shadow stack is not used for the init_task. The most ideal
>    thing would be to find a convenient, simple time where the regular
>    stack is shallow and it is simple to create a corresponding shadow
>    stack. This is not currently done.
>  * The context switching assembly is overly complicated and also
>    subverts the safety in the architecture-intended
>    RSTORSSP/SAVEPREVSSP sequence. This is more nicely fixed once all
>    tasks have a shadow stack, including the init task.
>  * Locating the FRED shadow stack event frame is ugly ("Stash kernel
>    SSP on FRED entry"). It is currently implemented by reading the
>    shadow stack pointer during event entry and stashing it on the
>    normal stack. Xen seems to accomplish the goal by unwinding the
>    stack instead, which has more complicated code, but has adds no
>    complexity or overhead to event entry or the entry data structures.

Xen is already in the process of moving to stashing on entry.

Unwinding the shadow stack was necessary at first, and it has taken a
while to sort out some prerequisites, but I don't recommend it as an
approach.


>  * The direct map alias of the shadow stack is left in place. This
>    means that an attacker can write to the shadow stack without needing
>    to leverage one of the very limited WRSS kernel sites. This is a
>    big weakness in the security model. But, kernel shadow stacks with
>    this weakness are still way better than no kernel shadow stacks.
>
> == Future Work / TODO ==
>
>  * The main thing left is to chew through the list of things in the
>    last patch that are incompatible with kernel shadow stacks. There
>    are some quite essential things in there.
>  * Add a "warn on #CP and continue". Good for debugging. But, bad
>    for security. Ideally, a secure kernel would have no easy to
>    reach gadgets to disable shadow stacks.

This looks attractive at first glance, but it's really not.  There is no
safe way to turn CET-SS off.

WRSS, RSTORSSP and INCSSP will #UD when you turn CET-SS off, and even
logic such as

    if (!ssef)
        return;
    wrss(ip, &ssef->ssef_lip);

in regs_set_return_ip() will die with a #UD as you're attempting to not
die from a #CP.

I suggest just leave CET-SS on and power through the reports.  It will
probably be faster overall, and it will definitely be a better end result.


>  * Zap the direct map shadow stack alias. Might also require some
>    performance optimization work to try and constrain the shadow
>    stack allocations to a more modest set of the physical address
>    space so the direct map damage is lessened.
>  * Work with non-vmap stacks
>  * Work with IDT-based systems (without FRED)

🤣  A courageous plan.

~Andrew

  parent reply	other threads:[~2026-10-23  2:21 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 19:51 Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 01/24] kernel/fork: Break out vmap task allocation into helper Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 02/24] kernel/fork: Use sizeof() union instead of TASK_SIZE Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 03/24] kernel/sched: Move thread stack to its own structure Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 04/24] kernel/fork: Allow arch-specific stack initialization Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 05/24] kernel/task: Add shadow stack to thread structure Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 06/24] kernel/task: Add "runtime" check for shadow stack support Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 07/24] kernel/fork: Clear shadow stacks alongside normal stacks Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 08/24] x86/cpu: Add basic x86 kernel shadow stack infrastructure Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 09/24] x86/cea: Refactor "CEA" macros to deal with multiple stacks Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 10/24] x86/cea: Refactor stack mapping macros Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 11/24] x86/mm: Add kernel shadow stack permission macros Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 12/24] x86/cea: Map and use FRED exception shadow stacks Dave Hansen
2026-10-21 21:40   ` Peter Zijlstra
2026-10-21 22:59     ` Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 13/24] x86/task: Grow thread_union for " Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 14/24] x86/mm: Establish shadow stack permissions in thread mapping Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 15/24] x86/task: Hook up arch hook to detect shadow stack enabling Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 16/24] x86/mm: Kill shadow stack page permission warning Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 17/24] x86/task: Context switch the kernel shadow stack register value Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 18/24] kernel/task: Add a helper to get the thread_union Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 19/24] x86/process: Initialize cloned task shadow stack Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 20/24] x86/entry: Stash kernel SSP on FRED entry Dave Hansen
2026-10-22 22:14   ` Andrew Cooper
2026-10-21 19:51 ` [RFC][PATCH 21/24] x86/extable: Update shadow stack entry frame during RIP overwrites Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 22/24] kernel/task: Add a helper to locate the top of the shadow stack Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 23/24] x86/entry: Populate FRED register for user=>kernel transitions Dave Hansen
2026-10-21 19:51 ` [RFC][PATCH 24/24] [DO NOT MERGE] x86/shstk: Depend out everything incompatible with kernel shadow stacks Dave Hansen
2026-10-22 21:35   ` Andrew Cooper
2026-10-22 21:38     ` Andrew Cooper
2026-10-21 21:36 ` [RFC][PATCH 00/24] x86 Kernel Shadow Stacks Peter Zijlstra
2026-10-21 21:53 ` Peter Zijlstra
2026-10-23  2:21 ` Andrew Cooper [this message]
2026-10-23  2:52   ` Edgecombe, Rick P

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=c8accd0f-118e-49ae-839d-7474250b14e4@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®