Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1422799imm; Thu, 5 Jul 2018 23:08:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc8iwettFlyigeObZVBvvURAJuYEg0JSIvALeudDnU6MfEIFAnSUFxfvT+dbuprxRV/4kDP X-Received: by 2002:a63:6743:: with SMTP id b64-v6mr1752342pgc.91.1530857326605; Thu, 05 Jul 2018 23:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530857326; cv=none; d=google.com; s=arc-20160816; b=vnoknqSoICAdFjbWq/vxfNhW5KQp32d+31WxdnroHnkBqgxMpzvw3ymnqIWm+he6Kk KetGX/rpuEtUQMARBAZvSwv8TNYBCGLzsvnMqMGGkdPIiTnl4PkGYARFTME42m9+kWuN MJCWXapsNbO4OJpkVYbJp07v8J5xjXd13neFwSWzuiTSuugORE6MCE3G8AT20AQKWAmY HKxUwmfBl4okyyNSme4AKxTOeevbfdQYgcn26r1CqrExQrcTDKBTPPQLTaUaYufNFiVK s+EBqyD1LBiQPvFZF01uB1Z/8/avOYCSSlbIh654JKP0kb+AAN5nSuHgNrJTGMJ2RyvC ob8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Gm5XUt0pZmDmew24CpjqebxdkW6Wzb0zRj+bxfm8OGA=; b=1EHJT3tHJ9BLhNY+5Fgmogd+8iD5KQto39x+EmBKe4XTO+7h2vDPCvR8xKDowytR0a rU/rTsZNjbCKbN4TcVLsePf5rLBSlA5e0L8fLTPlkNsNocFE2Tk/SsJcFVhNsaPKWMcW 3dWf2muTxpH3NxxCWoNy79g0YMIwSQcnckVPGIMHcxUROVsRsBeCHDaWjK2ujMMUD5Q9 gVM3+dauZrppNZaiEcn2Sy1QTrfN+aY91WtkYqISNcwyRNzP91u3EfC5hqhxkJS+zLs9 FO4pPqBNbZMhfJRmusF52mith88v85fGAfkyfMpquwaB9LSr0WvNBDymEqxNLucQuqPZ TbHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si7324395plt.258.2018.07.05.23.08.32; Thu, 05 Jul 2018 23:08:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933633AbeGFFth (ORCPT + 99 others); Fri, 6 Jul 2018 01:49:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60340 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932910AbeGFFte (ORCPT ); Fri, 6 Jul 2018 01:49:34 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 11623BC1; Fri, 6 Jul 2018 05:49:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Ryabinin , "Kirill A. Shutemov" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 4.17 45/46] x86/mm: Dont free P4D table when it is folded at runtime Date: Fri, 6 Jul 2018 07:47:06 +0200 Message-Id: <20180706054526.911333236@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054524.595521988@linuxfoundation.org> References: <20180706054524.595521988@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrey Ryabinin 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/pgalloc.h | 3 +++ 1 file changed, 3 insertions(+) --- 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(struc static inline void p4d_free(struct mm_struct *mm, p4d_t *p4d) { + if (!pgtable_l5_enabled) + return; + BUG_ON((unsigned long)p4d & (PAGE_SIZE-1)); free_page((unsigned long)p4d); }