lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Dec 2008 10:17:55 +0100
From:	Alexander van Heukelum <heukelum@...tmail.fm>
To:	linux-arch@...r.kernel.org,
	Alexander van Heukelum <heukelum@...lshack.com>,
	Ingo Molnar <mingo@...e.hu>,
	LKML <linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Sam Ravnborg <sam@...nborg.org>,
	Cyrill Gorcunov <gorcunov@...il.com>,
	Alexander van Heukelum <heukelum@...tmail.fm>
Subject: [PATCH last/many] x86: checking framework for correct use of ENTRY/PROC

[ DO NOT APPLY (yet...) At this point this patch will
just cause the build to abort due to annotation errors
found. ]

Introduce a checking framework to check correct pairing
of ENTRY/END and PROC/ENDPROC. It also checks that the
annotations are not nested. I have used the ideas and
most of the implementation from Cyrill Gorcunov who
introduced the framework to check for mismatching
KPROBE_ENTRY annotations, which was however soon made
obsolete by the removal of KPROBE_ENTRY/KPROBE_END.

Checks performed:
 o  END must terminate an ENTRY annotation
 o  ENDPROC must terminate a PROC annotation
 o  ENTRY or PROC cannot be nested inside
	another ENTRY or PROC section.

Finally the macro ENTRY_PROC_FINAL is introduced to
enable checking correct closing of PROC and ENTRY
sections at the end of assembly files.

Signed-off-by: Alexander van Heukelum <heukelum@...tmail.fm>
Cc: Cyrill Gorcunov <gorcunov@...il.com>
---
 arch/x86/include/asm/linkage.h |   96 ++++++++++++++++++++++++----------------
 1 files changed, 58 insertions(+), 38 deletions(-)

diff --git a/arch/x86/include/asm/linkage.h b/arch/x86/include/asm/linkage.h
index 5d98d0b..299cdf2 100644
--- a/arch/x86/include/asm/linkage.h
+++ b/arch/x86/include/asm/linkage.h
@@ -58,64 +58,84 @@
 #endif
 
 /*
- * to check ENTRY_X86/END_X86 and
- * KPROBE_ENTRY_X86/KPROBE_END_X86
+ * to check ENTRY/END and PROC/ENDPROC
  * unbalanced-missed-mixed appearance
  */
-#define __set_entry_x86		.set ENTRY_X86_IN, 0
-#define __unset_entry_x86	.set ENTRY_X86_IN, 1
-#define __set_kprobe_x86	.set KPROBE_X86_IN, 0
-#define __unset_kprobe_x86	.set KPROBE_X86_IN, 1
-
-#define __macro_err_x86 .error "ENTRY_X86/KPROBE_X86 unbalanced,missed,mixed"
-
-#define __check_entry_x86	\
-	.ifdef ENTRY_X86_IN;	\
-	.ifeq ENTRY_X86_IN;	\
-	__macro_err_x86;	\
-	.abort;			\
+#ifdef __ASSEMBLER__
+#define __set_entry		.set ENTRY_IN, 0
+#define __unset_entry		.set ENTRY_IN, 1
+#define __set_proc		.set PROC_IN, 0
+#define __unset_proc		.set PROC_IN, 1
+
+#define __macro_err \
+	.error "ENTRY/PROC unbalanced,missed,mixed"; \
+	.abort
+
+#define __check_entry		\
+	.ifdef ENTRY_IN;	\
+	.ifeq ENTRY_IN;		\
+	__macro_err;		\
 	.endif;			\
 	.endif
 
-#define __check_kprobe_x86	\
-	.ifdef KPROBE_X86_IN;	\
-	.ifeq KPROBE_X86_IN;	\
-	__macro_err_x86;	\
-	.abort;			\
+#define __check_in_entry	\
+	.ifndef ENTRY_IN;	\
+	__macro_err;		\
+	.else;			\
+	.ifeq !ENTRY_IN;	\
+	__macro_err;		\
 	.endif;			\
 	.endif
 
-#define __check_entry_kprobe_x86	\
-	__check_entry_x86;		\
-	__check_kprobe_x86
+#define __check_proc		\
+	.ifdef PROC_IN;		\
+	.ifeq PROC_IN;		\
+	__macro_err;		\
+	.endif;			\
+	.endif
 
-#define ENTRY_KPROBE_FINAL_X86 __check_entry_kprobe_x86
+#define __check_in_proc		\
+	.ifndef PROC_IN;	\
+	__macro_err;		\
+	.else;			\
+	.ifeq !PROC_IN;		\
+	__macro_err;		\
+	.endif;			\
+	.endif
 
-#define ENTRY_X86(name)			\
-	__check_entry_kprobe_x86;	\
-	__set_entry_x86;		\
+#define __check_entry_proc	\
+	__check_entry;		\
+	__check_proc
+
+#define ENTRY_PROC_FINAL __check_entry_proc
+
+#define ENTRY(name)			\
+	__check_entry_proc;		\
+	__set_entry;			\
 	.globl name;			\
 	__ALIGN;			\
 	name:
 
-#define END_X86(name)			\
-	__unset_entry_x86;		\
-	__check_entry_kprobe_x86;	\
+#define END(name)			\
+	__check_in_entry;		\
+	__unset_entry;			\
+	__check_entry_proc;		\
 	.size name, .-name
 
-#define KPROBE_ENTRY_X86(name)		\
-	__check_entry_kprobe_x86;	\
-	__set_kprobe_x86;		\
-	.pushsection .kprobes.text, "ax"; \
+#define PROC(name)			\
+	__check_entry_proc;		\
+	__set_proc;			\
 	.globl name;			\
 	__ALIGN;			\
 	name:
 
-#define KPROBE_END_X86(name)		\
-	__unset_kprobe_x86;		\
-	__check_entry_kprobe_x86;	\
-	.size name, .-name;		\
-	.popsection
+#define ENDPROC(name)			\
+	__check_in_proc;		\
+	__unset_proc;			\
+	__check_entry_proc;		\
+	.type name, @function;		\
+	.size name, .-name
+#endif /* __ASSEMBLER__ */
 
 #endif /* _ASM_X86_LINKAGE_H */
 
-- 
1.5.4.3

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ