aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel/image.h
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2016-01-15 07:28:57 -0500
committerWill Deacon <will.deacon@arm.com>2016-01-25 06:09:04 -0500
commit75feee3d9d51775072d3a04f47d4a439a4c4590e (patch)
treef376dc24908d5a1778a03eb059b49863dfa5f134 /arch/arm64/kernel/image.h
parent92e963f50fc74041b5e9e744c330dca48e04f08d (diff)
arm64: hide __efistub_ aliases from kallsyms
Commit e8f3010f7326 ("arm64/efi: isolate EFI stub from the kernel proper") isolated the EFI stub code from the kernel proper by prefixing all of its symbols with __efistub_, and selectively allowing access to core kernel symbols from the stub by emitting __efistub_ aliases for functions and variables that the stub can access legally. As an unintended side effect, these aliases are emitted into the kallsyms symbol table, which means they may turn up in backtraces, e.g., ... PC is at __efistub_memset+0x108/0x200 LR is at fixup_init+0x3c/0x48 ... [<ffffff8008328608>] __efistub_memset+0x108/0x200 [<ffffff8008094dcc>] free_initmem+0x2c/0x40 [<ffffff8008645198>] kernel_init+0x20/0xe0 [<ffffff8008085cd0>] ret_from_fork+0x10/0x40 The backtrace in question has nothing to do with the EFI stub, but simply returns one of the several aliases of memset() that have been recorded in the kallsyms table. This is undesirable, since it may suggest to people who are not aware of this that the issue they are seeing is somehow EFI related. So hide the __efistub_ aliases from kallsyms, by emitting them as absolute linker symbols explicitly. The distinction between those and section relative symbols is completely irrelevant to these definitions, and to the final link we are performing when these definitions are being taken into account (the distinction is only relevant to symbols defined inside a section definition when performing a partial link), and so the resulting values are identical to the original ones. Since absolute symbols are ignored by kallsyms, this will result in these values to be omitted from its symbol table. After this patch, the backtrace generated from the same address looks like this: ... PC is at __memset+0x108/0x200 LR is at fixup_init+0x3c/0x48 ... [<ffffff8008328608>] __memset+0x108/0x200 [<ffffff8008094dcc>] free_initmem+0x2c/0x40 [<ffffff8008645198>] kernel_init+0x20/0xe0 [<ffffff8008085cd0>] ret_from_fork+0x10/0x40 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel/image.h')
-rw-r--r--arch/arm64/kernel/image.h40
1 files changed, 25 insertions, 15 deletions
diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h
index bc2abb8b1599..999633bd7294 100644
--- a/arch/arm64/kernel/image.h
+++ b/arch/arm64/kernel/image.h
@@ -65,6 +65,16 @@
65#ifdef CONFIG_EFI 65#ifdef CONFIG_EFI
66 66
67/* 67/*
68 * Prevent the symbol aliases below from being emitted into the kallsyms
69 * table, by forcing them to be absolute symbols (which are conveniently
70 * ignored by scripts/kallsyms) rather than section relative symbols.
71 * The distinction is only relevant for partial linking, and only for symbols
72 * that are defined within a section declaration (which is not the case for
73 * the definitions below) so the resulting values will be identical.
74 */
75#define KALLSYMS_HIDE(sym) ABSOLUTE(sym)
76
77/*
68 * The EFI stub has its own symbol namespace prefixed by __efistub_, to 78 * The EFI stub has its own symbol namespace prefixed by __efistub_, to
69 * isolate it from the kernel proper. The following symbols are legally 79 * isolate it from the kernel proper. The following symbols are legally
70 * accessed by the stub, so provide some aliases to make them accessible. 80 * accessed by the stub, so provide some aliases to make them accessible.
@@ -73,25 +83,25 @@
73 * linked at. The routines below are all implemented in assembler in a 83 * linked at. The routines below are all implemented in assembler in a
74 * position independent manner 84 * position independent manner
75 */ 85 */
76__efistub_memcmp = __pi_memcmp; 86__efistub_memcmp = KALLSYMS_HIDE(__pi_memcmp);
77__efistub_memchr = __pi_memchr; 87__efistub_memchr = KALLSYMS_HIDE(__pi_memchr);
78__efistub_memcpy = __pi_memcpy; 88__efistub_memcpy = KALLSYMS_HIDE(__pi_memcpy);
79__efistub_memmove = __pi_memmove; 89__efistub_memmove = KALLSYMS_HIDE(__pi_memmove);
80__efistub_memset = __pi_memset; 90__efistub_memset = KALLSYMS_HIDE(__pi_memset);
81__efistub_strlen = __pi_strlen; 91__efistub_strlen = KALLSYMS_HIDE(__pi_strlen);
82__efistub_strcmp = __pi_strcmp; 92__efistub_strcmp = KALLSYMS_HIDE(__pi_strcmp);
83__efistub_strncmp = __pi_strncmp; 93__efistub_strncmp = KALLSYMS_HIDE(__pi_strncmp);
84__efistub___flush_dcache_area = __pi___flush_dcache_area; 94__efistub___flush_dcache_area = KALLSYMS_HIDE(__pi___flush_dcache_area);
85 95
86#ifdef CONFIG_KASAN 96#ifdef CONFIG_KASAN
87__efistub___memcpy = __pi_memcpy; 97__efistub___memcpy = KALLSYMS_HIDE(__pi_memcpy);
88__efistub___memmove = __pi_memmove; 98__efistub___memmove = KALLSYMS_HIDE(__pi_memmove);
89__efistub___memset = __pi_memset; 99__efistub___memset = KALLSYMS_HIDE(__pi_memset);
90#endif 100#endif
91 101
92__efistub__text = _text; 102__efistub__text = KALLSYMS_HIDE(_text);
93__efistub__end = _end; 103__efistub__end = KALLSYMS_HIDE(_end);
94__efistub__edata = _edata; 104__efistub__edata = KALLSYMS_HIDE(_edata);
95 105
96#endif 106#endif
97 107