From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796363265; b=uVw/NpqKyAG3/ulHiELzitOI+MUL20WYA+CsSkwVK9G0awgSWjXMBH2TruHsqkn56cZ5 X/y3xMrX43tLDtwi3jXdDC4RNIspJyKuM7mr57wgkRTf374diFIjTOUHUSS3LfnHZ6w4W LoLTHdp3ugYtGtLoy5i4+DjZ1TbAlTJ+DwZFGBSctMtTM9Os84I5Hs4KPJiGBU/xyrv1D GKN5golg0K8PHNc8mFa8UgtA2PZ35EWZesQzel3+SCyVm/gCasBlt+H0PgnhfNEhHLAYV VmLAb4h/hXx7yD+NPGGrz5jEq8e4jNjeimwk1k4mU/fVhJVYAlazutAxtn5eAn/7QaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796363265; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To: References:Subject:Content-Type:Content-Transfer-Encoding; bh=mdbuIjzCvvIAntL70ZHDEI6N/lKSGVii734EXnKBdWg=; b=EhjfFEmd1DUgiKQx3ikeFKJZjOnrlfEmHMD8QgcGEksV+W5u2a6vet6Ms+Qi19L15Dqs xc2FEFR8et6Unc/LwuWxRD9msW9EBkivgxj5I+6zMwhFx98gQztqmI08Ot9P5FzI5BsTn /OOd+xj2UKM0vwZ83UKjqL349rZOsHLxE6SgaQ/SUP8M+r3MVGAkuWKK0GBfslouRvdP9 6GE2etJFGfw0hz2b9/kknc9NWvfujfFikIdy4HncGXtkNO4h0smt9U4zxeDw/0ezkYeDo UIuvczaLvC2g3Ce0+E2ZszQaV686Hsn3ufmfvbu8oUgiMuswLwG7CoohJPE6O62YwvQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m54nmdF+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D251606A32C for ; Fri, 4 Dec 2026 05:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=m54nmdF+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E181F000CE; Fri, 4 Dec 2026 05:47:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796363265; bh=mdbuIjzCvvIAntL70ZHDEI6N/lKSGVii734EXnKBdWg=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=m54nmdF+z7JB0mOcno9jEQKjWhdykOWDbXa2SofJrnu/isAuMF9vRGc/aXnNVuAdt LTnYhz4ol06yI/sBnIHBiERTIvcBmzWRbpN9LM0nTzJCqOdJV4TxQMIVuOm0AXynPG YuKAB0EcKgEKDffdCJMejKkRYZxUwfrzZ9Y6Ibq4KekDBIsbsd8pXeiaU+9i3R3B5h obrvIn/hbQ1ZWqEMk3P0ZDkN/mK+kH2F6CMHmB21Esws7rU+lLnWl5ies9LrE3aSH+ kxXeWpPzXrF55qt+xzWp1jn/UafvlLBaaJ83Z1Lv2rZ93LZb5sFJ6Q5/EksyZPi/jh CBMcRO9d9NY8Q== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id C6166F40066; Fri, 4 Dec 2026 00:47:43 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Fri, 04 Dec 2026 00:47:43 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGnUH8yzAMMT7mIACO1QuKuWz45uhEj1dFT7Dy6D2nRLwVGZlfhzBiG76IRYzyzA0 3+SmKQ/KVyu8RWDwnbsJpS3iFZnffo8mbp8SwXH5nEVmic7GcN84/p3chNgk+mHQQ2Aklj zGfRcKtAE5Qh96VJs++fWHtGZv4+8zKTnCHz19L4N8bzCeznY91TiK8aGLARYYYQPmPN5u IGJ+PSEpaDfovKSfoVyqbeA2dOtp92igF1gHbmLUtSoWfwuP3CAEi3/PPLG8b9MsiaeKhh 44pTZh3RUTtVpdRO7QTiI8Ta8ag4YVNqTWikO5Yke3BmQhJHcKWb4gmuh1cknan0jSwCUZ iWVgRFL9EfrEQ50QMl5M7zlk8ZQe0Gncs434xqYcEHmSlCOSoZIU2oYMroLiIO51hMcHtx 6pze22x6HHjnibynNuiZCZLpX25/4h9GTwnwYLZ8mOOHrkw05xt1tChN4Yhz43dzTi5I1k scVLKTxxdQ9BSd/DITJMADWfYpv0njb/LjTf7AM9JCJ27PMgP4I8Mhke877rKyDxHCupQv lmVmSCGdchtsj4MlZIl3m7RHDlQ3lm38N2jAIEPKKEoqigPeOIlwqa2sXAqaWLnGkjRt5p jqBuw8agC/dqhmU09j+j4vHs5zTlffGTwqo9OoUTRAUaWRbQJczTWfEsCruA X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 989C2700069; Fri, 4 Dec 2026 00:47:43 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-ThreadId: AoHIqsiCY7sV Date: Thu, 03 Dec 2026 21:47:23 -0800 From: "Andy Lutomirski" To: "K Prateek Nayak" , "Dave Hansen" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "the arch/x86 maintainers" , "Linux Kernel Mailing List" Cc: "Peter Zijlstra (Intel)" , "Rick P Edgecombe" , "Andrew Cooper" , "Kees Cook" , "Pawan Gupta" Message-Id: In-Reply-To: <8de181b8-ac8e-4195-aa80-4bd5252523f1@amd.com> References: <20261129222953.9124-1-kprateek.nayak@amd.com> <20261129222953.9124-5-kprateek.nayak@amd.com> <9f3adeab-5fe8-4100-be62-60fd112a807a@app.fastmail.com> <905695ec-4d07-4243-8455-41b53cb00022@app.fastmail.com> <8de181b8-ac8e-4195-aa80-4bd5252523f1@amd.com> Subject: Re: [RFC PATCH 04/27] x86/cet: Make kernel shadow stack #CP fatal instead of livelocking Content-Type: text/plain Content-Transfer-Encoding: 7bit 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 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. --Andy