Message ID | 8afdf7eb0bae77d2e94210d689d524580cf5ed9a.1638308023.git.andreyknvl@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | kasan, vmalloc, arm64: add vmalloc tagging support for SW/HW_TAGS | expand |
On Tue, Nov 30, 2021 at 11:08PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov <andreyknvl@google.com> > > vmalloc tagging support for HW_TAGS KASAN is now complete. > > Allow enabling CONFIG_KASAN_VMALLOC. This actually doesn't "allow" enabling it, it unconditionally enables it and a user can't disable CONFIG_KASAN_VMALLOC. I found some background in acc3042d62cb9 why arm64 wants this. > Also adjust CONFIG_KASAN_VMALLOC description: > > - Mention HW_TAGS support. > - Remove unneeded internal details: they have no place in Kconfig > description and are already explained in the documentation. > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com> > --- > arch/arm64/Kconfig | 3 +-- > lib/Kconfig.kasan | 20 ++++++++++---------- > 2 files changed, 11 insertions(+), 12 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index c05d7a06276f..5981e5460c51 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -205,8 +205,7 @@ config ARM64 > select IOMMU_DMA if IOMMU_SUPPORT > select IRQ_DOMAIN > select IRQ_FORCED_THREADING > - select KASAN_VMALLOC if KASAN_GENERIC > - select KASAN_VMALLOC if KASAN_SW_TAGS > + select KASAN_VMALLOC This produces the following warning when making an arm64 defconfig: | WARNING: unmet direct dependencies detected for KASAN_VMALLOC | Depends on [n]: KASAN [=n] && HAVE_ARCH_KASAN_VMALLOC [=y] | Selected by [y]: | - ARM64 [=y] | | WARNING: unmet direct dependencies detected for KASAN_VMALLOC | Depends on [n]: KASAN [=n] && HAVE_ARCH_KASAN_VMALLOC [=y] | Selected by [y]: | - ARM64 [=y] To unconditionally select KASAN_VMALLOC, it should probably be select KASAN_VMALLOC if KASAN
On Tue, Nov 30, 2021 at 11:08PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov <andreyknvl@google.com> > > vmalloc tagging support for HW_TAGS KASAN is now complete. > > Allow enabling CONFIG_KASAN_VMALLOC. > > Also adjust CONFIG_KASAN_VMALLOC description: > > - Mention HW_TAGS support. > - Remove unneeded internal details: they have no place in Kconfig > description and are already explained in the documentation. > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com> > --- > arch/arm64/Kconfig | 3 +-- > lib/Kconfig.kasan | 20 ++++++++++---------- Like in the SW_TAGS case, consider moving the lib/Kconfig.kasan change to the final "kasan, vmalloc: add vmalloc support to HW_TAGS" and only leave the arm64 in its own patch.
On Wed, Dec 1, 2021 at 12:35 PM Marco Elver <elver@google.com> wrote: > > On Tue, Nov 30, 2021 at 11:08PM +0100, andrey.konovalov@linux.dev wrote: > > From: Andrey Konovalov <andreyknvl@google.com> > > > > vmalloc tagging support for HW_TAGS KASAN is now complete. > > > > Allow enabling CONFIG_KASAN_VMALLOC. > > This actually doesn't "allow" enabling it, it unconditionally enables it > and a user can't disable CONFIG_KASAN_VMALLOC. > > I found some background in acc3042d62cb9 why arm64 wants this. Indeed. Will adjust the description in v2. > > Also adjust CONFIG_KASAN_VMALLOC description: > > > > - Mention HW_TAGS support. > > - Remove unneeded internal details: they have no place in Kconfig > > description and are already explained in the documentation. > > > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com> > > --- > > arch/arm64/Kconfig | 3 +-- > > lib/Kconfig.kasan | 20 ++++++++++---------- > > 2 files changed, 11 insertions(+), 12 deletions(-) > > > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > > index c05d7a06276f..5981e5460c51 100644 > > --- a/arch/arm64/Kconfig > > +++ b/arch/arm64/Kconfig > > @@ -205,8 +205,7 @@ config ARM64 > > select IOMMU_DMA if IOMMU_SUPPORT > > select IRQ_DOMAIN > > select IRQ_FORCED_THREADING > > - select KASAN_VMALLOC if KASAN_GENERIC > > - select KASAN_VMALLOC if KASAN_SW_TAGS > > + select KASAN_VMALLOC > > This produces the following warning when making an arm64 defconfig: > > | WARNING: unmet direct dependencies detected for KASAN_VMALLOC > | Depends on [n]: KASAN [=n] && HAVE_ARCH_KASAN_VMALLOC [=y] > | Selected by [y]: > | - ARM64 [=y] > | > | WARNING: unmet direct dependencies detected for KASAN_VMALLOC > | Depends on [n]: KASAN [=n] && HAVE_ARCH_KASAN_VMALLOC [=y] > | Selected by [y]: > | - ARM64 [=y] > > To unconditionally select KASAN_VMALLOC, it should probably be > > select KASAN_VMALLOC if KASAN Will fix in v2. Thanks!
On Fri, Dec 3, 2021 at 1:40 PM Marco Elver <elver@google.com> wrote: > > On Tue, Nov 30, 2021 at 11:08PM +0100, andrey.konovalov@linux.dev wrote: > > From: Andrey Konovalov <andreyknvl@google.com> > > > > vmalloc tagging support for HW_TAGS KASAN is now complete. > > > > Allow enabling CONFIG_KASAN_VMALLOC. > > > > Also adjust CONFIG_KASAN_VMALLOC description: > > > > - Mention HW_TAGS support. > > - Remove unneeded internal details: they have no place in Kconfig > > description and are already explained in the documentation. > > > > Signed-off-by: Andrey Konovalov <andreyknvl@google.com> > > --- > > arch/arm64/Kconfig | 3 +-- > > lib/Kconfig.kasan | 20 ++++++++++---------- > > Like in the SW_TAGS case, consider moving the lib/Kconfig.kasan change > to the final "kasan, vmalloc: add vmalloc support to HW_TAGS" and only > leave the arm64 in its own patch. Will do in v2. Thanks!
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c05d7a06276f..5981e5460c51 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -205,8 +205,7 @@ config ARM64 select IOMMU_DMA if IOMMU_SUPPORT select IRQ_DOMAIN select IRQ_FORCED_THREADING - select KASAN_VMALLOC if KASAN_GENERIC - select KASAN_VMALLOC if KASAN_SW_TAGS + select KASAN_VMALLOC select MODULES_USE_ELF_RELA select NEED_DMA_MAP_STATE select NEED_SG_DMA_LENGTH diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 3f144a87f8a3..7834c35a7964 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -178,17 +178,17 @@ config KASAN_TAGS_IDENTIFY memory consumption. config KASAN_VMALLOC - bool "Back mappings in vmalloc space with real shadow memory" - depends on (KASAN_GENERIC || KASAN_SW_TAGS) && HAVE_ARCH_KASAN_VMALLOC + bool "Check accesses to vmalloc allocations" + depends on HAVE_ARCH_KASAN_VMALLOC help - By default, the shadow region for vmalloc space is the read-only - zero page. This means that KASAN cannot detect errors involving - vmalloc space. - - Enabling this option will hook in to vmap/vmalloc and back those - mappings with real shadow memory allocated on demand. This allows - for KASAN to detect more sorts of errors (and to support vmapped - stacks), but at the cost of higher memory usage. + This mode makes KASAN check accesses to vmalloc allocations for + validity. + + With software KASAN modes, checking is done for all types of vmalloc + allocations. Enabling this option leads to higher memory usage. + + With hardware tag-based KASAN, only VM_ALLOC mappings are checked. + There is no additional memory usage. config KASAN_KUNIT_TEST tristate "KUnit-compatible tests of KASAN bug detection capabilities" if !KUNIT_ALL_TESTS