From patchwork Fri Jun 10 23:35:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sami Tolvanen X-Patchwork-Id: 12878211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4AAAFC43334 for ; Sat, 11 Jun 2022 00:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=d1W6/ayBCPJc7pqJ9CHAIJ+x6S9rL8lh+Wh3A/mW4xc=; b=gqmVQjg2BDIIVzZQHgpefg/qWE ZXPFqOefES7kymwQ2ZgGbYR75OQdTxGNkE4wnREy8HlK6+1yJ6ber+0a6wAe1OLHGcPD8UPquUbBa UNvdNompDCCOFm0m145y7QLSPwtCn4I0ltpViKhFmXWWPOnBWPvBS2DIS2vmVUw3Zviwjliwuvafj Y1iu6uIKG5JBjc0t7rHsW05RQOYzGeGIFjYoV0h+031jhLpepGMgSGjDAfWxTj5wErXRGM4rxnRNW 1SGOt+D0Zjx0gdl9HesQXp0Hjc7IVnG2qfq6P9Gt59gJNB0EuEfBmpdXbiYyjp4XgB2RHC+STHh5G 6C6XmWeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoXi-00AZ1G-D6; Fri, 10 Jun 2022 23:59:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoXP-00AYwD-Be for linux-arm-kernel@bombadil.infradead.org; Fri, 10 Jun 2022 23:59:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A4Eml+JKEIubNZOvrdz+yW1eaCBFok/SqX3y3Lo8JPk=; b=s4/LlFH/EJElfm34GP3YkQGnAS u9+1frmQtnnE7MqG7IqvuPDD2d+mfBDNqhCb29yPDaut7eNktTyetyMpg8KyZ+8aD2h1YLpP8Uuwc BU3Yy2Rij+2LWIzgME02xBuuvsM+OehuAqQPca7Y7hnRixLvVsho8tpySXaFSsrAByjjd4LRlqw8G 65LeOFoXsi5b9J39TK3b3jrFs0Mg28Fut68+cHJsu+MS41nQvlXhkLJSUd3wYHbfJTWuChg+eg0w5 L51hjbsDFp6sPErgLD2i1dw5Fh7/Fj0S8vPPrHKEoghhZAXSD9+grdu/Q1MO51aTOBIxKsGH+rtPJ Xr/lMnUw==; Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzoAP-00Eq5X-4W for linux-arm-kernel@lists.infradead.org; Fri, 10 Jun 2022 23:35:51 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-30c9a01d1c5so6008887b3.11 for ; Fri, 10 Jun 2022 16:35:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=A4Eml+JKEIubNZOvrdz+yW1eaCBFok/SqX3y3Lo8JPk=; b=ICnq54isHnlcIXFq7R78Uk5/hJB4/xoFIMMyBix4W40Cd+eaY+XubVRTX5Qnd+//M2 10P1viq3F4l0BApMHj1I57uIRnRp/80T4vWiY7Ki5VHqLIdJmC+uOaWeKrEdUL3fFqru X6GQUSgh16HYu/aVwI2Iq3K0EzACqQkhd5oZMfP6JyWR6MlQghU2E0L82WWromfvj+u5 TGg2DXCRUMYaDpZkybad2dXJ5Ds4ha2NS+i4i51gDX+KZyWLRpPW51CreW6SPbbICj4m N8S4UDmnpdF+ds47BFpSbJ/CHXK0BVfpN58iumzf3zlkuN4oWj5mzCJzikoZmfoakou6 kzBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=A4Eml+JKEIubNZOvrdz+yW1eaCBFok/SqX3y3Lo8JPk=; b=mCA+PIsBwyjr+TnahvUoVyPFUz7Wp6h6GyfzB0hGhwyuoWMUdubC8t6W5LICIdJM9Y /jtn50JfHyBSKDDCzcvPip8SVonKiNj5rc9p5vdVS9CIx4c7hOUUktQDlRGTwBjpjIhI rhBQjBMm6lB4UdxJ/1PYhhG+6XPO3mjGn1z2trFqH9xZkCDHBrlBPflIIVVPyrI9ArxZ g3LVCzZ3TntzzMMs8Zlq0l6b3KFKiS/HH/ucUTzeUm14aCwlcyz+SLUkxYjhoShr3ouE 5XxDz3VXpYJskBkos/IRkmoSsdhkkqoX7vQ9m4lbJ9Nk8jeR5B/o962YbN0wDo11rDSc vsAQ== X-Gm-Message-State: AOAM5326IU1wjlQq6GYY3QsVTpFfNAgwz0uoR/nHwrs2Dl8KUxJRWUOe 1XqZzwE8tL8eJmYciKk2G3NGVY661LknGzHd4ho= X-Google-Smtp-Source: ABdhPJx3rWv57FeBwQEWM6oFIvs7P3CtHXeBLaqrJnarF3QKs+mKVjy+7OOtU2lt3kt6rHiYFVGINgTtgCkYMqfiuis= X-Received: from samitolvanen1.mtv.corp.google.com ([2620:15c:201:2:f464:6db6:3d47:ed14]) (user=samitolvanen job=sendgmr) by 2002:a0d:e857:0:b0:30c:34d9:26a with SMTP id r84-20020a0de857000000b0030c34d9026amr50927937ywe.452.1654904144744; Fri, 10 Jun 2022 16:35:44 -0700 (PDT) Date: Fri, 10 Jun 2022 16:35:05 -0700 In-Reply-To: <20220610233513.1798771-1-samitolvanen@google.com> Message-Id: <20220610233513.1798771-13-samitolvanen@google.com> Mime-Version: 1.0 References: <20220610233513.1798771-1-samitolvanen@google.com> X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=7472; h=from:subject; bh=GPeI2jXo672qyhEESIXuD7+8ae5gl84hUV7hYDqvorE=; b=owEB7QES/pANAwAKAUy19oSLvFbuAcsmYgBio9UuWrx1MXXVBdMFywRXAOfO2YvBygj7JJFtUOi8 G8KDBMaJAbMEAAEKAB0WIQQ1zPtjsoPW0663g5RMtfaEi7xW7gUCYqPVLgAKCRBMtfaEi7xW7k+OC/ 9dpLWjuTj9zfrMrWNrJVFHNL6uWBl3L9HYK5U6Lgv5m6Z03h7wWS6sa2LXLCrTpd9p3l5joJNewr7+ M2Y+lktQ3G4z+87/qQ4hGMsD46K35UovrQ5TFLuEVnyPleSKBZaad/OOkoJHFPAKpvMIcSug8ANQre 0DGcYYc7359wxVNSmk1Y06SGDXwPAjaGG37UjiY5Di5Y2zsuj/gJVX93hTNhLgi1PiNNWamYBG5B+F xfbJUgY5AP69lrC0TimyHVZYAnX2MivmJh2GPb1Dt70CGsE16F3ih3R/hr3fI563LdWQB4G3xzTj59 x5IW06T0dLN2GrgYXOaJqhQRR1PyIL04Q1a9bOuDLa32EJHd9xlqqxplAPQ/5qeKLUGukEnNaQST8q RHl4mrMt34cBzt+sfh/PWedaGhxICDWuq5hIVsCw7xYFcxyhFXzO1idT4z9CzU8n6M1MUeacly7+71 dk9ig+TYsTvQosaXAhFq715HYHfT63xcw7fJDbo16Y1wA= X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [RFC PATCH v3 12/20] 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220611_003549_278788_9B3A26A5 X-CRM114-Status: GOOD ( 15.87 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 ca0140d0b8cf..8fa4cfbdda90 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -164,7 +164,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp) 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(); 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 f6f9694d0448..6cd476f0d19c 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1668,7 +1668,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); cpu_install_idmap(); remap_fn(cpu, num_online_cpus(), __pa_symbol(swapper_pg_dir)); diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index f447c4a36f69..74c8ab01dd8c 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 cfb448eabdaa..aa3133cafced 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 63be1c23d676..76f5e41ea725 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__ */ /*