The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: "Andy Lutomirski" <luto@kernel.org>
Cc: "K Prateek Nayak" <kprateek.nayak@amd.com>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	"Thomas Gleixner" <tglx@kernel.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Rick P Edgecombe" <rick.p.edgecombe@intel.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Kees Cook" <kees@kernel.org>,
	"Pawan Gupta" <pawan.kumar.gupta@linux.intel.com>
Subject: Re: [RFC PATCH 04/27] x86/cet: Make kernel shadow stack #CP fatal instead of livelocking
Date: Sat, 5 Dec 2026 11:45:11 +0000	[thread overview]
Message-ID: <20261205114511.52d76d52@pumpkin> (raw)
In-Reply-To: <24cbe98e-17d0-4012-88d1-e3fe8a7b0082@app.fastmail.com>

On Fri, 04 Dec 2026 07:22:57 -0800
"Andy Lutomirski" <luto@kernel.org> wrote:

> On Fri, Dec 4, 2026, at 1:53 AM, David Laight wrote:
> > On Thu, 03 Dec 2026 21:47:23 -0800
> > "Andy Lutomirski" <luto@kernel.org> wrote:
> >  
> >> On Thu, Dec 3, 2026, at 7:39 PM, K Prateek Nayak wrote:  
> >> > Hello Andy,
> >> >    
> >>   
> >> >>> All of these should result in cleanly killing the offending task,
> >> >>> printing a log, *and still working correctly if it happens multiple
> >> >>> times*, which means we need to be able to escape from #DF context and
> >> >>> survive the do_exit experience.  Which will be great fun.
> >> >>>
> >> >>> Maybe this series already handles all of this.  Does it?    
> >> >
> >> > I'm not sure what the right call is for a #CP in kernel mode - that
> >> > really means someone has messed up the stack / has redirected regs->ip
> >> > to redirect execution without relying on the CET aware helpers.
> >> >
> >> > Since a return address in kernel has been hijacked, I don't think it
> >> > can be considered safe to allow program to return to the hijacked
> >> > address and eventually kill the task on exit to usermode right?    
> >> 
> >> ...
> >> 
> >>   
> >> > For #CP in kernel mode, I'm not too sure - I'll love to hear more form
> >> > the folks who have dealt with security aspects if the fault handler
> >> > should attempt some form of recovery - we can match the return address
> >> > on stack to that on the shadow stack but the integrity of the stack
> >> > at that point is questionable.    
> >> 
> >> 
> >> I think a decent heuristic should be to handle it like kernel stack overflow -- don't return per se but instead kill the offending task.
> >> 
> >> However, we have a bitrot situation here.  When I wrote the vmap stack code, I made a point of designing it to recover (so we could get logs!) from a stack overflow that got promoted to a double fault.  But I just read the code again and it's clearly broken.  I asked my friendly LLM to trace the bitrot, and it found:
> >> 
> >> commit 0d00449c7a28a1514595630735df383dec606812
> >> Author: Peter Zijlstra <peterz@infradead.org>
> >> Date:   Wed Feb 19 09:46:43 2020 +0100
> >> 
> >>     x86: Replace ist_enter() with nmi_enter()
> >>     
> >>     A few exceptions (like #DB and #BP) can happen at any location in the code,
> >>     this then means that tracers should treat events from these exceptions as
> >>     NMI-like. The interrupted context could be holding locks with interrupts
> >>     disabled for instance.
> >> 
> >> which caused in_interrupt() to return true in the #DF code, which broke recovery -- we'll kit panic("Fatal exception in interrupt").  And then FRED broke it more because rewind_stack_and_make_dead() never got FRED-ified.
> >> 
> >> I think we want this to get fixed for CET-SS.  CET-SS is new and, if something goes wrong, we're going to want to see the logs.  I'm inclined to think that any series that enables CET-SS should actually have the property that a #CP that gets promoted to #DF should successfully kill the task and leave the kernel working (unless locks were held, etc, obviously) and allow the log message to be seen.
> >> 
> >> Paranoid users can turn this off with kernel.panic_on_oops.  
> >
> > Most distributions end up with panic_on_oops set.
> > It would be nice if is stood a moderate chance of getting the 'oops' text
> > into /var/log/messages (or equiv.) before killing the system.
> > Otherwise oops get pretty hard to diagnose.  
> 
> We could have a fancy mode where, on OOPS, we stop running all user code but we do attempt to blast logs on the network.
> 
> Which would still require that we fix the stack rewind unless we want to do this blasting with CSL set wrong.

Isn't there code there already to force a different cpu to do most of the work?
I'm sure I remember backtraces being done by the 'wrong' cpu.

I wonder if the physical blocks of a file on a normal local filesystem
could be registered to receive the panic message?
That would be a bit like the 'dump to swap' that both SYSV and the BSDs
support(ed) but Linux never seems to have had.

David


> 
> >
> > David
> >  
> >> 
> >> --Andy
> >>  
> 


  reply	other threads:[~2026-12-05 11:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 22:29 [RFC PATCH 00/27] x86/shstk: More shadow stack enablement and path to IDT support K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 01/27] x86/entry: Parameterize kernel shadow stack handling at FRED entry K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 02/27] x86/perf_regs: Rename pt_regs_offset array to prevent build failure K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 03/27] x86/cet: Fix build for KERN_SHADOW_STACK and !USER_SHADOW_STACK K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 04/27] x86/cet: Make kernel shadow stack #CP fatal instead of livelocking K Prateek Nayak
2026-11-30 16:54   ` Andrew Cooper
2026-12-04  1:14   ` Andy Lutomirski
2026-12-04  2:26     ` Andy Lutomirski
2026-12-04  3:39       ` K Prateek Nayak
2026-12-04  5:47         ` Andy Lutomirski
2026-12-04  9:53           ` David Laight
2026-12-04 15:22             ` Andy Lutomirski
2026-12-05 11:45               ` David Laight [this message]
2026-11-29 22:29 ` [RFC PATCH 05/27] x86/sync_core: Don't use IRET-to-self with kernel shadow stacks K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 06/27] x86/process: Initialize and enable kernel shadow stack at boot K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 07/27] x86/entry: Handle int3 text patching with kernel shadow stack K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 08/27] x86/retpoline: Handle retpolies and thunks " K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 09/27] x86/ftrace: Prepare ftrace trampolines to handle " K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 10/27] x86/kprobes: Prepare optprobe trampoline to handle shadow stacks K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 11/27] x86/rethook: Prepare the rethook trampoline to handle shadow stack K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 12/27] x86/cet: Make regs_set_return_ip() helpers context aware K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 13/27] x86/cet: Introduce regs_set_return_trampoline() for rethook trampoline K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 14/27] x86/ftrace,livepatch: Use CET helpers for ftrace regs->ip and trampoline redirection K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 15/27] x86/rethook: Make the trampoline insert and return shadow stack aware K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 16/27] x86/error_inject: Use CET helpers to insert just_return_func trampoline K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 17/27] x86/kprobes: Use CET helpers in kprobe core to modify regs->ip K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 18/27] x86/bpf: Make BPF JIT aware of CET handling K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 19/27] x86/shstk: Remove profiling related dependencies for KERN_SHADOW_STACK K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 20/27] x86/shstk: Disable kenrel shadow stack when CPU is offlined K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 21/27] x86/shstsk: Allow suspend-resume and hibernation with kernel shadow stack K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 22/27] x86/shstk: Save and restore shadow stack pointer during kexec K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 23/27] x86/idt: Map MCE shadow stack and populate the INT_SPP table K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 24/27] x86/process: Initialize shadow stack for IDT systems K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 25/27] x86/entry: Prepare IDT entry for shadow stacks K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 26/27] x86/syscall: Toggle shadow stack busy on entry and exit from syscall K Prateek Nayak
2026-11-29 22:29 ` [RFC PATCH 27/27] x86/entry: Handle shadow stack on nested NMI K Prateek Nayak
2026-11-29 23:00 ` [RFC PATCH 00/27] x86/shstk: More shadow stack enablement and path to IDT support Andrew Cooper
2026-11-30  2:50   ` K Prateek Nayak
2026-11-30  0:32 ` Dave Hansen
2026-11-30  3:12   ` K Prateek Nayak

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=20261205114511.52d76d52@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=kees@kernel.org \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --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