lkml.org 
[lkml]   [2020]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 1/2] scs: switch to vmapped shadow stacks
On Mon, Nov 30, 2020 at 3:44 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Nov 24, 2020 at 11:59:39AM -0800, Sami Tolvanen wrote:
> > +void *scs_alloc(int node)
> > {
> > - void *s = kmem_cache_alloc_node(scs_cache, GFP_SCS, node);
> > + int i;
> > + void *s;
> > +
> > + for (i = 0; i < NR_CACHED_SCS; i++) {
> > + s = this_cpu_xchg(scs_cache[i], NULL);
> > + if (s) {
> > + kasan_unpoison_vmalloc(s, SCS_SIZE);
> > + memset(s, 0, SCS_SIZE);
> > + goto out;
> > + }
> > + }
> > +
> > + s = __vmalloc_node_range(SCS_SIZE, 1, VMALLOC_START, VMALLOC_END,
> > + GFP_SCS, PAGE_KERNEL, 0, node,
> > + __builtin_return_address(0));
> >
> > if (!s)
> > return NULL;
>
> Sorry I didn't spot this before, but if you put the xchg/vmalloc code
> into a new __scs_alloc() function then you can drop the label and this
> becomes:
>
> s = __scs_alloc(...);
> if (!s)
> return NULL;
>
> *__scs_maghic(s) = SCS_ENG_MAGIC;
> ...

Good point, I'll change this in v3.

Sami

\
 
 \ /
  Last update: 2020-11-30 21:07    [W:0.043 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site