From: Lukas Bulwahn Date: Tue, 1 Feb 2022 14:40:55 +0000 (+0100) Subject: x86/fault: Cast an argument to the proper address space in prefetch() X-Git-Tag: baikal/aarch64/sdk6.1~3999^2 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=b9302b6ba543cba2704af217dceab68e68e101e6;p=kernel.git x86/fault: Cast an argument to the proper address space in prefetch() Commit in Fixes uses accessors based on the access mode, i.e., it distinguishes its access if instr carries a user address or a kernel address. Since that commit, sparse complains about passing an argument without __user annotation to get_user(), which expects a pointer of the __user address space: arch/x86/mm/fault.c:152:29: warning: incorrect type in argument 1 (different address spaces) arch/x86/mm/fault.c:152:29: expected void const volatile [noderef] __user *ptr arch/x86/mm/fault.c:152:29: got unsigned char *[assigned] instr Cast instr to __user when accessing user memory. No functional change. No change in the generated object code. [ bp: Simplify commit message. ] Fixes: c7bee6230681 ("x86/fault: Fix AMD erratum #91 errata fixup for user code") Signed-off-by: Lukas Bulwahn Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220201144055.5670-1-lukas.bulwahn@gmail.com --- diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index d0074c6ed31a3..fad8faa29d042 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -149,7 +149,7 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr) unsigned char opcode; if (user_mode(regs)) { - if (get_user(opcode, instr)) + if (get_user(opcode, (unsigned char __user *) instr)) break; } else { if (get_kernel_nofault(opcode, instr))