mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: samuel@sortiz.org, linux-kernel@vger.kernel.org,
	paulmck@linux.vnet.ibm.com, ebiederm@xmission.com
Subject: [PATCH] [11/11] SYSCTL: Convert IRDA text sysctl to RCU
Date: Mon, 21 Dec 2009 02:20:32 +0100 (CET)	[thread overview]
Message-ID: <20091221012032.B73BAB158A@basil.firstfloor.org> (raw)
In-Reply-To: <20091221220.243954235@firstfloor.org>


This avoids races with lockless sysctl

Cc: samuel@sortiz.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,

  parent reply	other threads:[~2009-12-21  1:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-21  1:20 [PATCH] [0/11] SYSCTL: Use RCU to avoid races with string sysctls Andi Kleen
2009-12-21  1:20 ` [PATCH] [1/11] Add rcustring ADT for RCU protected strings Andi Kleen
2009-12-22  2:46   ` Paul E. McKenney
2009-12-22 10:05     ` Andi Kleen
2009-12-22 20:59       ` Paul E. McKenney
2009-12-21  1:20 ` [PATCH] [2/11] Add a kernel_address() that works for data too Andi Kleen
2009-12-21  1:20 ` [PATCH] [3/11] SYSCTL: Add proc_rcu_string to manage sysctls using rcu strings Andi Kleen
2009-12-22  2:51   ` Paul E. McKenney
2009-12-22  3:00     ` Eric W. Biederman
2009-12-22  7:44       ` Paul E. McKenney
2009-12-21  1:20 ` [PATCH] [4/11] SYSCTL: Use RCU strings for core_pattern sysctl Andi Kleen
2009-12-21  1:20 ` [PATCH] [5/11] SYSCTL: Add call_usermodehelper_cleanup() Andi Kleen
2009-12-21  1:20 ` [PATCH] [6/11] SYSCTL: Convert modprobe_path to proc_rcu_string() Andi Kleen
2009-12-21  1:20 ` [PATCH] [7/11] SYSCTL: Convert poweroff_command to proc_rcu_string Andi Kleen
2009-12-21  1:20 ` [PATCH] [8/11] SYSCTL: Convert hotplug helper string to proc_rcu_string() Andi Kleen
2009-12-22 19:03   ` Greg KH
2009-12-21  1:20 ` [PATCH] [9/11] SYSCTL: Add a mutex to the page_alloc zone order sysctl Andi Kleen
2009-12-21  1:20 ` [PATCH] [10/11] SYSCTL: Use RCU protected sysctl for ocfs group add helper Andi Kleen
2009-12-21  1:20 ` Andi Kleen [this message]
2009-12-21  1:59 ` [PATCH] [0/11] SYSCTL: Use RCU to avoid races with string sysctls Eric W. Biederman
2009-12-21  2:04   ` Andi Kleen
2009-12-21  2:31     ` Eric W. Biederman
2009-12-21  3:21       ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091221012032.B73BAB158A@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=samuel@sortiz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome