[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200421070206.GB14448@willie-the-truck>
Date: Tue, 21 Apr 2020 08:02:06 +0100
From: Will Deacon <will@...nel.org>
To: Kees Cook <keescook@...omium.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Elena Reshetova <elena.reshetova@...el.com>, x86@...nel.org,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Catalin Marinas <catalin.marinas@....com>,
Mark Rutland <mark.rutland@....com>,
Alexander Potapenko <glider@...gle.com>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Jann Horn <jannh@...gle.com>,
"Perla, Enrico" <enrico.perla@...el.com>,
kernel-hardening@...ts.openwall.com,
linux-arm-kernel@...ts.infradead.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 5/5] arm64: entry: Enable random_kstack_offset support
On Mon, Apr 20, 2020 at 03:34:57PM -0700, Kees Cook wrote:
> On Mon, Apr 20, 2020 at 09:54:58PM +0100, Will Deacon wrote:
> > On Tue, Mar 24, 2020 at 01:32:31PM -0700, Kees Cook wrote:
> > > + /*
> > > + * Since the compiler chooses a 4 bit alignment for the stack,
> > > + * let's save one additional bit (9 total), which gets us up
> > > + * near 5 bits of entropy.
> > > + */
> > > + choose_random_kstack_offset(get_random_int() & 0x1FF);
> >
> > Hmm, this comment doesn't make any sense to me. I mean, I get that 0x1ff
> > is 9 bits, and that is 4+5 but so what?
>
> Er, well, yes. I guess I was just trying to explain why there were 9
> bits saved here and to document what I was seeing the compiler actually
> doing with the values. (And it serves as a comparison to the x86 comment
> which is explaining similar calculations in the face of x86_64 vs ia32.)
>
> Would something like this be better?
>
> /*
> * Since the compiler uses 4 bit alignment for the stack (1 more than
> * x86_64), let's try to match the 5ish-bit entropy seen in x86_64,
> * instead of having needlessly lower entropy. As a result, keep the
> * low 9 bits.
> */
Yes, thank you! I was missing the comparison to x86_64 and so the one
"additional" bit didn't make sense to me.
With the new comment:
Acked-by: Will Deacon <will@...nel.org>
I'm assuming you're merging this via some other tree, but let me know
if you need anything else from me.
Cheers,
Will
Powered by blists - more mailing lists