mbox series

[v2,0/6] KASAN support for 64-bit Book 3S powerpc

Message ID YoTEb2BaH3MDkH+2@cleo (mailing list archive)
Headers show
Series KASAN support for 64-bit Book 3S powerpc | expand

Message

Paul Mackerras May 18, 2022, 10:03 a.m. UTC
This patch series implements KASAN on 64-bit POWER with radix MMU,
such as POWER9 or POWER10.  Daniel Axtens posted previous versions of
these patches, but is no longer working on KASAN, and I have been
asked to get them ready for inclusion.

Because of various technical difficulties, mostly around the need to
allow for code that runs in real mode, we only support "outline" mode
(as opposed to "inline" mode), where the compiler adds a call to
a checking procedure before every store to memory.

This series has known deficiencies, specifically that the kernel will
crash on boot on a HPT system, and that out-of-bounds accesses to
module global data are not caught (which leads to one of the KASAN
tests failing).

v2: Split the large patch 3/3 of the previous series into three
patches and addressed review comments; put the generic documentation
changes in a separate patch at the end of the series; removed the RFC
tag.

Comments welcome.

Paul.

 Documentation/dev-tools/kasan.rst                  |   7 +-
 Documentation/powerpc/kasan.txt                    |  58 ++++++++++++
 arch/powerpc/Kconfig                               |   5 +-
 arch/powerpc/Kconfig.debug                         |   3 +-
 arch/powerpc/include/asm/book3s/64/hash.h          |   4 +
 arch/powerpc/include/asm/book3s/64/pgtable.h       |   3 +
 arch/powerpc/include/asm/book3s/64/radix.h         |  12 ++-
 arch/powerpc/include/asm/interrupt.h               |  52 ++++++++---
 arch/powerpc/include/asm/kasan.h                   |  22 +++++
 arch/powerpc/kernel/Makefile                       |  11 +++
 arch/powerpc/kernel/smp.c                          |  22 ++---
 arch/powerpc/kernel/traps.c                        |   6 +-
 arch/powerpc/kexec/Makefile                        |   2 +
 arch/powerpc/kvm/Makefile                          |   5 +
 arch/powerpc/lib/Makefile                          |   3 +
 arch/powerpc/mm/book3s64/Makefile                  |   9 ++
 arch/powerpc/mm/kasan/Makefile                     |   3 +-
 .../mm/kasan/{kasan_init_32.c => init_32.c}        |   0
 arch/powerpc/mm/kasan/init_book3s_64.c             | 103 +++++++++++++++++++++
 arch/powerpc/mm/ptdump/ptdump.c                    |   3 +-
 arch/powerpc/platforms/Kconfig.cputype             |   1 +
 arch/powerpc/platforms/powernv/Makefile            |   8 ++
 arch/powerpc/platforms/powernv/smp.c               |   2 +-
 arch/powerpc/platforms/pseries/Makefile            |   6 ++
 arch/powerpc/sysdev/xics/xics-common.c             |   4 +-
 arch/powerpc/sysdev/xive/common.c                  |   4 +-
 26 files changed, 320 insertions(+), 38 deletions(-)

Comments

Christophe Leroy May 18, 2022, 1:29 p.m. UTC | #1
Le 18/05/2022 à 12:03, Paul Mackerras a écrit :
> This patch series implements KASAN on 64-bit POWER with radix MMU,
> such as POWER9 or POWER10.  Daniel Axtens posted previous versions of
> these patches, but is no longer working on KASAN, and I have been
> asked to get them ready for inclusion.
> 
> Because of various technical difficulties, mostly around the need to
> allow for code that runs in real mode, we only support "outline" mode
> (as opposed to "inline" mode), where the compiler adds a call to
> a checking procedure before every store to memory.
> 
> This series has known deficiencies, specifically that the kernel will
> crash on boot on a HPT system, and that out-of-bounds accesses to
> module global data are not caught (which leads to one of the KASAN
> tests failing).
> 
> v2: Split the large patch 3/3 of the previous series into three
> patches and addressed review comments; put the generic documentation
> changes in a separate patch at the end of the series; removed the RFC
> tag.
> 
> Comments welcome.

The series looks good to me.

Maybe patch 3 should go after patches 4 and 5 which are preparation patches.

Christophe

> 
> Paul.
> 
>   Documentation/dev-tools/kasan.rst                  |   7 +-
>   Documentation/powerpc/kasan.txt                    |  58 ++++++++++++
>   arch/powerpc/Kconfig                               |   5 +-
>   arch/powerpc/Kconfig.debug                         |   3 +-
>   arch/powerpc/include/asm/book3s/64/hash.h          |   4 +
>   arch/powerpc/include/asm/book3s/64/pgtable.h       |   3 +
>   arch/powerpc/include/asm/book3s/64/radix.h         |  12 ++-
>   arch/powerpc/include/asm/interrupt.h               |  52 ++++++++---
>   arch/powerpc/include/asm/kasan.h                   |  22 +++++
>   arch/powerpc/kernel/Makefile                       |  11 +++
>   arch/powerpc/kernel/smp.c                          |  22 ++---
>   arch/powerpc/kernel/traps.c                        |   6 +-
>   arch/powerpc/kexec/Makefile                        |   2 +
>   arch/powerpc/kvm/Makefile                          |   5 +
>   arch/powerpc/lib/Makefile                          |   3 +
>   arch/powerpc/mm/book3s64/Makefile                  |   9 ++
>   arch/powerpc/mm/kasan/Makefile                     |   3 +-
>   .../mm/kasan/{kasan_init_32.c => init_32.c}        |   0
>   arch/powerpc/mm/kasan/init_book3s_64.c             | 103 +++++++++++++++++++++
>   arch/powerpc/mm/ptdump/ptdump.c                    |   3 +-
>   arch/powerpc/platforms/Kconfig.cputype             |   1 +
>   arch/powerpc/platforms/powernv/Makefile            |   8 ++
>   arch/powerpc/platforms/powernv/smp.c               |   2 +-
>   arch/powerpc/platforms/pseries/Makefile            |   6 ++
>   arch/powerpc/sysdev/xics/xics-common.c             |   4 +-
>   arch/powerpc/sysdev/xive/common.c                  |   4 +-
>   26 files changed, 320 insertions(+), 38 deletions(-)
Michael Ellerman May 24, 2022, 11:09 a.m. UTC | #2
On Wed, 18 May 2022 20:03:27 +1000, Paul Mackerras wrote:
> This patch series implements KASAN on 64-bit POWER with radix MMU,
> such as POWER9 or POWER10.  Daniel Axtens posted previous versions of
> these patches, but is no longer working on KASAN, and I have been
> asked to get them ready for inclusion.
> 
> Because of various technical difficulties, mostly around the need to
> allow for code that runs in real mode, we only support "outline" mode
> (as opposed to "inline" mode), where the compiler adds a call to
> a checking procedure before every store to memory.
> 
> [...]

Patches 1-5 applied to powerpc/next.

[1/6] kasan: Document support on 32-bit powerpc
      https://git.kernel.org/powerpc/c/60e832def18de7a0753393034c6ae459b3bee70a
[2/6] powerpc/mm/kasan: rename kasan_init_32.c to init_32.c
      https://git.kernel.org/powerpc/c/f08aed52412c860f68e30da148da58ad8e40a43b
[3/6] powerpc: Book3S 64-bit outline-only KASAN support
      https://git.kernel.org/powerpc/c/41b7a347bf1491e7300563bb224432608b41f62a
[4/6] powerpc/kasan: Don't instrument non-maskable or raw interrupts
      https://git.kernel.org/powerpc/c/5352090a999570c6e8a701bcb755fd91e8c5a2cd
[5/6] powerpc/kasan: Disable address sanitization in kexec paths
      https://git.kernel.org/powerpc/c/2ab2d5794f14c08676690bf0859f16cc768bb3a4

cheers