From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D93F53F54A4 for ; Fri, 26 Jun 2026 13:53:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782482041; cv=none; b=ai9Qf8xrAjuHOupulLrPMmTEYVpZCoiOHBHuiLq0VhuVf+i+hpXcJLMoy42UqbL5bEZx4VlgqlJSGzUmF0jk/GPdRHkvntcjxCaN0M7a5HiVSqBHEQNA/86iWuiugMVPtouMR8CEY6rI+jDgXJY5oQvpX+GKGok0QltLwFeaZzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782482041; c=relaxed/simple; bh=Ymg67ountFGp5KFG5LV3HpbomYh4sLi7Sd3XabQzjvo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hjOZkyJQVSfyKWcZxZRhu0v2/WhUg3CshXzYLR6cQWJex0XevbEyshv6cpOSt9Q5OLwcN5wbtFahqGJd4hKQB5NAx33oLKe6L4IZjvJHTxDqnoyv54Tu1CEMS62Y26YcseDUv11Xe1NzJxC4xhK5J+aQ3hPMQc1owux8esbvY2Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aiV/MC02; arc=none smtp.client-ip=209.85.128.42 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.b="aiV/MC02" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490b7866869so8604105e9.2 for ; Fri, 26 Jun 2026 06:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782482038; x=1783086838; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=POFjX2Hf+49RKb0BHhcjZkT/UVCjs6ACVOPFKwDMwD0=; b=aiV/MC02gz+XelEb4U+vy+g/cygXJFfcDlhL++DCbI3JszriZEt5OwarsoeMsRtCbN cFBxjbapt5TRaTktFJb29T2uJto5IhHhOLtnSc2UE1txhBF+f7Pi+VXJA3iy0J8DnqHA L5tHq/m6NVaEjNQPtEdrKO1MxkROfb/7u839Y2dVaonoF8FkVDnY3wpRKxJq/AqH1c9r 2mgHQtL21V02ji1q+FYS2fjv5K8arvsEBtAguTOqvSKkbYe6AjuH5TfXH5jg2Tpr3bbR avZ/c9EEb6zn0Gq85OAB/aT9xTsTjAwRnbsgSSXnN1igdMxBjGAIIfII9RmCq4Z0SCxs b+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782482038; x=1783086838; h=content-transfer-encoding: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; bh=POFjX2Hf+49RKb0BHhcjZkT/UVCjs6ACVOPFKwDMwD0=; b=sp/ldtCjeZXOSa7r+qdtbiX6jO9vJ2p1mwIHibjLQaf8UpL7klEFgTtdCk5JJk3P3C /7loFxnhysD1WC/tZtDDEhcLvNdsOllOOTJWMexKcLjluX0J/Kpw+zMa6ryMFhJdK6lm eur6RTkEVVkEsYNunaMRWoYkqrrwGw1DdIkQbKKVvoZ8zwHcpjoCttJe+C6nddzkJjQx bFVMygtrFt4pz9ufG3SvP73VbGgkz8DDBG4Y2GUx/qJeDnPuVqgZ/CXm49JfYbqcjBMZ 9QuNszbMya9K60Y0F9zLwJShMC5er4LqntyZENZyqViHi9QgxdrJF5Ezh9wGbeKrwzQc jk8g== X-Forwarded-Encrypted: i=1; AFNElJ9K6UqKsUAaJpR694TZvY05wgwxVLIVxcuc/4BsYgOl/KJF/sCe69mykNxcgW9Z6B3euFl8H/qROtSqAB4=@vger.kernel.org X-Gm-Message-State: AOJu0YyoyB1Uoo8Q0rn+ksizcw+8i32u7EdOZfSkoL1j9Vm/bool06wu FzMVuhgyNSEblThVRDj6zAGWj5bOIqfZJsAXMabRa+3mcaiI1g4MjNlB X-Gm-Gg: AfdE7cl2l8TwBwKObZ4v7zzmNTalB4mSmPaP5faPmA1MVFLEClQHpVdGWkgMGHw+FbH UyLrTbC8N7BSOBIqCIXOM0CRDA+a4Sz8WET5Mxb9Q5b3YfEB9lIgAe9Cw3iyaKHqGpuOsEc4gF7 uWr70KnIdyrrmvXGH8xr97xPKtTwKj5fZT4GiLl7PHw2XzO2Jk2KJ8hNfh5o8X0PY0IS93+nfbH aVKOi3Y+JnMmPie0lGVddXyrEmZ9g5ddVnZWOxuTazkGRrpD7wLynAcIIP5WR5mnhrgOxrcvkeh MS9dI39cd8e24qRYEVVMjS90qYb4Ro26sxsKk5Zm4PT0Y/s6V8WqnsIfit1u236EYMI4VlexOzW SAsVck7dIBsbCIZxUO8IZ2lOZGpoY0UN8IqLn/0SoemMJOLF6yRgCeS6EZXvri8NvSa9H/EgePH 8HxndGsIjVXT5NwXCyNcziaSF4aMdY7VjlNfKxzHO1grv3Rz7JKA== X-Received: by 2002:a05:600c:3593:b0:492:6cd0:41b2 with SMTP id 5b1f17b1804b1-4926cd04404mr30657765e9.32.1782482038008; Fri, 26 Jun 2026 06:53:58 -0700 (PDT) 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-4926c00a34esm34262945e9.0.2026.06.26.06.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 06:53:57 -0700 (PDT) Date: Fri, 26 Jun 2026 14:53:56 +0100 From: David Laight To: Linus Walleij Cc: slipher , Nathan Chancellor , Kees Cook , Sami Tolvanen , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "regressions@lists.linux.dev" , "linus.walleij@linaro.org" , "rmk+kernel@armlinux.org.uk" Subject: Re: [REGRESSION] 32-bit ARM's BKPT instruction no longer works Message-ID: <20260626145356.4183d8c5@pumpkin> In-Reply-To: References: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 26 Jun 2026 14:53:56 +0200 Linus Walleij wrote: > [Adding Nathan and Kees so we can figure out how best to deal with this] >=20 > On Sun, Jun 21, 2026 at 9:15=E2=80=AFPM slipher = wrote: >=20 > > Consider the C program for 32-bit ARM architectures: > > > > > > int main() { > > __asm__ __volatile__ ("BKPT"); > > return 0; > > } > > > > Expected behavior is that this raises SIGTRAP. Since Linux 6.10 this no > > longer happens; instead execution perpetually resumes at the same > > instruction, using 100% of CPU. It does not matter whether GDB is > > attached. I have tested with an armv7l CPU, but I imagine any other > > variants with the BKPT instruction would be equally affected. > > > > I believe the culprit to be commit > > c3f89986fde7bb9ccc86a901bf28e1f7d69fc3b3 "ARM: 9391/2: hw_breakpoint: > > Handle CFI breakpoints". The commit defines the method-of-entry code 3 > > as "ARM_ENTRY_CFI_BREAKPOINT", but this is the code used for any BKPT > > instruction - see > > https://developer.arm.com/documentation/ddi0379/a/Debug-Register-Refere= nce/Control-and-status-registers/Debug-Status-and-Control-Register--DSCR-?l= ang=3Den > > "Method of Debug Entry (MOE), bits [5:2]". If the CFI option is disabled > > in the kernel config, hw_breakpoint_pending() returns 0 indicating the > > breakpoint was handled, but takes no action. So breakpoints cannot be > > used by user-space code, regardless of how CONFIG_CFI is set. The blog > > post > > https://www.jwhitham.org/2015/04/the-mystery-of-fifteen-millisecond.html > > gives a nice overview of the control flow in older, working kernels. =20 >=20 > Does simply reverting the patch solve the issue? >=20 > > The following Systemtap script can be used to demonstrate that the > > ARM_ENTRY_CFI_BREAKPOINT path is used, when running the above C program= . =20 >=20 > Yeah it's definitely that one causing it. >=20 > I sent the naive solution to it, and before anyone point it out: no it do= es > not allow custom breakpoints to be mixed with kernel CFI, but it > probably makes legacy systems work on newer kernels since they > probably don't select CFI. > https://lore.kernel.org/linux-arm-kernel/20260626-arm32-cfi-bug-v1-1-a467= b5050c0b@kernel.org/T/#u >=20 > I understand that this is not solving everything. I'm confused. Why would building a kernel with CFI (to check kernel indirect calls) change the behaviour of executing anything in userspace? If userspace is compiled with CFI and gets an equivalent fail then you'd (probably) want a fatal signal - but isn't that entirely unrelated to the kernel code. Do those checks even need kernel support? I know shadow stacks do. David >=20 > If it is under all circumstances unacceptable to be able to construct > a userspace which will change the user-facing behaviour of BKPT, > I think we need to revert CFI breakpoint handling, back put the patch, > disable CFI on ARM and wait for the compiler(s) to start behaving > differently on ARM. >=20 > CFI folks: any ideas on what we could do instead of BKPT > when we hit a CFI snag? Any ideas from other architectures? >=20 > Yours, > Linus Walleij >=20