]> www.infradead.org Git - linux-platform-drivers-x86.git/commitdiff
powerpc/align: Don't use __get_user_instr() on kernel addresses
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Wed, 10 Mar 2021 17:46:45 +0000 (17:46 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 3 Apr 2021 10:21:49 +0000 (21:21 +1100)
In the old days, when we didn't have kernel userspace access
protection and had set_fs(), it was wise to use __get_user()
and friends to read kernel memory.

Nowadays, get_user() is granting userspace access and is exclusively
for userspace access.

In alignment exception handler, use probe_kernel_read_inst()
instead of __get_user_instr() for reading instructions in kernel.

This will allow to remove the is_kernel_addr() check in
__get/put_user() in a following patch.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/d9ecbce00178484e66ca7adec2ff210058037704.1615398265.git.christophe.leroy@csgroup.eu
arch/powerpc/kernel/align.c

index f362c99213be26a1a29eea3846188fc2004bdd3e..a97d5f1a3905948a9cb27a0979e0d4a9fb87fb8c 100644 (file)
@@ -310,7 +310,12 @@ int fix_alignment(struct pt_regs *regs)
         */
        CHECK_FULL_REGS(regs);
 
-       if (unlikely(__get_user_instr(instr, (void __user *)regs->nip)))
+       if (is_kernel_addr(regs->nip))
+               r = probe_kernel_read_inst(&instr, (void *)regs->nip);
+       else
+               r = __get_user_instr(instr, (void __user *)regs->nip);
+
+       if (unlikely(r))
                return -EFAULT;
        if ((regs->msr & MSR_LE) != (MSR_KERNEL & MSR_LE)) {
                /* We don't handle PPC little-endian any more... */