Received: by 10.223.185.116 with SMTP id b49csp2559132wrg; Thu, 15 Feb 2018 13:38:07 -0800 (PST) X-Google-Smtp-Source: AH8x226QWp91voRzNszRfR8GnnffL5QXtEn49XzkZ6saXvkXZRmW+c9IGZ7Ka+beKVgxrz1FBCDZ X-Received: by 10.99.147.72 with SMTP id w8mr3182923pgm.300.1518730687349; Thu, 15 Feb 2018 13:38:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518730687; cv=none; d=google.com; s=arc-20160816; b=yILPqQGJdtHwZA+yuswa83nKnKKyl5gigigU3QcL9vd0cTi91hBiELMxliC8VH5hk9 pOXFclYV3pW8kG2Swr1/G8MlUOZ7wDhBC5kxiZHNMp0vhd9SHdISDz8dYO72pJGN5V77 JvqAKrZIu+UysVr++Pa09LMRP86vWqFZ+v43pU4C4jiQ/dxxk6Tg+kMmJvj5wJnklj8Q pzWsR9IpfoEsZ48EJDp7zaSDABrEzHBhn++5EleTGsLICZxVsoKNZo54HbNfsQPX/tJ7 d1ZaMJFyzjLanTzMrdhE8h2K9tWvniA3CF/FcyJd5KXy4FCJOCp/xMyh/qXrXKwQBnGS drdA== 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=dXGPX1lI+25t7CwWTf/xJUheyJ7jsLhzQksHpJNs1dc=; b=JpcFzXOiKfjUGy9y+jSVYjjOMp/9SRlgyeTq+IQD3QaOICfr0RbkD8vD2z1ER30mcX h9Zs7fdYvWSpxH/6ugp//SlR+wXDxQ34Pc4NBXqNS8kZoothxbcYL6KDHVgNVZLBPPpJ Tr3YGa+oBYmkHw9pEwnpSaiokidVJnTWWyQzrwblc3ZmUoaaUAAbq0FXLCvPORpluSX/ pTxjKhol6AegtcZTVclY+0hf9i15q2jh+Qmmj1AhHzGNK/J3g/q2etUI/AJKvHPHFf1n grLF/TkPEotfKOxRdp01wbbmokJkDrOU9cdc1EzHweO+zkylnEcWcE40lwUzEhmjhVlO GwmA== 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 k20-v6si2163313pll.606.2018.02.15.13.37.52; Thu, 15 Feb 2018 13:38:07 -0800 (PST) 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 S1164418AbeBOPb0 (ORCPT + 99 others); Thu, 15 Feb 2018 10:31:26 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55572 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164304AbeBOPbX (ORCPT ); Thu, 15 Feb 2018 10:31:23 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B5E94AE0; Thu, 15 Feb 2018 15:31:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.14 041/195] [Variant 3/Meltdown] arm64: use RET instruction for exiting the trampoline Date: Thu, 15 Feb 2018 16:15:32 +0100 Message-Id: <20180215151707.797592511@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit be04a6d1126b upstream. Speculation attacks against the entry trampoline can potentially resteer the speculative instruction stream through the indirect branch and into arbitrary gadgets within the kernel. This patch defends against these attacks by forcing a misprediction through the return stack: a dummy BL instruction loads an entry into the stack, so that the predicted program flow of the subsequent RET instruction is to a branch-to-self instruction which is finally resolved as a branch to the kernel vectors with speculation suppressed. Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -981,6 +981,14 @@ alternative_else_nop_endif .if \regsize == 64 msr tpidrro_el0, x30 // Restored in kernel_ventry .endif + /* + * Defend against branch aliasing attacks by pushing a dummy + * entry onto the return stack and using a RET instruction to + * enter the full-fat kernel vectors. + */ + bl 2f + b . +2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE adr x30, tramp_vectors + PAGE_SIZE @@ -993,7 +1001,7 @@ alternative_insn isb, nop, ARM64_WORKARO msr vbar_el1, x30 add x30, x30, #(1b - tramp_vectors) isb - br x30 + ret .endm .macro tramp_exit, regsize = 64