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-next>] [day] [month] [year] [list]
Message-ID: <20070410231126.GC7092@Krystal>
Date:	Tue, 10 Apr 2007 19:11:26 -0400
From:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] markers-generic-doc-section-fix-flags

Documents the linux/marker.h header. Fix a bitwise flag manipulation mistake
in the MARK_GENERIC macro.

Use the __marker (ro), new __marker_strings (ro) and __marker_data (rw)
sections. It depends on the linker modification which defines this last
section.

It allows the use of a probe "private" data : upon probe connexion, it
can provide a pointer to its own data structure which will be available
at the probe call site as the pdata field of the mdata structure.

With the new __marker_data section, much less data has to be defined in
the kernel .data segment : only the enable flag, in non-optimized
markers, is left in .data because it is used very often.

The marker flags now only define MF_* which are bitmasks. There is no
way to use the bitmask shift value, so it is less error prone.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>

--- a/include/linux/marker.h
+++ b/include/linux/marker.h
@@ -16,48 +16,59 @@
 
 #ifdef __KERNEL__
 
-typedef void marker_probe_func(const char *fmt, ...);
+struct __mark_marker_data;
 
-struct __mark_marker_c {
+typedef void marker_probe_func(const struct __mark_marker_data *mdata,
+	const char *fmt, ...);
+
+struct __mark_marker_data {
 	const char *name;
-	marker_probe_func **call;
 	const char *format;
 	int flags;
+	marker_probe_func *call;
+	void *pdata;
 } __attribute__((packed));
 
 struct __mark_marker {
-	const struct __mark_marker_c *cmark;
+	struct __mark_marker_data *mdata;
 	void *enable;
 } __attribute__((packed));
 
-/* Generic marker flavor always available */
 #ifdef CONFIG_MARKERS
 
-#define MF_OPTIMIZED 1	/* Use optimized markers */
-#define MF_LOCKDEP 2	/* Can call lockdep */
-#define MF_PRINTK 3	/* vprintk can be called in the probe */
+/* Marker flags : selects the mechanism used to connect the probes to the
+ * markers and what can be executed within the probes. This is primarily
+ * used at reentrancy-unfriendly sites. */
+#define MF_OPTIMIZED	(1 << 0)	/* Use optimized markers */
+#define MF_LOCKDEP	(1 << 1)	/* Can call lockdep */
+#define MF_PRINTK	(1 << 2)	/* vprintk can be called in the probe */
+#define _MF_NR		3		/* Number of marker flags */
 
-#define _MF_OPTIMIZED (1 << MF_OPTIMIZED)
-#define _MF_LOCKDEP (1 << MF_LOCKDEP)
-#define _MF_PRINTK (1 << MF_PRINTK)
+#define DECLARE_MARKER_DATA(flags, name, format) \
 
+/* Generic marker flavor always available */
 #define MARK_GENERIC(flags, name, format, args...) \
 	do { \
-		static marker_probe_func *__mark_call_##name = \
-					__mark_empty_function; \
+		static const char __mstrtab_name_##name[] \
+		__attribute__((section("__markers_strings"))) \
+		= #name; \
+		static const char __mstrtab_format_##name[] \
+		__attribute__((section("__markers_strings"))) \
+		= format; \
+		static struct __mark_marker_data __mark_data_##name \
+		__attribute__((section("__markers_data"))) = \
+		{ __mstrtab_name_##name,  __mstrtab_format_##name, \
+		(flags) & ~MF_OPTIMIZED, __mark_empty_function, NULL }; \
 		static char __marker_enable_##name = 0; \
-		static const struct __mark_marker_c __mark_c_##name \
-			__attribute__((section(".markers.c"))) = \
-			{ #name, &__mark_call_##name, format, \
-			(flags) | ~_MF_OPTIMIZED } ; \
 		static const struct __mark_marker __mark_##name \
-			__attribute__((section(".markers"))) = \
-			{ &__mark_c_##name, &__marker_enable_##name } ; \
+			__attribute__((section("__markers"))) = \
+			{ &__mark_data_##name, &__marker_enable_##name } ; \
 		asm volatile ( "" : : "i" (&__mark_##name)); \
 		__mark_check_format(format, ## args); \
 		if (unlikely(__marker_enable_##name)) { \
 			preempt_disable(); \
-			(*__mark_call_##name)(format, ## args); \
+			(*__mark_data_##name.call)(&__mark_data_##name, \
+						format, ## args); \
 			preempt_enable(); \
 		} \
 	} while (0)
@@ -87,21 +98,23 @@ static inline int marker_generic_set_enable(void *address, char enable)
 #endif
 
 #define MARK_MAX_FORMAT_LEN	1024
+/* Pass this as a format string for a marker with no argument */
 #define MARK_NOARGS " "
 
-static inline __attribute__ ((format (printf, 1, 2)))
+/* To be used for string format validity checking with sparse */
+static inline
 void __mark_check_format(const char *fmt, ...)
 { }
 
 extern marker_probe_func __mark_empty_function;
 
 extern int _marker_set_probe(int flags, const char *name, const char *format,
-				marker_probe_func *probe);
+				marker_probe_func *probe, void *pdata);
 
-#define marker_set_probe(name, format, probe) \
-	_marker_set_probe(_MF_DEFAULT, name, format, probe)
+#define marker_set_probe(name, format, probe, pdata) \
+	_marker_set_probe(MF_DEFAULT, name, format, probe, pdata)
 
-extern int marker_remove_probe(marker_probe_func *probe);
+extern int marker_remove_probe(const char *name);
 extern int marker_list_probe(marker_probe_func *probe);
 
 #endif /* __KERNEL__ */
-- 
Mathieu Desnoyers
Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
-
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