]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/lib: Refactor __patch_instruction() to use __put_user_asm()
authorRussell Currey <ruscur@russell.cc>
Thu, 18 Apr 2019 06:51:23 +0000 (16:51 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 21 Apr 2019 13:06:02 +0000 (23:06 +1000)
commit113fa923b25761726c6672826d9bebdc26f8f323
tree0a2784dc10894839d72048306ac0c69570d54897
parente1336af432f08afb29d0c3d8792187d342be8fcf
powerpc/lib: Refactor __patch_instruction() to use __put_user_asm()

__patch_instruction() is called in early boot, and uses
__put_user_size(), which includes the allow/prevent calls to enforce
KUAP, which could either be called too early, or in the Radix case,
forced to use "early_" versions of functions just to safely handle
this one case.

__put_user_asm() does not do this, and thus is safe to use both in
early boot, and later on since in this case it should only ever be
touching kernel memory.

__patch_instruction() was previously refactored to use
__put_user_size() in order to be able to return -EFAULT, which would
allow the kernel to patch instructions in userspace, which should
never happen. This has the functional change of causing faults on
userspace addresses if KUAP is turned on, which should never happen in
practice.

A future enhancement could be to double check the patch address is
definitely allowed to be tampered with by the kernel.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/lib/code-patching.c