From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37C4E358D20 for ; Mon, 12 Jan 2026 13:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768224985; cv=none; b=dIzJuMNvNnpoL03obSxylNxbXdaeDTuHkaOkUhGqplTkFh5zRI81s9GNv4XDopV30K6Vksoo/uSCwuj6mBa9cCBZCJcOwtm481GcnjH7nDkVdXbL1LvEumvr0piCXOPRb/d7PncQOoVI0x8N+Ygi18Xo6YHKo5qjALVa55w64fo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768224985; c=relaxed/simple; bh=aaBMsDaRPA4eC7AULe89WndPY2/JAXufqja2AvkHIwQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JeEOoSMyU9vPWrk45/Wxu2sALWhOcdeMlmumimkJQGpAS9kAb5VVTcpqiU5KdBkpXp7DjmJIbWKrpzxzgwYyroxjwwXNMAw7Kr1wjDYdc8yzPRbfyzWLasGEPRZd+Y6HqzTdJ4DGbloWcvfOEUwF2zEMGZ1/w0i9YobxhukErxI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m1GnUMgT; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m1GnUMgT" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-42fb0fc5aa9so2929459f8f.1 for ; Mon, 12 Jan 2026 05:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768224982; x=1768829782; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=bLo3Abz9wAwu25esY4s8FeJ9KMDvXVIZnqcKTN+SMTE=; b=m1GnUMgTpvRRJ4OCsauiIrR5KENIhR9QmjH2ccGYe3HF8tl+bZ9EenqMS0pYcQZ2mD OOa1JfPxvOqMSfiPos3WF10A7b02IA2/VKGZyQysv7aK0UupSD8HC5RDuqP6OsfjggUG 5DgERCj1wHZRBH+aPxoqLCINLwdIFlrZw8/D4ALvK3Su2wrfPxrem2hOVc8h+mxH2BVK ZnPNhvHXnVryJnu+Lsw27wL6lmwjWSJnXBtEbJ62Mn8nc4tWBUPUovM7VAHy/FMefhY2 Na40r+xZMaGgNuJacDwA8GttcE0qp0LfL+4X8WVUMHtzEFVx+YOiP8lZwCtNk618OCkV W7zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768224983; x=1768829783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bLo3Abz9wAwu25esY4s8FeJ9KMDvXVIZnqcKTN+SMTE=; b=B0/WQO/jAvqLAk/dvrqCCiICKeOKAfI1crq7fZYmyvp/a1ftCOyeFd7950s0/QhXjN CcFV+dSoZBzYmRFyjmLShnkZykUtSnapHfpn0x6Kp8v0u2T4W/1w180ucUN2RZp0CIv/ lO11VTq3rJhAp/KyGuOgyNEI8Y7rViRBasr0y2sBh8P5kWSpGEjCTxhwHgUMcRP4xQO6 mbgqgDDD/Uo70NHdz+YXlomHEqd1jG/x0r6VAyL4JyRdw8zzMb3kg3+Fp81r/9YlM4FT bbpprHB6fQY8KiQwG0sqYQHdEriknu3hquvpmKKwk8grx3fALZwcy+B3SqoxuBK7Yvw7 6ntw== X-Forwarded-Encrypted: i=1; AJvYcCX04j5o94KwTp4TLSDsksNfAUYyJWNvxIuQsH5zEu5vMexOKIJDI1lci89DjWMObbkoBuwFS/q8S+Vgsz8=@vger.kernel.org X-Gm-Message-State: AOJu0YyPT52z7wSTv9aVf/UZez+LNBdgI7MAx7TT4aiWYdNQrpJaIpph bYHJrw6UVzM9TRRFevnmvH7m+2HEJhX3Nh9hxs2DNzAHu8A3CJcKcEwJ X-Gm-Gg: AY/fxX5SvT7yVl7un57vds/+pZ36DvhPS6BDasEZAFN1+qJJtipPKrkoWMhtF4nWuom sNkIKTd00wiXNIZu+3zILxaEYwGHkdAcN7HACYCIN6AfwnIq5iM2l1ll32+ASW86wV/KROLQzF+ RcXITG77VuOsGUDUzyAWOFkfuiW6b8qsWLzI1nTHLn8nRYs94L6D/SlEdkv1zffZ1W0mAs1IATO WqieozOxWTYX6hYYQhJ99bIyg15rvHYKf4YCHPbll8+bO4xa8OyDq3F3PSVomTwYbpi7ynG3Rha 6wNcP4yKdII70oTcSFEBHopAnl0jKNA/qlPshQKAFnrtLEq4WicXQg19bSpcvPs9NQJeX8846+b WVKXZIACwS2hEEJrjr3ap2EtTKywi6aAf5n5If7j0+vf5xlg2qJ2wH56TON1NoGWGF2XAC8XPs5 UEwtY3QQz/xSwnmDO7ufunnpnTR4NHhbGvGBCibmlkGeyGPIKdPnkQ X-Google-Smtp-Source: AGHT+IGyxiv2XFt49Pj+G/FCKb6Do+/qO1fvIxMUjWKWGTcpTcAtASoZtqcJMaJZUWyMrmC4TwCROg== X-Received: by 2002:a05:6000:40c9:b0:430:fafd:f1d2 with SMTP id ffacd0b85a97d-432c3628374mr22009793f8f.11.1768224982426; Mon, 12 Jan 2026 05:36:22 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd5df9afsm41054434f8f.24.2026.01.12.05.36.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 05:36:22 -0800 (PST) Date: Mon, 12 Jan 2026 13:36:20 +0000 From: David Laight To: Ryan Roberts Cc: Catalin Marinas , Will Deacon , Huacai Chen , Madhavan Srinivasan , Michael Ellerman , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Kees Cook , "Gustavo A. R. Silva" , Arnd Bergmann , Mark Rutland , "Jason A. Donenfeld" , Ard Biesheuvel , Jeremy Linton , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3 3/3] randomize_kstack: Unify random source across arches Message-ID: <20260112133620.2863e1d6@pumpkin> In-Reply-To: <09de87bc-d952-41e7-9657-852c2924aaa7@arm.com> References: <20260102131156.3265118-1-ryan.roberts@arm.com> <20260102131156.3265118-4-ryan.roberts@arm.com> <20260104230136.7aaf8886@pumpkin> <20260107140533.2b3c46a1@pumpkin> <09de87bc-d952-41e7-9657-852c2924aaa7@arm.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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-Transfer-Encoding: 7bit On Mon, 12 Jan 2026 12:26:26 +0000 Ryan Roberts wrote: > On 07/01/2026 14:05, David Laight wrote: > > On Sun, 4 Jan 2026 23:01:36 +0000 > > David Laight wrote: ... > > I've trimmed the initialiser - it is very boring. > > The code to create the initialiser is actually slightly smaller than it is. > > Doable by hand provided you can do 128bit shift and xor without making > > any mistakes. > > > > I've just done a quick search through the kernel sources and haven't found > > many uses of prandom_u32_state() outside of test code. > > There is sched_rng() which uses a per-cpu rng to throw a 1024 sized die. > > bpf also has a per-cpu one for 'unprivileged user space'. > > net/sched/sch_netem.c seems to use one - mostly for packet loss generation. > > > > Since the randomize_kstack code is now using a per-task rng (initialised > > by clone?) that could be used instead of all the others provided they > > are run when 'current' is valid. > > > > But the existing prandom_u32_state() needs a big health warning that > > four outputs leak the entire state. > > That is fixable by changing the last line to: > > return state->s1 + state->s2 + state->s3 + state->s4; > > That only affects the output value, the period is unchanged. > > Hi David, > > This all seems interesting, but I'm not clear that it is a blocker for this > series. As I keep saying, we only use 6 bits for offset randmization so it is > trival to brute force, regardless of how easy it is to recover the prng state. > > Perhaps we can decouple these 2 things and make them independent: > > - this series, which is motivated by speeding up syscalls on arm64; given 6 > bits is not hard to brute force, spending a lot of cycles calculating those > bits is unjustified. > > - Your observation that that the current prng could be improved to make > recoving it's state harder. > > What do you think? They are separate. I should have a 'mostly written' patch series for prandom_u32_state(). If you unconditionally add a per-task prng there are a few places that could use it instead of a per-cpu one. It could be 'perturbed' during task switch - eg by: s->s1 = (s->s1 ^ something) | 2; (The 2 stops the new value being 0 or 1, losing 1 bit wont be significant.) This one is much nearer 'ready' and has an obvious impact. David > > Thanks, > Ryan > > > > > > David > > > > >