Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1230354 > unrolled thread

[PATCH v13 00/23] Compile-time stack metadata validation

Started byJosh Poimboeuf <jpoimboe@redhat.com>
First post2015-09-22 17:50 +0200
Last post2015-09-28 15:50 +0200
Articles 11 on this page of 31 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
    [PATCH v13 20/23] x86/asm/efi: Create a stack frame in efi_call() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
    [PATCH v13 22/23] x86/uaccess: Add stack frame output operand in get_user inline asm Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
    [PATCH v13 21/23] x86/asm/power: Create stack frames in hibernate_asm_64.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
    [PATCH v13 01/23] tools: Fix formatting of the "make -C tools" help message Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
    [PATCH v13 06/23] x86/stacktool: Add ignore macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 18/23] x86/asm/acpi: Create a stack frame in do_suspend_lowlevel() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 05/23] x86/stacktool: Add file and directory ignores Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 17/23] x86/asm/entry: Create stack frames in thunk functions Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 10/23] x86/amd: Set ELF function type for vide() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 08/23] x86/paravirt: Add stack frame dependency to PVOP inline asm calls Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 16/23] x86/asm/crypto: Create stack frames in clmul_ghash_mul/update() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
      Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S minipli@ld-linux.so - 2015-10-01 08:30 +0200
        Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 15:40 +0200
          Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Mathias Krause <minipli@ld-linux.so> - 2015-10-01 19:40 +0200
            Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 20:00 +0200
    [PATCH v13 09/23] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 14/23] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 15/23] x86/asm/crypto: Move jump_table to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    [PATCH v13 12/23] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
    [PATCH v13 02/23] x86/asm: Frame pointer macro cleanup Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
    [PATCH v13 07/23] x86/xen: Add stack frame dependency to hypercall inline asm calls Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
    [PATCH v13 11/23] x86/reboot: Add ljmp instructions to stacktool whitelist Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
    [PATCH v13 03/23] x86/asm: Add C versions of frame pointer macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
    Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata  validation Jiri Slaby <jslaby@suse.cz> - 2015-09-23 13:40 +0200
      Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata  validation Jiri Slaby <jslaby@suse.cz> - 2015-09-23 13:50 +0200
        Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Chris J Arges <chris.j.arges@canonical.com> - 2015-10-01 17:00 +0200
          Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 17:30 +0200
            Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Chris J Arges <chris.j.arges@canonical.com> - 2015-10-01 17:40 +0200
    Re: [PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-28 15:50 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1230406 — [PATCH v13 12/23] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-22 18:10 +0200
Subject[PATCH v13 12/23] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists
Message-ID<qbyiK-1PH-27@gated-at.bofh.it>
In reply to#1230354
stacktool reports the following false positive warnings:

  stacktool: arch/x86/xen/enlighten.o: xen_cpuid()+0x41: can't find jump dest instruction at .text+0x108
  stacktool: arch/x86/xen/enlighten.o: xen_setup_gdt.constprop.23()+0x2e: kernel entry/exit from callable instruction

The first warning is due to xen_cpuid()'s use of XEN_EMULATE_PREFIX to
insert some fake instructions which stacktool doesn't know how to
decode.

The second warning is due to xen_setup_gdt()'s use of an lret
instruction, which stacktool normally doesn't allow in callable
functions.  But this seems to be a valid use of the instruction.

Add both functions to the stacktool whitelist.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/xen/enlighten.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 30d12af..1e0fe3a 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -32,6 +32,7 @@
 #include <linux/gfp.h>
 #include <linux/memblock.h>
 #include <linux/edd.h>
+#include <linux/stacktool.h>
 
 #include <xen/xen.h>
 #include <xen/events.h>
@@ -346,8 +347,8 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
 	*cx &= maskecx;
 	*cx |= setecx;
 	*dx &= maskedx;
-
 }
+STACKTOOL_IGNORE_FUNC(xen_cpuid);
 
 static bool __init xen_check_mwait(void)
 {
@@ -1451,6 +1452,7 @@ static void __ref xen_setup_gdt(int cpu)
 	pv_cpu_ops.write_gdt_entry = xen_write_gdt_entry;
 	pv_cpu_ops.load_gdt = xen_load_gdt;
 }
+STACKTOOL_IGNORE_FUNC(xen_setup_gdt);
 
 #ifdef CONFIG_XEN_PVH
 /*
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1230410 — [PATCH v13 02/23] x86/asm: Frame pointer macro cleanup

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-22 18:10 +0200
Subject[PATCH v13 02/23] x86/asm: Frame pointer macro cleanup
Message-ID<qbyiL-1PH-43@gated-at.bofh.it>
In reply to#1230354
The asm macros for setting up and restoring the frame pointer aren't
currently being used.  However, they will be needed soon to help asm
functions to comply with stacktool.

Rename FRAME/ENDFRAME to FRAME_BEGIN/FRAME_END for more symmetry.  Also
make the code more readable and improve the comments.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/include/asm/frame.h | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/frame.h b/arch/x86/include/asm/frame.h
index 793179c..8a6cd26 100644
--- a/arch/x86/include/asm/frame.h
+++ b/arch/x86/include/asm/frame.h
@@ -1,23 +1,26 @@
+#ifndef _ASM_X86_FRAME_H
+#define _ASM_X86_FRAME_H
+
 #ifdef __ASSEMBLY__
 
 #include <asm/asm.h>
 
-/* The annotation hides the frame from the unwinder and makes it look
-   like a ordinary ebp save/restore. This avoids some special cases for
-   frame pointer later */
+/*
+ * These are stack frame creation macros.  They should be used by every
+ * callable non-leaf asm function to make kernel stack traces more reliable.
+ */
+.macro FRAME_BEGIN
+#ifdef CONFIG_FRAME_POINTER
+	push %_ASM_BP
+	_ASM_MOV %_ASM_SP, %_ASM_BP
+#endif
+.endm
+
+.macro FRAME_END
 #ifdef CONFIG_FRAME_POINTER
-	.macro FRAME
-	__ASM_SIZE(push,)	%__ASM_REG(bp)
-	__ASM_SIZE(mov)		%__ASM_REG(sp), %__ASM_REG(bp)
-	.endm
-	.macro ENDFRAME
-	__ASM_SIZE(pop,)	%__ASM_REG(bp)
-	.endm
-#else
-	.macro FRAME
-	.endm
-	.macro ENDFRAME
-	.endm
+	pop %_ASM_BP
 #endif
+.endm
 
 #endif  /*  __ASSEMBLY__  */
+#endif /* _ASM_X86_FRAME_H */
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1230411 — [PATCH v13 07/23] x86/xen: Add stack frame dependency to hypercall inline asm calls

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-22 18:10 +0200
Subject[PATCH v13 07/23] x86/xen: Add stack frame dependency to hypercall inline asm calls
Message-ID<qbyiL-1PH-57@gated-at.bofh.it>
In reply to#1230354
If a hypercall is inlined at the beginning of a function, gcc can insert
the call instruction before setting up a stack frame, which breaks frame
pointer convention if CONFIG_FRAME_POINTER is enabled and can result in
a bad stack trace.

Force a stack frame to be created if CONFIG_FRAME_POINTER is enabled by
listing the stack pointer as an output operand for the hypercall inline
asm statements.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 arch/x86/include/asm/xen/hypercall.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
index 83aea80..9b7dc62 100644
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -110,9 +110,10 @@ extern struct { char _entry[32]; } hypercall_page[];
 	register unsigned long __arg2 asm(__HYPERCALL_ARG2REG) = __arg2; \
 	register unsigned long __arg3 asm(__HYPERCALL_ARG3REG) = __arg3; \
 	register unsigned long __arg4 asm(__HYPERCALL_ARG4REG) = __arg4; \
-	register unsigned long __arg5 asm(__HYPERCALL_ARG5REG) = __arg5;
+	register unsigned long __arg5 asm(__HYPERCALL_ARG5REG) = __arg5; \
+	register void *__sp asm(_ASM_SP);
 
-#define __HYPERCALL_0PARAM	"=r" (__res)
+#define __HYPERCALL_0PARAM	"=r" (__res), "+r" (__sp)
 #define __HYPERCALL_1PARAM	__HYPERCALL_0PARAM, "+r" (__arg1)
 #define __HYPERCALL_2PARAM	__HYPERCALL_1PARAM, "+r" (__arg2)
 #define __HYPERCALL_3PARAM	__HYPERCALL_2PARAM, "+r" (__arg3)
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1230412 — [PATCH v13 11/23] x86/reboot: Add ljmp instructions to stacktool whitelist

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-22 18:10 +0200
Subject[PATCH v13 11/23] x86/reboot: Add ljmp instructions to stacktool whitelist
Message-ID<qbyiL-1PH-59@gated-at.bofh.it>
In reply to#1230354
stacktool reports a false positive warning for the ljmp instruction in
machine_real_restart().  Normally, ljmp isn't allowed in a function, but
this is a special case where it's jumping into real mode.

Add the jumps to a whitelist which tells stacktool to ignore them.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/kernel/reboot.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 02693dd..1ea1c5e 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -9,6 +9,7 @@
 #include <linux/sched.h>
 #include <linux/tboot.h>
 #include <linux/delay.h>
+#include <linux/stacktool.h>
 #include <acpi/reboot.h>
 #include <asm/io.h>
 #include <asm/apic.h>
@@ -97,11 +98,13 @@ void __noreturn machine_real_restart(unsigned int type)
 
 	/* Jump to the identity-mapped low memory code */
 #ifdef CONFIG_X86_32
-	asm volatile("jmpl *%0" : :
+	asm volatile(STACKTOOL_IGNORE_INSN
+		     "jmpl *%0;" : :
 		     "rm" (real_mode_header->machine_real_restart_asm),
 		     "a" (type));
 #else
-	asm volatile("ljmpl *%0" : :
+	asm volatile(STACKTOOL_IGNORE_INSN
+		     "ljmpl *%0" : :
 		     "m" (real_mode_header->machine_real_restart_asm),
 		     "D" (type));
 #endif
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1230417 — [PATCH v13 03/23] x86/asm: Add C versions of frame pointer macros

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-22 18:10 +0200
Subject[PATCH v13 03/23] x86/asm: Add C versions of frame pointer macros
Message-ID<qbyiN-1PH-91@gated-at.bofh.it>
In reply to#1230354
Add C versions of the frame pointer macros which can be used to create a
stack frame in inline assembly.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/include/asm/frame.h | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/frame.h b/arch/x86/include/asm/frame.h
index 8a6cd26..9a30ec7 100644
--- a/arch/x86/include/asm/frame.h
+++ b/arch/x86/include/asm/frame.h
@@ -1,10 +1,10 @@
 #ifndef _ASM_X86_FRAME_H
 #define _ASM_X86_FRAME_H
 
-#ifdef __ASSEMBLY__
-
 #include <asm/asm.h>
 
+#ifdef __ASSEMBLY__
+
 /*
  * These are stack frame creation macros.  They should be used by every
  * callable non-leaf asm function to make kernel stack traces more reliable.
@@ -22,5 +22,21 @@
 #endif
 .endm
 
+#else /* !__ASSEMBLY__ */
+
+#ifdef CONFIG_FRAME_POINTER
+
+#define FRAME_BEGIN				\
+	"push %" _ASM_BP "\n"			\
+	_ASM_MOV "%" _ASM_SP ", %" _ASM_BP "\n"
+
+#define FRAME_END "pop %" _ASM_BP "\n"
+
+#else /* !CONFIG_FRAME_POINTER */
+
+#define FRAME_BEGIN ""
+#define FRAME_END ""
+
+#endif /* CONFIG_FRAME_POINTER */
 #endif  /*  __ASSEMBLY__  */
 #endif /* _ASM_X86_FRAME_H */
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231370 — Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata validation

FromJiri Slaby <jslaby@suse.cz>
Date2015-09-23 13:40 +0200
SubjectRe: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata validation
Message-ID<qbQz0-2RY-3@gated-at.bofh.it>
In reply to#1230354
On 09/22/2015, 05:46 PM, Josh Poimboeuf wrote:
...
> --- /dev/null
> +++ b/tools/stacktool/elf.c
> @@ -0,0 +1,403 @@
...
> +static struct section *find_section_by_index(struct elf *elf,
> +					     unsigned int index)
> +{
...
> +}
> +
> +static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int index)
> +{

Hi, on openSUSE, I am getting:

elf.c:45: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here
elf.c: In function ‘find_symbol_by_index’:
elf.c:56: error: declaration of ‘index’ shadows a global declaration
/usr/include/string.h:487: error: shadowed declaration is here

which is index(3):
extern char *index (__const char *__s, int __c)
     __THROW __attribute_pure__ __nonnull ((1));

The same here:

> --- /dev/null
> +++ b/tools/stacktool/special.c
> @@ -0,0 +1,199 @@
...
> +static int get_alt_entry(struct elf *elf, struct special_entry *entry,
> +			 struct section *sec, int index,
> +			 struct special_alt *alt)
> +{
...
> +int special_get_alts(struct elf *elf, struct list_head *alts)
> +{

I fixed it obviously by s/index/idx/.

thanks,
-- 
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1231382 — Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata validation

FromJiri Slaby <jslaby@suse.cz>
Date2015-09-23 13:50 +0200
SubjectRe: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata validation
Message-ID<qbQIG-33j-41@gated-at.bofh.it>
In reply to#1231370
On 09/23/2015, 01:38 PM, Jiri Slaby wrote:
> On 09/22/2015, 05:46 PM, Josh Poimboeuf wrote:
> ...
>> --- /dev/null
>> +++ b/tools/stacktool/elf.c
>> @@ -0,0 +1,403 @@
> ...
>> +static struct section *find_section_by_index(struct elf *elf,
>> +					     unsigned int index)
>> +{
> ...
>> +}
>> +
>> +static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int index)
>> +{
> 
> Hi, on openSUSE, I am getting:
> 
> elf.c:45: error: declaration of ‘index’ shadows a global declaration
> /usr/include/string.h:487: error: shadowed declaration is here
> elf.c: In function ‘find_symbol_by_index’:
> elf.c:56: error: declaration of ‘index’ shadows a global declaration
> /usr/include/string.h:487: error: shadowed declaration is here
> 
> which is index(3):
> extern char *index (__const char *__s, int __c)
>      __THROW __attribute_pure__ __nonnull ((1));
> 
> The same here:
> 
>> --- /dev/null
>> +++ b/tools/stacktool/special.c
>> @@ -0,0 +1,199 @@
> ...
>> +static int get_alt_entry(struct elf *elf, struct special_entry *entry,
>> +			 struct section *sec, int index,
>> +			 struct special_alt *alt)
>> +{
> ...
>> +int special_get_alts(struct elf *elf, struct list_head *alts)
>> +{

I erased too much here. Index is a local var here:
        int index, ret;

> 
> I fixed it obviously by s/index/idx/.
> 
> thanks,
-- 
js
suse labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237480 — Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation

FromChris J Arges <chris.j.arges@canonical.com>
Date2015-10-01 17:00 +0200
SubjectRe: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation
Message-ID<qeNuX-7IQ-21@gated-at.bofh.it>
In reply to#1231382
<snip>
> +
> +$(STACKTOOL_IN): FORCE
> +	@$(MAKE) $(build)=stacktool
> +
> +$(STACKTOOL): $(STACKTOOL_IN)
> +	@(test -d ../../kernel -a -d ../../tools -a -d ../stacktool && (( \
> +	diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
> +	diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
> +	diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
> +	diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
> +	diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
> +	diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
> +	diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
> +	|| echo "Warning: stacktool: x86 instruction decoder differs from kernel" >&2 )) || true
> +	$(QUIET_LINK)$(CC) $(STACKTOOL_IN) $(LDFLAGS) -o $@
> +
> +clean:
> +	$(call QUIET_CLEAN, stacktool) $(RM) $(STACKTOOL)
> +	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
> +	$(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c
> +
> +FORCE:
> +
> +.PHONY: clean FORCE

Josh,

I'm getting the following error when the above makefile is called:
Warning: stacktool: x86 instruction decoder differs from kernel

This was seen with your patches rebased on v4.3-rc2.

It is failing on this diff:
diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt

And the output is as follows:
902,904d890
< 3: xrstors
< 4: xsavec
< 5: xsaves
949,950c935,936
< 6: XSAVEOPT | clwb (66) | mfence (11B)
< 7: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B)
---
> 6: XSAVEOPT | mfence (11B)
> 7: clflush | sfence (11B)

Why do these files essentially need to be duplicated? Would it be possible to
point Make at the files that are already in ../../arch/x86/*?

--chris j arges

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237512 — Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-10-01 17:30 +0200
SubjectRe: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation
Message-ID<qeNXY-6n-23@gated-at.bofh.it>
In reply to#1237480
On Thu, Oct 01, 2015 at 09:50:51AM -0500, Chris J Arges wrote:
> <snip>
> > +
> > +$(STACKTOOL_IN): FORCE
> > +	@$(MAKE) $(build)=stacktool
> > +
> > +$(STACKTOOL): $(STACKTOOL_IN)
> > +	@(test -d ../../kernel -a -d ../../tools -a -d ../stacktool && (( \
> > +	diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
> > +	diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
> > +	diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
> > +	diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
> > +	diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
> > +	diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
> > +	diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
> > +	|| echo "Warning: stacktool: x86 instruction decoder differs from kernel" >&2 )) || true
> > +	$(QUIET_LINK)$(CC) $(STACKTOOL_IN) $(LDFLAGS) -o $@
> > +
> > +clean:
> > +	$(call QUIET_CLEAN, stacktool) $(RM) $(STACKTOOL)
> > +	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
> > +	$(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c
> > +
> > +FORCE:
> > +
> > +.PHONY: clean FORCE
> 
> Josh,
> 
> I'm getting the following error when the above makefile is called:
> Warning: stacktool: x86 instruction decoder differs from kernel

It's just a warning, not an error, right?  Just want to make sure it
didn't fail the build.  The files are in sync on tip/master.

> This was seen with your patches rebased on v4.3-rc2.
> 
> It is failing on this diff:
> diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt
> 
> And the output is as follows:
> 902,904d890
> < 3: xrstors
> < 4: xsavec
> < 5: xsaves
> 949,950c935,936
> < 6: XSAVEOPT | clwb (66) | mfence (11B)
> < 7: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B)
> ---
> > 6: XSAVEOPT | mfence (11B)
> > 7: clflush | sfence (11B)
> 
> Why do these files essentially need to be duplicated? Would it be possible to
> point Make at the files that are already in ../../arch/x86/*?

They're duplicated because the "tools" dir is supposed to be source
independent from the rest of the kernel tree.

-- 
Josh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1237522 — Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation

FromChris J Arges <chris.j.arges@canonical.com>
Date2015-10-01 17:40 +0200
SubjectRe: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata validation
Message-ID<qeO7E-hB-29@gated-at.bofh.it>
In reply to#1237512

On 10/01/2015 10:25 AM, Josh Poimboeuf wrote:
> On Thu, Oct 01, 2015 at 09:50:51AM -0500, Chris J Arges wrote:
>> <snip>
>>> +
>>> +$(STACKTOOL_IN): FORCE
>>> +	@$(MAKE) $(build)=stacktool
>>> +
>>> +$(STACKTOOL): $(STACKTOOL_IN)
>>> +	@(test -d ../../kernel -a -d ../../tools -a -d ../stacktool && (( \
>>> +	diff -I'^#include' arch/x86/insn/insn.c ../../arch/x86/lib/insn.c >/dev/null && \
>>> +	diff -I'^#include' arch/x86/insn/inat.c ../../arch/x86/lib/inat.c >/dev/null && \
>>> +	diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt >/dev/null && \
>>> +	diff arch/x86/insn/gen-insn-attr-x86.awk ../../arch/x86/tools/gen-insn-attr-x86.awk >/dev/null && \
>>> +	diff -I'^#include' arch/x86/insn/insn.h ../../arch/x86/include/asm/insn.h >/dev/null && \
>>> +	diff -I'^#include' arch/x86/insn/inat.h ../../arch/x86/include/asm/inat.h >/dev/null && \
>>> +	diff -I'^#include' arch/x86/insn/inat_types.h ../../arch/x86/include/asm/inat_types.h >/dev/null) \
>>> +	|| echo "Warning: stacktool: x86 instruction decoder differs from kernel" >&2 )) || true
>>> +	$(QUIET_LINK)$(CC) $(STACKTOOL_IN) $(LDFLAGS) -o $@
>>> +
>>> +clean:
>>> +	$(call QUIET_CLEAN, stacktool) $(RM) $(STACKTOOL)
>>> +	$(Q)find $(OUTPUT) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
>>> +	$(Q)$(RM) $(OUTPUT)arch/x86/insn/inat-tables.c
>>> +
>>> +FORCE:
>>> +
>>> +.PHONY: clean FORCE
>>
>> Josh,
>>
>> I'm getting the following error when the above makefile is called:
>> Warning: stacktool: x86 instruction decoder differs from kernel
> 
> It's just a warning, not an error, right?  Just want to make sure it
> didn't fail the build.  The files are in sync on tip/master.
> 

Correct just a warning. And once I rebased correctly things are in sync.
Thanks and sorry for the noise.

--chris

>> This was seen with your patches rebased on v4.3-rc2.
>>
>> It is failing on this diff:
>> diff arch/x86/insn/x86-opcode-map.txt ../../arch/x86/lib/x86-opcode-map.txt
>>
>> And the output is as follows:
>> 902,904d890
>> < 3: xrstors
>> < 4: xsavec
>> < 5: xsaves
>> 949,950c935,936
>> < 6: XSAVEOPT | clwb (66) | mfence (11B)
>> < 7: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B)
>> ---
>>> 6: XSAVEOPT | mfence (11B)
>>> 7: clflush | sfence (11B)
>>
>> Why do these files essentially need to be duplicated? Would it be possible to
>> point Make at the files that are already in ../../arch/x86/*?
> 
> They're duplicated because the "tools" dir is supposed to be source
> independent from the rest of the kernel tree.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1234168

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-09-28 15:50 +0200
Message-ID<qdGYx-12Y-11@gated-at.bofh.it>
In reply to#1230354
Hi Ingo,

Do you have any more objections to these patches?  Would you be willing
to apply them?

Thanks!
Josh

On Tue, Sep 22, 2015 at 10:46:51AM -0500, Josh Poimboeuf wrote:
> This is v13 of the compile-time stack metadata validation patch set,
> along with proposed fixes for many of the warnings it found.  It's based
> on the tip/master branch.
> 
> v12 can be found here:
> 
>   https://lkml.kernel.org/r/cover.1441749989.git.jpoimboe@redhat.com
> 
> For more information about the motivation behind this patch set, and
> more details about what it does, see the patch 4 changelog and
> tools/stacktool/Documentation/stack-validation.txt.
> 
> Patch 1 fixes the formatting for the "make -C tools" help message.
> 
> Patches 2-6 add stacktool and some related macros.
> 
> Patches 7-21 are some proposed fixes for several of the warnings
> reported by stacktool.  They've been compile-tested and boot-tested in a
> VM, but I haven't attempted any meaningful testing for many of them.
> 
> Patches 22-23 are some additional warning fixes from Chris J Arges.
> 
> v13:
> - LDFLAGS order fix from Chris J Arges
> - new warning fix patches from Chris J Arges
> - "--frame-pointer" -> "--check-frame-pointer"
> 
> v12:
> - rename "stackvalidate" -> "stacktool"
> - move from scripts/ to tools/:
>   - makefile rework
>   - make a copy of the x86 insn code (and warn if the code diverges)
>   - use tools/include/linux/list.h
> - move warning macros to a new warn.h file
> - change wording: "stack validation" -> "stack metadata validation"
> 
> v11:
> - attempt to answer the "why" question better in the documentation and
>   commit message
> - s/FP_SAVE/FRAME_BEGIN/ in documentation
> 
> v10:
> - add scripts/mod to directory ignores
> - remove circular dependencies for ignored objects which are built
>   before stackvalidate
> - fix CONFIG_MODVERSIONS incompatibility
> 
> v9:
> - rename FRAME/ENDFRAME -> FRAME_BEGIN/FRAME_END
> - fix jump table issue for when the original instruction is a jump
> - drop paravirt thunk alignment patch
> - add maintainers to CC for proposed warning fixes
> 
> v8:
> - add proposed fixes for warnings
> - fix all memory leaks
> - process ignores earlier and add more ignore checks
> - always assume POPCNT alternative is enabled
> - drop hweight inline asm fix
> - drop __schedule() ignore patch
> - change .Ltemp_\@ to .Lstackvalidate_ignore_\@ in asm macro
> - fix CONFIG_* checks in asm macros
> - add C versions of ignore macros and frame macros
> - change ";" to "\n" in C macros
> - add ifdef CONFIG_STACK_VALIDATION checks in C ignore macros
> - use numbered label in C ignore macro
> - add missing break in switch case statement in arch-x86.c
> 
> v7:
> - sibling call support
> - document proposed solution for inline asm() frame pointer issues
> - say "kernel entry/exit" instead of "context switch"
> - clarify the checking of switch statement jump tables
> - discard __stackvalidate_ignore_* sections in linker script
> - use .Ltemp_\@ to get a unique label instead of static 3-digit number
> - change STACKVALIDATE_IGNORE_FUNC variable to a static
> - move STACKVALIDATE_IGNORE_INSN to arch-specific .h file
> 
> v6:
> - rename asmvalidate -> stackvalidate (again)
> - gcc-generated object file support
> - recursive branch state analysis
> - external jump support
> - fixup/exception table support
> - jump label support
> - switch statement jump table support
> - added documentation
> - detection of "noreturn" dead end functions
> - added a Kbuild mechanism for skipping files and dirs
> - moved frame pointer macros to arch/x86/include/asm/frame.h
> - moved ignore macros to include/linux/stackvalidate.h
> 
> v5:
> - stackvalidate -> asmvalidate
> - frame pointers only required for non-leaf functions
> - check for the use of the FP_SAVE/RESTORE macros instead of manually
>   analyzing code to detect frame pointer usage
> - additional checks to ensure each function doesn't leave its boundaries
> - make the macros simpler and more flexible
> - support for analyzing ALTERNATIVE macros
> - simplified the arch interfaces in scripts/asmvalidate/arch.h
> - fixed some asmvalidate warnings
> - rebased onto latest tip asm cleanups
> - many more small changes
> 
> v4:
> - Changed the default to CONFIG_STACK_VALIDATION=n, until all the asm
>   code can get cleaned up.
> - Fixed a stackvalidate error path exit code issue found by Michal
>   Marek.
> 
> v3:
> - Added a patch to make the push/pop CFI macros arch-independent, as
>   suggested by H. Peter Anvin
> 
> v2:
> - Fixed memory leaks reported by Petr Mladek
> 
> Cc: linux-kernel@vger.kernel.org
> Cc: live-patching@vger.kernel.org
> Cc: Michal Marek <mmarek@suse.cz>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Andi Kleen <andi@firstfloor.org>
> Cc: Pedro Alves <palves@redhat.com>
> Cc: Namhyung Kim <namhyung@gmail.com>
> Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
> Cc: Chris J Arges <chris.j.arges@canonical.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> 
> 
> Chris J Arges (2):
>   x86/uaccess: Add stack frame output operand in get_user inline asm
>   x86/stacktool: Ignore head_$(BITS) files.
> 
> Josh Poimboeuf (21):
>   tools: Fix formatting of the "make -C tools" help message
>   x86/asm: Frame pointer macro cleanup
>   x86/asm: Add C versions of frame pointer macros
>   x86/stacktool: Compile-time stack metadata validation
>   x86/stacktool: Add file and directory ignores
>   x86/stacktool: Add ignore macros
>   x86/xen: Add stack frame dependency to hypercall inline asm calls
>   x86/paravirt: Add stack frame dependency to PVOP inline asm calls
>   x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK
>   x86/amd: Set ELF function type for vide()
>   x86/reboot: Add ljmp instructions to stacktool whitelist
>   x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists
>   x86/asm/crypto: Create stack frames in aesni-intel_asm.S
>   x86/asm/crypto: Move .Lbswap_mask data to .rodata section
>   x86/asm/crypto: Move jump_table to .rodata section
>   x86/asm/crypto: Create stack frames in clmul_ghash_mul/update()
>   x86/asm/entry: Create stack frames in thunk functions
>   x86/asm/acpi: Create a stack frame in do_suspend_lowlevel()
>   x86/asm: Create stack frames in rwsem functions
>   x86/asm/efi: Create a stack frame in efi_call()
>   x86/asm/power: Create stack frames in hibernate_asm_64.S
> 
>  MAINTAINERS                                        |   7 +
>  Makefile                                           |   5 +-
>  arch/Kconfig                                       |   6 +
>  arch/x86/Kconfig                                   |   1 +
>  arch/x86/boot/Makefile                             |   3 +-
>  arch/x86/boot/compressed/Makefile                  |   3 +-
>  arch/x86/crypto/aesni-intel_asm.S                  |  21 +
>  arch/x86/crypto/crc32c-pcl-intel-asm_64.S          |   8 +-
>  arch/x86/crypto/ghash-clmulni-intel_asm.S          |   5 +
>  arch/x86/entry/thunk_64.S                          |   4 +
>  arch/x86/entry/vdso/Makefile                       |   5 +-
>  arch/x86/include/asm/frame.h                       |  51 +-
>  arch/x86/include/asm/paravirt.h                    |   9 +-
>  arch/x86/include/asm/paravirt_types.h              |  18 +-
>  arch/x86/include/asm/stacktool.h                   |  45 +
>  arch/x86/include/asm/uaccess.h                     |   5 +-
>  arch/x86/include/asm/xen/hypercall.h               |   5 +-
>  arch/x86/kernel/Makefile                           |   1 +
>  arch/x86/kernel/acpi/wakeup_64.S                   |   3 +
>  arch/x86/kernel/cpu/amd.c                          |   5 +-
>  arch/x86/kernel/reboot.c                           |   7 +-
>  arch/x86/kernel/vmlinux.lds.S                      |   5 +-
>  arch/x86/lib/rwsem.S                               |  11 +-
>  arch/x86/platform/efi/efi_stub_64.S                |   3 +
>  arch/x86/power/hibernate_asm_64.S                  |   7 +
>  arch/x86/purgatory/Makefile                        |   2 +
>  arch/x86/realmode/Makefile                         |   4 +-
>  arch/x86/realmode/rm/Makefile                      |   3 +-
>  arch/x86/xen/enlighten.c                           |   4 +-
>  drivers/firmware/efi/libstub/Makefile              |   1 +
>  include/linux/stacktool.h                          |  29 +
>  lib/Kconfig.debug                                  |  12 +
>  scripts/Makefile.build                             |  37 +-
>  scripts/mod/Makefile                               |   2 +
>  tools/Makefile                                     |  43 +-
>  tools/stacktool/.gitignore                         |   1 +
>  tools/stacktool/Build                              |   4 +
>  tools/stacktool/Documentation/stack-validation.txt | 336 +++++++
>  tools/stacktool/Makefile                           |  51 ++
>  tools/stacktool/arch.h                             |  44 +
>  tools/stacktool/arch/x86/Build                     |  12 +
>  tools/stacktool/arch/x86/decode.c                  | 163 ++++
>  .../stacktool/arch/x86/insn/gen-insn-attr-x86.awk  | 387 ++++++++
>  tools/stacktool/arch/x86/insn/inat.c               |  97 ++
>  tools/stacktool/arch/x86/insn/inat.h               | 221 +++++
>  tools/stacktool/arch/x86/insn/inat_types.h         |  29 +
>  tools/stacktool/arch/x86/insn/insn.c               | 594 +++++++++++++
>  tools/stacktool/arch/x86/insn/insn.h               | 201 +++++
>  tools/stacktool/arch/x86/insn/x86-opcode-map.txt   | 984 +++++++++++++++++++++
>  tools/stacktool/elf.c                              | 403 +++++++++
>  tools/stacktool/elf.h                              |  79 ++
>  tools/stacktool/special.c                          | 199 +++++
>  tools/stacktool/special.h                          |  42 +
>  tools/stacktool/stacktool.c                        | 980 ++++++++++++++++++++
>  tools/stacktool/warn.h                             |  60 ++
>  55 files changed, 5196 insertions(+), 71 deletions(-)
>  create mode 100644 arch/x86/include/asm/stacktool.h
>  create mode 100644 include/linux/stacktool.h
>  create mode 100644 tools/stacktool/.gitignore
>  create mode 100644 tools/stacktool/Build
>  create mode 100644 tools/stacktool/Documentation/stack-validation.txt
>  create mode 100644 tools/stacktool/Makefile
>  create mode 100644 tools/stacktool/arch.h
>  create mode 100644 tools/stacktool/arch/x86/Build
>  create mode 100644 tools/stacktool/arch/x86/decode.c
>  create mode 100644 tools/stacktool/arch/x86/insn/gen-insn-attr-x86.awk
>  create mode 100644 tools/stacktool/arch/x86/insn/inat.c
>  create mode 100644 tools/stacktool/arch/x86/insn/inat.h
>  create mode 100644 tools/stacktool/arch/x86/insn/inat_types.h
>  create mode 100644 tools/stacktool/arch/x86/insn/insn.c
>  create mode 100644 tools/stacktool/arch/x86/insn/insn.h
>  create mode 100644 tools/stacktool/arch/x86/insn/x86-opcode-map.txt
>  create mode 100644 tools/stacktool/elf.c
>  create mode 100644 tools/stacktool/elf.h
>  create mode 100644 tools/stacktool/special.c
>  create mode 100644 tools/stacktool/special.h
>  create mode 100644 tools/stacktool/stacktool.c
>  create mode 100644 tools/stacktool/warn.h
> 
> -- 
> 2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web