]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc: Do not dereference code as 'struct ppc_inst' (uprobe, code-patching, feature...
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 20 May 2021 13:50:42 +0000 (13:50 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Jun 2021 13:35:57 +0000 (23:35 +1000)
commit8bd113b5352011f7c2aef41e6e0542bcf198e1cf
tree95bc35968815c5c3cebab5105a7f004c06489b2d
parent2d4cadfd74a6aa896bc9eb19a862f1590f5a91d4
powerpc: Do not dereference code as 'struct ppc_inst' (uprobe, code-patching, feature-fixups)

'struct ppc_inst' is an internal structure to represent an instruction,
it is not directly the representation of that instruction in text code.
It is not meant to map and dereference code.

Dereferencing code directly through 'struct ppc_inst' has two main issues:
- On powerpc, structs are expected to be 8 bytes aligned while code is
spread every 4 byte.
- Should a non prefixed instruction lie at the end of the page and the
following page not be mapped, it would generate a page fault.

In-memory code must be accessed with ppc_inst_read().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/c9a1201dd0a66b4a0f91f0fb46d9385cbf030feb.1621516826.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/uprobes.c
arch/powerpc/lib/code-patching.c
arch/powerpc/lib/feature-fixups.c