Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-18 Thread Andrey Ryabinin
On 10/16/19 4:22 PM, Mark Rutland wrote: > Hi Andrey, > > On Wed, Oct 16, 2019 at 03:19:50PM +0300, Andrey Ryabinin wrote: >> On 10/14/19 4:57 PM, Daniel Axtens wrote: > + /* > + * Ensure poisoning is visible before the shadow is made visible > + * to other CPUs. > + */

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-16 Thread Mark Rutland
Hi Andrey, On Wed, Oct 16, 2019 at 03:19:50PM +0300, Andrey Ryabinin wrote: > On 10/14/19 4:57 PM, Daniel Axtens wrote: > >>> + /* > >>> + * Ensure poisoning is visible before the shadow is made visible > >>> + * to other CPUs. > >>> + */ > >>> + smp_wmb(); > >> > >> I'm not quite understand

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-16 Thread Andrey Ryabinin
On 10/14/19 4:57 PM, Daniel Axtens wrote: > Hi Andrey, > > >>> + /* >>> +* Ensure poisoning is visible before the shadow is made visible >>> +* to other CPUs. >>> +*/ >>> + smp_wmb(); >> >> I'm not quite understand what this barrier do and why it needed. >> And if it's really

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-15 Thread Daniel Axtens
> There is a potential problem here, as Will Deacon wrote up at: > > > https://lore.kernel.org/linux-arm-kernel/20190827131818.14724-1-w...@kernel.org/ > > ... in the section starting: > > | *** Other architecture maintainers -- start here! *** > > ... whereby the CPU can spuriously fault on

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-15 Thread Daniel Axtens
>>> @@ -2497,6 +2533,9 @@ void *__vmalloc_node_range(unsigned long size, >>> unsigned long align, >>> if (!addr) >>> return NULL; >>> >>> + if (kasan_populate_vmalloc(real_size, area)) >>> + return NULL; >>> + >> >> KASAN itself uses __vmalloc_node_range() to

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-15 Thread Daniel Axtens
Mark Rutland writes: > On Tue, Oct 01, 2019 at 04:58:30PM +1000, Daniel Axtens wrote: >> Hook into vmalloc and vmap, and dynamically allocate real shadow >> memory to back the mappings. >> >> Most mappings in vmalloc space are small, requiring less than a full >> page of shadow space.

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-14 Thread Mark Rutland
On Tue, Oct 01, 2019 at 04:58:30PM +1000, Daniel Axtens wrote: > Hook into vmalloc and vmap, and dynamically allocate real shadow > memory to back the mappings. > > Most mappings in vmalloc space are small, requiring less than a full > page of shadow space. Allocating a full shadow page per

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-14 Thread Mark Rutland
On Tue, Oct 15, 2019 at 12:57:44AM +1100, Daniel Axtens wrote: > Hi Andrey, > > > >> + /* > >> + * Ensure poisoning is visible before the shadow is made visible > >> + * to other CPUs. > >> + */ > >> + smp_wmb(); > > > > I'm not quite understand what this barrier do and why it needed. >

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-14 Thread Daniel Axtens
Hi Andrey, >> +/* >> + * Ensure poisoning is visible before the shadow is made visible >> + * to other CPUs. >> + */ >> +smp_wmb(); > > I'm not quite understand what this barrier do and why it needed. > And if it's really needed there should be a pairing barrier > on the

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-11 Thread Andrey Ryabinin
On 10/1/19 9:58 AM, Daniel Axtens wrote: > core_initcall(kasan_memhotplug_init); > #endif > + > +#ifdef CONFIG_KASAN_VMALLOC > +static int kasan_populate_vmalloc_pte(pte_t *ptep, unsigned long addr, > + void *unused) > +{ > + unsigned long page; > +

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-10 Thread Daniel Axtens
Hi Uladzislau, > Looking at it one more, i think above part of code is a bit wrong > and should be separated from merge_or_add_vmap_area() logic. The > reason is to keep it simple and do only what it is supposed to do: > merging or adding. > > Also the kasan_release_vmalloc() gets called twice

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-07 Thread Uladzislau Rezki
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index a3c70e275f4e..9fb7a16f42ae 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -690,8 +690,19 @@ merge_or_add_vmap_area(struct vmap_area *va, > struct list_head *next; > struct rb_node **link; > struct rb_node *parent; > +

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-02 Thread Uladzislau Rezki
On Wed, Oct 02, 2019 at 11:23:06AM +1000, Daniel Axtens wrote: > Hi, > > >>/* > >> * Find a place in the tree where VA potentially will be > >> * inserted, unless it is merged with its sibling/siblings. > >> @@ -741,6 +752,10 @@ merge_or_add_vmap_area(struct vmap_area *va, > >>

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-02 Thread Christophe Leroy
Daniel Axtens a écrit : Hi, /* * Find a place in the tree where VA potentially will be * inserted, unless it is merged with its sibling/siblings. @@ -741,6 +752,10 @@ merge_or_add_vmap_area(struct vmap_area *va, if (sibling->va_end == va->va_start) {

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-01 Thread Daniel Axtens
Hi, >> /* >> * Find a place in the tree where VA potentially will be >> * inserted, unless it is merged with its sibling/siblings. >> @@ -741,6 +752,10 @@ merge_or_add_vmap_area(struct vmap_area *va, >> if (sibling->va_end == va->va_start) { >>

Re: [PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-01 Thread Uladzislau Rezki
Hello, Daniel. > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index a3c70e275f4e..9fb7a16f42ae 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -690,8 +690,19 @@ merge_or_add_vmap_area(struct vmap_area *va, > struct list_head *next; > struct rb_node **link; > struct rb_node

[PATCH v8 1/5] kasan: support backing vmalloc space with real shadow memory

2019-10-01 Thread Daniel Axtens
Hook into vmalloc and vmap, and dynamically allocate real shadow memory to back the mappings. Most mappings in vmalloc space are small, requiring less than a full page of shadow space. Allocating a full shadow page per mapping would therefore be wasteful. Furthermore, to ensure that different