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 87828C433B4 for ; Tue, 6 Apr 2021 11:30:01 +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 25DC06128B for ; Tue, 6 Apr 2021 11:30:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25DC06128B 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=xlu57dlXgv3W96rVy7snJzsztNHMk8mdJ4Rw6qHm07o=; b=J3gVZwu+esSC9zlXg8ernlCz7 uDkdctfIdut5OHRskBEh5i33LR4UVwoFfwOSa1l7kS3erFZsvfkdTbHGuVWRdO8guAu9va0N6ROiI EJ56I/Tvi1mAY6BrZ2aXu7GRsuHiZi3GYNcgrESwnLRUIZyeZzfaVURBmtHMRUPPAE3q6pE/U/Jwr HHYbe4J77UgI3qNfn+0X4GYPBVszxsEd2ZtlSVuWeKNrsnTPZHEpw6arSjRTun3bqNaqbHtOMfPd6 b9G4W4PpqAhKZ1uWtu1DICkCAu/kDSZdBo5Gg3Gsn2IDnsXeIyu7LY64qDyZ8RqezbGPb7+q7ibRZ 4X7mLEGjA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTjrj-002Jci-Sy; Tue, 06 Apr 2021 11:27:28 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTjrf-002Jbo-Ip for linux-arm-kernel@lists.infradead.org; Tue, 06 Apr 2021 11:27:25 +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 43D8E31B; Tue, 6 Apr 2021 04:27:20 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C66723F73D; Tue, 6 Apr 2021 04:27:15 -0700 (PDT) Date: Tue, 6 Apr 2021 12:27:06 +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 03/18] mm: add generic function_nocfi macro Message-ID: <20210406112656.GA96480@C02TD0UTHF1T.local> References: <20210401233216.2540591-1-samitolvanen@google.com> <20210401233216.2540591-4-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210401233216.2540591-4-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_122723_816614_F0C7F6FF X-CRM114-Status: GOOD ( 23.54 ) 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:01PM -0700, Sami Tolvanen wrote: > With CONFIG_CFI_CLANG, the compiler replaces function addresses > in instrumented C code with jump table addresses. This means that > __pa_symbol(function) returns the physical address of the jump table > entry instead of the actual function, which may not work as the jump > table code will immediately jump to a virtual address that may not be > mapped. > > To avoid this address space confusion, this change adds a generic > definition for function_nocfi(), which architectures that support CFI > can override. The typical implementation of would use inline assembly > to take the function address, which avoids compiler instrumentation. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook FWIW: Acked-by: Mark Rutland Mark. > --- > include/linux/mm.h | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 8ba434287387..22cce9c7dd05 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -124,6 +124,16 @@ extern int mmap_rnd_compat_bits __read_mostly; > #define lm_alias(x) __va(__pa_symbol(x)) > #endif > > +/* > + * With CONFIG_CFI_CLANG, the compiler replaces function addresses in > + * instrumented C code with jump table addresses. Architectures that > + * support CFI can define this macro to return the actual function address > + * when needed. > + */ > +#ifndef function_nocfi > +#define function_nocfi(x) (x) > +#endif > + > /* > * To prevent common memory management code establishing > * a zero page mapping on a read fault. > -- > 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