lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 23 Mar 2021 13:39:32 -0700
From:   Sami Tolvanen <>
To:     Kees Cook <>
Cc:     Nathan Chancellor <>,
        Nick Desaulniers <>,
        Masahiro Yamada <>,
        Will Deacon <>, Jessica Yu <>,
        Arnd Bergmann <>, Tejun Heo <>,
        "Paul E. McKenney" <>,
        Christoph Hellwig <>,
        Peter Zijlstra <>,,,,,,,,
        Sami Tolvanen <>
Subject: [PATCH v3 03/17] mm: add generic __va_function and __pa_function macros

With CONFIG_CFI_CLANG, the compiler replaces function addresses
in instrumented C code with jump table addresses. This means that
__pa_symbol(function) returns the physical address of the jump table
entry instead of the actual function, which may not work as the jump
table code will immediately jump to a virtual address that may not be

To avoid this address space confusion, this change adds generic
definitions for __va_function and __pa_function, which architectures
that support CFI can override. The typical implementation of the
__va_function macro would use inline assembly to take the function
address, which avoids compiler instrumentation.

Signed-off-by: Sami Tolvanen <>
Reviewed-by: Kees Cook <>
 include/linux/mm.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 64a71bf20536..a0d285cd59ce 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -116,6 +116,14 @@ extern int mmap_rnd_compat_bits __read_mostly;
 #define __pa_symbol(x)  __pa(RELOC_HIDE((unsigned long)(x), 0))
+#ifndef __va_function
+#define __va_function(x) (x)
+#ifndef __pa_function
+#define __pa_function(x) __pa_symbol(__va_function(x))
 #ifndef page_to_virt
 #define page_to_virt(x)	__va(PFN_PHYS(page_to_pfn(x)))

Powered by blists - more mailing lists