From patchwork Thu Oct 17 08:14:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 11195099 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0ACA913BD for ; Thu, 17 Oct 2019 08:17:44 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA19B20820 for ; Thu, 17 Oct 2019 08:17:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PY23LZbs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA19B20820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=3Q+zYTItgu8dUWm1IUL3nk30nbOGBP0qEF/Zl5X7l7I=; b=PY23LZbsfOyB2WkKQs8RFws62p roG6xoKgJbkSJV1z2FHa7xIh6Tad4pBbzxML6W5FMYwc0UHevuQxGrmQRQfsihAGCbr5jczqvVzZD hSloc+iJ5hEYYxWH7oeXaBLBQTg5tM5KeQUMNkcigxqin6VhnhfTx9mDgLwHfir30NDEBWdoYezdt eKqxra0RyNI+7RCqEbaDLke64Hc+IUxRszDBvtJgNPyspbiywfg9RGoA7vt05ZlkQaAQsCiYTGMCd XrtS6zMURkwArq5Pi/zyMv5MB7IKs1xa+P+2wSEOmAxaOGBnmPnNwTPUUv1LeAAn7SPqINWdReyTf 7SqVCmig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL0yU-0004Sm-6X; Thu, 17 Oct 2019 08:17:34 +0000 Received: from [217.140.110.172] (helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iL0wS-0001bc-6P for linux-arm-kernel@lists.infradead.org; Thu, 17 Oct 2019 08:15:30 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9B48915AD; Thu, 17 Oct 2019 01:15:21 -0700 (PDT) Received: from a075553-lin.blr.arm.com (a075553-lin.blr.arm.com [10.162.0.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 00D9F3F6C4; Thu, 17 Oct 2019 01:15:17 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 10/11] arm64: mask PAC bits of __builtin_return_address Date: Thu, 17 Oct 2019 13:44:24 +0530 Message-Id: <1571300065-10236-11-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1571300065-10236-1-git-send-email-amit.kachhap@arm.com> References: <1571300065-10236-1-git-send-email-amit.kachhap@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191017_011528_435795_D52CD0F8 X-CRM114-Status: GOOD ( 12.06 ) X-Spam-Score: 1.3 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kees Cook , Suzuki K Poulose , Catalin Marinas , Ard Biesheuvel , Will Deacon , Kristina Martsenko , James Morse , Ramana Radhakrishnan , Amit Daniel Kachhap , Vincenzo Frascino , Dave Martin MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch redefines __builtin_return_address to mask pac bits when Pointer Authentication is enabled. As __builtin_return_address is used mostly used to refer to the caller function symbol address so masking runtime generated pac bits will make it clear to the user. This change fixes the utilities like cat /proc/vmallocinfo to now show the correct logs. Signed-off-by: Amit Daniel Kachhap --- Changes since RFC v2: - New patch arch/arm64/Kconfig | 1 + arch/arm64/include/asm/compiler.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 arch/arm64/include/asm/compiler.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 253e3c5..8e86f6a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -118,6 +118,7 @@ config ARM64 select HAVE_ALIGNED_STRUCT_PAGE if SLUB select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_BITREVERSE + select HAVE_ARCH_COMPILER_H select HAVE_ARCH_HUGE_VMAP select HAVE_ARCH_JUMP_LABEL select HAVE_ARCH_JUMP_LABEL_RELATIVE diff --git a/arch/arm64/include/asm/compiler.h b/arch/arm64/include/asm/compiler.h new file mode 100644 index 0000000..229efca --- /dev/null +++ b/arch/arm64/include/asm/compiler.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_ARM_COMPILER_H +#define __ASM_ARM_COMPILER_H + +#ifndef __ASSEMBLY__ + +#if defined(CONFIG_ARM64_PTR_AUTH) +#define __builtin_return_address(val) \ + (void *)((unsigned long)__builtin_return_address(val) | \ + (GENMASK(63, 56) | GENMASK(54, VA_BITS))) +#endif + +#endif + +#endif /* __ASM_ARM_COMPILER_H */