Return-Path: Received: from mail-eopbgr50136.outbound.protection.outlook.com ([40.107.5.136]:49856 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932286AbeGBI7z (ORCPT ); Mon, 2 Jul 2018 04:59:55 -0400 Subject: Re: [PATCH 4.17] x86/mm: Don't free P4D table when it is folded at runtime To: Greg KH Cc: stable-commits@vger.kernel.org, Linus Torvalds , Peter Zijlstra , Thomas Gleixner , stable@vger.kernel.org, Ingo Molnar References: <20180701143858.GA22410@kroah.com> <20180702084536.29833-1-aryabinin@virtuozzo.com> <20180702084758.GA15228@kroah.com> From: Andrey Ryabinin Message-ID: <293c5bfc-e402-ff1b-7e5b-4de938edcd17@virtuozzo.com> Date: Mon, 2 Jul 2018 12:01:26 +0300 MIME-Version: 1.0 In-Reply-To: <20180702084758.GA15228@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org List-ID: On 07/02/2018 11:47 AM, Greg KH wrote: > On Mon, Jul 02, 2018 at 11:45:36AM +0300, Andrey Ryabinin wrote: >> From: "gregkh@linuxfoundation.org" > > Huh? I didn't write this patch. Right, I've noticed this and sent v2 with this fixed. It's because I did 'git am' on your email with backported patch, but missed that git changed the autorship. > >> >> commit 0e311d237d7f3022b7dafb639b42541bfb42fe94 upstream. >> >> When the P4D page table layer is folded at runtime, the p4d_free() >> should do nothing, the same as in . >> >> It seems this bug should cause double-free in efi_call_phys_epilog(), >> but I don't know how to trigger that code path, so I can't confirm that >> by testing. >> >> Signed-off-by: Andrey Ryabinin >> Reviewed-by: Kirill A. Shutemov >> Cc: Linus Torvalds >> Cc: Peter Zijlstra >> Cc: Thomas Gleixner >> Cc: stable@vger.kernel.org # 4.17 >> Fixes: 98219dda2ab5 ("x86/mm: Fold p4d page table layer at runtime") >> Link: http://lkml.kernel.org/r/20180625102427.15015-1-aryabinin@virtuozzo.com >> Signed-off-by: Ingo Molnar >> Signed-off-by: Andrey Ryabinin >> --- >> arch/x86/include/asm/pgalloc.h | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h >> index 263c142a6a6c..f65e9e1cea4c 100644 >> --- a/arch/x86/include/asm/pgalloc.h >> +++ b/arch/x86/include/asm/pgalloc.h >> @@ -184,6 +184,9 @@ static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr) >> >> static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) >> { >> + if (!pgtable_l5_enabled) >> + return; >> + > > Did you test build this patch? > Sure, successfully built on top of 4.17.3 > Please do so, and be careful about author attribution, again, I did not > write this patch. > > greg k-h >