lkdtm: Really write into kernel text in WRITE_KERN
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 15 Feb 2022 12:41:06 +0000 (13:41 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Feb 2022 12:25:12 +0000 (23:25 +1100)
commitb64913394f123e819bffabc79a0e48f98e78dc5d
tree6bdf27b3d9814cf55f96d62d92731d04857aad60
parent69b420ed8fd3917ac7073256b4929aa246b6fe31
lkdtm: Really write into kernel text in WRITE_KERN

WRITE_KERN is supposed to overwrite some kernel text, namely
do_overwritten() function.

But at the time being it overwrites do_overwritten() function
descriptor, not function text.

Fix it by dereferencing the function descriptor to obtain
function text pointer. Export dereference_function_descriptor()
for when LKDTM is built as a module.

And make do_overwritten() noinline so that it is really
do_overwritten() which is called by lkdtm_WRITE_KERN().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/31e58eaffb5bc51c07d8d4891d1982100ade8cfc.1644928018.git.christophe.leroy@csgroup.eu
drivers/misc/lkdtm/perms.c
kernel/extable.c