From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796378004; b=Tb5BgKf7DNt4d/m4yBTy317ylWZmfGVGnoLz9djUlwKA2Nf6NOpUGiQ2BkbYuqTPzyI8 F+kmFEQDHdJbfm+Yos9yGVaXc9FaQMSafCmbswhB2itaBSMH8hrO3gayLo6YQM8l94faU hkSaS66OKGyWw0o/tNJIVWAds9yF6TDIf6hLa9iXIxTZKfdZRrvrVMvxGWyjKqSsn1PG3 HPWV6wu1+o+6lcZ5cIbk9wYm9TabFS+hkB3s6WhuSU1+pZFfG8AdQLvOlR5Wtv5hIUlKy tlQQTrGFk8I2D7uXzi/KEN8E7BBqDPdPNCSlQhXGXtfiyO6umbKtP9t36MhIYbixOqA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796378004; 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=lXetrfodm3JxK1/CDT2FXxLuzIXrKVd7/PD3BDiis4o=; b=HhkFZyHOJRAnSG/l/0I0OJdkHjLNTGXOtgE2jD9kKOl+BLHJg6PRxgGZvGaTrc/FC+qG AVdmxx8aL58F2UR0NTzTKSXHyhvVfqKnIvMbnuO7SjWFvLl8LALCS6w1dm3Vr8VIPC1Xq WfWU4FhnDpy9qgl7jAe6kcEeg75pkH/DGpJ41I7keCRtWqqomHO8jPwY7XGcuaX2ckyWN kqhONzNrz89TmJddw9sKUtz9D0ty1Qur1pkyStVBb/LX46dQx78c13xI8yzNIZTc+fbJQ UIXbdXxfwtWWtHjDRP34RRzXJY/BzNE/LywWQj/QWJwkuC1KRzeHNoa03TW9aYp+lzg== 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=qZf7zPWa; arc=none smtp.remote-ip=209.85.128.48 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 739C0606A335 for ; Fri, 4 Dec 2026 09:53:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 739C0606A335 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=qZf7zPWa Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a2000d5fb1so3814005e9.1 for ; Fri, 04 Dec 2026 01:53:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796378003; x=1796982803; 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=lXetrfodm3JxK1/CDT2FXxLuzIXrKVd7/PD3BDiis4o=; b=qZf7zPWagvQj27R7ng1Q3KiAgetbbc9BH+Qi1eGaEqz3S2sOSnQ75mRhWGvQtAZtFc PUWzYt/+DCsGpCocUcGY/l2OFKP9Mr+81FFxJMElz6ElrhIKtKx8SogvLVWDJQCV34pP rfJJbrs/6ZUpYjFkgkMBOsGfdZ2OLQlWyzZ0zX9jLXgqd9nuHc0ZjKdQo2df9uYqcb7J D98zpL5wPcZ7Q+heH9Lb67Fv5/xlgjCRnqKSj1HZUDWxJ02igEMTmudRZDXlemCJwtCG Vqh9J1nyRoIeWyTDz5aaQC6Gbrv+wrRI8YPBkkQ++nn3dDye7Y54WKM9vt5IreIYEaQJ 4IQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796378003; x=1796982803; 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=lXetrfodm3JxK1/CDT2FXxLuzIXrKVd7/PD3BDiis4o=; b=2eM1CqXN3D7mubjxhCHbLdNc7u+yww8HTSBz8TgaR1R6fu34J2+QzYadgdu2LM/AZQ nIzrNFYznOI7JxaKt1j4VzPJxrKcw41T5XFYrrIMPhX0A40ngQN1d1MvAcCxLPQBRhxf /hBq22L77Ff2s/98mYGPOLhqOl6g2JayE67pJJ7hT9A7Gi7/0kbv9gHA4nh+oWcjFBTC 282ebw3cL3NeQk1pJ4Q1yWere6LhOm608KUBV6HkUz2KaL2ztlDojGVwZBcDBPqBVjwd NEBR+byhfssRHqePW3WckxS6k/b/DQs2kPrJ4Af047Ecm5dltdlqxSwBEw2jaE11iO59 MJBA== X-Forwarded-Encrypted: i=1; AL+hErF4fp+tUXqQ2quvNyiU6YiagFrwh9byyBX9NK9zXdimow88OnRrX2KS9ppTfZpHMovEZiOZ2QQ6IIkrpE4=@vger.kernel.org X-Gm-Message-State: APuU4Z8tUwl+iPZFA3N4ICh/RXGM4vz1mkLDFmJtiqlgN7G0qd8fb0bx AU7x9OTXlaSmnwaBMjz+edRWjyHhS0ZjCqX0PbKRHdDIC4GhTfNw/ho/ X-Gm-Gg: AZFdTZcYZQBK5QArKuG2TXhAWeXzD5DHjzuyb4j1V6enT39fbnUxmvIW6pWUEmlaQgL OXEno1ydPYhulSJk7WvYUPRDC8T63EHPcxGsN7OviTtcW6FC6XQQ7wYSUXh2A23AjYTS8tS+ak9 hnlUnWqAUB3fnppf0CywSXhcFZ2AvL+W4LJ78JrgIh+9anoQFlaCvpDWO/SNBR2paptgPfSqQDa Xpn9umMFheOHONYrauWkFzGVFg5VGuY1yFLt5LnWexY6zTLVTV5V16ifayEC0cf0XOfRKr0hvB0 NK/KdIj/aOrOl+UJCqfDC5evnEm82bFlZd2c0O0sDCzZ9LYpuKexwxShOyqsaxyU80CrcJGf2UB jDhbNY1kdFh/zODy54Fsk4uqFYF5dISfMJEYL6dUsqOVYjX77lrm3Rwx4lnczxx+1h78eTyvB/S 2ywbCHgsNkm2bmS5+BVQf2FYB3RRbzPnp7o/CFxV8M4SkzL2nlGUSWdZXtH1E/qQLcDY+AiLnCX u6X8Npb7nsIMwxlYjubnvOT2+5pMsDP+cl5avtcE6r82jEgVe1X2qYdvxImaIn/VnQLFPZ04sz5 WaI9CNC3gfEm9VwqYp3x1nbloadzW+v79budTDAtZjYD47ufwWphly2eWrt0iQfszxU27J/K7UF tj6EGSxkC4g== X-Received: by 2002:a05:600c:3b0c:b0:4bb:ea05:6f19 with SMTP id 5b1f17b1804b1-4bbeb8cf063mr25360275e9.10.1796378002726; Fri, 04 Dec 2026 01:53:22 -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 ffacd0b85a97d-4d17302b0d4sm4516622f8f.29.2026.12.04.01.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 01:53:22 -0800 (PST) Date: Fri, 4 Dec 2026 09:53:21 +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: <20261204095321.10cdf35b@pumpkin> In-Reply-To: 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> 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 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. David > > --Andy >