stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Marc Zyngier <maz@kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.14 22/36] kallsyms: Don't let kallsyms_lookup_size_offset() fail on retrieving the first symbol
Date: Wed,  4 Sep 2019 12:01:08 -0400	[thread overview]
Message-ID: <20190904160122.4179-22-sashal@kernel.org> (raw)
In-Reply-To: <20190904160122.4179-1-sashal@kernel.org>

From: Marc Zyngier <maz@kernel.org>

[ Upstream commit 2a1a3fa0f29270583f0e6e3100d609e09697add1 ]

An arm64 kernel configured with

  CONFIG_KPROBES=y
  CONFIG_KALLSYMS=y
  # CONFIG_KALLSYMS_ALL is not set
  CONFIG_KALLSYMS_BASE_RELATIVE=y

reports the following kprobe failure:

  [    0.032677] kprobes: failed to populate blacklist: -22
  [    0.033376] Please take care of using kprobes.

It appears that kprobe fails to retrieve the symbol at address
0xffff000010081000, despite this symbol being in System.map:

  ffff000010081000 T __exception_text_start

This symbol is part of the first group of aliases in the
kallsyms_offsets array (symbol names generated using ugly hacks in
scripts/kallsyms.c):

  kallsyms_offsets:
          .long   0x1000 // do_undefinstr
          .long   0x1000 // efi_header_end
          .long   0x1000 // _stext
          .long   0x1000 // __exception_text_start
          .long   0x12b0 // do_cp15instr

Looking at the implementation of get_symbol_pos(), it returns the
lowest index for aliasing symbols. In this case, it return 0.

But kallsyms_lookup_size_offset() considers 0 as a failure, which
is obviously wrong (there is definitely a valid symbol living there).
In turn, the kprobe blacklisting stops abruptly, hence the original
error.

A CONFIG_KALLSYMS_ALL kernel wouldn't fail as there is always
some random symbols at the beginning of this array, which are never
looked up via kallsyms_lookup_size_offset.

Fix it by considering that get_symbol_pos() is always successful
(which is consistent with the other uses of this function).

Fixes: ffc5089196446 ("[PATCH] Create kallsyms_lookup_size_offset()")
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/kallsyms.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 127e7cfafa552..3e1b66366ac23 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -296,8 +296,10 @@ int kallsyms_lookup_size_offset(unsigned long addr, unsigned long *symbolsize,
 {
 	char namebuf[KSYM_NAME_LEN];
 
-	if (is_ksym_addr(addr))
-		return !!get_symbol_pos(addr, symbolsize, offset);
+	if (is_ksym_addr(addr)) {
+		get_symbol_pos(addr, symbolsize, offset);
+		return 1;
+	}
 	return !!module_address_lookup(addr, symbolsize, offset, NULL, namebuf) ||
 	       !!__bpf_address_lookup(addr, symbolsize, offset, namebuf);
 }
-- 
2.20.1


  parent reply	other threads:[~2019-09-04 16:07 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 16:00 [PATCH AUTOSEL 4.14 01/36] ARM: OMAP2+: Fix missing SYSC_HAS_RESET_STATUS for dra7 epwmss Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 02/36] s390/bpf: fix lcgr instruction encoding Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 03/36] ARM: OMAP2+: Fix omap4 errata warning on other SoCs Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 04/36] ARM: dts: dra74x: Fix iodelay configuration for mmc3 Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 05/36] s390/bpf: use 32-bit index for tail calls Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 06/36] batman-adv: fix uninit-value in batadv_netlink_get_ifindex() Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 07/36] fpga: altera-ps-spi: Fix getting of optional confd gpio Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 08/36] netfilter: xt_nfacct: Fix alignment mismatch in xt_nfacct_match_info Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 09/36] NFSv4: Fix return values for nfs4_file_open() Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 10/36] NFSv4: Fix return value in nfs_finish_open() Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 11/36] NFS: Fix initialisation of I/O result struct in nfs_pgio_rpcsetup Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 12/36] Kconfig: Fix the reference to the IDT77105 Phy driver in the description of ATM_NICSTAR_USE_IDT77105 Sasha Levin
2019-09-04 16:00 ` [PATCH AUTOSEL 4.14 13/36] qed: Add cleanup in qed_slowpath_start() Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 14/36] ARM: 8874/1: mm: only adjust sections of valid mm structures Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 15/36] batman-adv: Only read OGM tvlv_len after buffer len check Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 16/36] batman-adv: Only read OGM2 " Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 17/36] r8152: Set memory to all 0xFFs on failed reg reads Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 18/36] x86/apic: Fix arch_dynirq_lower_bound() bug for DT enabled machines Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 19/36] netfilter: nf_conntrack_ftp: Fix debug output Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 20/36] NFSv2: Fix eof handling Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 21/36] NFSv2: Fix write regression Sasha Levin
2019-09-04 16:01 ` Sasha Levin [this message]
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 23/36] cifs: set domainName when a domain-key is used in multiuser Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 24/36] cifs: Use kzfree() to zero out the password Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 25/36] x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 26/36] ARM: 8901/1: add a criteria for pfn_valid of arm Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 27/36] sky2: Disable MSI on yet another ASUS boards (P6Xxxx) Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 28/36] i2c: designware: Synchronize IRQs when unregistering slave client Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 29/36] perf/x86/intel: Restrict period on Nehalem Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 30/36] perf/x86/amd/ibs: Fix sample bias for dispatched micro-ops Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 31/36] amd-xgbe: Fix error path in xgbe_mod_init() Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 32/36] net: stmmac: dwmac-rk: Don't fail if phy regulator is absent Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 33/36] tools/power x86_energy_perf_policy: Fix "uninitialized variable" warnings at -O2 Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 34/36] tools/power x86_energy_perf_policy: Fix argument parsing Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 35/36] tools/power turbostat: fix buffer overrun Sasha Levin
2019-09-04 16:01 ` [PATCH AUTOSEL 4.14 36/36] net: seeq: Fix the function used to release some memory in an error handling path Sasha Levin

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=20190904160122.4179-22-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=acme@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=will@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).