From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Miroslav Benes <mbenes@suse.cz>,
Rusty Russell <rusty@rustcorp.com.au>,
Jiri Kosina <jkosina@suse.cz>
Subject: [PATCH 4.4 19/22] module: keep percpu symbols in modules symtab
Date: Mon, 8 Jan 2018 13:59:46 +0100 [thread overview]
Message-ID: <20180108125926.415702207@linuxfoundation.org> (raw)
In-Reply-To: <20180108125925.601688333@linuxfoundation.org>
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miroslav Benes <mbenes@suse.cz>
commit e0224418516b4d8a6c2160574bac18447c354ef0 upstream.
Currently, percpu symbols from .data..percpu ELF section of a module are
not copied over and stored in final symtab array of struct module.
Consequently such symbol cannot be returned via kallsyms API (for
example kallsyms_lookup_name). This can be especially confusing when the
percpu symbol is exported. Only its __ksymtab et al. are present in its
symtab.
The culprit is in layout_and_allocate() function where SHF_ALLOC flag is
dropped for .data..percpu section. There is in fact no need to copy the
section to final struct module, because kernel module loader allocates
extra percpu section by itself. Unfortunately only symbols from
SHF_ALLOC sections are copied due to a check in is_core_symbol().
The patch changes is_core_symbol() function to copy over also percpu
symbols (their st_shndx points to .data..percpu ELF section). We do it
only if CONFIG_KALLSYMS_ALL is set to be consistent with the rest of the
function (ELF section is SHF_ALLOC but !SHF_EXECINSTR). Finally
elf_type() returns type 'a' for a percpu symbol because its address is
absolute.
Signed-off-by: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/module.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2404,7 +2404,7 @@ static char elf_type(const Elf_Sym *sym,
}
if (sym->st_shndx == SHN_UNDEF)
return 'U';
- if (sym->st_shndx == SHN_ABS)
+ if (sym->st_shndx == SHN_ABS || sym->st_shndx == info->index.pcpu)
return 'a';
if (sym->st_shndx >= SHN_LORESERVE)
return '?';
@@ -2433,7 +2433,7 @@ static char elf_type(const Elf_Sym *sym,
}
static bool is_core_symbol(const Elf_Sym *src, const Elf_Shdr *sechdrs,
- unsigned int shnum)
+ unsigned int shnum, unsigned int pcpundx)
{
const Elf_Shdr *sec;
@@ -2442,6 +2442,11 @@ static bool is_core_symbol(const Elf_Sym
|| !src->st_name)
return false;
+#ifdef CONFIG_KALLSYMS_ALL
+ if (src->st_shndx == pcpundx)
+ return true;
+#endif
+
sec = sechdrs + src->st_shndx;
if (!(sec->sh_flags & SHF_ALLOC)
#ifndef CONFIG_KALLSYMS_ALL
@@ -2479,7 +2484,8 @@ static void layout_symtab(struct module
/* Compute total space required for the core symbols' strtab. */
for (ndst = i = 0; i < nsrc; i++) {
if (i == 0 ||
- is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
+ is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
+ info->index.pcpu)) {
strtab_size += strlen(&info->strtab[src[i].st_name])+1;
ndst++;
}
@@ -2537,7 +2543,8 @@ static void add_kallsyms(struct module *
src = mod->kallsyms->symtab;
for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) {
if (i == 0 ||
- is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
+ is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
+ info->index.pcpu)) {
dst[ndst] = src[i];
dst[ndst++].st_name = s - mod->core_kallsyms.strtab;
s += strlcpy(s, &mod->kallsyms->strtab[src[i].st_name],
next prev parent reply other threads:[~2018-01-08 12:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-08 12:59 [PATCH 4.4 00/22] 4.4.111-stable review Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 01/22] x86/kasan: Write protect kasan zero shadow Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 02/22] kernel/acct.c: fix the acct->needcheck check in check_free_space() Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 03/22] crypto: n2 - cure use after free Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 04/22] crypto: chacha20poly1305 - validate the digest size Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 05/22] crypto: pcrypt - fix freeing pcrypt instances Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 07/22] fscache: Fix the default for fscache_maybe_release_page() Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 08/22] kernel: make groups_sort calling a responsibility group_info allocators Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 09/22] kernel/signal.c: protect the traced SIGNAL_UNKILLABLE tasks from SIGKILL Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 10/22] kernel/signal.c: protect the SIGNAL_UNKILLABLE tasks from !sig_kernel_only() signals Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 11/22] kernel/signal.c: remove the no longer needed SIGNAL_UNKILLABLE check in complete_signal() Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 12/22] ARC: uaccess: dont use "l" gcc inline asm constraint modifier Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 13/22] Input: elantech - add new icbody type 15 Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 14/22] x86/microcode/AMD: Add support for fam17h microcode loading Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 15/22] parisc: Fix alignment of pa_tlb_lock in assembly on 32-bit SMP kernel Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 17/22] x86/tlb: Drop the _GPL from the cpu_tlbstate export Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 18/22] genksyms: Handle string literals with spaces in reference files Greg Kroah-Hartman
2018-01-08 12:59 ` Greg Kroah-Hartman [this message]
2018-01-08 12:59 ` [PATCH 4.4 20/22] module: Issue warnings when tainting kernel Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 21/22] proc: much faster /proc/vmstat Greg Kroah-Hartman
2018-01-08 12:59 ` [PATCH 4.4 22/22] Map the vsyscall page with _PAGE_USER Greg Kroah-Hartman
2018-01-08 14:25 ` [PATCH 4.4 00/22] 4.4.111-stable review Nathan Chancellor
2018-01-08 16:32 ` Greg Kroah-Hartman
2018-01-08 15:21 ` 王金浦
2018-01-08 16:32 ` Greg Kroah-Hartman
2018-01-08 17:29 ` Christoph Biedl
2018-01-08 17:44 ` Borislav Petkov
2018-01-08 21:00 ` Shuah Khan
2018-01-08 23:29 ` Guenter Roeck
2018-01-09 9:13 ` Greg Kroah-Hartman
2018-01-09 9:23 ` Greg Kroah-Hartman
2018-01-09 13:50 ` Guenter Roeck
2018-01-09 9:51 ` Naresh Kamboju
2018-01-09 10:50 ` Greg Kroah-Hartman
2018-01-09 16:16 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180108125926.415702207@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=rusty@rustcorp.com.au \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).