From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752721AbdLKMNV (ORCPT ); Mon, 11 Dec 2017 07:13:21 -0500 Received: from merlin.infradead.org ([205.233.59.134]:46774 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751281AbdLKMNT (ORCPT ); Mon, 11 Dec 2017 07:13:19 -0500 Date: Mon, 11 Dec 2017 13:13:02 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , Linus Torvalds , x86@kernel.org, Andy Lutomirski , Borislav Petkov , Brian Gerst , David Laight , Kees Cook Subject: Re: [patch V2 2/2] x86/ldt: Prevent ldt inheritance on exec Message-ID: <20171211121302.bdjkhnfv2ncclrht@hirez.programming.kicks-ass.net> References: <20171208223241.367344665@linutronix.de> <20171208223421.711848352@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 09, 2017 at 07:24:35PM +0100, 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. But read_ldt() will still nest mmap_sem inside context.lock, no? Lockdep doesn't care about old_mm vs new_mm.