Message ID | 20180723122414.735940678@linuxfoundation.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
On Mon, 2018-07-23 at 14:41 +0200, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Dave Hansen <dave.hansen@linux.intel.com> > > commit 39a0526fb3f7d93433d146304278477eb463f8af upstream [...] > --- a/arch/x86/include/asm/mmu_context.h > +++ b/arch/x86/include/asm/mmu_context.h [...] > +static inline int init_new_context(struct task_struct *tsk, > + struct mm_struct *mm) > +{ > + init_new_context_ldt(tsk, mm); > + return 0; > +} [...] This hides errors from init_new_context_ldt(), which is very bad. Fixed upstream by: commit ccd5b3235180eef3cfec337df1c8554ab151b5cc Author: Eric Biggers <ebiggers@google.com> Date: Thu Aug 24 10:50:29 2017 -0700 x86/mm: Fix use-after-free of ldt_struct Ben.
On Sat, Aug 25, 2018 at 12:44:10AM +0100, Ben Hutchings wrote: > On Mon, 2018-07-23 at 14:41 +0200, Greg Kroah-Hartman wrote: > > 4.4-stable review patch. If anyone has any objections, please let me know. > > > > ------------------ > > > > From: Dave Hansen <dave.hansen@linux.intel.com> > > > > commit 39a0526fb3f7d93433d146304278477eb463f8af upstream > [...] > > --- a/arch/x86/include/asm/mmu_context.h > > +++ b/arch/x86/include/asm/mmu_context.h > [...] > > +static inline int init_new_context(struct task_struct *tsk, > > + struct mm_struct *mm) > > +{ > > + init_new_context_ldt(tsk, mm); > > + return 0; > > +} > [...] > > This hides errors from init_new_context_ldt(), which is very bad. > Fixed upstream by: > > commit ccd5b3235180eef3cfec337df1c8554ab151b5cc > Author: Eric Biggers <ebiggers@google.com> > Date: Thu Aug 24 10:50:29 2017 -0700 > > x86/mm: Fix use-after-free of ldt_struct > > Ben. Good catch, now applied, thanks. greg k-h
--- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -52,15 +52,15 @@ struct ldt_struct { /* * Used for LDT copy/destruction. */ -int init_new_context(struct task_struct *tsk, struct mm_struct *mm); -void destroy_context(struct mm_struct *mm); +int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm); +void destroy_context_ldt(struct mm_struct *mm); #else /* CONFIG_MODIFY_LDT_SYSCALL */ -static inline int init_new_context(struct task_struct *tsk, - struct mm_struct *mm) +static inline int init_new_context_ldt(struct task_struct *tsk, + struct mm_struct *mm) { return 0; } -static inline void destroy_context(struct mm_struct *mm) {} +static inline void destroy_context_ldt(struct mm_struct *mm) {} #endif static inline void load_mm_ldt(struct mm_struct *mm) @@ -102,6 +102,17 @@ static inline void enter_lazy_tlb(struct this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY); } +static inline int init_new_context(struct task_struct *tsk, + struct mm_struct *mm) +{ + init_new_context_ldt(tsk, mm); + return 0; +} +static inline void destroy_context(struct mm_struct *mm) +{ + destroy_context_ldt(mm); +} + extern void switch_mm(struct mm_struct *prev, struct mm_struct *next, struct task_struct *tsk); --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c @@ -119,7 +119,7 @@ static void free_ldt_struct(struct ldt_s * we do not have to muck with descriptors here, that is * done in switch_mm() as needed. */ -int init_new_context(struct task_struct *tsk, struct mm_struct *mm) +int init_new_context_ldt(struct task_struct *tsk, struct mm_struct *mm) { struct ldt_struct *new_ldt; struct mm_struct *old_mm; @@ -160,7 +160,7 @@ out_unlock: * * 64bit: Don't touch the LDT register - we're already in the next thread. */ -void destroy_context(struct mm_struct *mm) +void destroy_context_ldt(struct mm_struct *mm) { free_ldt_struct(mm->context.ldt); mm->context.ldt = NULL;