Skip to content

Commit 944fad4

Browse files
bulwahnsuryasaimadhu
authored andcommitted
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: 35f1c89 ("x86/fault: Fix AMD erratum #91 errata fixup for user code") Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lore.kernel.org/r/20220201144055.5670-1-lukas.bulwahn@gmail.com
1 parent 3123109 commit 944fad4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/mm/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
149149
unsigned char opcode;
150150

151151
if (user_mode(regs)) {
152-
if (get_user(opcode, instr))
152+
if (get_user(opcode, (unsigned char __user *) instr))
153153
break;
154154
} else {
155155
if (get_kernel_nofault(opcode, instr))

0 commit comments

Comments
 (0)