mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 13:44:15 +08:00
lkdtm: use function_nocfi
To ensure we take the actual address of a function in kernel text, use function_nocfi. Otherwise, with CONFIG_CFI_CLANG, the compiler replaces the address with a pointer to the CFI jump table, which is actually in the module when compiled with CONFIG_LKDTM=m. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Acked-by: Kees Cook <keescook@chromium.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20210408182843.1754385-11-samitolvanen@google.com
This commit is contained in:
parent
4f0f586bf0
commit
6c4df54ed2
@ -314,7 +314,7 @@ void lkdtm_USERCOPY_KERNEL(void)
|
|||||||
|
|
||||||
pr_info("attempting bad copy_to_user from kernel text: %px\n",
|
pr_info("attempting bad copy_to_user from kernel text: %px\n",
|
||||||
vm_mmap);
|
vm_mmap);
|
||||||
if (copy_to_user((void __user *)user_addr, vm_mmap,
|
if (copy_to_user((void __user *)user_addr, function_nocfi(vm_mmap),
|
||||||
unconst + PAGE_SIZE)) {
|
unconst + PAGE_SIZE)) {
|
||||||
pr_warn("copy_to_user failed, but lacked Oops\n");
|
pr_warn("copy_to_user failed, but lacked Oops\n");
|
||||||
goto free_user;
|
goto free_user;
|
||||||
|
Loading…
Reference in New Issue
Block a user