<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/fs/proc/inode.c, branch v2.6.32.31</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>proc 2/2: remove struct proc_dir_entry::owner</title>
<updated>2009-03-30T21:14:44+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2009-03-25T19:48:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=99b76233803beab302123d243eea9e41149804f3'/>
<id>99b76233803beab302123d243eea9e41149804f3</id>
<content type='text'>
Setting -&gt;owner as done currently (pde-&gt;owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
-&gt;owner, thus not pinning enything, and release it later resulting
in module refcount underflow.

We can keep -&gt;owner and supply it at registration time like -&gt;proc_fops
and -&gt;data.

But this leaves -&gt;owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching -&gt;owner. -&gt;proc_fops is declared as "const" which should give
some thoughts.

-&gt;read_proc/-&gt;write_proc were just fixed to not require -&gt;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 -&gt;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 &lt;adobriyan@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Setting -&gt;owner as done currently (pde-&gt;owner = THIS_MODULE) is racy
as correctly noted at bug #12454. Someone can lookup entry with NULL
-&gt;owner, thus not pinning enything, and release it later resulting
in module refcount underflow.

We can keep -&gt;owner and supply it at registration time like -&gt;proc_fops
and -&gt;data.

But this leaves -&gt;owner as easy-manipulative field (just one C assignment)
and somebody will forget to unpin previous/pin current module when
switching -&gt;owner. -&gt;proc_fops is declared as "const" which should give
some thoughts.

-&gt;read_proc/-&gt;write_proc were just fixed to not require -&gt;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 -&gt;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 &lt;adobriyan@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc 1/2: do PDE usecounting even for -&gt;read_proc, -&gt;write_proc</title>
<updated>2009-03-30T21:14:27+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2009-02-20T14:04:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3dec7f59c370c7b58184d63293c3dc984d475840'/>
<id>3dec7f59c370c7b58184d63293c3dc984d475840</id>
<content type='text'>
struct proc_dir_entry::owner is going to be removed. Now it's only necessary
to protect PDEs which are using -&gt;read_proc, -&gt;write_proc hooks.

However, -&gt;owner assignments are racy and make it very easy for someone to switch
-&gt;owner on live PDE (as some subsystems do) without fixing refcounts and so on.

http://bugzilla.kernel.org/show_bug.cgi?id=12454

So, -&gt;owner is on death row.

Proxy file operations exist already (proc_file_operations), just bump usecount
when necessary.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
struct proc_dir_entry::owner is going to be removed. Now it's only necessary
to protect PDEs which are using -&gt;read_proc, -&gt;write_proc hooks.

However, -&gt;owner assignments are racy and make it very easy for someone to switch
-&gt;owner on live PDE (as some subsystems do) without fixing refcounts and so on.

http://bugzilla.kernel.org/show_bug.cgi?id=12454

So, -&gt;owner is on death row.

Proxy file operations exist already (proc_file_operations), just bump usecount
when necessary.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: proc_get_inode should de_put when inode already initialized</title>
<updated>2009-02-24T02:25:32+00:00</updated>
<author>
<name>Krzysztof Sachanowicz</name>
<email>analyzer1@gmail.com</email>
</author>
<published>2009-02-23T21:21:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=cac711211a039ae2e2dc6322ffb3c2279d093bf1'/>
<id>cac711211a039ae2e2dc6322ffb3c2279d093bf1</id>
<content type='text'>
de_get is called before every proc_get_inode, but corresponding de_put is
called only when dropping last reference to an inode. This might cause
something like
remove_proc_entry: /proc/stats busy, count=14496
to be printed to the syslog.

The fix is to call de_put in case of an already initialized inode in
proc_get_inode.

Signed-off-by: Krzysztof Sachanowicz &lt;analyzer1@gmail.com&gt;
Tested-by: Marcin Pilipczuk &lt;marcin.pilipczuk@gmail.com&gt;
Acked-by: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
de_get is called before every proc_get_inode, but corresponding de_put is
called only when dropping last reference to an inode. This might cause
something like
remove_proc_entry: /proc/stats busy, count=14496
to be printed to the syslog.

The fix is to call de_put in case of an already initialized inode in
proc_get_inode.

Signed-off-by: Krzysztof Sachanowicz &lt;analyzer1@gmail.com&gt;
Tested-by: Marcin Pilipczuk &lt;marcin.pilipczuk@gmail.com&gt;
Acked-by: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: stop using BKL</title>
<updated>2009-01-05T09:27:44+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-10-27T19:48:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b4df2b92d8461444fac429c75ba6e125c63056bc'/>
<id>b4df2b92d8461444fac429c75ba6e125c63056bc</id>
<content type='text'>
There are four BKL users in proc: de_put(), proc_lookup_de(),
proc_readdir_de(), proc_root_readdir(),

1) de_put()
-----------
de_put() is classic atomic_dec_and_test() refcount wrapper -- no BKL
needed. BKL doesn't matter to possible refcount leak as well.

2) proc_lookup_de()
-------------------
Walking PDE list is protected by proc_subdir_lock(), proc_get_inode() is
potentially blocking, all callers of proc_lookup_de() eventually end up
from -&gt;lookup hooks which is protected by directory's -&gt;i_mutex -- BKL
doesn't protect anything.

3) proc_readdir_de()
--------------------
"." and ".." part doesn't need BKL, walking PDE list is under
proc_subdir_lock, calling filldir callback is potentially blocking
because it writes to luserspace. All proc_readdir_de() callers
eventually come from -&gt;readdir hook which is under directory's
-&gt;i_mutex -- BKL doesn't protect anything.

4) proc_root_readdir_de()
-------------------------
proc_root_readdir_de is -&gt;readdir hook, see (3).

Since readdir hooks doesn't use BKL anymore, switch to
generic_file_llseek, since it also takes directory's i_mutex.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are four BKL users in proc: de_put(), proc_lookup_de(),
proc_readdir_de(), proc_root_readdir(),

1) de_put()
-----------
de_put() is classic atomic_dec_and_test() refcount wrapper -- no BKL
needed. BKL doesn't matter to possible refcount leak as well.

2) proc_lookup_de()
-------------------
Walking PDE list is protected by proc_subdir_lock(), proc_get_inode() is
potentially blocking, all callers of proc_lookup_de() eventually end up
from -&gt;lookup hooks which is protected by directory's -&gt;i_mutex -- BKL
doesn't protect anything.

3) proc_readdir_de()
--------------------
"." and ".." part doesn't need BKL, walking PDE list is under
proc_subdir_lock, calling filldir callback is potentially blocking
because it writes to luserspace. All proc_readdir_de() callers
eventually come from -&gt;readdir hook which is under directory's
-&gt;i_mutex -- BKL doesn't protect anything.

4) proc_root_readdir_de()
-------------------------
proc_root_readdir_de is -&gt;readdir hook, see (3).

Since readdir hooks doesn't use BKL anymore, switch to
generic_file_llseek, since it also takes directory's i_mutex.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: proc_init_inodecache() can't fail</title>
<updated>2008-10-23T09:27:50+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-10-16T23:43:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5bcd7ff9e1690dbdbccb2a1cb3c2ea8b8381c435'/>
<id>5bcd7ff9e1690dbdbccb2a1cb3c2ea8b8381c435</id>
<content type='text'>
kmem_cache creation code will panic, don't return anything.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
kmem_cache creation code will panic, don't return anything.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: fix return value of proc_reg_open() in "too late" case</title>
<updated>2008-10-10T00:18:54+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-10-02T20:18:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=300b994b74e75120dd1a48529552a44977e0a82a'/>
<id>300b994b74e75120dd1a48529552a44977e0a82a</id>
<content type='text'>
If -&gt;open() wasn't called, returning 0 is misleading and, theoretically,
oopsable:
1) remove_proc_entry clears -&gt;proc_fops, drops lock,
2) -&gt;open "succeeds",
3) -&gt;release oopses, because it assumes -&gt;open was called (single_release()).

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If -&gt;open() wasn't called, returning 0 is misleading and, theoretically,
oopsable:
1) remove_proc_entry clears -&gt;proc_fops, drops lock,
2) -&gt;open "succeeds",
3) -&gt;release oopses, because it assumes -&gt;open was called (single_release()).

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[PATCH] sanitize proc_sysctl</title>
<updated>2008-07-27T00:53:12+00:00</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2008-07-15T12:54:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=9043476f726802f4b00c96d0c4f418dde48d1304'/>
<id>9043476f726802f4b00c96d0c4f418dde48d1304</id>
<content type='text'>
* keep references to ctl_table_head and ctl_table in /proc/sys inodes
* grab the former during operations, use the latter for access to
  entry if that succeeds
* have -&gt;d_compare() check if table should be seen for one who does lookup;
  that allows us to avoid flipping inodes - if we have the same name resolve
  to different things, we'll just keep several dentries and -&gt;d_compare()
  will reject the wrong ones.
* have -&gt;lookup() and -&gt;readdir() scan the table of our inode first, then
  walk all ctl_table_header and scan -&gt;attached_by for those that are
  attached to our directory.
* implement -&gt;getattr().
* get rid of insane amounts of tree-walking
* get rid of the need to know dentry in -&gt;permission() and of the contortions
  induced by that.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* keep references to ctl_table_head and ctl_table in /proc/sys inodes
* grab the former during operations, use the latter for access to
  entry if that succeeds
* have -&gt;d_compare() check if table should be seen for one who does lookup;
  that allows us to avoid flipping inodes - if we have the same name resolve
  to different things, we'll just keep several dentries and -&gt;d_compare()
  will reject the wrong ones.
* have -&gt;lookup() and -&gt;readdir() scan the table of our inode first, then
  walk all ctl_table_header and scan -&gt;attached_by for those that are
  attached to our directory.
* implement -&gt;getattr().
* get rid of insane amounts of tree-walking
* get rid of the need to know dentry in -&gt;permission() and of the contortions
  induced by that.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>SL*B: drop kmem cache argument from constructor</title>
<updated>2008-07-26T19:00:07+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-07-26T02:45:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=51cc50685a4275c6a02653670af9f108a64e01cf'/>
<id>51cc50685a4275c6a02653670af9f108a64e01cf</id>
<content type='text'>
Kmem cache passed to constructor is only needed for constructors that are
themselves multiplexeres.  Nobody uses this "feature", nor does anybody uses
passed kmem cache in non-trivial way, so pass only pointer to object.

Non-trivial places are:
	arch/powerpc/mm/init_64.c
	arch/powerpc/mm/hugetlbpage.c

This is flag day, yes.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Acked-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Acked-by: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Cc: Jon Tollefson &lt;kniht@linux.vnet.ibm.com&gt;
Cc: Nick Piggin &lt;nickpiggin@yahoo.com.au&gt;
Cc: Matt Mackall &lt;mpm@selenic.com&gt;
[akpm@linux-foundation.org: fix arch/powerpc/mm/hugetlbpage.c]
[akpm@linux-foundation.org: fix mm/slab.c]
[akpm@linux-foundation.org: fix ubifs]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Kmem cache passed to constructor is only needed for constructors that are
themselves multiplexeres.  Nobody uses this "feature", nor does anybody uses
passed kmem cache in non-trivial way, so pass only pointer to object.

Non-trivial places are:
	arch/powerpc/mm/init_64.c
	arch/powerpc/mm/hugetlbpage.c

This is flag day, yes.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Acked-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Acked-by: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Cc: Jon Tollefson &lt;kniht@linux.vnet.ibm.com&gt;
Cc: Nick Piggin &lt;nickpiggin@yahoo.com.au&gt;
Cc: Matt Mackall &lt;mpm@selenic.com&gt;
[akpm@linux-foundation.org: fix arch/powerpc/mm/hugetlbpage.c]
[akpm@linux-foundation.org: fix mm/slab.c]
[akpm@linux-foundation.org: fix ubifs]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: remove pathetic remount code</title>
<updated>2008-07-25T17:53:45+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-07-25T08:48:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=a9bd4a3e070ba7494f154e1a11687a8a957d88dc'/>
<id>a9bd4a3e070ba7494f154e1a11687a8a957d88dc</id>
<content type='text'>
MS_RMT_MASK will unmask changes in do_remount_sb() anyway.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
MS_RMT_MASK will unmask changes in do_remount_sb() anyway.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>proc: always do -&gt;release</title>
<updated>2008-07-25T17:53:44+00:00</updated>
<author>
<name>Alexey Dobriyan</name>
<email>adobriyan@gmail.com</email>
</author>
<published>2008-07-25T08:48:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=881adb85358309ea9c6f707394002719982ec607'/>
<id>881adb85358309ea9c6f707394002719982ec607</id>
<content type='text'>
Current two-stage scheme of removing PDE emphasizes one bug in proc:

		open
				rmmod
				remove_proc_entry
		close

-&gt;release won't be called because -&gt;proc_fops were cleared.  In simple
cases it's small memory leak.

For every -&gt;open, -&gt;release has to be done.  List of openers is introduced
which is traversed at remove_proc_entry() if neeeded.

Discussions with Al long ago (sigh).

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Current two-stage scheme of removing PDE emphasizes one bug in proc:

		open
				rmmod
				remove_proc_entry
		close

-&gt;release won't be called because -&gt;proc_fops were cleared.  In simple
cases it's small memory leak.

For every -&gt;open, -&gt;release has to be done.  List of openers is introduced
which is traversed at remove_proc_entry() if neeeded.

Discussions with Al long ago (sigh).

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
