From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796471119; b=nUR1dVicushzV6+Zf26nZ6wlqBY/VcS9WXo0+15eftHKlIRyFwjLfsL2WtquG9/qmkO6 /wdkyrMP3mzcJtlsdY9urR3B/4umShKX8vx+FFSFVjzh4CRVq4CFPYC06llQBWpYjTfWx 22ovN0Tl867KaCGGzyfz0yvkVI6IRYkgrroVWhW5kLTnqPfyGOy0LJwZdru1Vu3Qt52eP xhrjRUM+BWNcgN3sAX5a02s118oBBlPyne9u1ajR5hML1QhTjzpouB8HdXtlVa/uDcTlv 3nXy73rHkTTRBtWaKPNTrcDeO1b6Wfo3nw2Uc4DdNwI/TAStsP4W2u3MD37PGjx/SrA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796471119; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=khn4TBUXhWSSf9NNFq9VrcyWPGqgx0a8nRVSnZbE2fo=; b=wCNBjo3K3100cnTAT/iUf3I9GH2ERSOoUnbTzAT1Wv2kLzLcRBBIzXMv3eWRFw41t9xx CxtSSxLxxhLswKYb0ROSVNUcHG2js3ZheWD92ApL/Bo6aQM5wNEjrSXxRhsDEdWGy2O7r 8OdZ23mGBu7PCR2C1E4JNGGvDe24/q4I9gS2UKBGcjHRchEHVVNwG5aYYA1wwSrL5S45f 2uwqk5en+GuBK8vyRtdC1r2CirgRcCCyEgnp6ngeL4+4IDmmFibDbjc8PPAvHKhRv9aVS Pqo57TdtEa3kDkU/dHp3Bt3UlNdwHhIy9JxRCvIX1GBLeCGT1ch7MpHUwMwRgqsmrhQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VmeM3+B+; arc=none smtp.remote-ip=209.85.128.52 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42AF5606A322 for ; Sat, 5 Dec 2026 11:45:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 42AF5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VmeM3+B+ Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4bb6ba3b244so14124405e9.3 for ; Sat, 05 Dec 2026 03:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796471118; x=1797075918; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=khn4TBUXhWSSf9NNFq9VrcyWPGqgx0a8nRVSnZbE2fo=; b=VmeM3+B+PH6B+obbPnUWtK82X8gNt3jzJdGU9DeuLYT+f95hMFuNbNNvKGGEjPfTFB V6/gNhcKuBLpS/gwj/4pJwNA1UBQ6CwPKtyRD2r7TQ25qFXPmC4jwHsRhSHwhcDZulaQ Kg38WiVJxB6X7y2/ICGzJCufYqlcgDZD26hpEsNOzvKfadDQmZW9aSLWsj6A7rWJoOZG TdjSqwD+g9wk+EK2wdtvBCHkwN0brWNwzcRnAen959lkZoFdDaeeEy6Z3+t4gE+y7//D hKqWo3CMzo3+ZOPPMYjWVONAryOeOYN26cgyi1ucYAdR67FGJS5EBPFUmqnEJCfNtXYK xFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796471118; x=1797075918; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=khn4TBUXhWSSf9NNFq9VrcyWPGqgx0a8nRVSnZbE2fo=; b=h93vrUiv6+AwgZV0//UOUlwmFuXLfZ875ew6IVRQV6esY4bMSZKkQflw1XWyISrBxY 8HlFGW7UCMlJKHf9MqzQ1t+rXCGQ4r6qE570VhlsZyJ8QsQJGPNNdcXP1+0ghf9c2Jqc 7yn12bcDIrp6raDKxJ3gYYsgE+b9EIE23FFMJ+n4O3x3ze2VgTnsuhHqsMxotDI94PQ8 cEyGuiCmcIyaK53z5+7q5jBB3lo/qnOOfKglftkBQDtOW4uTwF4elyCZoSHJfld2El76 07Fw0heYNJYFy4tgZVvQ9T8HUhszH2mxeveIWmnhlX2CwBCkA8ALO/vrpGBDcDqvHDIO UPVg== X-Forwarded-Encrypted: i=1; AL+hErEWVKscvywz+isdc40OWegEl0t0f3R1dp3ObAEl10Emkzdccy204MkiZz8x1/eD5CtM+ZSsnN3Ri1sEhZk=@vger.kernel.org X-Gm-Message-State: APuU4Z/qe5MFV4sLo/Wfe8O88kKYZXSgzBY9gjW+HbCG+SczbjyHzXRI 9VzLZj/pFj1WA0f3swmjpQNZn/Noj2azJBmiBI8qXCIQTK43B2NspKHB X-Gm-Gg: AZFdTZcCfVl90noTFxh7MHKGvu5WaTPqJrqWD+tX1HsLnwyzHwoTKbHWlBJA6IiI1iP XygZ1p4H1m222PmHwuNQZRl6UVaK0EFkoPnznsEgPY4LNIC+lvURtbWUHcYBRgPbmuoPjF+Nqky Hr65tpTUfZ098w3Jhb1ubdd3pjAuN/zFYmcEOLInmYyxMTfNp5dgppArPBcOcsP8r+iWQAQyNBJ 1z3RtrAj9pGahd/wiyqt4qPl0gr2geVIn6yxVNr34cJCwG7voXgzrxvB/YXi+tSIW1/5AxRmP+4 dbqI2DMtgdNgdFlYKgZt/GoA7EZGnPNi4653xvlGiTvETRDo3E/n4hRjS4tPZVtrPVoNKzDhzyA WaDY91Ncna/92GzKLzeYKTRYq1N1J+8P2lg3p6AEkZM4wrCEFg1gNjNlqQNIyAYy2qvTZr3ckRh XpS4VHFpCk7zSfTFRvvDu6iAaki7f4A5i8JS05Rzk/11ZAH7X75tBB7NwgS+OcdiJURX/TE4IJ+ rteqT4YQAFlrmxPofEbWxuu7wLea+Nz8BuLjvn7JoeD7Sh13ZEEgKuJluuWnNink7vug2dmDq51 YyucjnQm/migH0JCZrx7WEmDhepTXWmR9rtWkKqM7qiNu5n6D2AEPaTjcI0/9IR0lg== X-Received: by 2002:a05:600c:8b67:b0:4bb:e1f0:1fd6 with SMTP id 5b1f17b1804b1-4bbeb6fbfa9mr101776975e9.4.1796471117554; Sat, 05 Dec 2026 03:45:17 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe06edeb7sm379836605e9.11.2026.12.05.03.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 03:45:17 -0800 (PST) Date: Sat, 5 Dec 2026 11:45:11 +0000 From: David Laight To: "Andy Lutomirski" 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" Subject: Re: [RFC PATCH 04/27] x86/cet: Make kernel shadow stack #CP fatal instead of livelocking Message-ID: <20261205114511.52d76d52@pumpkin> In-Reply-To: <24cbe98e-17d0-4012-88d1-e3fe8a7b0082@app.fastmail.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> <20261204095321.10cdf35b@pumpkin> <24cbe98e-17d0-4012-88d1-e3fe8a7b0082@app.fastmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 04 Dec 2026 07:22:57 -0800 "Andy Lutomirski" wrote: > 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. 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 > >> >