From: Ming Lei <tom.leiming@gmail.com> Date: 2013-10-28 15:49:26
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
Cc: Russell King <redacted>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Michal Marek <redacted>
Acked-by: Rusty Russell <redacted>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
scripts/kallsyms.c | 12 +++++++++++-
scripts/link-vmlinux.sh | 2 ++
2 files changed, 13 insertions(+), 1 deletion(-)
From: Andrew Morton <akpm@linux-foundation.org> Date: 2013-10-31 22:43:14
On Mon, 28 Oct 2013 23:48:59 +0800 Ming Lei [off-list ref] wrote:
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
This is a non-back-compatible change and I'd like to see a much
stronger assurance that it is safe to merge and will not break any
existing application on the planet, please.
For a start, please describe with great precision what these excluded
symbols are (examples would help) and explain why no application will
conceivably have had any use for them.
From: Russell King - ARM Linux <hidden> Date: 2013-10-31 22:50:34
On Thu, Oct 31, 2013 at 03:43:11PM -0700, Andrew Morton wrote:
On Mon, 28 Oct 2013 23:48:59 +0800 Ming Lei [off-list ref] wrote:
quoted
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
This is a non-back-compatible change and I'd like to see a much
stronger assurance that it is safe to merge and will not break any
existing application on the planet, please.
For a start, please describe with great precision what these excluded
symbols are (examples would help) and explain why no application will
conceivably have had any use for them.
These symbols are used to build what is relocatable code; the code which
ends up being placed in the machine vectors and the following page.
Rather than have to manually calculate them, I merged a patch which used
the tools we have, namely the assembler and linker, to do the job for us.
Unfortunately, these symbols have ended up in kallsyms, which various
programs read, and having symbols down at the lower 8k is not what they
expect.
What it means is we don't have to play these kinds of games in the
assembler:
- .equ stubs_offset, __vectors_start + 0x1000 - __stubs_start
__vectors_start:
- W(b) vector_rst + stubs_offset
- W(b) vector_und + stubs_offset
- W(ldr) pc, .LCvswi + stubs_offset
- W(b) vector_pabt + stubs_offset
- W(b) vector_dabt + stubs_offset
- W(b) vector_addrexcptn + stubs_offset
- W(b) vector_irq + stubs_offset
- W(b) vector_fiq + stubs_offset
where each vector_* symbol is located at an address greater than
__stubs_start. Here's the obvious question: can you understand what's
going on with all that?
From: Andrew Morton <akpm@linux-foundation.org> Date: 2013-10-31 22:58:33
On Thu, 31 Oct 2013 22:50:22 +0000 Russell King - ARM Linux [off-list ref] wrote:
On Thu, Oct 31, 2013 at 03:43:11PM -0700, Andrew Morton wrote:
quoted
On Mon, 28 Oct 2013 23:48:59 +0800 Ming Lei [off-list ref] wrote:
quoted
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
This is a non-back-compatible change and I'd like to see a much
stronger assurance that it is safe to merge and will not break any
existing application on the planet, please.
For a start, please describe with great precision what these excluded
symbols are (examples would help) and explain why no application will
conceivably have had any use for them.
These symbols are used to build what is relocatable code; the code which
ends up being placed in the machine vectors and the following page.
Rather than have to manually calculate them, I merged a patch which used
the tools we have, namely the assembler and linker, to do the job for us.
OK. Do you recall which patch that was? And is it the case that this
patch excludes only the symbols which that patch accidentally added?
Unfortunately, these symbols have ended up in kallsyms, which various
programs read, and having symbols down at the lower 8k is not what they
expect.
What it means is we don't have to play these kinds of games in the
assembler:
- .equ stubs_offset, __vectors_start + 0x1000 - __stubs_start
__vectors_start:
- W(b) vector_rst + stubs_offset
- W(b) vector_und + stubs_offset
- W(ldr) pc, .LCvswi + stubs_offset
- W(b) vector_pabt + stubs_offset
- W(b) vector_dabt + stubs_offset
- W(b) vector_addrexcptn + stubs_offset
- W(b) vector_irq + stubs_offset
- W(b) vector_fiq + stubs_offset
where each vector_* symbol is located at an address greater than
__stubs_start. Here's the obvious question: can you understand what's
going on with all that?
From: Russell King - ARM Linux <hidden> Date: 2013-10-31 23:53:43
On Thu, Oct 31, 2013 at 03:58:31PM -0700, Andrew Morton wrote:
On Thu, 31 Oct 2013 22:50:22 +0000 Russell King - ARM Linux [off-list ref] wrote:
quoted
On Thu, Oct 31, 2013 at 03:43:11PM -0700, Andrew Morton wrote:
quoted
On Mon, 28 Oct 2013 23:48:59 +0800 Ming Lei [off-list ref] wrote:
quoted
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
This is a non-back-compatible change and I'd like to see a much
stronger assurance that it is safe to merge and will not break any
existing application on the planet, please.
For a start, please describe with great precision what these excluded
symbols are (examples would help) and explain why no application will
conceivably have had any use for them.
These symbols are used to build what is relocatable code; the code which
ends up being placed in the machine vectors and the following page.
Rather than have to manually calculate them, I merged a patch which used
the tools we have, namely the assembler and linker, to do the job for us.
OK. Do you recall which patch that was? And is it the case that this
patch excludes only the symbols which that patch accidentally added?
It's not a case of "accidentally added" - as we include all symbols in
kallsyms which are marked as text/data etc, irrespective of whether they
are local or global.
b9b32bf70f2fb made the change, backported to stable trees. e39e3f3ebfef
depended on that change so that it could get at the correct offset to
copy FIQ code.
Both commits are part of closing an information leak from the kernel
as part of a security report back in July.
From: Ming Lei <tom.leiming@gmail.com> Date: 2013-11-01 02:10:40
Hi Andrew,
Thanks for your comment.
On Fri, Nov 1, 2013 at 6:43 AM, Andrew Morton [off-list ref] wrote:
For a start, please describe with great precision what these excluded
symbols are (examples would help) and explain why no application will
conceivably have had any use for them.
Looks Russell has given the example symbols already, and all these
symbols should be only for generating code, and they won't be run by
kernel since kernel can't run code which isn't in kernel virtual address
space, so there is no reason for application to use these symbols.
Actually, there is already report on the problem, see below link:
http://www.gossamer-threads.com/lists/linux/kernel/1808193?page=last
OK. Do you recall which patch that was? And is it the case that this
patch excludes only the symbols which that patch accidentally added?
This patch excludes all kernel symbols(non-module symbols) which
aren't in kernel virtual address space, I think it is reasonable and correct.
Thanks,
--
Ming Lei
From: Rusty Russell <hidden> Date: 2013-11-01 02:36:58
From: Ming Lei <tom.leiming@gmail.com>
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which may be
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, this patch fixes the
problem (introduced b9b32bf70f2fb710b07c94e13afbc729afe221da)
Cc: Russell King <redacted>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Michal Marek <redacted>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Rusty Russell <redacted>
Cc: stable at kernel.org
---
Stephen, please run this on todays' linux-next, so I can push to Linus
asap. Thanks...
scripts/kallsyms.c | 12 +++++++++++-
scripts/link-vmlinux.sh | 2 ++
2 files changed, 13 insertions(+), 1 deletion(-)
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
Cc: Russell King <redacted>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Michal Marek <redacted>
Acked-by: Rusty Russell <redacted>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Sorry for the late report, but I seem to have encountered a problem with this
patch, now that it has made it into all stable kernels.
When linking an ARM nommu kernel, I get the output "No valid symbol." twice,
from scripts/kallsyms. The problem evidently is that PAGE_OFFSET is still
set to 0xC0000000 on ARM NOMMU builds but the kernel is linked to start at
PLAT_PHYS_OFFSET instead, which may be elsehwere. For most platforms,
this is defined in Kconfig these days, so we could get away with
but there are still a few ARM platforms that define their own PLAT_PHYS_OFFSET
in memory.h, and it wouldn't help on non-ARM systems that might have the same
problem.
Arnd
From: Ming Lei <tom.leiming@gmail.com> Date: 2014-01-07 14:33:46
Hi Arnd,
On Tue, Jan 7, 2014 at 10:12 PM, Arnd Bergmann [off-list ref] wrote:
quoted hunk
On Monday 28 October 2013, Ming Lei wrote:
quoted
This patch uses CONFIG_PAGE_OFFSET to filter symbols which
are not in kernel address space because these symbols are
generally for generating code purpose and can't be run at
kernel mode, so we needn't keep them in /proc/kallsyms.
For example, on ARM there are some symbols which are
linked in relocatable code section, then perf can't parse
symbols any more from /proc/kallsyms, and this patch fixes
the problem.
Cc: Russell King <redacted>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Michal Marek <redacted>
Acked-by: Rusty Russell <redacted>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Sorry for the late report, but I seem to have encountered a problem with this
patch, now that it has made it into all stable kernels.
When linking an ARM nommu kernel, I get the output "No valid symbol." twice,
from scripts/kallsyms. The problem evidently is that PAGE_OFFSET is still
set to 0xC0000000 on ARM NOMMU builds but the kernel is linked to start at
PLAT_PHYS_OFFSET instead, which may be elsehwere. For most platforms,
this is defined in Kconfig these days, so we could get away with
but there are still a few ARM platforms that define their own PLAT_PHYS_OFFSET
in memory.h, and it wouldn't help on non-ARM systems that might have the same
problem.
The patch "scripts/link-vmlinux.sh: only filter kernel symbols for arm"
has made it in now, which is good for all other architectures, but it
makes no difference for nommu-arm, because CONFIG_PAGE_OFFSET is
still set.
The second patch from Jonathan Austin has not been applied yet, as of
today's linux-next, and it's exactly what I suggested. However it
won't work on ARM platforms that define their own PLAT_PHYS_OFFSET:
ebsa110, ep93xx, exynos, footbridge, integrator, iop13xx, ks8695,
omap1, realview, rpc, s5pv210 and sa1100. Fortunately these all have
MMUs, so in practice it won't hurt, but it doesn't seem correct.
Arnd