From: "Arnd Bergmann" <arnd@arndb.de>
To: "Jeremy Linton" <jeremy.linton@arm.com>,
linux-arm-kernel@lists.infradead.org
Cc: "Catalin Marinas" <catalin.marinas@arm.com>,
"Will Deacon" <will@kernel.org>,
"Kees Cook" <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Mark Brown" <broonie@kernel.org>,
"Guo Hui" <guohui@uniontech.com>,
Manoj.Iyer@arm.com, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org,
"James Yang" <james.yang@arm.com>,
"Shiyou Huang" <shiyou.huang@arm.com>
Subject: Re: [RFC] arm64: syscall: Direct PRNG kstack randomization
Date: Wed, 21 Feb 2024 10:48:12 +0100 [thread overview]
Message-ID: <938f3418-fd88-476d-b67f-3f7ada98e444@app.fastmail.com> (raw)
In-Reply-To: <20240221020258.1210148-1-jeremy.linton@arm.com>
On Wed, Feb 21, 2024, at 03:02, Jeremy Linton wrote:
> The existing arm64 stack randomization uses the kernel rng to acquire
> 5 bits of address space randomization. This is problematic because it
> creates non determinism in the syscall path when the rng needs to be
> generated or reseeded. This shows up as large tail latencies in some
> benchmarks and directly affects the minimum RT latencies as seen by
> cyclictest.
Hi Jeremy,
I think from your description it's clear that reseeding the
rng is a problem for predictable RT latencies, but at the same
time we have too many things going on to fix this by
special-casing kstack randomization on one architecture:
- if reseeding latency is a problem, can we be sure that
none of the other ~500 files containing a call to
get_random_{bytes,long,u8,u16,u32,u64} are in an equally
critical path for RT? Maybe those are just harder to hit?
- CONFIG_RANDOMIZE_KSTACK_OFFSET can already be disabled
at compile or at at boot time to avoid the overhead entirely,
which may be the right thing to do for users that care more
deeply about syscall latencies than the fairly weak stack
randomization. Most architectures don't implement it at all.
- It looks like the unpredictable latency from reseeding
started with f5b98461cb81 ("random: use chacha20 for
get_random_int/long"), which was intended to make
get_random() faster and better, but it could be seen
as regression for real-time latency guarantees. If this
turns out to be a general problem for RT workloads,
the answer might be to bring back an option to make
get_random() have predictable overhead everywhere
rather than special-casing the stack randomization.
> Other architectures are using timers/cycle counters for this function,
> which is sketchy from a randomization perspective because it should be
> possible to estimate this value from knowledge of the syscall return
> time, and from reading the current value of the timer/counters.
>
> So, a poor rng should be better than the cycle counter if it is hard
> to extract the stack offsets sufficiently to be able to detect the
> PRNG's period.
I'm not convinced by the argument that the implementation you
have here is less predictable than the cycle counter, but I
have not done any particular research here and would rely on
others to take a closer look. The 32 bit global state variable
does appear weak, and I know that
OTOH if we can show that a particular implementation is in fact
better than a cycle counter, I strongly think we should
use the same one across all architectures that currently
use the cycle counter.
Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2024-02-21 9:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 2:02 [RFC] arm64: syscall: Direct PRNG kstack randomization Jeremy Linton
2024-02-21 6:33 ` Kees Cook
2024-02-21 12:44 ` Jason A. Donenfeld
2024-02-21 16:54 ` Jeremy Linton
2024-02-21 16:35 ` Jeremy Linton
2024-02-21 9:48 ` Arnd Bergmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=938f3418-fd88-476d-b67f-3f7ada98e444@app.fastmail.com \
--to=arnd@arndb.de \
--cc=Manoj.Iyer@arm.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=guohui@uniontech.com \
--cc=gustavoars@kernel.org \
--cc=james.yang@arm.com \
--cc=jeremy.linton@arm.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rostedt@goodmis.org \
--cc=shiyou.huang@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox