netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
To: netdev@vger.kernel.org
Cc: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Nick Piggin <npiggin@kernel.dk>
Subject: [PATCH] proc_sysctl: use rcu_dereference before accessing proc_inode->sysctl->* members
Date: Fri, 15 Apr 2011 17:52:16 +0200	[thread overview]
Message-ID: <1302882736-30157-1-git-send-email-lucian.grijincu@gmail.com> (raw)

rcu_dereference/rcu_assign_pointer were added to protect some accesses
to ->sysctl in:

    commit dfef6dcd35cb4a251f6322ca9b2c06f0bb1aa1f4
    Author: Al Viro <viro@zeniv.linux.org.uk>
    Date:   Tue Mar 8 01:25:28 2011 -0500

      unfuck proc_sysctl ->d_compare()

This patch puts rcu_dereference where it's missing.

I'm not sure that this patch is needed. I may have misunderstood
Documentation/RCU/checklist.txt

Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Nick Piggin <npiggin@kernel.dk>
Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@gmail.com>
---
 fs/proc/proc_sysctl.c   |    9 +++++----
 include/linux/proc_fs.h |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index f50133c..0f5a063 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -70,8 +70,9 @@ static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
 
 static struct ctl_table_header *grab_header(struct inode *inode)
 {
-	if (PROC_I(inode)->sysctl)
-		return sysctl_head_grab(PROC_I(inode)->sysctl);
+	struct ctl_table_header *head = rcu_dereference(PROC_I(inode)->sysctl);
+	if (head)
+		return sysctl_head_grab(head);
 	else
 		return sysctl_head_next(NULL);
 }
@@ -394,12 +395,12 @@ static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
 	if (nd->flags & LOOKUP_RCU)
 		return -ECHILD;
-	return !PROC_I(dentry->d_inode)->sysctl->unregistering;
+	return !rcu_dereference(PROC_I(dentry->d_inode)->sysctl)->unregistering;
 }
 
 static int proc_sys_delete(const struct dentry *dentry)
 {
-	return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
+	return !!rcu_dereference(PROC_I(dentry->d_inode)->sysctl)->unregistering;
 }
 
 static int proc_sys_compare(const struct dentry *parent,
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 838c114..a38cb74 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -266,7 +266,7 @@ struct proc_inode {
 	int fd;
 	union proc_op op;
 	struct proc_dir_entry *pde;
-	struct ctl_table_header *sysctl;
+	struct ctl_table_header *__rcu sysctl;
 	struct ctl_table *sysctl_entry;
 	struct inode vfs_inode;
 };
-- 
1.7.5.rc0


                 reply	other threads:[~2011-04-15 15:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1302882736-30157-1-git-send-email-lucian.grijincu@gmail.com \
    --to=lucian.grijincu@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=npiggin@kernel.dk \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).