powerpc/pkeys: Fix handling of pkey state across fork()
authorRam Pai <linuxram@us.ibm.com>
Thu, 20 Dec 2018 20:03:30 +0000 (12:03 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 21 Dec 2018 03:46:50 +0000 (14:46 +1100)
commit2cd4bd192ee94848695c1c052d87913260e10f36
tree196e1d7a1fb878dae550092bc739c5ac5e4318db
parent2f07229f02d4c55affccd11a61af4fd4b94dc436
powerpc/pkeys: Fix handling of pkey state across fork()

Protection key tracking information is not copied over to the
mm_struct of the child during fork(). This can cause the child to
erroneously allocate keys that were already allocated. Any allocated
execute-only key is lost aswell.

Add code; called by dup_mmap(), to copy the pkey state from parent to
child explicitly.

This problem was originally found by Dave Hansen on x86, which turns
out to be a problem on powerpc aswell.

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/mmu_context.h
arch/powerpc/mm/pkeys.c