[PATCH] riscv: Add kCFI type prefix to unaligned copy routines

Kees Cook kees at kernel.org
Thu Jun 18 09:54:11 PDT 2026



On June 18, 2026 3:10:00 AM PDT, Nam Cao <namcao at linutronix.de> wrote:
>Kees Cook <kees at kernel.org> writes:
>> __riscv_copy_words_unaligned() and __riscv_copy_bytes_unaligned() are
>> called indirectly through function pointers from measure_cycles() (via
>> compare_unaligned_access()) during the boot-time unaligned-access
>> probe. Under kCFI, an indirect call checks the type id stored in the
>> word immediately preceding the callee against the type id of the
>> function-pointer type at the call site. These two routines are defined
>> with SYM_FUNC_START(), which emits no __cfi_ prefix, so the check reads
>> the alignment padding ahead of the function (zero) instead of a type id
>> and traps:
>
>This has already been fixed by commit f2abc305aa93f ("riscv: Define
>__riscv_copy_{,vec_}{words,bytes}_unaligned() using SYM_TYPED_FUNC_START")

Ah-ha! Great. I need to update my tree, it seems. :)

-Kees

-- 
Kees Cook



More information about the linux-riscv mailing list