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>] [day] [month] [year] [list]
Message-Id: <1302882736-30157-1-git-send-email-lucian.grijincu@gmail.com>
Date:	Fri, 15 Apr 2011 17:52:16 +0200
From:	Lucian Adrian Grijincu <lucian.grijincu@...il.com>
To:	netdev@...r.kernel.org
Cc:	Lucian Adrian Grijincu <lucian.grijincu@...il.com>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Nick Piggin <npiggin@...nel.dk>
Subject: [PATCH] proc_sysctl: use rcu_dereference before accessing proc_inode->sysctl->* members

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

    commit dfef6dcd35cb4a251f6322ca9b2c06f0bb1aa1f4
    Author: Al Viro <viro@...iv.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@...ux.vnet.ibm.com>
Cc: Al Viro <viro@...iv.linux.org.uk>
Cc: Nick Piggin <npiggin@...nel.dk>
Signed-off-by: Lucian Adrian Grijincu <lucian.grijincu@...il.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

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ