From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0D1822EB841 for ; Mon, 24 Nov 2025 20:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764017519; cv=none; b=EfFMBvPXidkuzi/bxN579VpPnTWS8i6OGMFwOUiPJOMUQv3QTvdaNotcHWp/QR6H6ZaTS5GCGeKupB54aRNYI55WZRM+3FpCem4tC9BcZeXkQRBsW5HYxKMkMonLX3DnOru7l7wgmikZZvvgeTVVB7mFeM6rzFa3eFpbiuQ5Cig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764017519; c=relaxed/simple; bh=V+Uwt+ZdbJkBrqBbLMY3BQCOogr0mkRy+ckU06EArFU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ElPcVynIKkPaVkwsEVWGfxAniy5keXsM8sNXhq1CDoFUV5rQnKCVgQGduQuXhE3SQqcplQD4mChAUgVtUUJq5wKj4vugBBjz3dborUm9gPe2qtuUPPkgOdLE4KyeBX99PLanzXjU9nGcOaDnk8vaC7iyfs8yeLLsm+OzPXzCdEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L02WjnJW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L02WjnJW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E166C16AAE; Mon, 24 Nov 2025 20:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764017518; bh=V+Uwt+ZdbJkBrqBbLMY3BQCOogr0mkRy+ckU06EArFU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L02WjnJWfVbhAXiT/h0NFN+hEBPiubc2NS6O7J/ZHxdyXcS1jbjrfE+8/mkySFlWC +J1GyjhG4rnXHRJxtVcP+E+x5wH1wFw8JjpWj3CSwJnbww2zMaQrJth8PvqiFzyThv mte/qHteRbAC1XoXRdGk8DO/Vbx9zkUXEsOhNnqis4YOMsreRPRDuQLYZNomi0PS2d pvfgsmGDp43gT75M70iuE9R66srWy+7U2YGbiZFaY4pTZGvzflx+q2Tz+aOTxVHKJ3 13ZIb762wmHtP/QjIE/AY5p6Bq+j8B4q5pcIstUC6Szso82GawAH0AENekc5Ozk3wP axLDfP4QuBp+A== Date: Mon, 24 Nov 2025 12:51:58 -0800 From: Kees Cook To: Ryan Roberts Cc: Will Deacon , Arnd Bergmann , Ard Biesheuvel , Jeremy Linton , Catalin Marinas , Mark Rutland , "linux-arm-kernel@lists.infradead.org" , Linux Kernel Mailing List Subject: Re: [DISCUSSION] kstack offset randomization: bugs and performance Message-ID: <202511241250.EB2ADED@keescook> References: <66c4e2a0-c7fb-46c2-acce-8a040a71cd8e@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Nov 24, 2025 at 05:50:14PM +0000, Ryan Roberts wrote: > On 24/11/2025 17:11, Kees Cook wrote: > > > > > > On November 24, 2025 6:36:25 AM PST, Will Deacon wrote: > >> On Mon, Nov 17, 2025 at 11:31:22AM +0000, Ryan Roberts wrote: > >>> On 17/11/2025 11:30, Ryan Roberts wrote: > >>>> Could this give us a middle ground between strong-crng and > >>>> weak-timestamp-counter? Perhaps the main issue is that we need to store the > >>>> secret key for a long period? > >>>> > >>>> > >>>> Anyway, I plan to work up a series with the bugfixes and performance > >>>> improvements. I'll add the siphash approach as an experimental addition and get > >>>> some more detailed numbers for all the options. But wanted to raise it all here > >>>> first to get any early feedback. > >> > >> FWIW, I share Mark's concerns about using a counter for this. Given that > >> the feature currently appears to be both slow _and_ broken I'd vote for > >> either removing it or switching over to per-thread offsets as a first > >> step. > > > > That it has potential weaknesses doesn't mean it should be entirely removed. > > > >> We already have a per-task stack canary with > >> CONFIG_STACKPROTECTOR_PER_TASK so I don't understand the reluctance to > >> do something similar here. > > > > That's not a reasonable comparison: the stack canary cannot change arbitrarily for a task or it would immediately crash on a function return. :) > > > >> Speeding up the crypto feels like something that could happen separately. > > > > Sure. But let's see what Ryan's patches look like. The suggested changes sound good to me. > > Just to say I haven't forgotten about this; I ended up having to switch to > something more urgent. Hoping to get back to it later this week. I don't think > this is an urgent issue, so hopefully folks are ok waiting. > > I propose to post whatever I end up with then we can all disscuss from there. > But the rough shape so far: > > Fixes: > - Remove choose_random_kstack_offset() > - arch passes random into add_random_kstack_offset() (fixes migration bypass) > - Move add_random_kstack_offset() to el0_svc()/el0_svc_compat() (before > enabling interrupts) to fix non-preemption requirement (arm64) I thought we'd keep choose_random_kstack_offset() and just move everything into a per-task location? (And for arm64 only) -- Kees Cook