Re: [PATCH] x86/entry/64: randomize kernel stack offset upon syscall

From: Ingo Molnar
Date: Thu May 09 2019 - 02:00:48 EST



* Reshetova, Elena <elena.reshetova@xxxxxxxxx> wrote:

> > * Reshetova, Elena <elena.reshetova@xxxxxxxxx> wrote:
> >
> > > CONFIG_PAGE_TABLE_ISOLATION=n:
> > >
> > > base: Simple syscall: 0.0510 microseconds
> > > get_random_bytes(4096 bytes buffer): Simple syscall: 0.0597 microseconds
> > >
> > > So, pure speed wise get_random_bytes() with 1 page per-cpu buffer wins.
> >
> > It still adds +17% overhead to the system call path, which is sad.
> > Why is it so expensive?
>
> I guess I can experiment further with buffer size increase and/or
> using HW acceleration (I mostly played around different rdrand paths now).
>
> What would be acceptable overheard approximately (so that I know how
> much I need to squeeze this thing)?

As much as possible? No idea, I'm sad about anything that is more than
0%, and I'd be *really* sad about anything more than say 1-2%.

I find it ridiculous that even with 4K blocked get_random_bytes(), which
gives us 32k bits, which with 5 bits should amortize the RNG call to
something like "once per 6553 calls", we still see 17% overhead? It's
either a measurement artifact, or something doesn't compute.

Thanks,

Ingo