lkml.org 
[lkml]   [2017]   [Dec]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH v2 03/17] arch: Allow arch_dup_mmap() to fail
    From: Thomas Gleixner <tglx@linutronix.de>

    In order to sanitize the LDT initialization on x86 arch_dup_mmap() must be
    allowed to fail. Fix up all instances.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    ---
    arch/powerpc/include/asm/mmu_context.h | 5 +++--
    arch/um/include/asm/mmu_context.h | 3 ++-
    arch/unicore32/include/asm/mmu_context.h | 5 +++--
    arch/x86/include/asm/mmu_context.h | 4 ++--
    include/asm-generic/mm_hooks.h | 5 +++--
    kernel/fork.c | 3 +--
    6 files changed, 14 insertions(+), 11 deletions(-)

    --- a/arch/powerpc/include/asm/mmu_context.h
    +++ b/arch/powerpc/include/asm/mmu_context.h
    @@ -160,9 +160,10 @@ static inline void enter_lazy_tlb(struct
    #endif
    }

    -static inline void arch_dup_mmap(struct mm_struct *oldmm,
    - struct mm_struct *mm)
    +static inline int arch_dup_mmap(struct mm_struct *oldmm,
    + struct mm_struct *mm)
    {
    + return 0;
    }

    #ifndef CONFIG_PPC_BOOK3S_64
    --- a/arch/um/include/asm/mmu_context.h
    +++ b/arch/um/include/asm/mmu_context.h
    @@ -15,9 +15,10 @@ extern void uml_setup_stubs(struct mm_st
    /*
    * Needed since we do not use the asm-generic/mm_hooks.h:
    */
    -static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
    +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
    {
    uml_setup_stubs(mm);
    + return 0;
    }
    extern void arch_exit_mmap(struct mm_struct *mm);
    static inline void arch_unmap(struct mm_struct *mm,
    --- a/arch/unicore32/include/asm/mmu_context.h
    +++ b/arch/unicore32/include/asm/mmu_context.h
    @@ -81,9 +81,10 @@ do { \
    } \
    } while (0)

    -static inline void arch_dup_mmap(struct mm_struct *oldmm,
    - struct mm_struct *mm)
    +static inline int arch_dup_mmap(struct mm_struct *oldmm,
    + struct mm_struct *mm)
    {
    + return 0;
    }

    static inline void arch_unmap(struct mm_struct *mm,
    --- a/arch/x86/include/asm/mmu_context.h
    +++ b/arch/x86/include/asm/mmu_context.h
    @@ -176,10 +176,10 @@ do { \
    } while (0)
    #endif

    -static inline void arch_dup_mmap(struct mm_struct *oldmm,
    - struct mm_struct *mm)
    +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
    {
    paravirt_arch_dup_mmap(oldmm, mm);
    + return 0;
    }

    static inline void arch_exit_mmap(struct mm_struct *mm)
    --- a/include/asm-generic/mm_hooks.h
    +++ b/include/asm-generic/mm_hooks.h
    @@ -7,9 +7,10 @@
    #ifndef _ASM_GENERIC_MM_HOOKS_H
    #define _ASM_GENERIC_MM_HOOKS_H

    -static inline void arch_dup_mmap(struct mm_struct *oldmm,
    - struct mm_struct *mm)
    +static inline int arch_dup_mmap(struct mm_struct *oldmm,
    + struct mm_struct *mm)
    {
    + return 0;
    }

    static inline void arch_exit_mmap(struct mm_struct *mm)
    --- a/kernel/fork.c
    +++ b/kernel/fork.c
    @@ -721,8 +721,7 @@ static __latent_entropy int dup_mmap(str
    goto out;
    }
    /* a new mm has just been created */
    - arch_dup_mmap(oldmm, mm);
    - retval = 0;
    + retval = arch_dup_mmap(oldmm, mm);
    out:
    up_write(&mm->mmap_sem);
    flush_tlb_mm(oldmm);

    \
     
     \ /
      Last update: 2017-12-14 12:47    [W:4.055 / U:0.132 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site