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: <20091221012032.B73BAB158A@basil.firstfloor.org>
Date:	Mon, 21 Dec 2009 02:20:32 +0100 (CET)
From:	Andi Kleen <andi@...stfloor.org>
To:	samuel@...tiz.org, linux-kernel@...r.kernel.org,
	paulmck@...ux.vnet.ibm.com, ebiederm@...ssion.com
Subject: [PATCH] [11/11] SYSCTL: Convert IRDA text sysctl to RCU 


This avoids races with lockless sysctl

Cc: samuel@...tiz.org

---
 net/irda/irlmp.c    |    3 +--
 net/irda/irsysctl.c |    9 ++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

Index: linux-2.6.33-rc1-ak/net/irda/irlmp.c
===================================================================
--- linux-2.6.33-rc1-ak.orig/net/irda/irlmp.c
+++ linux-2.6.33-rc1-ak/net/irda/irlmp.c
@@ -56,7 +56,7 @@ int  sysctl_discovery         = 0;
 int  sysctl_discovery_timeout = 3; /* 3 seconds by default */
 int  sysctl_discovery_slots   = 6; /* 6 slots by default */
 int  sysctl_lap_keepalive_time = LM_IDLE_TIMEOUT * 1000 / HZ;
-char sysctl_devname[65];
+char *sysctl_devname = "Linux";
 
 const char *irlmp_reasons[] = {
 	"ERROR, NOT USED",
@@ -101,7 +101,6 @@ int __init irlmp_init(void)
 	spin_lock_init(&irlmp->cachelog->hb_spinlock);
 
 	irlmp->last_lsap_sel = 0x0f; /* Reserved 0x00-0x0f */
-	strcpy(sysctl_devname, "Linux");
 
 	init_timer(&irlmp->discovery_timer);
 
Index: linux-2.6.33-rc1-ak/net/irda/irsysctl.c
===================================================================
--- linux-2.6.33-rc1-ak.orig/net/irda/irsysctl.c
+++ linux-2.6.33-rc1-ak/net/irda/irsysctl.c
@@ -27,6 +27,7 @@
 #include <linux/ctype.h>
 #include <linux/sysctl.h>
 #include <linux/init.h>
+#include <linux/rcupdate.h>
 
 #include <net/irda/irda.h>		/* irda_debug */
 #include <net/irda/irlmp.h>
@@ -38,7 +39,7 @@ extern int  sysctl_discovery_slots;
 extern int  sysctl_discovery_timeout;
 extern int  sysctl_slot_timeout;
 extern int  sysctl_fast_poll_increase;
-extern char sysctl_devname[];
+extern char *sysctl_devname;
 extern int  sysctl_max_baud_rate;
 extern int  sysctl_min_tx_turn_time;
 extern int  sysctl_max_tx_data_size;
@@ -78,13 +79,15 @@ static int do_devname(ctl_table *table,
 {
 	int ret;
 
-	ret = proc_dostring(table, write, buffer, lenp, ppos);
+	ret = proc_rcu_string(table, write, buffer, lenp, ppos);
 	if (ret == 0 && write) {
 		struct ias_value *val;
 
+		rcu_read_lock();
 		val = irias_new_string_value(sysctl_devname);
 		if (val)
 			irias_object_change_attribute("Device", "DeviceName", val);
+		rcu_read_unlock();
 	}
 	return ret;
 }
@@ -121,7 +124,7 @@ static ctl_table irda_table[] = {
 	},
 	{
 		.procname	= "devname",
-		.data		= sysctl_devname,
+		.data		= &sysctl_devname,
 		.maxlen		= 65,
 		.mode		= 0644,
 		.proc_handler	= do_devname,
--
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