Skip to content

Commit 607289a

Browse files
samitolvanenkees
authored andcommitted
treewide: Drop function_nocfi
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 <samitolvanen@google.com> Reviewed-by: Kees Cook <keescook@chromium.org> Tested-by: Kees Cook <keescook@chromium.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20220908215504.3686827-14-samitolvanen@google.com
1 parent 5dbbb3e commit 607289a

File tree

11 files changed

+11
-21
lines changed

11 files changed

+11
-21
lines changed

arch/arm64/include/asm/ftrace.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
2727
#define ARCH_SUPPORTS_FTRACE_OPS 1
2828
#else
29-
#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount))
29+
#define MCOUNT_ADDR ((unsigned long)_mcount)
3030
#endif
3131

3232
/* The BL at the callsite's adjusted rec->ip */

arch/arm64/include/asm/mmu_context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static inline void cpu_replace_ttbr1(pgd_t *pgdp, pgd_t *idmap)
168168
ttbr1 |= TTBR_CNP_BIT;
169169
}
170170

171-
replace_phys = (void *)__pa_symbol(function_nocfi(idmap_cpu_replace_ttbr1));
171+
replace_phys = (void *)__pa_symbol(idmap_cpu_replace_ttbr1);
172172

173173
__cpu_install_idmap(idmap);
174174
replace_phys(ttbr1);

arch/arm64/kernel/acpi_parking_protocol.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int acpi_parking_protocol_cpu_boot(unsigned int cpu)
9999
* that read this address need to convert this address to the
100100
* Boot-Loader's endianness before jumping.
101101
*/
102-
writeq_relaxed(__pa_symbol(function_nocfi(secondary_entry)),
102+
writeq_relaxed(__pa_symbol(secondary_entry),
103103
&mailbox->entry_point);
104104
writel_relaxed(cpu_entry->gic_cpu_id, &mailbox->cpu_id);
105105

arch/arm64/kernel/cpufeature.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1713,7 +1713,7 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused)
17131713
if (arm64_use_ng_mappings)
17141714
return;
17151715

1716-
remap_fn = (void *)__pa_symbol(function_nocfi(idmap_kpti_install_ng_mappings));
1716+
remap_fn = (void *)__pa_symbol(idmap_kpti_install_ng_mappings);
17171717

17181718
if (!cpu) {
17191719
alloc = __get_free_pages(GFP_ATOMIC | __GFP_ZERO, order);

arch/arm64/kernel/ftrace.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
5656
unsigned long pc;
5757
u32 new;
5858

59-
pc = (unsigned long)function_nocfi(ftrace_call);
59+
pc = (unsigned long)ftrace_call;
6060
new = aarch64_insn_gen_branch_imm(pc, (unsigned long)func,
6161
AARCH64_INSN_BRANCH_LINK);
6262

arch/arm64/kernel/machine_kexec.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void machine_kexec(struct kimage *kimage)
204204
typeof(cpu_soft_restart) *restart;
205205

206206
cpu_install_idmap();
207-
restart = (void *)__pa_symbol(function_nocfi(cpu_soft_restart));
207+
restart = (void *)__pa_symbol(cpu_soft_restart);
208208
restart(is_hyp_nvhe(), kimage->start, kimage->arch.dtb_mem,
209209
0, 0);
210210
} else {

arch/arm64/kernel/psci.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int __init cpu_psci_cpu_prepare(unsigned int cpu)
3838

3939
static int cpu_psci_cpu_boot(unsigned int cpu)
4040
{
41-
phys_addr_t pa_secondary_entry = __pa_symbol(function_nocfi(secondary_entry));
41+
phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry);
4242
int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry);
4343
if (err)
4444
pr_err("failed to boot CPU%d (%d)\n", cpu, err);

arch/arm64/kernel/smp_spin_table.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static int smp_spin_table_cpu_init(unsigned int cpu)
6666
static int smp_spin_table_cpu_prepare(unsigned int cpu)
6767
{
6868
__le64 __iomem *release_addr;
69-
phys_addr_t pa_holding_pen = __pa_symbol(function_nocfi(secondary_holding_pen));
69+
phys_addr_t pa_holding_pen = __pa_symbol(secondary_holding_pen);
7070

7171
if (!cpu_release_addr[cpu])
7272
return -ENODEV;

drivers/firmware/psci/psci.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static int __init psci_features(u32 psci_func_id)
334334
static int psci_suspend_finisher(unsigned long state)
335335
{
336336
u32 power_state = state;
337-
phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume));
337+
phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume);
338338

339339
return psci_ops.cpu_suspend(power_state, pa_cpu_resume);
340340
}
@@ -359,7 +359,7 @@ int psci_cpu_suspend_enter(u32 state)
359359

360360
static int psci_system_suspend(unsigned long unused)
361361
{
362-
phys_addr_t pa_cpu_resume = __pa_symbol(function_nocfi(cpu_resume));
362+
phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume);
363363

364364
return invoke_psci_fn(PSCI_FN_NATIVE(1_0, SYSTEM_SUSPEND),
365365
pa_cpu_resume, 0, 0);

drivers/misc/lkdtm/usercopy.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static void lkdtm_USERCOPY_KERNEL(void)
330330

331331
pr_info("attempting bad copy_to_user from kernel text: %px\n",
332332
vm_mmap);
333-
if (copy_to_user((void __user *)user_addr, function_nocfi(vm_mmap),
333+
if (copy_to_user((void __user *)user_addr, vm_mmap,
334334
unconst + PAGE_SIZE)) {
335335
pr_warn("copy_to_user failed, but lacked Oops\n");
336336
goto free_user;

include/linux/compiler.h

-10
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,6 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
203203
__v; \
204204
})
205205

206-
/*
207-
* With CONFIG_CFI_CLANG, the compiler replaces function addresses in
208-
* instrumented C code with jump table addresses. Architectures that
209-
* support CFI can define this macro to return the actual function address
210-
* when needed.
211-
*/
212-
#ifndef function_nocfi
213-
#define function_nocfi(x) (x)
214-
#endif
215-
216206
#endif /* __KERNEL__ */
217207

218208
/*

0 commit comments

Comments
 (0)