From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F116EC433B4 for ; Tue, 6 Apr 2021 11:50:14 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 81946613A3 for ; Tue, 6 Apr 2021 11:50:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81946613A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=m+q3onhOZTzLI4fnjeo1ZmxABxVYVNEsnsmxBisQqCQ=; b=clwM93Gwpw+n8mQxIsw4omx0/ WvV7xTj4OKChgRKRYkcJtr4PrRDsUcwIWh6H+1SwOqVLreqG2xc0s1/mPx9NeiXmdvnUANh7rw+Pw 7GMBIztEeIlyGvpbZMhVHOeYuU7jgoaBy0jLrM/7mkHmz887D/e5YcYDo2BatOZ/dgDPpgDMci7R7 yjnuEqDcZNxXQA2KcCny9y9HAbdJvtuxeVDXRSoEjieawXVAiHXDcqh2LUGbKMQqrJsIqhHPvIfAW +yc7i79XjYghCfZmz9sxqKjzDJDfI99gQQq/IBxGQnWasq26WghgsxrbnpZZ8bdAeJ4hTUTr3UYD5 RCvG8Fq+A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTkBo-002Qp7-55; Tue, 06 Apr 2021 11:48:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTk15-002NJB-Dv for linux-arm-kernel@lists.infradead.org; Tue, 06 Apr 2021 11:37:20 +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 EF9C9101E; Tue, 6 Apr 2021 04:37:05 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 243363F73D; Tue, 6 Apr 2021 04:37:00 -0700 (PDT) Date: Tue, 6 Apr 2021 12:36:57 +0100 From: Mark Rutland To: Sami Tolvanen Cc: Kees Cook , Nathan Chancellor , Nick Desaulniers , Masahiro Yamada , Will Deacon , Jessica Yu , Arnd Bergmann , Tejun Heo , "Paul E. McKenney" , Christoph Hellwig , Peter Zijlstra , Sedat Dilek , Catalin Marinas , bpf@vger.kernel.org, linux-hardening@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: Re: [PATCH v5 12/18] arm64: implement function_nocfi Message-ID: <20210406113657.GC96480@C02TD0UTHF1T.local> References: <20210401233216.2540591-1-samitolvanen@google.com> <20210401233216.2540591-13-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210401233216.2540591-13-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_123708_097105_723CE0C4 X-CRM114-Status: GOOD ( 21.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 01, 2021 at 04:32:10PM -0700, Sami Tolvanen wrote: > With CONFIG_CFI_CLANG, the compiler replaces function addresses in > instrumented C code with jump table addresses. This change implements > the function_nocfi() macro, which returns the actual function address > instead. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook I think that it's unfortunate that we have to drop to assembly here, but given this is infrequent I agree it's not the end of the world, so: Acked-by: Mark Rutland > --- > arch/arm64/include/asm/memory.h | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 0aabc3be9a75..b55410afd3d1 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -321,6 +321,21 @@ static inline void *phys_to_virt(phys_addr_t x) > #define virt_to_pfn(x) __phys_to_pfn(__virt_to_phys((unsigned long)(x))) > #define sym_to_pfn(x) __phys_to_pfn(__pa_symbol(x)) > > +#ifdef CONFIG_CFI_CLANG > +/* > + * With CONFIG_CFI_CLANG, the compiler replaces function address > + * references with the address of the function's CFI jump table > + * entry. The function_nocfi macro always returns the address of the > + * actual function instead. > + */ > +#define function_nocfi(x) ({ \ > + void *addr; \ > + asm("adrp %0, " __stringify(x) "\n\t" \ > + "add %0, %0, :lo12:" __stringify(x) : "=r" (addr)); \ If it's not too painful, could we please move the asm constrain onto its own line? That makes it slightly easier to read, and aligns with what we've (mostly) done elsewhere in arm64. Not a big deal either way, and the ack stands regardless. Thanks, Mark. > + addr; \ > +}) > +#endif > + > /* > * virt_to_page(x) convert a _valid_ virtual address to struct page * > * virt_addr_valid(x) indicates whether a virtual address is valid > -- > 2.31.0.208.g409f899ff0-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel