[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191204224037.GA12896@pc636>
Date: Wed, 4 Dec 2019 23:40:37 +0100
From: Uladzislau Rezki <urezki@...il.com>
To: Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Alexander Potapenko <glider@...gle.com>,
Dmitry Vyukov <dvyukov@...gle.com>, kasan-dev@...glegroups.com,
Daniel Axtens <dja@...ens.net>, Qian Cai <cai@....pw>,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
syzbot+82e323920b78d54aaed5@...kaller.appspotmail.com
Subject: Re: [PATCH 1/2] kasan: fix crashes on access to memory mapped by
vm_map_ram()
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index 4d3b3d60d893..a5412f14f57f 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -1073,6 +1073,7 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
> struct vmap_area *va, *pva;
> unsigned long addr;
> int purged = 0;
> + int ret = -EBUSY;
>
> BUG_ON(!size);
> BUG_ON(offset_in_page(size));
> @@ -1139,6 +1140,10 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
> va->va_end = addr + size;
> va->vm = NULL;
>
> + ret = kasan_populate_vmalloc(addr, size);
> + if (ret)
> + goto out;
> +
But it introduces another issues when is CONFIG_KASAN_VMALLOC=y. If
the kasan_populate_vmalloc() gets failed for some reason it just
leaves the function, that will lead to waste of vmap space.
> spin_lock(&vmap_area_lock);
> insert_vmap_area(va, &vmap_area_root, &vmap_area_list);
> spin_unlock(&vmap_area_lock);
>
ret = kasan_populate_vmalloc(addr, size);
if (ret) {
free_vmap_area(va);
return ERR_PTR(-EBUSY);;
}
> @@ -1169,8 +1174,9 @@ static struct vmap_area *alloc_vmap_area(unsigned long size,
> pr_warn("vmap allocation for size %lu failed: use vmalloc=<size> to increase size\n",
> size);
>
> +out:
> kmem_cache_free(vmap_area_cachep, va);
> - return ERR_PTR(-EBUSY);
> + return ERR_PTR(ret);
> }
>
Powered by blists - more mailing lists