diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-03-25 15:48:06 -0400 |
---|---|---|
committer | Alexey Dobriyan <adobriyan@gmail.com> | 2009-03-30 17:14:44 -0400 |
commit | 99b76233803beab302123d243eea9e41149804f3 (patch) | |
tree | 398178210fe66845ccd6fa4258ba762a87e023ad /drivers/char | |
parent | 3dec7f59c370c7b58184d63293c3dc984d475840 (diff) |
proc 2/2: remove struct proc_dir_entry::owner
Setting ->owner as done currently (pde->owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
->owner, thus not pinning enything, and release it later resulting
in module refcount underflow.
We can keep ->owner and supply it at registration time like ->proc_fops
and ->data.
But this leaves ->owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching ->owner. ->proc_fops is declared as "const" which should give
some thoughts.
->read_proc/->write_proc were just fixed to not require ->owner for
protection.
rmmod'ed directories will be empty and return "." and ".." -- no harm.
And directories with tricky enough readdir and lookup shouldn't be modular.
We definitely don't want such modular code.
Removing ->owner will also make PDE smaller.
So, let's nuke it.
Kudos to Jeff Layton for reminding about this, let's say, oversight.
http://bugzilla.kernel.org/show_bug.cgi?id=12454
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 12 | ||||
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 6 |
2 files changed, 7 insertions, 11 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 7a88dfd4427b..e93fc8d22fb2 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c | |||
@@ -1944,7 +1944,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off, | |||
1944 | 1944 | ||
1945 | int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, | 1945 | int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, |
1946 | read_proc_t *read_proc, | 1946 | read_proc_t *read_proc, |
1947 | void *data, struct module *owner) | 1947 | void *data) |
1948 | { | 1948 | { |
1949 | int rv = 0; | 1949 | int rv = 0; |
1950 | #ifdef CONFIG_PROC_FS | 1950 | #ifdef CONFIG_PROC_FS |
@@ -1970,7 +1970,6 @@ int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, | |||
1970 | } else { | 1970 | } else { |
1971 | file->data = data; | 1971 | file->data = data; |
1972 | file->read_proc = read_proc; | 1972 | file->read_proc = read_proc; |
1973 | file->owner = owner; | ||
1974 | 1973 | ||
1975 | mutex_lock(&smi->proc_entry_lock); | 1974 | mutex_lock(&smi->proc_entry_lock); |
1976 | /* Stick it on the list. */ | 1975 | /* Stick it on the list. */ |
@@ -1993,23 +1992,21 @@ static int add_proc_entries(ipmi_smi_t smi, int num) | |||
1993 | smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); | 1992 | smi->proc_dir = proc_mkdir(smi->proc_dir_name, proc_ipmi_root); |
1994 | if (!smi->proc_dir) | 1993 | if (!smi->proc_dir) |
1995 | rv = -ENOMEM; | 1994 | rv = -ENOMEM; |
1996 | else | ||
1997 | smi->proc_dir->owner = THIS_MODULE; | ||
1998 | 1995 | ||
1999 | if (rv == 0) | 1996 | if (rv == 0) |
2000 | rv = ipmi_smi_add_proc_entry(smi, "stats", | 1997 | rv = ipmi_smi_add_proc_entry(smi, "stats", |
2001 | stat_file_read_proc, | 1998 | stat_file_read_proc, |
2002 | smi, THIS_MODULE); | 1999 | smi); |
2003 | 2000 | ||
2004 | if (rv == 0) | 2001 | if (rv == 0) |
2005 | rv = ipmi_smi_add_proc_entry(smi, "ipmb", | 2002 | rv = ipmi_smi_add_proc_entry(smi, "ipmb", |
2006 | ipmb_file_read_proc, | 2003 | ipmb_file_read_proc, |
2007 | smi, THIS_MODULE); | 2004 | smi); |
2008 | 2005 | ||
2009 | if (rv == 0) | 2006 | if (rv == 0) |
2010 | rv = ipmi_smi_add_proc_entry(smi, "version", | 2007 | rv = ipmi_smi_add_proc_entry(smi, "version", |
2011 | version_file_read_proc, | 2008 | version_file_read_proc, |
2012 | smi, THIS_MODULE); | 2009 | smi); |
2013 | #endif /* CONFIG_PROC_FS */ | 2010 | #endif /* CONFIG_PROC_FS */ |
2014 | 2011 | ||
2015 | return rv; | 2012 | return rv; |
@@ -4265,7 +4262,6 @@ static int ipmi_init_msghandler(void) | |||
4265 | return -ENOMEM; | 4262 | return -ENOMEM; |
4266 | } | 4263 | } |
4267 | 4264 | ||
4268 | proc_ipmi_root->owner = THIS_MODULE; | ||
4269 | #endif /* CONFIG_PROC_FS */ | 4265 | #endif /* CONFIG_PROC_FS */ |
4270 | 4266 | ||
4271 | setup_timer(&ipmi_timer, ipmi_timeout, 0); | 4267 | setup_timer(&ipmi_timer, ipmi_timeout, 0); |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 3000135f2ead..e58ea4cd55ce 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -2899,7 +2899,7 @@ static int try_smi_init(struct smi_info *new_smi) | |||
2899 | 2899 | ||
2900 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", | 2900 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "type", |
2901 | type_file_read_proc, | 2901 | type_file_read_proc, |
2902 | new_smi, THIS_MODULE); | 2902 | new_smi); |
2903 | if (rv) { | 2903 | if (rv) { |
2904 | printk(KERN_ERR | 2904 | printk(KERN_ERR |
2905 | "ipmi_si: Unable to create proc entry: %d\n", | 2905 | "ipmi_si: Unable to create proc entry: %d\n", |
@@ -2909,7 +2909,7 @@ static int try_smi_init(struct smi_info *new_smi) | |||
2909 | 2909 | ||
2910 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats", | 2910 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "si_stats", |
2911 | stat_file_read_proc, | 2911 | stat_file_read_proc, |
2912 | new_smi, THIS_MODULE); | 2912 | new_smi); |
2913 | if (rv) { | 2913 | if (rv) { |
2914 | printk(KERN_ERR | 2914 | printk(KERN_ERR |
2915 | "ipmi_si: Unable to create proc entry: %d\n", | 2915 | "ipmi_si: Unable to create proc entry: %d\n", |
@@ -2919,7 +2919,7 @@ static int try_smi_init(struct smi_info *new_smi) | |||
2919 | 2919 | ||
2920 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "params", | 2920 | rv = ipmi_smi_add_proc_entry(new_smi->intf, "params", |
2921 | param_read_proc, | 2921 | param_read_proc, |
2922 | new_smi, THIS_MODULE); | 2922 | new_smi); |
2923 | if (rv) { | 2923 | if (rv) { |
2924 | printk(KERN_ERR | 2924 | printk(KERN_ERR |
2925 | "ipmi_si: Unable to create proc entry: %d\n", | 2925 | "ipmi_si: Unable to create proc entry: %d\n", |