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]
Message-Id: <1431949832-13606-2-git-send-email-iulia.manda21@gmail.com>
Date:	Mon, 18 May 2015 14:50:31 +0300
From:	Iulia Manda <iulia.manda21@...il.com>
To:	tim.bird@...ymobile.com
Cc:	linux-kernel@...r.kernel.org, josh@...htriplett.org
Subject: [PATCH 2/3] linux: Add macros that define and declare a core_param variable

This patch introduces two macros for kernel command line arguments
subsequently defined as core parameters:
* DECLARE_CORE_PARAM - declares an extern variable in case CMDLINE_PARSE is
set. In the other case it will make the variable a static constant asigned
with a default value to enable constant folding;
* DEFINE_CORE_PARAM - defines a core_param variable if CMDLINE_PARSE is
set. In the other case it leaves the definition to be handled by
DECLARE_CORE_PARAM macro.

Introducing a new header file for the declaration of kernel parameters
seemed to be the best option, because it solves the circular includes
problem. Any other proposal that would be fit for this case is welcomed.

Signed-off-by: Iulia Manda <iulia.manda21@...il.com>
Reviewed-by: Josh Triplett <josh@...htriplett.org>
---
 include/linux/moduleparam.h |  7 +++++++
 include/linux/params.h      | 12 ++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 include/linux/params.h

diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 570f70e..f7607c9 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -310,6 +310,13 @@ static inline void __kernel_param_unlock(void)
 #define core_param(name, var, type, perm)				\
 	param_check_##type(name, &(var));				\
 	__module_param_call("", name, &param_ops_##type, &var, perm, -1, 0)
+#ifdef CONFIG_CMDLINE_PARSE
+#define DEFINE_CORE_PARAM(name, var, val, type, perm)			\
+	type var = val;							\
+	core_param(name, var, type, perm)
+#else
+#define DEFINE_CORE_PARAM(name, var, val, type, perm)
+#endif
 #endif /* !MODULE */
 
 /**
diff --git a/include/linux/params.h b/include/linux/params.h
new file mode 100644
index 0000000..29c97dc
--- /dev/null
+++ b/include/linux/params.h
@@ -0,0 +1,12 @@
+#ifndef _LINUX_PARAMS_H
+#define _LINUX_PARAMS_H
+
+#ifdef CONFIG_CMDLINE_PARSE
+#define DECLARE_CORE_PARAM(var, val, type)				\
+	extern type var
+#else
+#define DECLARE_CORE_PARAM(var, val, type)				\
+	static const type var = val
+#endif
+
+#endif /* _LINUX_PARAMS_H */
-- 
1.8.3.2

--
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