Skip to contentSkip to conversation

Further PDE->data assignments cleanups

PATCH New Denis V. Lunev 7 participants 28 messages Apr 29, 2008 – Jul 12, 2008

Subsystems (10)
lore
Share & tools
lore
#1 lore raw

PATCH 1/12 sunrpc: assign PDE->data before gluing PDE into /proc tree

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
---
 net/sunrpc/cache.c |   15 ++++++---------
 net/sunrpc/stats.c |    8 +-------
 2 files changed, 7 insertions(+), 16 deletions(-)
net/sunrpc/cache.c +6 -9
index d75530f..c996671 100644
@@ -316,31 +316,28 @@ static int create_cache_proc_entries(struct cache_detail *cd)
 	cd->proc_ent->owner = cd->owner;
 	cd->channel_ent = cd->content_ent = NULL;
 
-	p = proc_create("flush", S_IFREG|S_IRUSR|S_IWUSR,
-			cd->proc_ent, &cache_flush_operations);
+	p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
+			     cd->proc_ent, &cache_flush_operations, cd);
 	cd->flush_ent = p;
 	if (p == NULL)
 		goto out_nomem;
 	p->owner = cd->owner;
-	p->data = cd;
 
 	if (cd->cache_request || cd->cache_parse) {
-		p = proc_create("channel", S_IFREG|S_IRUSR|S_IWUSR,
-				cd->proc_ent, &cache_file_operations);
+		p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
+				     cd->proc_ent, &cache_file_operations, cd);
 		cd->channel_ent = p;
 		if (p == NULL)
 			goto out_nomem;
 		p->owner = cd->owner;
-		p->data = cd;
 	}
 	if (cd->cache_show) {
-		p = proc_create("content", S_IFREG|S_IRUSR|S_IWUSR,
-				cd->proc_ent, &content_file_operations);
+		p = proc_create_data("content", S_IFREG|S_IRUSR|S_IWUSR,
+				cd->proc_ent, &content_file_operations, cd);
 		cd->content_ent = p;
 		if (p == NULL)
 			goto out_nomem;
 		p->owner = cd->owner;
-		p->data = cd;
 	}
 	return 0;
 out_nomem:
net/sunrpc/stats.c +1 -7
index c6061a4..50b049c 100644
@@ -224,16 +224,10 @@ EXPORT_SYMBOL_GPL(rpc_print_iostats);
 static inline struct proc_dir_entry *
 do_register(const char *name, void *data, const struct file_operations *fops)
 {
-	struct proc_dir_entry *ent;
-
 	rpc_proc_init();
 	dprintk("RPC:       registering /proc/net/rpc/%s\n", name);
 
-	ent = proc_create(name, 0, proc_net_rpc, fops);
-	if (ent) {
-		ent->data = data;
-	}
-	return ent;
+	return proc_create_data(name, 0, proc_net_rpc, fops, data);
 }
 
 struct proc_dir_entry *
Signature · 1 line
1.5.3.rc5
maintainer Applied
#2 lore raw

Re: [PATCH 1/12] sunrpc: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:11 +0400

Quoted 3 lines

Simply replace proc_create and further data assigned with proc_create_data.

Applied.

#3 lore raw

PATCH 2/12 netfilter: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/ipv4/netfilter/ipt_CLUSTERIP.c |    6 +++---
 net/netfilter/xt_hashlimit.c       |   12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)
net/ipv4/netfilter/ipt_CLUSTERIP.c +3 -3
index 22d8e7c..1819ad7 100644
@@ -169,14 +169,14 @@ clusterip_config_init(const struct ipt_clusterip_tgt_info *i, __be32 ip,
 
 		/* create proc dir entry */
 		sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip));
-		c->pde = proc_create(buffer, S_IWUSR|S_IRUSR,
-				     clusterip_procdir, &clusterip_proc_fops);
+		c->pde = proc_create_data(buffer, S_IWUSR|S_IRUSR,
+					  clusterip_procdir,
+					  &clusterip_proc_fops, c);
 		if (!c->pde) {
 			kfree(c);
 			return NULL;
 		}
 	}
-	c->pde->data = c;
 #endif
 
 	write_lock_bh(&clusterip_lock);
net/netfilter/xt_hashlimit.c +6 -6
index 40d344b..6809af5 100644
@@ -237,15 +237,15 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, int family)
 	hinfo->family = family;
 	hinfo->rnd_initialized = 0;
 	spin_lock_init(&hinfo->lock);
-	hinfo->pde = proc_create(minfo->name, 0,
+	hinfo->pde =
+		proc_create_data(minfo->name, 0,
 				 family == AF_INET ? hashlimit_procdir4 :
 						     hashlimit_procdir6,
-				 &dl_file_ops);
+				 &dl_file_ops, hinfo);
 	if (!hinfo->pde) {
 		vfree(hinfo);
 		return -1;
 	}
-	hinfo->pde->data = hinfo;
 
 	setup_timer(&hinfo->timer, htable_gc, (unsigned long )hinfo);
 	hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
@@ -301,15 +301,15 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo,
 	hinfo->rnd_initialized = 0;
 	spin_lock_init(&hinfo->lock);
 
-	hinfo->pde = proc_create(minfo->name, 0,
+	hinfo->pde =
+		proc_create_data(minfo->name, 0,
 				 family == AF_INET ? hashlimit_procdir4 :
 						     hashlimit_procdir6,
-				 &dl_file_ops);
+				 &dl_file_ops, hinfo);
 	if (hinfo->pde == NULL) {
 		vfree(hinfo);
 		return -1;
 	}
-	hinfo->pde->data = hinfo;
 
 	setup_timer(&hinfo->timer, htable_gc, (unsigned long)hinfo);
 	hinfo->timer.expires = jiffies + msecs_to_jiffies(hinfo->cfg.gc_interval);
Signature · 1 line
1.5.3.rc5
maintainer Applied
#4 lore raw

Re: [PATCH 2/12] netfilter: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:12 +0400

Quoted 6 lines

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>

Applied, with Patrick's ACK.

#5 lore raw

PATCH 3/12 net: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data. Additionally, there is no need to assign NULL to PDE->data after creation, /proc generic has already done this for us.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc David S. Miller <[email protected]>
---
 net/core/neighbour.c |    5 ++---
 net/core/pktgen.c    |   14 +++++---------
 2 files changed, 7 insertions(+), 12 deletions(-)
net/core/neighbour.c +2 -3
index 75075c3..f4f9a63 100644
@@ -1430,11 +1430,10 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
 		panic("cannot create neighbour cache statistics");
 
 #ifdef CONFIG_PROC_FS
-	tbl->pde = proc_create(tbl->id, 0, init_net.proc_net_stat,
-			       &neigh_stat_seq_fops);
+	tbl->pde = proc_create_data(tbl->id, 0, init_net.proc_net_stat,
+				    &neigh_stat_seq_fops, tbl);
 	if (!tbl->pde)
 		panic("cannot create neighbour proc dir entry");
-	tbl->pde->data = tbl;
 #endif
 
 	tbl->hash_mask = 1;
net/core/pktgen.c +4 -8
index a803b44..48a48c8 100644
@@ -3570,15 +3570,14 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
 	if (err)
 		goto out1;
 
-	pkt_dev->entry = proc_create(ifname, 0600,
-				     pg_proc_dir, &pktgen_if_fops);
+	pkt_dev->entry = proc_create_data(ifname, 0600, pg_proc_dir,
+					  &pktgen_if_fops, pkt_dev);
 	if (!pkt_dev->entry) {
 		printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
 		       PG_PROC_DIR, ifname);
 		err = -EINVAL;
 		goto out2;
 	}
-	pkt_dev->entry->data = pkt_dev;
 #ifdef CONFIG_XFRM
 	pkt_dev->ipsmode = XFRM_MODE_TRANSPORT;
 	pkt_dev->ipsproto = IPPROTO_ESP;
@@ -3628,7 +3627,8 @@ static int __init pktgen_create_thread(int cpu)
 	kthread_bind(p, cpu);
 	t->tsk = p;
 
-	pe = proc_create(t->tsk->comm, 0600, pg_proc_dir, &pktgen_thread_fops);
+	pe = proc_create_data(t->tsk->comm, 0600, pg_proc_dir,
+			      &pktgen_thread_fops, t);
 	if (!pe) {
 		printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
 		       PG_PROC_DIR, t->tsk->comm);
@@ -3638,8 +3638,6 @@ static int __init pktgen_create_thread(int cpu)
 		return -EINVAL;
 	}
 
-	pe->data = t;
-
 	wake_up_process(p);
 
 	return 0;
@@ -3716,8 +3714,6 @@ static int __init pg_init(void)
 		return -EINVAL;
 	}
 
-	pe->data = NULL;
-
 	/* Register us to receive netdevice events */
 	register_netdevice_notifier(&pktgen_notifier_block);
 
Signature · 1 line
1.5.3.rc5
maintainer Applied
#6 lore raw

Re: [PATCH 3/12] net: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:13 +0400

Quoted 5 lines

Simply replace proc_create and further data assigned with proc_create_data. Additionally, there is no need to assign NULL to PDE->data after creation, /proc generic has already done this for us.

Applied, thanks.

#7 lore raw

PATCH 4/12 ipv6: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Hideaki YOSHIFUJI <[email protected]>
---
 net/ipv6/proc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
net/ipv6/proc.c +2 -4
index ca8b82f..df0736a 100644
@@ -247,13 +247,11 @@ int snmp6_register_dev(struct inet6_dev *idev)
 	if (!proc_net_devsnmp6)
 		return -ENOENT;
 
-	p = proc_create(idev->dev->name, S_IRUGO,
-			proc_net_devsnmp6, &snmp6_seq_fops);
+	p = proc_create_data(idev->dev->name, S_IRUGO,
+			     proc_net_devsnmp6, &snmp6_seq_fops, idev);
 	if (!p)
 		return -ENOMEM;
 
-	p->data = idev;
-
 	idev->stats.proc_dir_entry = p;
 	return 0;
 }
Signature · 1 line
1.5.3.rc5
maintainer Applied
#8 lore raw

Re: [PATCH 4/12] ipv6: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:14 +0400

Quoted 3 lines

Simply replace proc_create and further data assigned with proc_create_data.

Applied, thanks.

#9 lore raw

PATCH 5/12 atm: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data. proc_atm_dev_ops holds proper referrence.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Chas Williams <[email protected]>
---
 net/atm/proc.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
net/atm/proc.c +2 -4
index 5c9f3d1..49487b3 100644
@@ -417,12 +417,10 @@ int atm_proc_dev_register(struct atm_dev *dev)
 		goto err_out;
 	sprintf(dev->proc_name,"%s:%d",dev->type, dev->number);
 
-	dev->proc_entry = proc_create(dev->proc_name, 0, atm_proc_root,
-				      &proc_atm_dev_ops);
+	dev->proc_entry = proc_create_data(dev->proc_name, 0, atm_proc_root,
+					   &proc_atm_dev_ops, dev);
 	if (!dev->proc_entry)
 		goto err_free_name;
-	dev->proc_entry->data = dev;
-	dev->proc_entry->owner = THIS_MODULE;
 	return 0;
 err_free_name:
 	kfree(dev->proc_name);
Signature · 1 line
1.5.3.rc5
maintainer Applied
#10 lore raw

Re: [PATCH 5/12] atm: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:15 +0400

Quoted 4 lines

Simply replace proc_create and further data assigned with proc_create_data. proc_atm_dev_ops holds proper referrence.

Applied.

#11 lore raw

PATCH 6/12 vlan: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/8021q/vlanproc.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
net/8021q/vlanproc.c +3 -4
index daad006..08b54b5 100644
@@ -176,12 +176,11 @@ int vlan_proc_add_dev(struct net_device *vlandev)
 	struct vlan_dev_info *dev_info = vlan_dev_info(vlandev);
 	struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
 
-	dev_info->dent = proc_create(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
-				     vn->proc_vlan_dir, &vlandev_fops);
+	dev_info->dent =
+		proc_create_data(vlandev->name, S_IFREG|S_IRUSR|S_IWUSR,
+				 vn->proc_vlan_dir, &vlandev_fops, vlandev);
 	if (!dev_info->dent)
 		return -ENOBUFS;
-
-	dev_info->dent->data = vlandev;
 	return 0;
 }
 
Signature · 1 line
1.5.3.rc5
maintainer Applied
#12 lore raw

Re: [PATCH 6/12] vlan: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:16 +0400

Quoted 6 lines

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>

Applied, with Patrick's ACK.

Thanks.

#13 lore raw

PATCH 7/12 cciss: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/block/cciss.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/block/cciss.c +2 -6
index e539be5..e336b05 100644
@@ -428,13 +428,9 @@ static void __devinit cciss_procinit(int i)
 		proc_cciss = proc_mkdir("driver/cciss", NULL);
 	if (!proc_cciss)
 		return;
-	pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP |
+	pde = proc_create_data(hba[i]->devname, S_IWUSR | S_IRUSR | S_IRGRP |
 					S_IROTH, proc_cciss,
-					&cciss_proc_fops);
-	if (!pde)
-		return;
-
-	pde->data = hba[i];
+					&cciss_proc_fops, hba[i]);
 }
 #endif				/* CONFIG_PROC_FS */
 
Signature · 1 line
1.5.3.rc5
Acked-by on v1 7/12
#14 lore raw

RE: [PATCH 7/12] cciss: assign PDE->data before gluing PDE into /proc tree

Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Denis V. Lunev
Sent: Tuesday, April 29, 2008 6:13 AM
To: [email protected]
Cc: [email protected]; Denis V. Lunev; Alexey Dobriyan; Eric W. Biederman; ISS StorageDev; Greg Kroah-Hartman
Subject: [PATCH 7/12] cciss: assign PDE->data before gluing PDE into /proc tree

Quoted 8 lines

Simply replace proc_create and further data assigned with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 30 lines
---
 drivers/block/cciss.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/block/cciss.c +0 -1
index e539be5..e336b05 100644
@@ -428,13 +428,9 @@ static void __devinit cciss_procinit(int i)
                proc_cciss = proc_mkdir("driver/cciss", NULL);
        if (!proc_cciss)
                return;
-       pde = proc_create(hba[i]->devname, S_IWUSR | S_IRUSR

| S_IRGRP |

drivers/block/cciss.c +3 -6
+       pde = proc_create_data(hba[i]->devname, S_IWUSR | S_IRUSR |
+ S_IRGRP |
                                        S_IROTH, proc_cciss,
-                                       &cciss_proc_fops);
-       if (!pde)
-               return;
-
-       pde->data = hba[i];
+                                       &cciss_proc_fops, hba[i]);
 }
 #endif                         /* CONFIG_PROC_FS */
 
--

1.5.3.rc5

#15 lore raw

PATCH 8/12 powerpc: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Simply replace proc_create and further data assigned with proc_create_data. No need to check for data!=NULL after that.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 arch/powerpc/platforms/pseries/scanlog.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)
arch/powerpc/platforms/pseries/scanlog.c +2 -17
index e5b0ea8..7a76f63 100644
@@ -57,11 +57,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
         dp = PDE(inode);
  	data = (unsigned int *)dp->data;
 
-	if (!data) {
-		printk(KERN_ERR "scanlog: read failed no data\n");
-		return -EIO;
-	}
-
 	if (count > RTAS_DATA_BUF_SIZE)
 		count = RTAS_DATA_BUF_SIZE;
 
@@ -153,11 +148,6 @@ static int scanlog_open(struct inode * inode, struct file * file)
 	struct proc_dir_entry *dp = PDE(inode);
 	unsigned int *data = (unsigned int *)dp->data;
 
-	if (!data) {
-		printk(KERN_ERR "scanlog: open failed no data\n");
-		return -EIO;
-	}
-
 	if (data[0] != 0) {
 		/* This imperfect test stops a second copy of the
 		 * data (or a reset while data is being copied)
@@ -175,10 +165,6 @@ static int scanlog_release(struct inode * inode, struct file * file)
 	struct proc_dir_entry *dp = PDE(inode);
 	unsigned int *data = (unsigned int *)dp->data;
 
-	if (!data) {
-		printk(KERN_ERR "scanlog: release failed no data\n");
-		return -EIO;
-	}
 	data[0] = 0;
 
 	return 0;
@@ -207,12 +193,11 @@ static int __init scanlog_init(void)
 	if (!data)
 		goto err;
 
-	ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
-			  &scanlog_fops);
+	ent = proc_create_data("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
+			       &scanlog_fops, data);
 	if (!ent)
 		goto err;
 
-	ent->data = data;
 	proc_ppc64_scan_log_dump = ent;
 
 	return 0;
Signature · 1 line
1.5.3.rc5
#16 lore raw

PATCH 9/12 ipv4: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

The check for PDE->data != NULL becomes useless after the replacement of proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc David S. Miller <[email protected]>
---
 net/ipv4/tcp_ipv4.c |   10 +++-------
 net/ipv4/udp.c      |    7 +++----
 2 files changed, 6 insertions(+), 11 deletions(-)
net/ipv4/tcp_ipv4.c +3 -7
index 7766151..4d97b28 100644
@@ -2214,9 +2214,6 @@ static int tcp_seq_open(struct inode *inode, struct file *file)
 	struct tcp_iter_state *s;
 	int err;
 
-	if (unlikely(afinfo == NULL))
-		return -EINVAL;
-
 	err = seq_open_net(inode, file, &afinfo->seq_ops,
 			  sizeof(struct tcp_iter_state));
 	if (err < 0)
@@ -2241,10 +2238,9 @@ int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo)
 	afinfo->seq_ops.next		= tcp_seq_next;
 	afinfo->seq_ops.stop		= tcp_seq_stop;
 
-	p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-	if (p)
-		p->data = afinfo;
-	else
+	p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
+			     &afinfo->seq_fops, afinfo);
+	if (!p)
 		rc = -ENOMEM;
 	return rc;
 }
net/ipv4/udp.c +3 -4
index b053ac7..c19c491 100644
@@ -1605,10 +1605,9 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
 	afinfo->seq_ops.next		= udp_seq_next;
 	afinfo->seq_ops.stop		= udp_seq_stop;
 
-	p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-	if (p)
-		p->data = afinfo;
-	else
+	p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
+			     &afinfo->seq_fops, afinfo);
+	if (!p)
 		rc = -ENOMEM;
 	return rc;
 }
Signature · 1 line
1.5.3.rc5
maintainer Applied
#17 lore raw

Re: [PATCH 9/12] ipv4: assign PDE->data before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:19 +0400

Quoted 4 lines

The check for PDE->data != NULL becomes useless after the replacement of proc_net_fops_create with proc_create_data.

Applied.

#18 lore raw

Re: [PATCH 9/12] ipv4: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

First off, sorry to bring such an old email back but I can seem to get a bad feeling when looking back over it.

Quoted 17 lines · Denis V. Lunev

The check for PDE->data != NULL becomes useless after the replacement of proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc David S. Miller <[email protected]>
---
 net/ipv4/tcp_ipv4.c |   10 +++-------
 net/ipv4/udp.c      |    7 +++----
 2 files changed, 6 insertions(+), 11 deletions(-)
net/ipv4/tcp_ipv4.c +0 -0
index 7766151..4d97b28 100644

net/ipv4/tcp_ipv4.c static int tcp_seq_open(struct inode *inode, struct file *file) · line 2218

Quoted 5 lines
net/ipv4/tcp_ipv4.c +0 -2
@@ -2214,9 +2214,6 @@ static int tcp_seq_open(struct inode *inode, struct file *file)
       struct tcp_iter_state *s;
       int err;
 
-       if (unlikely(afinfo == NULL))
-               return -EINVAL;

I think that this check needs to stay in some form, reason below.

net/ipv4/tcp_ipv4.c int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) · line 2241

Quoted 13 lines
net/ipv4/tcp_ipv4.c +1 -5
-
       err = seq_open_net(inode, file, &afinfo->seq_ops,
                         sizeof(struct tcp_iter_state));
       if (err < 0)
@@ -2241,10 +2238,9 @@ int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo)
       afinfo->seq_ops.next            = tcp_seq_next;
       afinfo->seq_ops.stop            = tcp_seq_stop;
 
-       p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-       if (p)
-               p->data = afinfo;
-       else
+       p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,

When you try to pass in afinfo->name (and also the seq_fops) you are assuming that afinfo is not null meaning in the unlikely(as shown above) even that it is null you get a very bad null pointer problem. If I am just way off do let me know because this just seams to me like a bad idea. This is also still present in 2.6.26-rc9.

-Stoyan G

Quoted 32 lines
net/ipv4/tcp_ipv4.c +2 -0
+                            &afinfo->seq_fops, afinfo);
+       if (!p)
               rc = -ENOMEM;
       return rc;
 }
net/ipv4/udp.c +3 -5
index b053ac7..c19c491 100644
@@ -1605,10 +1605,9 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo)
       afinfo->seq_ops.next            = udp_seq_next;
       afinfo->seq_ops.stop            = udp_seq_stop;
 
-       p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-       if (p)
-               p->data = afinfo;
-       else
+       p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
+                            &afinfo->seq_fops, afinfo);
+       if (!p)
               rc = -ENOMEM;
       return rc;
 }
--

1.5.3.rc5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#19 lore raw

Re: [PATCH 9/12] ipv4: assign PDE->data before gluing PDE into /proc tree

Quoted 43 lines · Stoyan Gaydarov

First off, sorry to bring such an old email back but I can seem to get a bad feeling when looking back over it.

net/ipv4/tcp_ipv4.c static int tcp_seq_open(struct inode *inode, struct file

Quoted 17 lines · Denis V. Lunev

The check for PDE->data != NULL becomes useless after the replacement of proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc David S. Miller <[email protected]>
---
 net/ipv4/tcp_ipv4.c |   10 +++-------
 net/ipv4/udp.c      |    7 +++----
 2 files changed, 6 insertions(+), 11 deletions(-)
net/ipv4/tcp_ipv4.c +0 -0
index 7766151..4d97b28 100644
@@ -2214,9 +2214,6 @@ static int tcp_seq_open(struct inode *inode, struct file

*file)

net/ipv4/tcp_ipv4.c static int tcp_seq_open(struct inode *inode, struct file *file) · line 2218

Quoted 5 lines
net/ipv4/tcp_ipv4.c +0 -2
       struct tcp_iter_state *s;
       int err;
 
-       if (unlikely(afinfo == NULL))
-               return -EINVAL;

I think that this check needs to stay in some form, reason below.

net/ipv4/tcp_ipv4.c int tcp_proc_register(struct net *net, struct

Quoted 5 lines
net/ipv4/tcp_ipv4.c +0 -1
-
       err = seq_open_net(inode, file, &afinfo->seq_ops,
                         sizeof(struct tcp_iter_state));
       if (err < 0)
@@ -2241,10 +2238,9 @@ int tcp_proc_register(struct net *net, struct

tcp_seq_afinfo *afinfo)

net/ipv4/tcp_ipv4.c int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) · line 2241

Quoted 8 lines
net/ipv4/tcp_ipv4.c +1 -4
       afinfo->seq_ops.next            = tcp_seq_next;
       afinfo->seq_ops.stop            = tcp_seq_stop;
 
- p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-       if (p)
-               p->data = afinfo;
-       else
+       p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,
Quoted 5 lines

When you try to pass in afinfo->name (and also the seq_fops) you are assuming that afinfo is not null meaning in the unlikely(as shown above) even that it is null you get a very bad null pointer problem. If I am just way off do let me know because this just seams to me like a bad idea. This is also still present in 2.6.26-rc9.

It appears you are getting things confused. The original window is that tcp_seq_open (which is what get called when you open the proc file) had a small race that p->data could be read before it was set.

With proc_create_data that race was closed.

You are saying that it is a problem for tcp_seq_open to be passed a NULL afinfo. It is. That has nothing to do with the original race (as that is a very different part of the code). Feel free to audit all of the callers if you like. That problem however is not subtle or racy.

So I see nothing wrong with this patch unless you can find a problem with proc_create_data.

Eric

#20 lore raw

Re: [PATCH 9/12] ipv4: assign PDE->data before gluing PDE into /proc tree

In reply to Stoyan Gaydarov
Quoted 35 lines · Stoyan Gaydarov

First off, sorry to bring such an old email back but I can seem to get a bad feeling when looking back over it.

Quoted 17 lines · Denis V. Lunev

The check for PDE->data != NULL becomes useless after the replacement of proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc David S. Miller <[email protected]>
---
 net/ipv4/tcp_ipv4.c |   10 +++-------
 net/ipv4/udp.c      |    7 +++----
 2 files changed, 6 insertions(+), 11 deletions(-)
net/ipv4/tcp_ipv4.c +0 -0
index 7766151..4d97b28 100644

net/ipv4/tcp_ipv4.c static int tcp_seq_open(struct inode *inode, struct file *file) · line 2218

Quoted 5 lines
net/ipv4/tcp_ipv4.c +0 -2
@@ -2214,9 +2214,6 @@ static int tcp_seq_open(struct inode *inode, struct file *file)
       struct tcp_iter_state *s;
       int err;
 
-       if (unlikely(afinfo == NULL))
-               return -EINVAL;

I think that this check needs to stay in some form, reason below.

Quoted 8 lines
net/ipv4/tcp_ipv4.c +0 -1
-
       err = seq_open_net(inode, file, &afinfo->seq_ops,
                         sizeof(struct tcp_iter_state));
       if (err < 0)
@@ -2241,10 +2238,9 @@ int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo)
       afinfo->seq_ops.next            = tcp_seq_next;
       afinfo->seq_ops.stop            = tcp_seq_stop;
 
Quoted 11 lines

net/ipv4/tcp_ipv4.c int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) · line 2241

Quoted 5 lines
net/ipv4/tcp_ipv4.c +1 -4
-       p = proc_net_fops_create(net, afinfo->name, S_IRUGO, &afinfo->seq_fops);
-       if (p)
-               p->data = afinfo;
-       else
+       p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net,

When you try to pass in afinfo->name (and also the seq_fops) you are assuming that afinfo is not null meaning in the unlikely(as shown above) even that it is null you get a very bad null pointer problem. If I am just way off do let me know because this just seams to me like a bad idea. This is also still present in 2.6.26-rc9.

The reason to remove the check is simple - afinfo comes in the form of the static pointer during init time. It is impossible to face NULL pointer the problem in the reality. It can come as the programmer mistake, but the OOPS will be immediate and straightforward. Namely, the kernel will not boot/work at all.

Regards,
Den

#21 lore raw

PATCH 10/12 netfilter: assign PDE->fops before gluing PDE into /proc tree

In reply to Denis V. Lunev

Replace create_proc_entry with specially created for this purpose proc_create.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/netfilter/nf_conntrack_standalone.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
net/netfilter/nf_conntrack_standalone.c +3 -3
index b59871f..46ea542 100644
@@ -296,11 +296,11 @@ static int nf_conntrack_standalone_init_proc(void)
 	pde = proc_net_fops_create(&init_net, "nf_conntrack", 0440, &ct_file_ops);
 	if (!pde)
 		goto out_nf_conntrack;
-	pde = create_proc_entry("nf_conntrack", S_IRUGO, init_net.proc_net_stat);
+
+	pde = proc_create("nf_conntrack", S_IRUGO, init_net.proc_net_stat,
+			  &ct_cpu_seq_fops);
 	if (!pde)
 		goto out_stat_nf_conntrack;
-	pde->proc_fops = &ct_cpu_seq_fops;
-	pde->owner = THIS_MODULE;
 	return 0;
 
 out_stat_nf_conntrack:
Signature · 1 line
1.5.3.rc5
maintainer Applied
#22 lore raw

Re: [PATCH 10/12] netfilter: assign PDE->fops before gluing PDE into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:20 +0400

Quoted 6 lines

Replace create_proc_entry with specially created for this purpose proc_create.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>

Applied, with Patrick's ACK.

#23 lore raw

PATCH 11/12 netfilter: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

Replace proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>
---
 net/netfilter/x_tables.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
net/netfilter/x_tables.c +6 -7
index f52f7f8..c3aa45b 100644
@@ -936,25 +936,24 @@ int xt_proto_init(struct net *net, int af)
 #ifdef CONFIG_PROC_FS
 	strlcpy(buf, xt_prefix[af], sizeof(buf));
 	strlcat(buf, FORMAT_TABLES, sizeof(buf));
-	proc = proc_net_fops_create(net, buf, 0440, &xt_table_ops);
+	proc = proc_create_data(buf, 0440, net->proc_net, &xt_table_ops,
+				(void *)(unsigned long)af);
 	if (!proc)
 		goto out;
-	proc->data = (void *)(unsigned long)af;
-
 
 	strlcpy(buf, xt_prefix[af], sizeof(buf));
 	strlcat(buf, FORMAT_MATCHES, sizeof(buf));
-	proc = proc_net_fops_create(net, buf, 0440, &xt_match_ops);
+	proc = proc_create_data(buf, 0440, net->proc_net, &xt_match_ops,
+				(void *)(unsigned long)af);
 	if (!proc)
 		goto out_remove_tables;
-	proc->data = (void *)(unsigned long)af;
 
 	strlcpy(buf, xt_prefix[af], sizeof(buf));
 	strlcat(buf, FORMAT_TARGETS, sizeof(buf));
-	proc = proc_net_fops_create(net, buf, 0440, &xt_target_ops);
+	proc = proc_create_data(buf, 0440, net->proc_net, &xt_target_ops,
+				(void *)(unsigned long)af);
 	if (!proc)
 		goto out_remove_matches;
-	proc->data = (void *)(unsigned long)af;
 #endif
 
 	return 0;
Signature · 1 line
1.5.3.rc5
maintainer Applied
#25 lore raw

Re: [PATCH 11/12] netfilter: assign PDE->data before gluing PDE into /proc tree

In reply to Denis V. Lunev

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:21 +0400

Quoted 6 lines

Replace proc_net_fops_create with proc_create_data.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Patrick McHardy <[email protected]>

Applied, with Patrick's ACK.

#26 lore raw

PATCH 12/12 netns: assign PDE->data before gluing entry into /proc tree

In reply to Denis V. Lunev

In this unfortunate case, proc_mkdir_mode wrapper can't be used anymore and this is no way to reuse proc_create_data due to nlinks assignment. So, copy the code from proc_mkdir and assign PDE->data at the appropriate moment.

Cc Alexey Dobriyan <[email protected]>
Cc Eric W. Biederman <[email protected]>
---
 fs/proc/generic.c  |   17 +++++++++++++++++
 fs/proc/proc_net.c |   11 -----------
 2 files changed, 17 insertions(+), 11 deletions(-)
fs/proc/generic.c +17 -0
index 9d53b39..43e54e8 100644
@@ -641,6 +641,23 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
 	return ent;
 }
 
+struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
+		struct proc_dir_entry *parent)
+{
+	struct proc_dir_entry *ent;
+
+	ent = __proc_create(&parent, name, S_IFDIR | S_IRUGO | S_IXUGO, 2);
+	if (ent) {
+		ent->data = net;
+		if (proc_register(parent, ent) < 0) {
+			kfree(ent);
+			ent = NULL;
+		}
+	}
+	return ent;
+}
+EXPORT_SYMBOL_GPL(proc_net_mkdir);
+
 struct proc_dir_entry *proc_mkdir(const char *name,
 		struct proc_dir_entry *parent)
 {
fs/proc/proc_net.c +0 -11
index 13cd783..83f357b 100644
@@ -159,17 +159,6 @@ struct net *get_proc_net(const struct inode *inode)
 }
 EXPORT_SYMBOL_GPL(get_proc_net);
 
-struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
-		struct proc_dir_entry *parent)
-{
-	struct proc_dir_entry *pde;
-	pde = proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent);
-	if (pde != NULL)
-		pde->data = net;
-	return pde;
-}
-EXPORT_SYMBOL_GPL(proc_net_mkdir);
-
 static __net_init int proc_net_ns_init(struct net *net)
 {
 	struct proc_dir_entry *netd, *net_statd;
Signature · 1 line
1.5.3.rc5
maintainer Applied
#27 lore raw

Re: [PATCH 12/12] netns: assign PDE->data before gluing entry into /proc tree

From: "Denis V. Lunev" <[email protected]>
Date: Tue, 29 Apr 2008 15:13:22 +0400

Quoted 6 lines

In this unfortunate case, proc_mkdir_mode wrapper can't be used anymore and this is no way to reuse proc_create_data due to nlinks assignment. So, copy the code from proc_mkdir and assign PDE->data at the appropriate moment.

Oh well, the cost of correctness sometimes :-)

Applied, thanks.