All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf, tool: Fix perf stack to non executable on x86_64
@ 2012-02-01 12:54 Jiri Olsa
  2012-02-03  9:50 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiri Olsa @ 2012-02-01 12:54 UTC (permalink / raw)
  To: acme, a.p.zijlstra, mingo, paulus, cjashfor; +Cc: linux-kernel, Jiri Olsa

By adding following objects:
  bench/mem-memset-x86-64-asm.o
  bench/mem-memcpy-x86-64-asm.o
the x86_64 perf binary ended up with executable stack.

The reason was that above objects are assembler sourced and
are missing the GNU-stack note section. In such case the linker
assumes that the final binary should not be restricted at all
and mark the stack as RWX.

Adding section ".note.GNU-stack" definition to mentioned objects,
with all flags disabled, thus omiting those objects from linker
stack flags decision.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/bench/mem-memcpy-x86-64-asm.S |    7 +++++++
 tools/perf/bench/mem-memset-x86-64-asm.S |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index a20780b..a6c8909 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -4,3 +4,10 @@
 #define Lmemcpy_c globl memcpy_c; memcpy_c
 #define Lmemcpy_c_e globl memcpy_c_e; memcpy_c_e
 #include "../../../arch/x86/lib/memcpy_64.S"
+
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits
diff --git a/tools/perf/bench/mem-memset-x86-64-asm.S b/tools/perf/bench/mem-memset-x86-64-asm.S
index cb92170..9e5af89 100644
--- a/tools/perf/bench/mem-memset-x86-64-asm.S
+++ b/tools/perf/bench/mem-memset-x86-64-asm.S
@@ -4,3 +4,10 @@
 #define Lmemset_c globl memset_c; memset_c
 #define Lmemset_c_e globl memset_c_e; memset_c_e
 #include "../../../arch/x86/lib/memset_64.S"
+
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf, tool: Fix perf stack to non executable on x86_64
  2012-02-01 12:54 [PATCH] perf, tool: Fix perf stack to non executable on x86_64 Jiri Olsa
@ 2012-02-03  9:50 ` Eric Dumazet
  2012-02-07 19:34 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
  2012-02-07 19:37 ` [tip:perf/core] perf tool: " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2012-02-03  9:50 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: acme, a.p.zijlstra, mingo, paulus, cjashfor, linux-kernel

Le mercredi 01 février 2012 à 13:54 +0100, Jiri Olsa a écrit :
> By adding following objects:
>   bench/mem-memset-x86-64-asm.o
>   bench/mem-memcpy-x86-64-asm.o
> the x86_64 perf binary ended up with executable stack.
> 
> The reason was that above objects are assembler sourced and
> are missing the GNU-stack note section. In such case the linker
> assumes that the final binary should not be restricted at all
> and mark the stack as RWX.
> 
> Adding section ".note.GNU-stack" definition to mentioned objects,
> with all flags disabled, thus omiting those objects from linker
> stack flags decision.
> 
> Signed-off-by: Jiri Olsa <jolsa@redhat.com>
> ---

Good catch, thanks !

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf tools: Fix perf stack to non executable on x86_64
  2012-02-01 12:54 [PATCH] perf, tool: Fix perf stack to non executable on x86_64 Jiri Olsa
  2012-02-03  9:50 ` Eric Dumazet
@ 2012-02-07 19:34 ` tip-bot for Jiri Olsa
  2012-02-07 19:37 ` [tip:perf/core] perf tool: " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2012-02-07 19:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, eric.dumazet,
	a.p.zijlstra, williams, jolsa, tglx, cjashfor, mingo

Commit-ID:  7a0153ee15575a4d07b5da8c96b79e0b0fd41a12
Gitweb:     http://git.kernel.org/tip/7a0153ee15575a4d07b5da8c96b79e0b0fd41a12
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Mon, 6 Feb 2012 18:54:06 -0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 6 Feb 2012 18:54:06 -0200

perf tools: Fix perf stack to non executable on x86_64

By adding following objects:
  bench/mem-memcpy-x86-64-asm.o
the x86_64 perf binary ended up with executable stack.

The reason was that above object are assembler sourced and is missing the
GNU-stack note section. In such case the linker assumes that the final binary
should not be restricted at all and mark the stack as RWX.

Adding section ".note.GNU-stack" definition to mentioned object, with all
flags disabled, thus omiting this object from linker stack flags decision.

Problem introduced in:

  $ git describe ea7872b
  v2.6.37-rc2-19-gea7872b

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=783570
Reported-by: Clark Williams <williams@redhat.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: stable@kernel.org
Link: http://lkml.kernel.org/r/1328100848-5630-1-git-send-email-jolsa@redhat.com
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
[ committer note: Backported fix to perf/urgent (3.3-rc2+) ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bench/mem-memcpy-x86-64-asm.S |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index a57b66e..185a96d 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -1,2 +1,8 @@
 
 #include "../../../arch/x86/lib/memcpy_64.S"
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf tool: Fix perf stack to non executable on x86_64
  2012-02-01 12:54 [PATCH] perf, tool: Fix perf stack to non executable on x86_64 Jiri Olsa
  2012-02-03  9:50 ` Eric Dumazet
  2012-02-07 19:34 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
@ 2012-02-07 19:37 ` tip-bot for Jiri Olsa
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Jiri Olsa @ 2012-02-07 19:37 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, eric.dumazet,
	a.p.zijlstra, williams, jolsa, tglx, cjashfor, mingo

Commit-ID:  e89cef136a8b56eef1acf702591fd3039fc3385d
Gitweb:     http://git.kernel.org/tip/e89cef136a8b56eef1acf702591fd3039fc3385d
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Wed, 1 Feb 2012 13:54:08 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 6 Feb 2012 19:14:17 -0200

perf tool: Fix perf stack to non executable on x86_64

By adding following objects:
  bench/mem-memset-x86-64-asm.o
  bench/mem-memcpy-x86-64-asm.o
the x86_64 perf binary ended up with executable stack.

The reason was that above objects are assembler sourced and are missing the
GNU-stack note section. In such case the linker assumes that the final binary
should not be restricted at all and mark the stack as RWX.

Adding section ".note.GNU-stack" definition to mentioned objects, with all
flags disabled, thus omiting those objects from linker stack flags decision.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=783570
Reported-by: Clark Williams <williams@redhat.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328100848-5630-1-git-send-email-jolsa@redhat.com
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
[ committer note: Remaining bits after what was already added to perf/urgent ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/bench/mem-memset-x86-64-asm.S |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/tools/perf/bench/mem-memset-x86-64-asm.S b/tools/perf/bench/mem-memset-x86-64-asm.S
index cb92170..9e5af89 100644
--- a/tools/perf/bench/mem-memset-x86-64-asm.S
+++ b/tools/perf/bench/mem-memset-x86-64-asm.S
@@ -4,3 +4,10 @@
 #define Lmemset_c globl memset_c; memset_c
 #define Lmemset_c_e globl memset_c_e; memset_c_e
 #include "../../../arch/x86/lib/memset_64.S"
+
+/*
+ * We need to provide note.GNU-stack section, saying that we want
+ * NOT executable stack. Otherwise the final linking will assume that
+ * the ELF stack should not be restricted at all and set it RWX.
+ */
+.section .note.GNU-stack,"",@progbits

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-07 19:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-01 12:54 [PATCH] perf, tool: Fix perf stack to non executable on x86_64 Jiri Olsa
2012-02-03  9:50 ` Eric Dumazet
2012-02-07 19:34 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2012-02-07 19:37 ` [tip:perf/core] perf tool: " tip-bot for Jiri Olsa

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.