Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1706174lqp; Sat, 23 Mar 2024 05:48:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4P5/i0v3bMBo/2J+N8nD7w6LgjzoXOj5KcH9cejGJho/9NqBqln2kc/XwTAa+5j5UuzwXyjEqHeLsu44Ql+dmDi1xMIJeMJ8TvDc4Og== X-Google-Smtp-Source: AGHT+IFC7nT1j+WL048wP2O8bG91KqhIsWj6r8FLMvWKm9esFo9ED+A3+6uwj1VA+1CyS7lwOpOZ X-Received: by 2002:ad4:5d6f:0:b0:696:455c:a849 with SMTP id fn15-20020ad45d6f000000b00696455ca849mr2788105qvb.25.1711198083179; Sat, 23 Mar 2024 05:48:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711198083; cv=pass; d=google.com; s=arc-20160816; b=FM6f58gRuHeycHe2CcxF5o34HHQEhqi9hVWiS23ADcl8Pm/T8vhJzlDj6/HgEJXDSI YYCiOT2kVk5rZ6eVdksq0GoDlC8//iJ++DUvpKGAUB54qk/DMb1T8Kj8lD1Nq1/P7AnC mAdbkzOnEc7D8eBVSy1SPpnw8HxMJ0yPCWxFA/JmGXO9jWr3xfJQ9EKVn72PaZJ3aB6+ x6lKyE2UX+K5cshxUy9a7f7X6jfSLDaobUpqmHqCg3kol4fsnfuXq2zUR+0Dq5+K/O8B hIm6NL/BV/sQH9KmHMSgYfxvjJC+P7aV0XySnI+Dg4DPgdze11P+96coRBFc4Mylm5y4 Qtrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=no3SxpIrjYuNJG9JdLGwJceQHSCubNomtZhDzLJ/D4o=; fh=5a75ftJHdPwdzLfr6x/JVxfHynQDxgfWeBTSvQSS4Co=; b=yaXVQjBfmyKrUYppCkQv7uO+BFIohJfW1sPfbmMqDw7ZW7tcLiTVDQ7Fks/XZBbMKE RMUi+of/OTIhmGf3o4kBRhT0G4Fkhqnd3n+wPGDVTobrp1Dtnm0Z0GrqKKKAsRgppaz+ VR6clmxSV7/ohX2w2+XzsEXfKs1YBbMdmJ4AVUlvn4AoNfylolgFtiXlLPubVSQPiVmx LwfFq75vDGBOf7udjQEJx31zAAzfMiZ9aA37iMY/SgZ/H6kaO+J6rGeCSDc6FzOoaRw1 3iarZsXEetGfPt2vs0tnwlM+Qp7MhJt2cj8xCsMMe8B0PK7jTZFupAhyGnhe663JmaT5 wItw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=epygnKxe; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rWHPG+dj; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-112348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id im1-20020a056214246100b0069037a85652si4046148qvb.18.2024.03.23.05.48.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Mar 2024 05:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=epygnKxe; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rWHPG+dj; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-112348-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112348-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D17EE1C21EBF for ; Sat, 23 Mar 2024 12:48:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FA7539AF1; Sat, 23 Mar 2024 12:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="epygnKxe"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rWHPG+dj" Received: from wfout5-smtp.messagingengine.com (wfout5-smtp.messagingengine.com [64.147.123.148]) (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 498501DDC9; Sat, 23 Mar 2024 12:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711198075; cv=none; b=liZpDy2fHbUuua86gQKcF09V8g7K/qKITe6nXQIWMjrT5AjOfYC9yaNVFpQRUF0dZb1U2pSek52Ctx8lZU2oL09xcFYoD1cwyqsOX64Y/wE5uMk9JLA1vJy++ID3QExddUr0h1wUoBhlFGQOCd3pVyR6u598cUMJDODFblaviMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711198075; c=relaxed/simple; bh=DK8kn31nMc4vLLNkopTWFlKbbvyPKPiFHunCkcXMieQ=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=K8xSfujddaxRiySNtUpQDm1JzursNXXEHIlF4+/JzcUvvJZoaEZTK0nUmPMbqDC6aB8C9NhvflgHZ4/bLzO+hCXsG+S9IIFJuZSD4GRZdFe5kMwefYEzlbMKRMK2JLnRi9D+Cr570wyvBxvCRNO/xel3NIxWAhU+QIYceaYCwfk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=epygnKxe; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=rWHPG+dj; arc=none smtp.client-ip=64.147.123.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id DF3811C000A7; Sat, 23 Mar 2024 08:47:50 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Sat, 23 Mar 2024 08:47:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1711198070; x=1711284470; bh=no3SxpIrjY uNJG9JdLGwJceQHSCubNomtZhDzLJ/D4o=; b=epygnKxeUHDKv/1k8Tp6dWRUzA QjRORAIJdjyi+4voAuYw3zil0q9w2xtCJLqnqIIltzo9zW/INN5mfqU28X9ykelU uXDHsrwuHNXk5/IRa1SprNynh+6h4ca7nzjox4+tgdxd1kX3O8KX2Nut7Qy0Q2SU aXcerVaYPHRjijlcAJZEM2jc1e9kgg3ASmI6RgCGwjOPaN8x+8Z10AtrWfo43Bl8 JTvSirUgRSD+Y4mNngF61z69NorJvRLPtzgfPUIewhr9q8JS9BdlrdwOcWZiwCd5 HW3ONw2gveusbmHYoMUWtZekbt63Pnq74V7hV6cgzjCLdYaXo6xQveGXrg8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1711198070; x=1711284470; bh=no3SxpIrjYuNJG9JdLGwJceQHSCu bNomtZhDzLJ/D4o=; b=rWHPG+djIQkMTy7dtpYCukU5eXVYdVF5nJEwLAmtIyyx YM+oSx2HAHvNEEORhOTWM3rFSj6opLGuLMjidwamWbdwG53Luv690zsJciwnNARl xinbwufK1SVOY48KBufE9ZxdfgwJ3WcE4vpyr6ksu0KQahLl+EvjoDInVQEoMwDi x2wPgy9v86CCvmWFMeeq9yROkRmtupo/0G7o07xkQN9Jv3xxx2abC0KzgPzJU4Gh oKEZ7+u4Q1OYiI7NlJv3yGLIkJ6B0zOsKqbR6SuclltnHI1uEbmOTSKmVFi/OACl nYwUl3O1XBZNLIbjvKXdlJfKeun386Wt1muNfoTuIQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledruddtgedggeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8DE76B6008D; Sat, 23 Mar 2024 08:47:49 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-332-gdeb4194079-fm-20240319.002-gdeb41940 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: In-Reply-To: <2ebe2ea5-b107-4020-8e60-ff8cf43a3aab@arm.com> 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> <2ebe2ea5-b107-4020-8e60-ff8cf43a3aab@arm.com> Date: Sat, 23 Mar 2024 13:47:29 +0100 From: "Arnd Bergmann" To: "Jeremy Linton" , "Kees Cook" Cc: 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 Content-Type: text/plain On Sat, Mar 23, 2024, at 00:40, Jeremy Linton wrote: > On 3/8/24 14:29, Arnd Bergmann wrote: >> On Fri, Mar 8, 2024, at 17:49, Jeremy Linton wrote: >>> On 3/7/24 05:10, Arnd Bergmann wrote: >>>> >>>> I'm not sure I understand the logic. Do you mean that accessing >>>> CNTVCT itself is slow, or that reseeding based on CNTVCT is slow >>>> because of the overhead of reseeding? >>> >>> Slow, as in, its running at a much lower frequency than a cycle counter. >> >> Ok, I see. Would it be possible to use PMEVCNTR0 instead? > > So, I presume you actually mean PMCCNTR_EL0 because I don't see the > point of a dedicated event, although maybe... Right, that would make more sense. > So, the first and maybe largest problem is the PMxxx registers are all > optional because the PMU is optional! Although, they are strongly > recommended and most (AFAIK) machines do implement them. So, maybe if > its just using a cycle counter to dump some entropy into rnd_state it > becomes a statement that kstack randomization is slower or unsupported > if there isn't a PMU? I think that sounds workable, especially as there is already the randomize_kstack_offset=on/off conditional at boot time, it could fall back to just not randomizing and print a warning if the feature is enabled but unavailable at boot time. > But then we have to basically enable the PMU cycle counter globally, > which requires reworking how it works, because the cycle counter is > enabled/disabled and reset on the fly depending on whether the user is > trying to profile something. So, I have hacked that up, and it appears > to be working, although i'm not sure what kind of interaction will > happen with KVM yet. > > But I guess the larger question is whether its worth changing the PMU > behavior for this? I don't know too much about how the PMU works in detail, but I'm also worried about two possible issues that end up preventing us from using it in practice: - if enabling PMCCNTR_EL0 takes away one of the limited number of available counters, we probably don't want to go there - similarly, I would expect it to have a nonzero power consumption if the default is to have the clock disabled and non-counting. Probably not a big deal for server machines, but could be an issue on battery powered embedded devices. Arnd