[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrW93mtF+Q=A=t2OkAN3dTFonrZRMUzQhQ+2gkS3o1W1ZA@mail.gmail.com>
Date: Wed, 1 May 2019 16:33:35 -0700
From: Andy Lutomirski <luto@...nel.org>
To: David Laight <David.Laight@...lab.com>
Cc: "Reshetova, Elena" <elena.reshetova@...el.com>,
"Theodore Ts'o" <tytso@....edu>,
Eric Biggers <ebiggers3@...il.com>,
"ebiggers@...gle.com" <ebiggers@...gle.com>,
"herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
"keescook@...omium.org" <keescook@...omium.org>,
Daniel Borkmann <daniel@...earbox.net>,
"luto@...nel.org" <luto@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"jpoimboe@...hat.com" <jpoimboe@...hat.com>,
"jannh@...gle.com" <jannh@...gle.com>,
"Perla, Enrico" <enrico.perla@...el.com>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
"Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
Subject: Re: [PATCH] x86/entry/64: randomize kernel stack offset upon syscall
On Wed, May 1, 2019 at 1:42 AM David Laight <David.Laight@...lab.com> wrote:
>
> From: Reshetova, Elena
> > Sent: 30 April 2019 18:51
> ...
> > +unsigned char random_get_byte(void)
> > +{
> > + struct rnd_buffer *buffer = &get_cpu_var(stack_rand_offset);
> > + unsigned char res;
> > +
> > + if (buffer->byte_counter >= RANDOM_BUFFER_SIZE) {
> > + get_random_bytes(&(buffer->buffer), sizeof(buffer->buffer));
> > + buffer->byte_counter = 0;
> > + }
> > +
> > + res = buffer->buffer[buffer->byte_counter];
> > + buffer->buffer[buffer->byte_counter] = 0;
>
> If is really worth dirtying a cache line to zero data we've used?
> The unused bytes following are much more interesting.
>
For this particular use case, zeroing is probably worthless. But, for
the general case of get_random_bytes(), we need to zero, and I would
argue that get_random_bytes() should be doing exactly this in general.
Powered by blists - more mailing lists