[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202403071112.01B4579@keescook>
Date: Thu, 7 Mar 2024 11:15:23 -0800
From: Kees Cook <keescook@...omium.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Jeremy Linton <jeremy.linton@....com>,
linux-arm-kernel@...ts.infradead.org,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
"Jason A . Donenfeld" <Jason@...c4.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Mark Brown <broonie@...nel.org>, Guo Hui <guohui@...ontech.com>,
Manoj.Iyer@....com, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, James Yang <james.yang@....com>,
Shiyou Huang <shiyou.huang@....com>
Subject: Re: [PATCH 1/1] arm64: syscall: Direct PRNG kstack randomization
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
Powered by blists - more mailing lists