* [acme@kernel.org: [PATCH 3/3] perf tools: Fix copying of /proc/kcore]
@ 2015-09-25 15:30 Arnaldo Carvalho de Melo
2015-10-13 20:13 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-09-25 15:30 UTC (permalink / raw)
To: stable
Sorry, forgot the "vger.", but I guess it would be nice to have a
forwarder from stable@kernel.org to stable@vger.kernel.org :-)
- Arnaldo
----- Forwarded message from Arnaldo Carvalho de Melo <acme@kernel.org> -----
Date: Fri, 25 Sep 2015 12:28:38 -0300
From: Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: [PATCH 3/3] perf tools: Fix copying of /proc/kcore
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Adrian Hunter <adrian.hunter@intel.com>, Jiri Olsa <jolsa@redhat.com>, stable@kernel.org, Arnaldo Carvalho de Melo
<acme@redhat.com>
From: Adrian Hunter <adrian.hunter@intel.com>
A copy of /proc/kcore containing the kernel text can be made to the
buildid cache. e.g.
perf buildid-cache -v -k /proc/kcore
To workaround objdump limitations, a copy is also made when annotating
against /proc/kcore.
The copying process stops working from libelf about v1.62 onwards (the
problem was found with v1.63).
The cause is that a call to gelf_getphdr() in kcore__add_phdr() fails
because additional validation has been added to gelf_getphdr().
The use of gelf_getphdr() is a misguided attempt to get default
initialization of the Gelf_Phdr structure. That should not be
necessary because every member of the Gelf_Phdr structure is
subsequently assigned. So just remove the call to gelf_getphdr().
Similarly, a call to gelf_getehdr() in gelf_kcore__init() can be
removed also.
Committer notes:
Note to stable@kernel.org, from Adrian in the cover letter for this
patchkit:
The "Fix copying of /proc/kcore" problem goes back to v3.13 if you think
it is important enough for stable.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@kernel.org
Link: http://lkml.kernel.org/r/1443089122-19082-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/symbol-elf.c | 35 +++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index f78ea3dc4c08..475d88d0a1c9 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1271,8 +1271,6 @@ out_close:
static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
bool temp)
{
- GElf_Ehdr *ehdr;
-
kcore->elfclass = elfclass;
if (temp)
@@ -1289,9 +1287,7 @@ static int kcore__init(struct kcore *kcore, char *filename, int elfclass,
if (!gelf_newehdr(kcore->elf, elfclass))
goto out_end;
- ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
- if (!ehdr)
- goto out_end;
+ memset(&kcore->ehdr, 0, sizeof(GElf_Ehdr));
return 0;
@@ -1348,23 +1344,18 @@ static int kcore__copy_hdr(struct kcore *from, struct kcore *to, size_t count)
static int kcore__add_phdr(struct kcore *kcore, int idx, off_t offset,
u64 addr, u64 len)
{
- GElf_Phdr gphdr;
- GElf_Phdr *phdr;
-
- phdr = gelf_getphdr(kcore->elf, idx, &gphdr);
- if (!phdr)
- return -1;
-
- phdr->p_type = PT_LOAD;
- phdr->p_flags = PF_R | PF_W | PF_X;
- phdr->p_offset = offset;
- phdr->p_vaddr = addr;
- phdr->p_paddr = 0;
- phdr->p_filesz = len;
- phdr->p_memsz = len;
- phdr->p_align = page_size;
-
- if (!gelf_update_phdr(kcore->elf, idx, phdr))
+ GElf_Phdr phdr = {
+ .p_type = PT_LOAD,
+ .p_flags = PF_R | PF_W | PF_X,
+ .p_offset = offset,
+ .p_vaddr = addr,
+ .p_paddr = 0,
+ .p_filesz = len,
+ .p_memsz = len,
+ .p_align = page_size,
+ };
+
+ if (!gelf_update_phdr(kcore->elf, idx, &phdr))
return -1;
return 0;
--
2.1.0
----- End forwarded message -----
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [acme@kernel.org: [PATCH 3/3] perf tools: Fix copying of /proc/kcore]
2015-09-25 15:30 [acme@kernel.org: [PATCH 3/3] perf tools: Fix copying of /proc/kcore] Arnaldo Carvalho de Melo
@ 2015-10-13 20:13 ` Greg KH
2015-10-14 3:11 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2015-10-13 20:13 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: stable
On Fri, Sep 25, 2015 at 12:30:43PM -0300, Arnaldo Carvalho de Melo wrote:
> Sorry, forgot the "vger.", but I guess it would be nice to have a
> forwarder from stable@kernel.org to stable@vger.kernel.org :-)
My scripts know to pick up both of these, thanks, I got it now.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [acme@kernel.org: [PATCH 3/3] perf tools: Fix copying of /proc/kcore]
2015-10-13 20:13 ` Greg KH
@ 2015-10-14 3:11 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-10-14 3:11 UTC (permalink / raw)
To: Greg KH; +Cc: stable
Em Tue, Oct 13, 2015 at 01:13:21PM -0700, Greg KH escreveu:
> On Fri, Sep 25, 2015 at 12:30:43PM -0300, Arnaldo Carvalho de Melo wrote:
> > Sorry, forgot the "vger.", but I guess it would be nice to have a
> > forwarder from stable@kernel.org to stable@vger.kernel.org :-)
>
> My scripts know to pick up both of these, thanks, I got it now.
Great,
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-14 3:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-25 15:30 [acme@kernel.org: [PATCH 3/3] perf tools: Fix copying of /proc/kcore] Arnaldo Carvalho de Melo
2015-10-13 20:13 ` Greg KH
2015-10-14 3:11 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.