Re: [PATCH v3 12/17] arm64: implement __va_function
From: Peter Collingbourne <hidden>
Date: 2021-03-26 00:04:30
Also in:
bpf, linux-arch, linux-hardening, linux-kbuild, linux-pci, lkml
On Thu, Mar 25, 2021 at 4:28 PM Sami Tolvanen [off-list ref] wrote:
On Thu, Mar 25, 2021 at 3:38 AM Mark Rutland [off-list ref] wrote:quoted
On Tue, Mar 23, 2021 at 01:39:41PM -0700, Sami Tolvanen wrote:quoted
With CONFIG_CFI_CLANG, the compiler replaces function addresses in instrumented C code with jump table addresses. This change implements the __va_function() macro, which returns the actual function address instead. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Kees Cook <redacted>Is there really no attribute or builtin that can be used to do this without assembly?I don't think the compiler currently offers anything that could help us here. Peter, can you think of another way to avoid the function address to jump table address conversion with -fno-sanitize-cfi-canonical-jump-tables?
No, the assembly seems like the best way at the moment.
quoted
IIUC from other patches the symbol tables will contain the "real" non-cfi entry points (unless we explciitly asked to make the jump table address canonical), so AFAICT here the compiler should have all the necessary information to generate either the CFI or non-CFI entry point addresses, even if it doesn't expose an interface for that today. It'd be a lot nicer if we could get the compiler to do this for us.I agree, that would be quite useful in the kernel.
Maybe. The kernel's requirements seem quite specialized here though. A normal C or C++ program has little need for the actual entry point, so if you need it you are probably doing something low level enough to require assembly anyway. Peter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel