From patchwork Sun Oct 27 21:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 177877 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp2551778ill; Sun, 27 Oct 2019 14:35:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3x/G7Yw0tSBCKW3SHcn5CkK4HV8FBHHCIJKIjhFrZm6ElsHkLF3XlYvd6Hl68rQIHGMN/ X-Received: by 2002:aa7:db46:: with SMTP id n6mr14682893edt.46.1572212102493; Sun, 27 Oct 2019 14:35:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572212102; cv=none; d=google.com; s=arc-20160816; b=QU7BZzJmDaYYLqy2jrybV7OfJPcuHxAknL6r/0i7pJJGLVJPoIjXpCyNSE+Kst68E8 x0HS/BW3nt7GESdMVuNzk8FAAMEgWi85xIXSBxw7iM5Cve9SStNW+3KFydXZvE7JY26W zA9/x3Xk8sXshvuEDJN1vd62zzHtaQ6JfZcfZpFhQONQ2vpVBRhF2Yf6BDC//GZ2DBJF FQeH+3t54OdunQoWYniTUZH6HJYHequdHdH6PegTD6xdhJNzY0rCSsrrWhAuTIxHLsP1 MSYufrXLnQ4HNQERKOfL2ErKlUNprLrPWWAU8gdmKo0gzXjJEfwWgOdtc1bSTo07/PLr we2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yeUtHVmib6FItw4LM5KwgCtoVZaCkEXHrz/xLc8UuBg=; b=T5T4WG8vv3vpRUf4FDNQ1uy3FJA3ObFsT94f5V6Du09v4cTNtf6nOC/OFQd+yVuuvh 2Ja3T37e0q7pBKbaaXMYKfbJylNk00hAGS6D4NQNVevtGe6UwIR+1UVNqfQFfviHiSv9 WMgbHT9+BAlXl7BZex9yTptEtHQwvjt6LIv44EWYchuwvPG84v5aNUj66Qmkrdpd+0bB yEJ4zqA41cgkucuHBtPuC5T5JLYNjtuqlbjzp2+U+9Wdighj7LxlDrd0LFs1j/M1wS4q HnRuyd76XIwPcb6MU95GWC6lHFX+QGveJDzIveivnavu5cWBlQKloszhYxbvAQ+OzYNm QCvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BL2Z1cYc; 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 p20si5174313ejj.394.2019.10.27.14.35.02; Sun, 27 Oct 2019 14:35:02 -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; dkim=pass header.i=@kernel.org header.s=default header.b=BL2Z1cYc; 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 S1731576AbfJ0VfA (ORCPT + 26 others); Sun, 27 Oct 2019 17:35:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729526AbfJ0VJm (ORCPT ); Sun, 27 Oct 2019 17:09:42 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3D8EB20873; Sun, 27 Oct 2019 21:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210581; bh=Kdkl6MjKw9XcZ+JW5R1/iavV97KIaMZNlGVouRBiJCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BL2Z1cYch2LkgJcuuEQxDxhPsdS4+uRY3cnqn/T3D8aYuZ06Hl8sAExZD+kQa/Mp1 EHjU9Yk4HHXSVB89xxE40U0zC5smK7YRWhnD8ugKZFX+HBmG3ZI9VpdT02qkfakmjq CxnR+ZjXcedq5BfpVL2m2GjQjEjrMAX+pCEwKsHQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Mark Rutland , Catalin Marinas , Suzuki K Poulose , Will Deacon , Ard Biesheuvel Subject: [PATCH 4.14 066/119] arm64: dont zero DIT on signal return Date: Sun, 27 Oct 2019 22:00:43 +0100 Message-Id: <20191027203332.526906764@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203259.948006506@linuxfoundation.org> References: <20191027203259.948006506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland [ Upstream commit 1265132127b63502d34e0f58c8bdef3a4dc927c2 ] Currently valid_user_regs() treats SPSR_ELx.DIT as a RES0 bit, causing it to be zeroed upon exception return, rather than preserved. Thus, code relying on DIT will not function as expected, and may expose an unexpected timing sidechannel. Let's remove DIT from the set of RES0 bits, such that it is preserved. At the same time, the related comment is updated to better describe the situation, and to take into account the most recent documentation of SPSR_ELx, in ARM DDI 0487C.a. Signed-off-by: Mark Rutland Fixes: 7206dc93a58fb764 ("arm64: Expose Arm v8.4 features") Cc: Catalin Marinas Cc: Suzuki K Poulose Cc: Will Deacon Signed-off-by: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/ptrace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1402,15 +1402,19 @@ asmlinkage void syscall_trace_exit(struc } /* - * Bits which are always architecturally RES0 per ARM DDI 0487A.h + * SPSR_ELx bits which are always architecturally RES0 per ARM DDI 0487C.a + * We also take into account DIT (bit 24), which is not yet documented, and + * treat PAN and UAO as RES0 bits, as they are meaningless at EL0, and may be + * allocated an EL0 meaning in future. * Userspace cannot use these until they have an architectural meaning. + * Note that this follows the SPSR_ELx format, not the AArch32 PSR format. * We also reserve IL for the kernel; SS is handled dynamically. */ #define SPSR_EL1_AARCH64_RES0_BITS \ - (GENMASK_ULL(63,32) | GENMASK_ULL(27, 22) | GENMASK_ULL(20, 10) | \ - GENMASK_ULL(5, 5)) + (GENMASK_ULL(63,32) | GENMASK_ULL(27, 25) | GENMASK_ULL(23, 22) | \ + GENMASK_ULL(20, 10) | GENMASK_ULL(5, 5)) #define SPSR_EL1_AARCH32_RES0_BITS \ - (GENMASK_ULL(63,32) | GENMASK_ULL(24, 22) | GENMASK_ULL(20,20)) + (GENMASK_ULL(63,32) | GENMASK_ULL(23, 22) | GENMASK_ULL(20,20)) static int valid_compat_regs(struct user_pt_regs *regs) {