Received: by 10.223.185.116 with SMTP id b49csp68140wrg; Thu, 15 Feb 2018 16:44:16 -0800 (PST) X-Google-Smtp-Source: AH8x226eVzaxFAhJprbgSfJIJqwKUXcZacFlJVHl3SWHmiAu6bYNhcsIfzGj/7Cdhcg+S+IH4QSu X-Received: by 10.98.26.143 with SMTP id a137mr4401705pfa.100.1518741855921; Thu, 15 Feb 2018 16:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518741855; cv=none; d=google.com; s=arc-20160816; b=R4LbJMID7UxA6vhp1sxmYDX4Hk6p/1hs0DMBpLOxYkg8Ss96077uyJ1H5cqGu5+Rdz gCyu4T1J+1WfShHjlwlUzVpGjkPWF3HGMlDBCHPfYG1mxy4cK5z538PcThzTy6fqh58S Ag7eeZUyKY1GfIXsmHZcupQ027k7VZvJs+Q3rGSErrUc+ZXGj5lcW43WEeAVYCdbU9VK wQchjipQ6oi+wTQZ9/2kfSOgCXOvedbYxffjlTKR3Rq9NiHMlmDhgq+Sm4NpvniQsgk1 rHBQtaVzxAJteH93auDUbqi2R+j2TtAFBb2KGrj1i7v568B94qahlErrjp85D30kDv+b vN0A== 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=0KqrBnNjbSepq9Rpoe5qrw+hIAkxN0/PSi7QiP2LsR8=; b=xdRa1cGu9CxZVQe47n7e7yo2yPLiS9wIjmapxqZhLEgrKo4IRYx1L2BmN73rR0bUIg Qg8Ln7bdbn8ERuv0Q+6gMI6x59fb5X2OygGPbbl+sOfKRbELl3mbkEx/GX3VB74yo7RV Bu0ixzy/9cArikikyNuVlLwTeJ7uVFLuvoWIUqFfPUNDWIALBJVHcrx+ibiHkJSZSQ3z 5f5P/JbuHHeFM30N5dXa2CU8M71SJ6h5WmUsuaODosAFiT9OdPpq7HU1xyCbJN28IeYc M2vMGeuiVw8LaTZNpRBm+BuhnDhafQm2+PpZ3n+iGmWBL9+8nWowT40p0qJhhUDMPmCT s53w== 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 x1-v6si706005pln.571.2018.02.15.16.44.01; Thu, 15 Feb 2018 16:44:15 -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 S1423654AbeBOPkF (ORCPT + 99 others); Thu, 15 Feb 2018 10:40:05 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:59956 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423370AbeBOPkB (ORCPT ); Thu, 15 Feb 2018 10:40:01 -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 B693510F0; Thu, 15 Feb 2018 15:40:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Catalin Marinas Subject: [PATCH 4.15 033/202] [Variant 3/Meltdown] arm64: use RET instruction for exiting the trampoline Date: Thu, 15 Feb 2018 16:15:33 +0100 Message-Id: <20180215151714.729202314@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@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.15-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: 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 @@ -1029,6 +1029,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 @@ -1041,7 +1049,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