All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 0/5] kasan: support backing vmalloc space with real shadow memory
@ 2019-10-29  4:20 Daniel Axtens
  2019-10-29  4:20 ` [PATCH v10 1/5] " Daniel Axtens
                   ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Daniel Axtens @ 2019-10-29  4:20 UTC (permalink / raw)
  To: kasan-dev, linux-mm, x86, aryabinin, glider, luto, linux-kernel,
	mark.rutland, dvyukov, christophe.leroy
  Cc: linuxppc-dev, gor, Daniel Axtens

Currently, vmalloc space is backed by the early shadow page. This
means that kasan is incompatible with VMAP_STACK.

This series provides a mechanism to back vmalloc space with real,
dynamically allocated memory. I have only wired up x86, because that's
the only currently supported arch I can work with easily, but it's
very easy to wire up other architectures, and it appears that there is
some work-in-progress code to do this on arm64 and s390.

This has been discussed before in the context of VMAP_STACK:
 - https://bugzilla.kernel.org/show_bug.cgi?id=202009
 - https://lkml.org/lkml/2018/7/22/198
 - https://lkml.org/lkml/2019/7/19/822

In terms of implementation details:

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.

Daniel Axtens (5):
  kasan: support backing vmalloc space with real shadow memory
  kasan: add test for vmalloc
  fork: support VMAP_STACK with KASAN_VMALLOC
  x86/kasan: support KASAN_VMALLOC
  kasan debug: track pages allocated for vmalloc shadow

 Documentation/dev-tools/kasan.rst |  63 ++++++++
 arch/Kconfig                      |   9 +-
 arch/x86/Kconfig                  |   1 +
 arch/x86/mm/kasan_init_64.c       |  60 +++++++
 include/linux/kasan.h             |  31 ++++
 include/linux/moduleloader.h      |   2 +-
 include/linux/vmalloc.h           |  12 ++
 kernel/fork.c                     |   4 +
 lib/Kconfig.kasan                 |  16 ++
 lib/test_kasan.c                  |  26 +++
 mm/kasan/common.c                 | 254 ++++++++++++++++++++++++++++++
 mm/kasan/generic_report.c         |   3 +
 mm/kasan/kasan.h                  |   1 +
 mm/vmalloc.c                      |  53 ++++++-
 14 files changed, 522 insertions(+), 13 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-10-31  9:39 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-10-29 16:42     ` Andrey Ryabinin
2019-10-30 14:29   ` Uladzislau Rezki
2019-10-30 14:29     ` Uladzislau Rezki
2019-10-31  9:36     ` Daniel Axtens
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 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-29 17:21     ` Andrey Ryabinin
2019-10-30 13:50     ` Daniel Axtens
2019-10-30 13:50       ` Daniel Axtens
2019-10-30 14:12       ` Andrey Ryabinin
2019-10-30 14:12         ` Andrey Ryabinin
2019-10-30 14:21         ` Daniel Axtens
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
2019-10-29 17:34     ` Andrey Ryabinin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.