Commit 8eeee8b1 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETFILTER]: Replate direct proc_fops assignment with proc_create call.

This elliminates infamous race during module loading when one could lookup
proc entry without proc_fops assigned.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 920fc941
...@@ -588,11 +588,9 @@ static int __init ip_queue_init(void) ...@@ -588,11 +588,9 @@ static int __init ip_queue_init(void)
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); proc = proc_create(IPQ_PROC_FS_NAME, 0, init_net.proc_net,
if (proc) { &ip_queue_proc_fops);
proc->owner = THIS_MODULE; if (!proc) {
proc->proc_fops = &ip_queue_proc_fops;
} else {
printk(KERN_ERR "ip_queue: failed to create proc entry\n"); printk(KERN_ERR "ip_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
......
...@@ -167,14 +167,13 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip, ...@@ -167,14 +167,13 @@ clusterip_config_init(struct ipt_clusterip_tgt_info *i, __be32 ip,
/* create proc dir entry */ /* create proc dir entry */
sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip)); sprintf(buffer, "%u.%u.%u.%u", NIPQUAD(ip));
c->pde = create_proc_entry(buffer, S_IWUSR|S_IRUSR, c->pde = proc_create(buffer, S_IWUSR|S_IRUSR,
clusterip_procdir); clusterip_procdir, &clusterip_proc_fops);
if (!c->pde) { if (!c->pde) {
kfree(c); kfree(c);
return NULL; return NULL;
} }
} }
c->pde->proc_fops = &clusterip_proc_fops;
c->pde->data = c; c->pde->data = c;
#endif #endif
......
...@@ -276,12 +276,11 @@ recent_mt_check(const char *tablename, const void *ip, ...@@ -276,12 +276,11 @@ recent_mt_check(const char *tablename, const void *ip,
for (i = 0; i < ip_list_hash_size; i++) for (i = 0; i < ip_list_hash_size; i++)
INIT_LIST_HEAD(&t->iphash[i]); INIT_LIST_HEAD(&t->iphash[i]);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
t->proc = create_proc_entry(t->name, ip_list_perms, proc_dir); t->proc = proc_create(t->name, ip_list_perms, proc_dir, &recent_fops);
if (t->proc == NULL) { if (t->proc == NULL) {
kfree(t); kfree(t);
goto out; goto out;
} }
t->proc->proc_fops = &recent_fops;
t->proc->uid = ip_list_uid; t->proc->uid = ip_list_uid;
t->proc->gid = ip_list_gid; t->proc->gid = ip_list_gid;
t->proc->data = t; t->proc->data = t;
......
...@@ -395,13 +395,10 @@ int __init nf_conntrack_ipv4_compat_init(void) ...@@ -395,13 +395,10 @@ int __init nf_conntrack_ipv4_compat_init(void)
if (!proc_exp) if (!proc_exp)
goto err2; goto err2;
proc_stat = create_proc_entry("ip_conntrack", S_IRUGO, init_net.proc_net_stat); proc_stat = proc_create("ip_conntrack", S_IRUGO,
init_net.proc_net_stat, &ct_cpu_seq_fops);
if (!proc_stat) if (!proc_stat)
goto err3; goto err3;
proc_stat->proc_fops = &ct_cpu_seq_fops;
proc_stat->owner = THIS_MODULE;
return 0; return 0;
err3: err3:
......
...@@ -591,11 +591,9 @@ static int __init ip6_queue_init(void) ...@@ -591,11 +591,9 @@ static int __init ip6_queue_init(void)
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); proc = proc_create(IPQ_PROC_FS_NAME, 0, init_net.proc_net,
if (proc) { &ip6_queue_proc_fops);
proc->owner = THIS_MODULE; if (!proc) {
proc->proc_fops = &ip6_queue_proc_fops;
} else {
printk(KERN_ERR "ip6_queue: failed to create proc entry\n"); printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
......
...@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid); ...@@ -395,7 +395,7 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid);
static int __init nf_conntrack_standalone_init(void) static int __init nf_conntrack_standalone_init(void)
{ {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc, *proc_stat; struct proc_dir_entry *proc;
#endif #endif
int ret = 0; int ret = 0;
...@@ -407,12 +407,9 @@ static int __init nf_conntrack_standalone_init(void) ...@@ -407,12 +407,9 @@ static int __init nf_conntrack_standalone_init(void)
proc = proc_net_fops_create(&init_net, "nf_conntrack", 0440, &ct_file_ops); proc = proc_net_fops_create(&init_net, "nf_conntrack", 0440, &ct_file_ops);
if (!proc) goto cleanup_init; if (!proc) goto cleanup_init;
proc_stat = create_proc_entry("nf_conntrack", S_IRUGO, init_net.proc_net_stat); if (!proc_create("nf_conntrack", S_IRUGO,
if (!proc_stat) init_net.proc_net_stat, &ct_cpu_seq_fops))
goto cleanup_proc; goto cleanup_proc;
proc_stat->proc_fops = &ct_cpu_seq_fops;
proc_stat->owner = THIS_MODULE;
#endif #endif
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
nf_ct_sysctl_header = register_sysctl_paths(nf_ct_path, nf_ct_sysctl_header = register_sysctl_paths(nf_ct_path,
......
...@@ -168,13 +168,9 @@ static const struct file_operations nflog_file_ops = { ...@@ -168,13 +168,9 @@ static const struct file_operations nflog_file_ops = {
int __init netfilter_log_init(void) int __init netfilter_log_init(void)
{ {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *pde; if (!proc_create("nf_log", S_IRUGO,
proc_net_netfilter, &nflog_file_ops))
pde = create_proc_entry("nf_log", S_IRUGO, proc_net_netfilter);
if (!pde)
return -1; return -1;
pde->proc_fops = &nflog_file_ops;
#endif #endif
return 0; return 0;
} }
...@@ -348,12 +348,9 @@ static const struct file_operations nfqueue_file_ops = { ...@@ -348,12 +348,9 @@ static const struct file_operations nfqueue_file_ops = {
int __init netfilter_queue_init(void) int __init netfilter_queue_init(void)
{ {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *pde; if (!proc_create("nf_queue", S_IRUGO,
proc_net_netfilter, &nfqueue_file_ops))
pde = create_proc_entry("nf_queue", S_IRUGO, proc_net_netfilter);
if (!pde)
return -1; return -1;
pde->proc_fops = &nfqueue_file_ops;
#endif #endif
return 0; return 0;
} }
......
...@@ -923,9 +923,6 @@ static const struct file_operations nful_file_ops = { ...@@ -923,9 +923,6 @@ static const struct file_operations nful_file_ops = {
static int __init nfnetlink_log_init(void) static int __init nfnetlink_log_init(void)
{ {
int i, status = -ENOMEM; int i, status = -ENOMEM;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nful;
#endif
for (i = 0; i < INSTANCE_BUCKETS; i++) for (i = 0; i < INSTANCE_BUCKETS; i++)
INIT_HLIST_HEAD(&instance_table[i]); INIT_HLIST_HEAD(&instance_table[i]);
...@@ -943,11 +940,9 @@ static int __init nfnetlink_log_init(void) ...@@ -943,11 +940,9 @@ static int __init nfnetlink_log_init(void)
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc_nful = create_proc_entry("nfnetlink_log", 0440, if (!proc_create("nfnetlink_log", 0440,
proc_net_netfilter); proc_net_netfilter, &nful_file_ops))
if (!proc_nful)
goto cleanup_subsys; goto cleanup_subsys;
proc_nful->proc_fops = &nful_file_ops;
#endif #endif
return status; return status;
......
...@@ -896,9 +896,6 @@ static const struct file_operations nfqnl_file_ops = { ...@@ -896,9 +896,6 @@ static const struct file_operations nfqnl_file_ops = {
static int __init nfnetlink_queue_init(void) static int __init nfnetlink_queue_init(void)
{ {
int i, status = -ENOMEM; int i, status = -ENOMEM;
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_nfqueue;
#endif
for (i = 0; i < INSTANCE_BUCKETS; i++) for (i = 0; i < INSTANCE_BUCKETS; i++)
INIT_HLIST_HEAD(&instance_table[i]); INIT_HLIST_HEAD(&instance_table[i]);
...@@ -911,11 +908,9 @@ static int __init nfnetlink_queue_init(void) ...@@ -911,11 +908,9 @@ static int __init nfnetlink_queue_init(void)
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
proc_nfqueue = create_proc_entry("nfnetlink_queue", 0440, if (!proc_create("nfnetlink_queue", 0440,
proc_net_netfilter); proc_net_netfilter, &nfqnl_file_ops))
if (!proc_nfqueue)
goto cleanup_subsys; goto cleanup_subsys;
proc_nfqueue->proc_fops = &nfqnl_file_ops;
#endif #endif
register_netdevice_notifier(&nfqnl_dev_notifier); register_netdevice_notifier(&nfqnl_dev_notifier);
......
...@@ -237,14 +237,14 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, int family) ...@@ -237,14 +237,14 @@ static int htable_create_v0(struct xt_hashlimit_info *minfo, int family)
hinfo->family = family; hinfo->family = family;
hinfo->rnd_initialized = 0; hinfo->rnd_initialized = 0;
spin_lock_init(&hinfo->lock); spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hinfo->pde = proc_create(minfo->name, 0,
family == AF_INET ? hashlimit_procdir4 : family == AF_INET ? hashlimit_procdir4 :
hashlimit_procdir6); hashlimit_procdir6,
&dl_file_ops);
if (!hinfo->pde) { if (!hinfo->pde) {
vfree(hinfo); vfree(hinfo);
return -1; return -1;
} }
hinfo->pde->proc_fops = &dl_file_ops;
hinfo->pde->data = hinfo; hinfo->pde->data = hinfo;
setup_timer(&hinfo->timer, htable_gc, (unsigned long )hinfo); setup_timer(&hinfo->timer, htable_gc, (unsigned long )hinfo);
...@@ -301,14 +301,14 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo, ...@@ -301,14 +301,14 @@ static int htable_create(struct xt_hashlimit_mtinfo1 *minfo,
hinfo->rnd_initialized = 0; hinfo->rnd_initialized = 0;
spin_lock_init(&hinfo->lock); spin_lock_init(&hinfo->lock);
hinfo->pde = create_proc_entry(minfo->name, 0, hinfo->pde = proc_create(minfo->name, 0,
family == AF_INET ? hashlimit_procdir4 : family == AF_INET ? hashlimit_procdir4 :
hashlimit_procdir6); hashlimit_procdir6,
&dl_file_ops);
if (hinfo->pde == NULL) { if (hinfo->pde == NULL) {
vfree(hinfo); vfree(hinfo);
return -1; return -1;
} }
hinfo->pde->proc_fops = &dl_file_ops;
hinfo->pde->data = hinfo; hinfo->pde->data = hinfo;
setup_timer(&hinfo->timer, htable_gc, (unsigned long)hinfo); setup_timer(&hinfo->timer, htable_gc, (unsigned long)hinfo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment