]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/32s: Fix kuap_kernel_restore()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 15 Sep 2021 14:12:24 +0000 (16:12 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 7 Oct 2021 12:34:00 +0000 (23:34 +1100)
commitf8c4744f65b4c14519140e4087dbfd3c6cd08faf
treeb7ad46461874a1fd9252027258a64e27b1e42536
parent4c7ef5da44b8fba3b52fd07e09fabab0586236a1
powerpc/32s: Fix kuap_kernel_restore()

At interrupt exit, kuap_kernel_restore() calls kuap_unlock() with the
value contained in regs->kuap. However, when regs->kuap contains
0xffffffff it means that KUAP was not unlocked so calling kuap_unlock()
is unrelevant and results in jeopardising the contents of kernel space
segment registers.

So check that regs->kuap doesn't contain KUAP_NONE before calling
kuap_unlock(). In the meantime it also means that if KUAP has not
been correcly locked back at interrupt exit, it must be locked
before continuing. This is done by checking the content of
current->thread.kuap which was returned by kuap_get_and_assert_locked()

Fixes: 6f1f1e509039 ("powerpc/32s: Rework Kernel Userspace Access Protection")
Reported-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0d0c4d0f050a637052287c09ba521bad960a2790.1631715131.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/book3s/32/kup.h