lkml.org 
[lkml]   [2019]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] x86/entry/64: randomize kernel stack offset upon syscall
On Wed, May 1, 2019 at 1:42 AM David Laight <David.Laight@aculab.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.

\
 
 \ /
  Last update: 2019-05-02 01:34    [W:0.128 / U:0.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site