lkdtm: Fix execute_[user]_location()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 15 Feb 2022 12:41:07 +0000 (13:41 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Feb 2022 12:25:12 +0000 (23:25 +1100)
commit72a86433049dcfe918886645ac3d19c1eaaa67ab
tree0f3d48d5d295ef2d4a98f86929e088e0426b6c2b
parentb64913394f123e819bffabc79a0e48f98e78dc5d
lkdtm: Fix execute_[user]_location()

execute_location() and execute_user_location() intent
to copy do_nothing() text and execute it at a new location.
However, at the time being it doesn't copy do_nothing() function
but do_nothing() function descriptor which still points to the
original text. So at the end it still executes do_nothing() at
its original location allthough using a copied function descriptor.

So, fix that by really copying do_nothing() text and build a new
function descriptor by copying do_nothing() function descriptor and
updating the target address with the new location.

Also fix the displayed addresses by dereferencing do_nothing()
function descriptor.

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/4055839683d8d643cd99be121f4767c7c611b970.1644928018.git.christophe.leroy@csgroup.eu
drivers/misc/lkdtm/perms.c