OSDN Git Service

powerpc/pkeys: key allocation/deallocation must not change pkey registers
authorRam Pai <linuxram@us.ibm.com>
Tue, 17 Jul 2018 13:51:04 +0000 (06:51 -0700)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 24 Jul 2018 11:34:08 +0000 (21:34 +1000)
commit4a4a5e5d2aadc793be95024f454cf511d115b62d
tree49417dd127929898f5929e9ef2caa200586cf4e6
parentde113256f8c1c24d8c79ae388bf2a5abd70f7577
powerpc/pkeys: key allocation/deallocation must not change pkey registers

Key allocation and deallocation has the side effect of programming the
UAMOR/AMR/IAMR registers. This is wrong, since its the responsibility of
the application and not that of the kernel, to modify the permission on
the key.

Do not modify the pkey registers at key allocation/deallocation.

This patch also fixes a bug where a sys_pkey_free() resets the UAMOR
bits of the key, thus making its permissions unmodifiable from user
space. Later if the same key gets reallocated from a different thread
this thread will no longer be able to change the permissions on the key.

Fixes: cf43d3b26452 ("powerpc: Enable pkey subsystem")
Cc: stable@vger.kernel.org # v4.16+
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/pkeys.h
arch/powerpc/mm/pkeys.c