From: Uladzislau Rezki <urezki@gmail.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
kasan-dev@googlegroups.com, Daniel Axtens <dja@axtens.net>,
Qian Cai <cai@lca.pw>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
syzbot+82e323920b78d54aaed5@syzkaller.appspotmail.com
Subject: Re: [PATCH 1/2] kasan: fix crashes on access to memory mapped by vm_map_ram()
Date: Wed, 4 Dec 2019 23:40:37 +0100 [thread overview]
Message-ID: <20191204224037.GA12896@pc636> (raw)
In-Reply-To: <20191204204534.32202-1-aryabinin@virtuozzo.com>
> 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);
> }
>
next prev parent reply other threads:[~2019-12-04 22:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-04 20:45 Andrey Ryabinin
2019-12-04 20:45 ` [PATCH 2/2] kasan: Don't allocate page tables in kasan_release_vmalloc() Andrey Ryabinin
2019-12-04 22:22 ` Andrew Morton
2019-12-06 16:20 ` Andrey Ryabinin
2019-12-04 23:28 ` Daniel Axtens
2019-12-05 14:08 ` Daniel Axtens
2019-12-04 22:40 ` Uladzislau Rezki [this message]
2019-12-05 9:59 ` [PATCH v2] kasan: fix crashes on access to memory mapped by vm_map_ram() Andrey Ryabinin
2019-12-06 17:32 ` Uladzislau Rezki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191204224037.GA12896@pc636 \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=cai@lca.pw \
--cc=dja@axtens.net \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=syzbot+82e323920b78d54aaed5@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox