Le 15/02/2019 à 01:04, Daniel Axtens a écrit :
Wire up KASAN. Only outline instrumentation is supported.

The KASAN shadow area is mapped into vmemmap space:
0x8000 0400 0000 0000 to 0x8000 0600 0000 0000.
To do this we require that vmemmap be disabled. (This is the default
in the kernel config that QorIQ provides for the machine in their
SDK anyway - they use flat memory.)

Only the kernel linear mapping (0xc000...) is checked. The vmalloc and
ioremap areas (also in 0x800...) are all mapped to a zero page. As
with the Book3S hash series, this requires overriding the memory <->
shadow mapping.

Also, as with both previous 64-bit series, early instrumentation is not
supported.  It would allow us to drop the check_return_arch_not_ready()
hook in the KASAN core, but it's tricky to get it set up early enough:
we need it setup before the first call to instrumented code like printk().
Perhaps in the future.

Only KASAN_MINIMAL works.

Lightly tested on e6500. KVM, kexec and xmon have not been tested.

The test_kasan module fires warnings as expected, except for the
following tests:

  - Expected/by design:
kasan test: memcg_accounted_kmem_cache allocate memcg accounted object

  - Due to only supporting KASAN_MINIMAL:
kasan test: kasan_stack_oob out-of-bounds on stack
kasan test: kasan_global_oob out-of-bounds global variable
kasan test: kasan_alloca_oob_left out-of-bounds to left on alloca
kasan test: kasan_alloca_oob_right out-of-bounds to right on alloca
kasan test: use_after_scope_test use-after-scope on int
kasan test: use_after_scope_test use-after-scope on array

Thanks to those who have done the heavy lifting over the past several years:
  - Christophe's 32 bit series: 
https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-February/185379.html
  - Aneesh's Book3S hash series: https://lwn.net/Articles/655642/
  - Balbir's Book3S radix series: https://patchwork.ozlabs.org/patch/795211/

Cc: Christophe Leroy <christophe.le...@c-s.fr>
Cc: Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com>
Cc: Balbir Singh <bsinghar...@gmail.com>
Signed-off-by: Daniel Axtens <d...@axtens.net>

---

While useful if you have a book3e device, this is mostly intended
as a warm-up exercise for reviving Aneesh's series for book3s hash.
In particular, changes to the kasan core are going to be required
for hash and radix as well.
---
  arch/powerpc/Kconfig                         |  1 +
  arch/powerpc/Makefile                        |  2 +
  arch/powerpc/include/asm/kasan.h             | 77 ++++++++++++++++++--
  arch/powerpc/include/asm/ppc_asm.h           |  7 ++
  arch/powerpc/include/asm/string.h            |  7 +-
  arch/powerpc/lib/mem_64.S                    |  6 +-
  arch/powerpc/lib/memcmp_64.S                 |  5 +-
  arch/powerpc/lib/memcpy_64.S                 |  3 +-
  arch/powerpc/lib/string.S                    | 15 ++--
  arch/powerpc/mm/Makefile                     |  2 +
  arch/powerpc/mm/kasan/Makefile               |  1 +
  arch/powerpc/mm/kasan/kasan_init_book3e_64.c | 53 ++++++++++++++
  arch/powerpc/purgatory/Makefile              |  3 +
  arch/powerpc/xmon/Makefile                   |  1 +
  14 files changed, 164 insertions(+), 19 deletions(-)
  create mode 100644 arch/powerpc/mm/kasan/kasan_init_book3e_64.c

[snip]

diff --git a/arch/powerpc/mm/kasan/kasan_init_book3e_64.c 
b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
new file mode 100644
index 000000000000..93b9afcf1020
--- /dev/null
+++ b/arch/powerpc/mm/kasan/kasan_init_book3e_64.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define DISABLE_BRANCH_PROFILING
+
+#include <linux/kasan.h>
+#include <linux/printk.h>
+#include <linux/memblock.h>
+#include <linux/sched/task.h>
+#include <asm/pgalloc.h>
+
+DEFINE_STATIC_KEY_FALSE(powerpc_kasan_enabled_key);
+EXPORT_SYMBOL(powerpc_kasan_enabled_key);

Why does this symbol need to be exported ?

Christophe

Reply via email to