From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Daniel Axtens <dja@axtens.net>,
kasan-dev@googlegroups.com, linux-mm@kvack.org, x86@kernel.org,
glider@google.com, luto@kernel.org, linux-kernel@vger.kernel.org,
mark.rutland@arm.com, dvyukov@google.com,
christophe.leroy@c-s.fr
Cc: linuxppc-dev@lists.ozlabs.org, gor@linux.ibm.com,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v10 1/5] kasan: support backing vmalloc space with real shadow memory
Date: Tue, 29 Oct 2019 19:42:57 +0300 [thread overview]
Message-ID: <f847fc8c-f875-8d93-9d49-8f03d4c6303a@virtuozzo.com> (raw)
In-Reply-To: <20191029042059.28541-2-dja@axtens.net>
On 10/29/19 7:20 AM, 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 mapping would
> therefore be wasteful. Furthermore, to ensure that different mappings
> use different shadow pages, mappings would have to be aligned to
> KASAN_SHADOW_SCALE_SIZE * PAGE_SIZE.
>
> Instead, share backing space across multiple mappings. Allocate a
> backing page when a mapping in vmalloc space uses a particular page of
> the shadow region. This page can be shared by other vmalloc mappings
> later on.
>
> We hook in to the vmap infrastructure to lazily clean up unused shadow
> memory.
>
> To avoid the difficulties around swapping mappings around, this code
> expects that the part of the shadow region that covers the vmalloc
> space will not be covered by the early shadow page, but will be left
> unmapped. This will require changes in arch-specific code.
>
> This allows KASAN with VMAP_STACK, and may be helpful for architectures
> that do not have a separate module space (e.g. powerpc64, which I am
> currently working on). It also allows relaxing the module alignment
> back to PAGE_SIZE.
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=202009
> Acked-by: Vasily Gorbik <gor@linux.ibm.com>
> Co-developed-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com> [shadow rework]
> Signed-off-by: Daniel Axtens <dja@axtens.net>
Small nit bellow, otherwise looks fine:
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> static __always_inline bool
> @@ -1196,8 +1201,8 @@ static void free_vmap_area(struct vmap_area *va)
> * Insert/Merge it back to the free tree/list.
> */
> spin_lock(&free_vmap_area_lock);
> - merge_or_add_vmap_area(va,
> - &free_vmap_area_root, &free_vmap_area_list);
> + (void)merge_or_add_vmap_area(va, &free_vmap_area_root,
> + &free_vmap_area_list);
> spin_unlock(&free_vmap_area_lock);
> }
>
..
>
> @@ -3391,8 +3428,8 @@ struct vm_struct **pcpu_get_vm_areas(const unsigned long *offsets,
> * and when pcpu_get_vm_areas() is success.
> */
> while (area--) {
> - merge_or_add_vmap_area(vas[area],
> - &free_vmap_area_root, &free_vmap_area_list);
> + (void)merge_or_add_vmap_area(vas[area], &free_vmap_area_root,
I don't think these (void) casts are necessary.
> + &free_vmap_area_list);
> vas[area] = NULL;
> }
>
>
next prev parent reply other threads:[~2019-10-29 16:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 4:20 [PATCH v10 0/5] kasan: support backing vmalloc space with real shadow memory Daniel Axtens
2019-10-29 4:20 ` [PATCH v10 1/5] " Daniel Axtens
2019-10-29 16:42 ` Andrey Ryabinin [this message]
2019-10-30 14:29 ` Uladzislau Rezki
2019-10-31 9:36 ` Daniel Axtens
2019-10-29 4:20 ` [PATCH v10 2/5] kasan: add test for vmalloc Daniel Axtens
2019-10-29 16:43 ` Andrey Ryabinin
2019-10-29 4:20 ` [PATCH v10 3/5] fork: support VMAP_STACK with KASAN_VMALLOC Daniel Axtens
2019-10-29 17:07 ` Andrey Ryabinin
2019-10-29 4:20 ` [PATCH v10 4/5] x86/kasan: support KASAN_VMALLOC Daniel Axtens
2019-10-29 17:21 ` Andrey Ryabinin
2019-10-30 13:50 ` Daniel Axtens
2019-10-30 14:12 ` Andrey Ryabinin
2019-10-30 14:21 ` Daniel Axtens
2019-10-29 4:20 ` [PATCH v10 5/5] kasan debug: track pages allocated for vmalloc shadow Daniel Axtens
2019-10-29 17:34 ` Andrey Ryabinin
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=f847fc8c-f875-8d93-9d49-8f03d4c6303a@virtuozzo.com \
--to=aryabinin@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=christophe.leroy@c-s.fr \
--cc=dja@axtens.net \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=gor@linux.ibm.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mark.rutland@arm.com \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).