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=1796397800; b=AgE8y5mQTK3PWLvqTaYseKxg1BuPlJNFRTfZFOlQ95qqLul6nmD7fNba2DSQj4xwTVfm Zh4g/4z8ISQ1hZNxcS/M80tbXoXPMPPIRlsWjCYE52O7BrEYA3rzyd6xR3d+UcH3CrPY3 p0fMLGE0CN3gusGfVpZJP6Mgf4/8DomrgeqSyWq+5lJ4qigTm58jBehQhycPiJ3eAq97q BIF2eqKneQbqZr8MyASJNAQYS/iln8dfRO1Ww9GblVzQ15CfCpShFUvXWvHtBPxPyFdcm JDefvcIrtKdDopAawPWN/TDqLCVhYMYSioXpLpLhihT1JVdxuCB34gHImRcauubaa6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796397800; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type:Content-Transfer-Encoding; bh=DW0En/tkEnFLuJurjoM4sQCis4VHcg745h6MIEOUmlU=; b=fZfq1fmHaYc60EzIA1Vm4eWsmhn0OajB5iooGcUlmXQd3jKRwaBHoGQSlteYFbxp7Juu TzFA9KHezXSAzbWP0REtwRUikuoJJWSqiTgMSIQp+E7O6gkkO9ISLaBYes6QS8o+4hS0w zXs1S9JrfHEUhzBQk5187T0vg6XkdZvdxbY2ZXAWGqjgD8wvNljKQpten2JfDRurDnax4 P9u180zduJqNSESKkcuMff+yqSeMJVb0c+IQLu730qYIVX4pKVSstROZxpTCQz74037pa 6CuiQgCGDFQS8kdTDBbLbirBIxk0pYkvofhBlgW4TSvlUdx5MLsPnArBBmuqBhG6glw== 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=asGCDq1r; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0605606A322 for ; Fri, 4 Dec 2026 15:23:19 +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=asGCDq1r Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1751F1F000CE; Fri, 4 Dec 2026 15:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796397799; bh=DW0En/tkEnFLuJurjoM4sQCis4VHcg745h6MIEOUmlU=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=asGCDq1rntc+QwPUbLdBx4ZDfphR1QCa0TWuuhQNWuDT7x7QXyKlav0Jc3iBYGc78 XRxQinrymmMyusAkUlxlaPnYEh6v8Wx27qTZTtsdvcFgV9aplFvElQOJVWbRx7oOXX vz0uhPMSeBEh55MMwcm1UXmzKvZ1VfEw7T2jOGmmKeIuFbRHJl4EF92JI+LX6pWuvj 6Dlsd6AnJVTj39w3ODHpH5EiRWAjWQ7Ah49x3WWOkKlc4k2F0V4BnUVl3312/aaVk7 99ve29gMHxbnCisxfKo+H+7Lgdjq+5EmKOPs1Mk4M4y63N0H4AXPe4mMJxsaS4oJh7 JQZOEt2UCVkZQ== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id E8A07F40066; Fri, 4 Dec 2026 10:23:17 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-01.internal (MEProxy); Fri, 04 Dec 2026 10:23:17 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTFYE8xJHfIgALNC4h6kgulCCh8xmFkBp06etNtNQlzMjZPBwb+84icDJHcrEtnlId eMvHxsxyBre0mdcQfWuDJm+nFunU+oPuEPjaSBxhGLN9NRt/8GnPH5jsis9HzIa9Gu9hM1 pLMX09HM6zMYrdxWAQFBiccebOJ4WGtaV/daa7E6kSS9KzQ0viSkP9b5KqAh+nUQ67LBKh UkT3GEsih4h/gl7tZzpdoUd9K1opWfS88qWEM52buiuBd3MGEp0Bnoa1PlUPnIXX4NtYnl FrA71Gw7b5EMoiVjwzvKZ7ZzpPGNcQ+yUzJTafB0I2Zf0MTC82kQhqxdJWPsh6sp9kdOTZ gmP1HTZ53c4rHIJT/QKi9n6NdjNSLPlz77BXhiKHXP5WtmoosPC5AP61ksLkOBtkBfOPXN WCGkmwDF1MPcU2JxPWmqIf1bObhoQ8wW76vSUDu+ZuR1t1GC5FEBPa65Lt1i+BmXSi5Nxb CQt570zGoxDmlAncY9KTe/6ThMjbMI+2vaVATvl0N4pzNxBPKJiKHoon/2J/jzbpNOnvLa 7cH2VlXdDSGPcWtY+3mQjXMUvqNK7lXN/IWRkeH8NVci2oTEb5jkvd66lH9ZtUFYpSFU4E fzvyRW20oefY5GgOu11POuFzdnCBnViwbOEhZPbgYLj4rrQBeL2uPZNxDlFQ X-ME-Proxy: Feedback-ID: ieff94742:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id CCB0570006A; Fri, 4 Dec 2026 10:23:17 -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 Date: Fri, 04 Dec 2026 07:22:57 -0800 From: "Andy Lutomirski" To: "david.laight.linux@gmail.com" Cc: "K Prateek Nayak" , "Dave Hansen" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "the arch/x86 maintainers" , "Linux Kernel Mailing List" , "Peter Zijlstra (Intel)" , "Rick P Edgecombe" , "Andrew Cooper" , "Kees Cook" , "Pawan Gupta" Message-Id: <24cbe98e-17d0-4012-88d1-e3fe8a7b0082@app.fastmail.com> In-Reply-To: <20261204095321.10cdf35b@pumpkin> 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> <20261204095321.10cdf35b@pumpkin> 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 Fri, Dec 4, 2026, at 1:53 AM, David Laight wrote: > On Thu, 03 Dec 2026 21:47:23 -0800 > "Andy Lutomirski" 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 >> 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. > > David > >> >> --Andy >>