Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4761686rwe; Tue, 30 Aug 2022 16:57:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Pgtt/qaBTqTkbNofSNr5tg44vhQ26e6PajWNR3XSgvA343upMw81WsXTA25vAXMifULq4 X-Received: by 2002:a17:90b:3908:b0:1fe:1a98:abe1 with SMTP id ob8-20020a17090b390800b001fe1a98abe1mr494020pjb.27.1661903838764; Tue, 30 Aug 2022 16:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661903838; cv=none; d=google.com; s=arc-20160816; b=xPKU/vsX6NnXOCSlAyLRSDobkILdkMETirg24pFnBhW1YidPHeOV5AceW26OlHj8TA pqr7Lk82UJf3xvhqEwH1ZJSK5K5MtHWDQcpMabqvKA6jHemr1zj3WmQekqi5HgiWPFvt uDgMZ9eLjNkNyNLvPP1vznN1VSfRXdNPmMY11U7tMRYoEbUbyFKMRUI31MJtwdbzFtcJ R6prB88b9/eGrMXA01UXUhUQJGDEo+swDU/5DUX8txORLeOEwXPJLmLcd8YIsG8LYzHS qn3U8dRDHY8D0+HqWsveWGR+CEx96pQZKvGkc6vZUrO2nbSxXHXndsf3LqdmjlyCG6HY VxJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=2RJzzt50GfkBkKzSKhsY7PPvK5P139xVWWGbb18iAUo=; b=ONwokFLlBphGUJePEMnGm8KKRt1i7H8MweyOFKVB7y3wv0C44wmaEOKzQv9GpDS7rU 5YWsfYU397j2LpINKHdgL99A9stLSvEFjUppX/4qjnSriFFsqKQ79Jf7G35sMQEepwux mzgYzWlD0XIyO0k+CJ9SzmJ67ySQAErLI5EaqIIDQvnHxNVj8cPCdZuoZ1gizU26g2mb Y7IyWKM04CEhLOj8N00bwhQNcoZdMrN/xvlcJact310SAsUim6zO+tWriW8oiHV4w0kF Kwoqp/28MbOURqNCx8qKBK/868tnpawNMJaTyElr0b76iVhxFvQ4L2yw2uiS5RzQlCRu 6AnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=R6GPGEjJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a170902729500b00174c2240848si2414351pll.212.2022.08.30.16.57.08; Tue, 30 Aug 2022 16:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=R6GPGEjJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231741AbiH3XdQ (ORCPT + 99 others); Tue, 30 Aug 2022 19:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbiH3Xcg (ORCPT ); Tue, 30 Aug 2022 19:32:36 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07FC07A52A for ; Tue, 30 Aug 2022 16:32:09 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id n18-20020a25d612000000b0069661a1dc48so886887ybg.20 for ; Tue, 30 Aug 2022 16:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date; bh=2RJzzt50GfkBkKzSKhsY7PPvK5P139xVWWGbb18iAUo=; b=R6GPGEjJY+7YK8cDpLcBb1w6hkR8Hf2a4SNGCWP0ycCg1936jaA5LdXrBTGi6TYwqI VYnU32jZjYr2Rsf1yaw9FDmYSSGFRc5sk4a/80vO6Zw8MLk1+lgBM+xxajL+9vkFNolR 0ZwoBMKZTckPcbSdwQxsP3DfqCwXr3OSwWVUdAx1UOZIQoTHvOsczZ87984vIGCYePpW 8880MDiA5vB2ae/5MOnnp56ZWQa4zBIvDwlVcQYxxCSe0Kyf9KTyg0vRukSlM+7nMflk J6hGrbVvb8mTYTv4OOvF7KVmXzPpU+iBwFq6k+qJ+W5vNgq1lECDFzmbB1/9+pv3x0Ia pkkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=2RJzzt50GfkBkKzSKhsY7PPvK5P139xVWWGbb18iAUo=; b=XNTKJQj1jov4Nj0U4l92/AoUn2f4AIgx98GXnGH6F4svhl9T+ljuNWJExIECLx8SL5 JUROuFniIAZz6lKOSvNX5/qrsyIOfAAfzDNyuGyZXsOt8IZGM8NmNsltiyNppvRkXBGn QUXake/ZIuyTFX9V5PPTAdqXaTDYuBeluj+wqRQe2bJgso/HShAQrvAKbb0xjlKPqPCl DM1M5gG2z2yHbfflPj8eInCpUZUPn8EGWSDvP+szJ/8I+e+Xhhy+6XeUWXBVnQGQVQcX Ino9DpPMizsreOeoMCdayUKnbUeiNs+r7IuxB4QK72Sc25Vc20Pb3mG9IUfLXbqibLfw Sg6Q== X-Gm-Message-State: ACgBeo3FTI/hwU/DzgqCh+49yZVMTCUNAkX7rxdODxwa2LQRqIxIQYNs 5poV/mXb6Ip4d9glIoujK83CIPWMcrKgVLQn9r8VA+fV5Ex+h4etAChRqDBPenTo2CgsZGgd8Tr sJjY6jEIxCSfj28wXuKBR0Ap4xEXg7xE6arzbcux8uQtM3VqU0P57TbUKId0oAPmvIEt4Mj94k5 gfQWAj6gBF0Q== X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:54d9:7143:6a7d:91d]) (user=samitolvanen job=sendgmr) by 2002:a5b:7d1:0:b0:68c:c23a:6c08 with SMTP id t17-20020a5b07d1000000b0068cc23a6c08mr13358515ybq.327.1661902328531; Tue, 30 Aug 2022 16:32:08 -0700 (PDT) Date: Tue, 30 Aug 2022 16:31:21 -0700 In-Reply-To: <20220830233129.30610-1-samitolvanen@google.com> Message-Id: <20220830233129.30610-14-samitolvanen@google.com> Mime-Version: 1.0 References: <20220830233129.30610-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=7480; i=samitolvanen@google.com; h=from:subject; bh=pydGyiCp6+TYUef/iIF5ioe5+KZhG3vYC8bwhJPrUzE=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBjDp3OQmmoavox/3xbE3Q+Eb2RMNEZIGgQzvAz4Y4T 7ZjaP5iJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYw6dzgAKCRBMtfaEi7xW7llEC/ 4yCsRkIF8EFINpwkz205dfDNgQgzmCDBj1Xo5yqaYKV0UW6QBMDp1wHY8qWC9lFzDT+MaCIcLMmT43 Qa8LryJemUfbaExnfHW2nN9RW1qGyBOaf+3ZW7Rb/h5cYhz/h5liX0wsrgjJZ5de5Q2hRhspEkfyDg zix1Cj/CPwvy1nwp7gfmWSG2yYeyjby6eCG+Xmgqx+TwtgyNgbt9nZPf5drBZtlX2cLqQk2EDi4eVs tQMVQpXtqirV/2CV7HKCr/Gcj6bLzGv4GIo7Xisd1hUDWV9AZF7P7VhTEzsQNTiKJN+5epxbmJH6QC VP+08pYrNzzJI690cb9Yob5x0Od4uzujqZUCrEz34osS3v0//3f4BZFK1uTjv3Ip5E92ZI5p64pWQE qeZYFVb16bbMz+pef5zXKfka5IBm70IfFaUQwdivcq8FM1V/p4oNjSCiTrCyvqEjOCrqTfZgGH1zLB tIRvJzt6oGkVmfiX6xekfyBorjUfDGjuXJHJswTNh3IpE= X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Subject: [PATCH v4 13/21] treewide: Drop function_nocfi From: Sami Tolvanen To: linux-kernel@vger.kernel.org Cc: Kees Cook , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With -fsanitize=kcfi, we no longer need function_nocfi() as the compiler won't change function references to point to a jump table. Remove all implementations and uses of the macro. Signed-off-by: Sami Tolvanen Reviewed-by: Kees Cook --- arch/arm64/include/asm/ftrace.h | 2 +- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/kernel/acpi_parking_protocol.c | 2 +- arch/arm64/kernel/cpufeature.c | 2 +- arch/arm64/kernel/ftrace.c | 2 +- arch/arm64/kernel/machine_kexec.c | 2 +- arch/arm64/kernel/psci.c | 2 +- arch/arm64/kernel/smp_spin_table.c | 2 +- drivers/firmware/psci/psci.c | 4 ++-- drivers/misc/lkdtm/usercopy.c | 2 +- include/linux/compiler.h | 10 ---------- 11 files changed, 11 insertions(+), 21 deletions(-) diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h index dbc45a4157fa..329dbbd4d50b 100644 --- a/arch/arm64/include/asm/ftrace.h +++ b/arch/arm64/include/asm/ftrace.h @@ -26,7 +26,7 @@ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS #define ARCH_SUPPORTS_FTRACE_OPS 1 #else -#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount)) +#define MCOUNT_ADDR ((unsigned long)_mcount) #endif /* The BL at the callsite's adjusted rec->ip */ diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index bba0e630c8bc..d3f8b5df0c1f 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -168,7 +168,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap) ttbr1 |= TTBR_CNP_BIT; } - replace_phys = (void *)__pa_symbol(function_nocfi(idmap_cpu_replace_ttbr1)); + replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1); __cpu_install_idmap(idmap); replace_phys(ttbr1); diff --git a/arch/arm64/kernel/acpi_parking_protocol.c b/arch/arm64/kernel/acpi_parking_protocol.c index bfeeb5319abf..b1990e38aed0 100644 --- a/arch/arm64/kernel/acpi_parking_protocol.c +++ b/arch/arm64/kernel/acpi_parking_protocol.c @@ -99,7 +99,7 @@ static int acpi_parking_protocol_cpu_boot(unsigned int cpu) * that read this address need to convert this address to the * Boot-Loader's endianness before jumping. */ - writeq_relaxed(__pa_symbol(function_nocfi(secondary_entry)), + writeq_relaxed(__pa_symbol(secondary_entry), &mailbox->entry_point); writel_relaxed(cpu_entry->gic_cpu_id, &mailbox->cpu_id); diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index ca6e5ca7104e..d8361691efeb 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1713,7 +1713,7 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused) if (arm64_use_ng_mappings) return; - remap_fn = (void *)__pa_symbol(function_nocfi(idmap_kpti_install_ng_mappings)); + remap_fn = (void *)__pa_symbol(idmap_kpti_install_ng_mappings); if (!cpu) { alloc = __get_free_pages(GFP_ATOMIC | __GFP_ZERO, order); diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index ea5dc7c90f46..26789865748c 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -56,7 +56,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func) unsigned long pc; u32 new; - pc = (unsigned long)function_nocfi(ftrace_call); + pc = (unsigned long)ftrace_call; new = aarch64_insn_gen_branch_imm(pc, (unsigned long)func, AARCH64_INSN_BRANCH_LINK); diff --git a/arch/arm64/kernel/machine_kexec.c b/arch/arm64/kernel/machine_kexec.c index 19c2d487cb08..ce3d40120f72 100644 --- a/arch/arm64/kernel/machine_kexec.c +++ b/arch/arm64/kernel/machine_kexec.c @@ -204,7 +204,7 @@ void machine_kexec(struct kimage *kimage) typeof(cpu_soft_restart) *restart; cpu_install_idmap(); - restart = (void *)__pa_symbol(function_nocfi(cpu_soft_restart)); + restart = (void *)__pa_symbol(cpu_soft_restart); restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem, 0, 0); } else { diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index ab7f4c476104..29a8e444db83 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -38,7 +38,7 @@ static int __init cpu_psci_cpu_prepare(unsigned int cpu) static int cpu_psci_cpu_boot(unsigned int cpu) { - phys_addr_t pa_secondary_entry = __pa_symbol(function_nocfi(secondary_entry)); + phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); if (err) pr_err("failed to boot CPU%d (%d)\n", cpu, err); diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c index 7e1624ecab3c..49029eace3ad 100644 --- a/arch/arm64/kernel/smp_spin_table.c +++ b/arch/arm64/kernel/smp_spin_table.c @@ -66,7 +66,7 @@ static int smp_spin_table_cpu_init(unsigned int cpu) static int smp_spin_table_cpu_prepare(unsigned int cpu) { __le64 __iomem *release_addr; - phys_addr_t pa_holding_pen = __pa_symbol(function_nocfi(secondary_holding_pen)); + phys_addr_t pa_holding_pen = __pa_symbol(secondary_holding_pen); if (!cpu_release_addr[cpu]) return -ENODEV; diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 75ef784a3789..bc6b5a12bf74 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -334,7 +334,7 @@ static int __init psci_features(u32 psci_func_id) static int psci_suspend_finisher(unsigned long state) { u32 power_state = state; - phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); + phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume); return psci_ops.cpu_suspend(power_state, pa_cpu_resume); } @@ -359,7 +359,7 @@ int psci_cpu_suspend_enter(u32 state) static int psci_system_suspend(unsigned long unused) { - phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume)); + phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume); return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND), pa_cpu_resume, 0, 0); diff --git a/drivers/misc/lkdtm/usercopy.c b/drivers/misc/lkdtm/usercopy.c index 6215ec995cd3..67db57249a34 100644 --- a/drivers/misc/lkdtm/usercopy.c +++ b/drivers/misc/lkdtm/usercopy.c @@ -330,7 +330,7 @@ static void lkdtm_USERCOPY_KERNEL(void) pr_info("attempting bad copy_to_user from kernel text: %px\n", vm_mmap); - if (copy_to_user((void __user *)user_addr, function_nocfi(vm_mmap), + if (copy_to_user((void __user *)user_addr, vm_mmap, unconst + PAGE_SIZE)) { pr_warn("copy_to_user failed, but lacked Oops\n"); goto free_user; diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 7bfafc69172a..973a1bfd7ef5 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -203,16 +203,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, __v; \ }) -/* - * 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 - #endif /* __KERNEL__ */ /* -- 2.37.2.672.g94769d06f0-goog