diff options
author | Will Deacon <will@kernel.org> | 2019-09-11 15:26:46 +0300 |
---|---|---|
committer | Jessica Yu <jeyu@kernel.org> | 2019-09-11 19:53:30 +0300 |
commit | 069e1c07c18ac2ccecdfb5ac287a37d6fb2d7a00 (patch) | |
tree | 96f7b9ee7080adeb85d4804102502d0f24c41320 /include/linux/export.h | |
parent | 32bca2df7da27be34371a37f9bb5e2b85fdd92bd (diff) | |
download | linux-069e1c07c18ac2ccecdfb5ac287a37d6fb2d7a00.tar.xz |
module: Fix link failure due to invalid relocation on namespace offset
Commit 8651ec01daed ("module: add support for symbol namespaces.")
broke linking for arm64 defconfig:
| lib/crypto/arc4.o: In function `__ksymtab_arc4_setkey':
| arc4.c:(___ksymtab+arc4_setkey+0x8): undefined reference to `no symbol'
| lib/crypto/arc4.o: In function `__ksymtab_arc4_crypt':
| arc4.c:(___ksymtab+arc4_crypt+0x8): undefined reference to `no symbol'
This is because the dummy initialisation of the 'namespace_offset' field
in 'struct kernel_symbol' when using EXPORT_SYMBOL on architectures with
support for PREL32 locations uses an offset from an absolute address (0)
in an effort to trick 'offset_to_pointer' into behaving as a NOP,
allowing non-namespaced symbols to be treated in the same way as those
belonging to a namespace.
Unfortunately, place-relative relocations require a symbol reference
rather than an absolute value and, although x86 appears to get away with
this due to placing the kernel text at the top of the address space, it
almost certainly results in a runtime failure if the kernel is relocated
dynamically as a result of KASLR.
Rework 'namespace_offset' so that a value of 0, which cannot occur for a
valid namespaced symbol, indicates that the corresponding symbol does
not belong to a namespace.
Cc: Matthias Maennich <maennich@google.com>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Fixes: 8651ec01daed ("module: add support for symbol namespaces.")
Reported-by: kbuild test robot <lkp@intel.com>
Tested-by: Matthias Maennich <maennich@google.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Matthias Maennich <maennich@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Diffstat (limited to 'include/linux/export.h')
-rw-r--r-- | include/linux/export.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/export.h b/include/linux/export.h index 2c5468d8ea9a..ef5d015d754a 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -68,7 +68,7 @@ extern struct module __this_module; "__ksymtab_" #sym ": \n" \ " .long " #sym "- . \n" \ " .long __kstrtab_" #sym "- . \n" \ - " .long 0 - . \n" \ + " .long 0 \n" \ " .previous \n") struct kernel_symbol { |