lkml.org 
[lkml]   [2021]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH v2 06/15] powerpc/align: Don't use __get_user_instr() on kernel addresses
    Date
    Christophe Leroy <christophe.leroy@csgroup.eu> writes:

    > 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.
    >

    Looks good to me!

    Reviewed-by: Daniel Axtens <dja@axtens.net>

    Kind regards,
    Daniel

    > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
    > ---
    > arch/powerpc/kernel/align.c | 6 +++++-
    > 1 file changed, 5 insertions(+), 1 deletion(-)
    >
    > diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
    > index c4d7b445b459..8d4c7af262e2 100644
    > --- a/arch/powerpc/kernel/align.c
    > +++ b/arch/powerpc/kernel/align.c
    > @@ -310,7 +310,11 @@ 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... */
    > --
    > 2.25.0

    \
     
     \ /
      Last update: 2021-03-25 23:13    [W:4.249 / U:0.124 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site