From 062642e76e8bf4f2cb993dd438fdd3bd97dd78e4 Mon Sep 17 00:00:00 2001 From: Prasad Sodagudi Date: Tue, 15 Sep 2020 10:07:13 -0700 Subject: [PATCH] ANDROID: lkdtm/usercopy: Use __va_function to find proper vm_mmap address With CFI enabled compiler replacing the reference to vm_mmap passed to copy_to_user with a pointer to the CFI jump table in the module itself. So use the __va_function API for finding the proper address of vm_mmap. Bug: 166220312 Suggested-by: Sami Tolvanen Change-Id: Id5bd96cc9bfa1aa99f34bd4785792e0a4eeae5b1 Git-commit: 33752ec915fb9dcccfe3afe4c4df4e032a0d823f Git-repo: https://android.googlesource.com/kernel/common/ Signed-off-by: Prasad Sodagudi --- drivers/misc/lkdtm/usercopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c index b833367a45d0..120e9ffd0f28 100644 --- a/drivers/misc/lkdtm/usercopy.c +++ b/drivers/misc/lkdtm/usercopy.c @@ -314,7 +314,7 @@ void lkdtm_USERCOPY_KERNEL(void) pr_info("attempting bad copy_to_user from kernel text: %px\n", vm_mmap); - if (copy_to_user((void __user *)user_addr, vm_mmap, + if (copy_to_user((void __user *)user_addr, __va_function(vm_mmap), unconst + PAGE_SIZE)) { pr_warn("copy_to_user failed, but lacked Oops\n"); goto free_user;