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:	Thu, 25 Jun 2015 09:04:08 -0400
From:	Dan Streetman <ddstreet@...e.org>
To:	Rusty Russell <rusty@...tcorp.com.au>
Cc:	Stephen Rothwell <sfr@...b.auug.org.au>,
	linux-next@...r.kernel.org, linux-kernel@...r.kernel.org,
	Dan Streetman <ddstreet@...e.org>
Subject: [PATCH] modules: elide param_lock if !CONFIG_SYSFS

Only include the built-in and per-module param_lock, and corresponding
lock/unlock functions, if sysfs is enabled.  If there is no sysfs there
is no need for locking kernel params.

This fixes a build break when CONFIG_SYSFS is not enabled, introduced
by commit b51d23e.

Reported-by: Stephen Rothwell <sfr@...b.auug.org.au>
Signed-off-by: Dan Streetman <ddstreet@...e.org>
---
 include/linux/module.h |  2 ++
 kernel/params.c        | 21 ++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index 6ba0e87..46efa1c 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -240,7 +240,9 @@ struct module {
 	unsigned int num_syms;
 
 	/* Kernel parameters. */
+#ifdef CONFIG_SYSFS
 	struct mutex param_lock;
+#endif
 	struct kernel_param *kp;
 	unsigned int num_kp;
 
diff --git a/kernel/params.c b/kernel/params.c
index 9c955cd..d2c6a2a 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -25,6 +25,7 @@
 #include <linux/slab.h>
 #include <linux/ctype.h>
 
+#ifdef CONFIG_SYSFS
 /* Protects all built-in parameters, modules use their own param_lock */
 static DEFINE_MUTEX(param_lock);
 
@@ -38,6 +39,17 @@ static inline struct mutex *__param_lock(struct module *mod)
 #endif
 }
 
+static inline void __check_param_lock(struct module *mod)
+{
+	BUG_ON(!mutex_is_locked(__param_lock(mod)));
+}
+#else /* !CONFIG_SYSFS */
+/* we don't need any param lock if there's no sysfs */
+static inline void __check_param_lock(struct module *mod)
+{
+}
+#endif
+
 /* This just allows us to keep track of which parameters are kmalloced. */
 struct kmalloced_param {
 	struct list_head list;
@@ -465,7 +477,7 @@ static int param_array(struct module *mod,
 		/* nul-terminate and parse */
 		save = val[len];
 		((char *)val)[len] = '\0';
-		BUG_ON(!mutex_is_locked(__param_lock(mod)));
+		__check_param_lock(mod);
 		ret = set(val, &kp);
 
 		if (ret != 0)
@@ -502,7 +514,7 @@ static int param_array_get(char *buffer, const struct kernel_param *kp)
 		if (i)
 			buffer[off++] = ',';
 		p.arg = arr->elem + arr->elemsize * i;
-		BUG_ON(!mutex_is_locked(__param_lock(p.mod)));
+		__check_param_lock(p.mod);
 		ret = arr->ops->get(buffer + off, &p);
 		if (ret < 0)
 			return ret;
@@ -622,18 +634,17 @@ static ssize_t param_attr_store(struct module_attribute *mattr,
 #define __modinit __init
 #endif
 
+#ifdef CONFIG_SYSFS
 void kernel_param_lock(struct module *mod)
 {
 	mutex_lock(__param_lock(mod));
 }
+EXPORT_SYMBOL(kernel_param_lock);
 
 void kernel_param_unlock(struct module *mod)
 {
 	mutex_unlock(__param_lock(mod));
 }
-
-#ifdef CONFIG_SYSFS
-EXPORT_SYMBOL(kernel_param_lock);
 EXPORT_SYMBOL(kernel_param_unlock);
 
 /*
-- 
2.1.0

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