Re: [patch V2 2/2] x86/ldt: Prevent ldt inheritance on exec
From: Thomas Gleixner
Date: Sat Dec 09 2017 - 13:28:41 EST
On Sat, 9 Dec 2017, Thomas Gleixner wrote:
> On Fri, 8 Dec 2017, Thomas Gleixner wrote:
> > +int ldt_dup_context(struct mm_struct *old_mm, struct mm_struct *mm)
> > {
> > struct ldt_struct *new_ldt;
> > - struct mm_struct *old_mm;
> > int retval = 0;
> >
> > - mutex_init(&mm->context.lock);
> > - old_mm = current->mm;
> > - if (!old_mm) {
> > - mm->context.ldt = NULL;
> > + if (!old_mm)
> > return 0;
> > - }
> >
> > mutex_lock(&old_mm->context.lock);
>
> Bah. That's broken. It now nests into old_mm->mmap_sem which is the reverse
> lock order than in ldt_write. Will fix.
Confused myself. mmap_sem is not taken in mainline ldt_write. It's just in
the stuff I'm working on.
Thanks,
tglx