From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751994AbdLIS2f (ORCPT ); Sat, 9 Dec 2017 13:28:35 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:58221 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752010AbdLIS2d (ORCPT ); Sat, 9 Dec 2017 13:28:33 -0500 Date: Sat, 9 Dec 2017 19:28:31 +0100 (CET) From: Thomas Gleixner To: LKML cc: Linus Torvalds , x86@kernel.org, Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Brian Gerst , David Laight , Kees Cook Subject: Re: [patch V2 2/2] x86/ldt: Prevent ldt inheritance on exec In-Reply-To: Message-ID: References: <20171208223241.367344665@linutronix.de> <20171208223421.711848352@linutronix.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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