OSDN Git Service

powerpc/8xx: Add Kernel Userspace Access Protection
authorChristophe Leroy <christophe.leroy@c-s.fr>
Mon, 11 Mar 2019 08:30:34 +0000 (08:30 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 21 Apr 2019 13:11:46 +0000 (23:11 +1000)
commit2679f9bd0abafb3044bcbaac0600b32159ac8bf2
tree77543dc9837adb96bd9bd4ee3465015a47c08029
parent06fbe81b5909847aa13f9c86c2b6f9bbc5c2795b
powerpc/8xx: Add Kernel Userspace Access Protection

This patch adds Kernel Userspace Access Protection on the 8xx.

When a page is RO or RW, it is set RO or RW for Key 0 and NA
for Key 1.

Up to now, the User group is defined with Key 0 for both User and
Supervisor.

By changing the group to Key 0 for User and Key 1 for Supervisor,
this patch prevents the Kernel from being able to access user data.

At exception entry, the kernel saves SPRN_MD_AP in the regs struct,
and reapply the protection. At exception exit it restores SPRN_MD_AP
with the value saved on exception entry.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
[mpe: Drop allow_read/write_to/from_user() as they're now in kup.h]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/kup.h
arch/powerpc/include/asm/nohash/32/kup-8xx.h [new file with mode: 0644]
arch/powerpc/include/asm/nohash/32/mmu-8xx.h
arch/powerpc/mm/8xx_mmu.c
arch/powerpc/platforms/Kconfig.cputype