From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C90B5C54E4A for ; Thu, 7 Mar 2024 19:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5NyeQTFYxrfuTw0vWGu+g8pC6uFCt9LGVKDbM3FH03o=; b=NjtWuBP/FjRAMV uI2DQ8L4s//mdK4I3UNWXWpGy3Dt16+jFp6ELXEd3loGXhepuGDydBAhtmZ/8RtKjsdGoMv571+Iu aRc6+6c6rmDkHJXSuzkRx8HSw1tZtflk8WdZAyS1M0Z3ZSL31QV+qPgEEuVt15XisnMi5GD8XzaR9 YyVE/3cFSP2ClhtqaKmx29iLVHBm9T9HMopJoc05z5gvNKQLOrH4kq9utpU2EWfxtrw9pRC5D5kOC dyoeme+tG3qY8SOXBCH0pn5QJ6mWmP1drtJ4IkWINmymbQNgO4RHT1V4t/octX3J2boMqa0khQ990 xjFHmrkVrOFB2FigK6Ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riJDE-000000061pU-3Fyp; Thu, 07 Mar 2024 19:15:28 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riJDC-000000061ox-1PLx for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 19:15:27 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1dd0d46ecc3so9885145ad.2 for ; Thu, 07 Mar 2024 11:15:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709838924; x=1710443724; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=adtXnm+UfFx0dkkz1N9cMCbOWjdrx1dY7LOvsQ2Ti4s=; b=IWxpBlpg1fOjX8ckZVf5gjHhSJ/mJjTS/5CdtbP+DJrnJp1h2lUMnAPMhZ6vhj57u8 vSoIVdKt9PZyoagMMifZbbnI9AeayUFu73dGJuUh/sq1cEhOQByYB3mrQZH0WLPs16Tv xYZePkh0V6EG53MI1kEe0IlMvWRyCmw+y7Agw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709838924; x=1710443724; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=adtXnm+UfFx0dkkz1N9cMCbOWjdrx1dY7LOvsQ2Ti4s=; b=vuuQ1BTgpevmKzubqokBKH8vEg6a0xxC7z99xCSzaHE0wTuAeUPgviylKUQYnSNcwz 2Zs3qU+axHvbxC4BalcGk1lZIBzKfoChZ6lOX+e1ibw7j5aKFfk461K1ktIzz/xcwVgS 8yLIFy33rujRdwWLigxzk6nu5ZXxMs9YmO4jSCA3WKeXHe0UfgtQsXiX6HADwQGboWkL 74E2PlU013XBkNVKV3Gt9ZDbKYpGBJvSefrkIJtd3xWw7UdB+MbWcJXoMNAlP0wKXbA5 B/fGx73Zq3VXi3Dn3PR4JQfwmyXVR6zXQSHl8VjaMXH56WjNsaI4ZpzdxIsMbCaLoEwE Y0+g== X-Forwarded-Encrypted: i=1; AJvYcCUif4HA1zfxSRJY+IhQ3qlPO3UEP553Fx2ExWRZCG+RNbHUDhrrjxIZvejHsRklURkG6In5yGLb7kwB6rCJk2kkahqJVcw4QRxmH5o5whsQNn5QYa8= X-Gm-Message-State: AOJu0YyKEmrNvO+tNFLZd4I4tEl3N70NWUFhn3uu6siptXAIjDUiAoiQ ZStfxNCgpucI2xLO4Za/S1n6KUreMAbuTEd5B/VBKxNJM/TlvHuS88mfv9rxeg== X-Google-Smtp-Source: AGHT+IEfz0ZlLYkTZgYNEzshYOrsBM9a29I/dbatU4XBUS/LLZXPEPxmsUjxmgrOyECAYIyMWb6Mxg== X-Received: by 2002:a17:902:6845:b0:1db:e78e:b38d with SMTP id f5-20020a170902684500b001dbe78eb38dmr8469823pln.18.1709838924636; Thu, 07 Mar 2024 11:15:24 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id li4-20020a170903294400b001d8f82c61cdsm15036341plb.231.2024.03.07.11.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 11:15:24 -0800 (PST) Date: Thu, 7 Mar 2024 11:15:23 -0800 From: Kees Cook To: Arnd Bergmann Cc: Jeremy Linton , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , "Jason A . Donenfeld" , "Gustavo A. R. Silva" , Mark Rutland , Steven Rostedt , Mark Brown , Guo Hui , Manoj.Iyer@arm.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, James Yang , Shiyou Huang Subject: Re: [PATCH 1/1] arm64: syscall: Direct PRNG kstack randomization Message-ID: <202403071112.01B4579@keescook> References: <20240305221824.3300322-1-jeremy.linton@arm.com> <20240305221824.3300322-2-jeremy.linton@arm.com> <202403051526.0BE26F99E@keescook> <34351804-ad1d-498f-932a-c1844b78589f@app.fastmail.com> <38f9541b-dd88-4d49-af3b-bc7880a4e2f4@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240307_111526_405696_ED3CB10C X-CRM114-Status: GOOD ( 18.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Mar 07, 2024 at 12:10:34PM +0100, Arnd Bergmann wrote: > There is not even any attempt to use the most random bits of > the cycle counter, as both the high 22 to 24 bits get masked > out (to keep the wasted stack space small) and the low 3 or 4 > bits get ignored because of stack alignment. If there was > any desire to make it more random, a trivial improvement > would be: > > +++ b/include/linux/randomize_kstack.h > @@ -80,7 +80,7 @@ DECLARE_PER_CPU(u32, kstack_offset); > if (static_branch_maybe(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT, \ > &randomize_kstack_offset)) { \ > u32 offset = raw_cpu_read(kstack_offset); \ > - offset ^= (rand); \ > + offset = ror32(offset, 5) & (rand); \ Shouldn't this stay ^ instead of & ? > raw_cpu_write(kstack_offset, offset); \ > } \ > } while (0) But yeah, we should likely make this change regardless. > My impression is that is is already bordering on becoming > a "bespoke rng" implementation that Jason was objecting to, > so the current version is intentionally left weak in order > to not even give the appearance of being a security relevant > feature. I don't think it's bad to make a trivial improvement to entropy diffusion. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel