From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA7D440D57F for ; Sun, 28 Jun 2026 16:46:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782665196; cv=none; b=DM0Cyfb0GA7mgml1whS9SFKnHEu0tM72PEuzrynwCzGgsLnHYRMxnrKYi17t2cr/PV+cxX2WPVZgLgcfWvxIMvqc0KWQfg08Kw1N56/6oHtIJsCvQX79/XLUpW2wgXBGrwNTeqAni1kfgG3SvZMf4hBffleblRe9aIdVNXFSSFw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782665196; c=relaxed/simple; bh=THp64I9/31adVTX3Es1NaaEmLtXylmJ/nlw0Onko050=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=SIJYEAfEhCqIDpIOo+t6d7hdMB9f+OOHxVd/cGvwkffT6botVMK+Sd1cyJ40u1jfAQ7rQdA5tL8/rxww89W5Uxwuq4H0YDRd2nHYgi/GwaI8dRAK6hCUwjsjmFvVElC+LmmEE1wOFa6zBc27cdvfiDnH9b2IY1nBck6KsBh5SqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T2r/74FM; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T2r/74FM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C909D1F000E9; Sun, 28 Jun 2026 16:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782665195; bh=THp64I9/31adVTX3Es1NaaEmLtXylmJ/nlw0Onko050=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=T2r/74FMf/7gQgsL/45OzYzUr8Kl7WLfPCebvUFVd9iV0Kpvdnx6Zn22StMRLHECx crRp5Nh3YSpNZUejpnapuaFZ8oW/QW0srztGBsRKazpUMyOpCn84BhDbKFC2EVQhK9 qbNev2RfZZvbIegaa3ePFGwxllrwG6LZ6iaXKC7OxQclpsC9jP5fYIdNQ7krRESti7 yDrv732uIb7jVkbvlM4ryCUmEagryXhZ2N5Et5Q5YuHM5YXuxPdagIUNdldU9JaAF0 wKZ5zx7Gi23v3cmcvzTGMURfddEQ6CJMKawY3IUOruQkUd4A5yq4/fYFprgyKiNw8V Ne4etnQZ+/35Q== From: Thomas Gleixner To: David Stevens Cc: Pasha Tatashin , Linus Walleij , Will Deacon , Quentin Perret , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Xin Li , Peter Zijlstra , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Uladzislau Rezki , Kees Cook , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 12/13] x86: Add support for dynamic kernel stacks via FRED In-Reply-To: References: <20260424191456.2679717-1-stevensd@google.com> <20260424191456.2679717-13-stevensd@google.com> <87zf0hgc3r.ffs@fw13> Date: Sun, 28 Jun 2026 18:46:32 +0200 Message-ID: <87ldbyhatz.ffs@fw13> 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, Jun 26 2026 at 21:05, David Stevens wrote: > On Fri, Jun 26, 2026 at 3:39=E2=80=AFPM Thomas Gleixner = wrote: > That is definitely a situation that could happen, I hadn't thought of > it. Luckily, I don't think we need NMI-safe re-entrancy to handle > this, since an NMI on SL0 couldn't have interrupted a dynamic stack > fault. Correct. >> As a consequence you copy stack data around to the same place, which >> should be benign, but it is well understood that memcpy() source and >> destination areas _must_ not overlap. That's UB, no? >> >> I know that should not happen, but that doesn't make it less UB :) > > That sort of fault would probably end up either with a > page_fault_oops() or risk a context switch with SL>0, but we shouldn't > make debugging harder with UB. Definitely not :) You can avoid quite some of the problems right in the ASM entry code. Instead of checking event type/vector and then going to the stack switch logic, you can check the stack level on which the event happened first. If it's not 0, then there is nothing to do.