Re: [Bugme-new] [Bug 10737] New: pktgen procfs problem
From: Eric W. Biederman <hidden>
Date: 2008-05-20 01:20:26
Ben Greear [off-list ref] writes:
Denis V. Lunev wrote:quoted
could you consider this preliminary patch? It fixes the problem for me and Pavel agrees with it. The problem is that module_get is called for each file opening while module_put is called only when /proc inode is destroyed. So, lets put module counter if we are dealing with already initialised inode.
Acked-by: "Eric W. Biederman" <redacted>
quoted
------------------------------------------------------------------------diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 6f4e8dc..b08d100 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c@@ -425,7 +425,8 @@ struct inode *proc_get_inode(struct super_block *sb,unsigned int ino,quoted
} } unlock_new_inode(inode); - } + } else + module_put(de->owner); return inode; out_ino:I just tested this and it seems to fix my problem (I applied this to 2.6.25 kernel).
Looks good and it seems to follow the characterization.
proc_lookup -> proc_lookup_de -> proc_get_inode
Will happen each time a dentry is created for a name/inode.
Which is much easier now with multiple instances in
proc.
It looks like this bug an old bug that has existed since
commit e9543659715602e3180f00a227bb6db34141ac41
Author: Kirill Korotaev [off-list ref]
Date: Sun Oct 30 15:02:26 2005 -0800
[PATCH] proc: fix of error path in proc_get_inode()
This patch fixes incorrect error path in proc_get_inode(), when module
can't be get due to being unloaded. When try_module_get() fails, this
function puts de(!) and still returns inode with non-getted de.
There are still unresolved known bugs in proc yet to be fixed:
- proc_dir_entry tree is managed without any serialization
- create_proc_entry() doesn't setup de->owner anyhow,
so setting it later manually is inatomic.
- looks like almost all modules do not care whether
it's de->owner is set...
Signed-Off-By: Denis Lunev [off-list ref]
Signed-Off-By: Kirill Korotaev [off-list ref]
Signed-off-by: Andrew Morton [off-list ref]
Signed-off-by: Linus Torvalds [off-list ref]
Eric