Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751057AbdL3Vdm (ORCPT ); Sat, 30 Dec 2017 16:33:42 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:46574 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdL3Vdl (ORCPT ); Sat, 30 Dec 2017 16:33:41 -0500 X-Google-Smtp-Source: ACJfBov+JUgpOSFXtDNfq+JWxj+dxGYMHpMvMAcWcex2iy3ELQHAQ13zck0vA4qbUMvnTYme5nF4Vg== Date: Sat, 30 Dec 2017 22:33:37 +0100 From: Ingo Molnar To: Thomas Gleixner Cc: LKML , Linus Torvalds , x86@kernel.org, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Borislav Petkov , Dominik Brodowski , Mathieu Desnoyers Subject: Re: [patch 1/3] x86/ldt: Free the right LDT memory in write_ldt() error path Message-ID: <20171230213337.tns3dtj7z526bvf2@gmail.com> References: <20171230211351.980176980@linutronix.de> <20171230211829.508293470@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171230211829.508293470@linutronix.de> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 918 Lines: 36 * Thomas Gleixner wrote: > The error path in write_ldt() frees the already installed LDT memory > instead of the newly allocated which cannot be installed. s/newly allocated /newly allocated one > > Fixes: f55f0501cbf6 ("x86/pti: Put the LDT in its own PGD if PTI is on") > Reported-by: Mathieu Desnoyers > Signed-off-by: Thomas Gleixner > --- > arch/x86/kernel/ldt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/arch/x86/kernel/ldt.c > +++ b/arch/x86/kernel/ldt.c > @@ -421,7 +421,7 @@ static int write_ldt(void __user *ptr, u > */ > error = map_ldt_struct(mm, new_ldt, old_ldt ? !old_ldt->slot : 0); > if (error) { > - free_ldt_struct(old_ldt); > + free_ldt_struct(new_ldt); > goto out_unlock; > } > This bug kind of scares me ... Reviewed-by: Ingo Molnar Thanks, Ingo