Received: by 10.192.165.148 with SMTP id m20csp2427191imm; Sun, 22 Apr 2018 06:57:27 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/BMvLeV+IcztIQsbgYs6ZxZujuoK4rW5AyskqrnU7r7yq58uPjx+YCiysRdki3U8jpj2uD X-Received: by 2002:a17:902:6786:: with SMTP id g6-v6mr17298347plk.362.1524405447215; Sun, 22 Apr 2018 06:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405447; cv=none; d=google.com; s=arc-20160816; b=M3INb1UK+KhCc/JPI4jtN+Ms7oglQ/IprhBjnPqVA3U/FLdr4rhL4aae75vT82Weff iiKud2VkTf6+QN9NZTUp04L89KLl4THYPOdY8cEDNl/+YDSDwpjdDuFzQzyKduUcctzm 5w6cIeM0xKZFrReHRcNH1V7EJasXW3MZ6hH0sOTRTDG/vh7H+MpaKvxOjCfVTxwBDFBx 9zFmEcZSBFV1yA23ThdRq0EoqDVtFiQOsVfuggPZneHCbzydpyBYzFc022y7sJct8ooI tBaF4ww/ujtHmIiaEsAGmnKhpWXMWzodlRANFNq+UUnsFj5sBloufW+RyCpkV368k6xL Gllg== 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=apUiSRUhgX74oVquj8GUOU4eGKQGuw6VwojoVz+m+ZU=; b=KPwi144jrtacpwJIOAGejhQeSwMtHAG0ry6PoqrztPQhqmmc54ueOWyXLuAbOM/1D8 ZSvtDEoE3ZNk++vA4huunJB4/jXWipsso5Pvis7GR48LSemWnAKzJ7d9+oKLqUSW7br8 j2XWHLdGpkKjO6mFNcJBP5E9EPfm97UbcdIrDRmxm4Y6XiN24g3YhtjFLPFOYpUTmTNR g8hY6OAvW1AELJd6az1GxftVRBaLAjlVopLjeh+SaL4QS2zkGfaSnyiWSeQy2UumgJyG Hkj/jOS7dQNNXpfuMGh2S5khalZapyw4HMKqftCOUyLyhD/NTYJsz1QYHvMiUiGL1XPS JMyg== 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 s36-v6si9584279pld.114.2018.04.22.06.57.13; Sun, 22 Apr 2018 06:57:27 -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 S1753669AbeDVN4C (ORCPT + 99 others); Sun, 22 Apr 2018 09:56:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44860 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753642AbeDVNz4 (ORCPT ); Sun, 22 Apr 2018 09:55:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C42458FF; Sun, 22 Apr 2018 13:55:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Andryuk , Boris Ostrovsky Subject: [PATCH 4.16 035/196] x86/xen: Delay get_cpu_cap until stack canary is established Date: Sun, 22 Apr 2018 15:50:55 +0200 Message-Id: <20180422135105.924554029@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Andryuk commit 36104cb9012a82e73c32a3b709257766b16bcd1d upstream. Commit 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") introduced a call to get_cpu_cap, which is fstack-protected. This is works on x86-64 as commit 4f277295e54c ("x86/xen: init %gs very early to avoid page faults with stack protector") ensures the stack protector is configured, but it it did not cover x86-32. Delay calling get_cpu_cap until after xen_setup_gdt has initialized the stack canary. Without this, a 32bit PV machine crashes early in boot. (XEN) Domain 0 (vcpu#0) crashed on cpu#0: (XEN) ----[ Xen-4.6.6-xc x86_64 debug=n Tainted: C ]---- (XEN) CPU: 0 (XEN) RIP: e019:[<00000000c10362f8>] And the PV kernel IP corresponds to init_scattered_cpuid_features 0xc10362f8 <+24>: mov %gs:0x14,%eax Fixes 2cc42bac1c79 ("x86-64/Xen: eliminate W+X mappings") Signed-off-by: Jason Andryuk Reviewed-by: Boris Ostrovsky Signed-off-by: Boris Ostrovsky Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/enlighten_pv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/x86/xen/enlighten_pv.c +++ b/arch/x86/xen/enlighten_pv.c @@ -1259,10 +1259,6 @@ asmlinkage __visible void __init xen_sta */ __userpte_alloc_gfp &= ~__GFP_HIGHMEM; - /* Work out if we support NX */ - get_cpu_cap(&boot_cpu_data); - x86_configure_nx(); - /* Get mfn list */ xen_build_dynamic_phys_to_machine(); @@ -1272,6 +1268,10 @@ asmlinkage __visible void __init xen_sta */ xen_setup_gdt(0); + /* Work out if we support NX */ + get_cpu_cap(&boot_cpu_data); + x86_configure_nx(); + xen_init_irq_ops(); /* Let's presume PV guests always boot on vCPU with id 0. */