[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <db9bc2dc-6a66-4248-b8ab-abc2723af053@app.fastmail.com>
Date: Thu, 07 Mar 2024 23:02:44 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Kees Cook" <keescook@...omium.org>
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 7, 2024, at 20:15, Kees Cook wrote:
> 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 & ?
Yes, my mistake.
>> raw_cpu_write(kstack_offset, offset); \
>> } \
>> } while (0)
>
> But yeah, we should likely make this change regardless.
Ok, do you want to send a patch, or should I?
Arnd
Powered by blists - more mailing lists