From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E5393090E0 for ; Mon, 17 Nov 2025 17:46:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763401618; cv=none; b=SMkb2S+gk4WQdQ7aqyF/j//YtTeW4V0a4xqI7zNQwlJQlu7VYvVOgQLi5T9tsqMZtOMKaxFz5Dnbt2JmAZE4aQP+Z/pYxtLJBn/ApVkpU9zlzVLbuwRU4ITblpuvkFOmGqgExnv8UYq1mYl4uRRMQHi+s7u/40wcjN1OnGTS380= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763401618; c=relaxed/simple; bh=flgqLIpLrbuSQLQfubWfoPikNhjmbEuY51qXjlVw5Fo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gPhdBYmx94TY550J83ODHwqKf/40Vhz+ekph95alyWgAi+HWLcts3r0sMRGsz//6kq7O3rb1PGn6inWMh16L1Cj52AwrcUyHMFt1Mvn6VkLGLAkY9EjA/XIcQ048mZaAEu0s+F6laFerLR5y7JTMEX1KKmnXq9eMW1A7G4DttpA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D295EFEC; Mon, 17 Nov 2025 09:46:48 -0800 (PST) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8EE8E3F66E; Mon, 17 Nov 2025 09:46:54 -0800 (PST) Date: Mon, 17 Nov 2025 17:46:49 +0000 From: Mark Rutland To: Arnd Bergmann Cc: Ryan Roberts , Kees Cook , Ard Biesheuvel , Jeremy Linton , Will Deacon , Catalin Marinas , "linux-arm-kernel@lists.infradead.org" , Linux Kernel Mailing List , "Jason A. Donenfeld" Subject: Re: [DISCUSSION] kstack offset randomization: bugs and performance Message-ID: 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 17, 2025 at 05:47:05PM +0100, Arnd Bergmann wrote: > As I understand, the other architectures already just use the cycle counter > because that is random enough, but for arm64 the cntvct runs on an > unspecified frequency that is often too low. > > However, most future machines are ARMv9.1 or higher and require a 1GHz > timer frequency. I also checked Graviton-3 (Neoverse-V1, ARMv8.4), which > is running its timer at 1.05GHz. Note that 1GHz requirement is for the *effective frequency*, not the underlying counter resolution. The 1GHz requirement means that the counter must increment by 10^9 per second, but it doesn't mean that it actually increments by 1 every 1 ns. See ARM DDI 0487 L.b, page D12-6793, which says: | Counter resolution | | The counter resolution is a representation of how frequently the | counter is updated. | | For example, a counter might have an effective frequency of 1GHz, but | the actual clock runs at 125MHz and therefore the counter resolution | is 125Mhz. | | From Armv8.6, Arm recommends the counter resolution is not less than | 50MHz in normal running operation. ... and note that (unfortunately) that latter point is a recommendation, not a requirement. > My M2 Mac is running at a slower 24MHz timer. Between two getpid() > syscalls, I see cntvct_el0 advance between 20 and 70 cycles, which > still gives a few bits of entropy but not the six bits we actually > want to use. > > How about we just check the timer frequency at boot and patch out the > get_random_u16 call for a cntvct read if it gets updated fast enough? > That would at least take care of the overhead on most new designs and > hopefully on a large subset of the servers that are in active use. As above, we cannot rely on the frequency for this, and I don't think we should use the timer in this way. To be clear, my objection here is purely about the timer. I don't want us to rely upon something that doesn't actually provide the guarantee we need. I'm more than happy with the mechanism for randomization being changed. Mark.