<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/seq_file.c, branch v3.0.36</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/fs/seq_file.c?h=v3.0.36</id>
<link rel='self' href='https://git.amat.us/linux/atom/fs/seq_file.c?h=v3.0.36'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2011-12-21T20:57:36Z</updated>
<entry>
<title>fix apparmor dereferencing potentially freed dentry, sanitize __d_path() API</title>
<updated>2011-12-21T20:57:36Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2011-12-05T13:43:34Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=58a48c4b50249df1bebcedca479f6faa7091bd0e'/>
<id>urn:sha1:58a48c4b50249df1bebcedca479f6faa7091bd0e</id>
<content type='text'>
commit 02125a826459a6ad142f8d91c5b6357562f96615 upstream.

__d_path() API is asking for trouble and in case of apparmor d_namespace_path()
getting just that.  The root cause is that when __d_path() misses the root
it had been told to look for, it stores the location of the most remote ancestor
in *root.  Without grabbing references.  Sure, at the moment of call it had
been pinned down by what we have in *path.  And if we raced with umount -l, we
could have very well stopped at vfsmount/dentry that got freed as soon as
prepend_path() dropped vfsmount_lock.

It is safe to compare these pointers with pre-existing (and known to be still
alive) vfsmount and dentry, as long as all we are asking is "is it the same
address?".  Dereferencing is not safe and apparmor ended up stepping into
that.  d_namespace_path() really wants to examine the place where we stopped,
even if it's not connected to our namespace.  As the result, it looked
at -&gt;d_sb-&gt;s_magic of a dentry that might've been already freed by that point.
All other callers had been careful enough to avoid that, but it's really
a bad interface - it invites that kind of trouble.

The fix is fairly straightforward, even though it's bigger than I'd like:
	* prepend_path() root argument becomes const.
	* __d_path() is never called with NULL/NULL root.  It was a kludge
to start with.  Instead, we have an explicit function - d_absolute_root().
Same as __d_path(), except that it doesn't get root passed and stops where
it stops.  apparmor and tomoyo are using it.
	* __d_path() returns NULL on path outside of root.  The main
caller is show_mountinfo() and that's precisely what we pass root for - to
skip those outside chroot jail.  Those who don't want that can (and do)
use d_path().
	* __d_path() root argument becomes const.  Everyone agrees, I hope.
	* apparmor does *NOT* try to use __d_path() or any of its variants
when it sees that path-&gt;mnt is an internal vfsmount.  In that case it's
definitely not mounted anywhere and dentry_path() is exactly what we want
there.  Handling of sysctl()-triggered weirdness is moved to that place.
	* if apparmor is asked to do pathname relative to chroot jail
and __d_path() tells it we it's not in that jail, the sucker just calls
d_absolute_path() instead.  That's the other remaining caller of __d_path(),
BTW.
        * seq_path_root() does _NOT_ return -ENAMETOOLONG (it's stupid anyway -
the normal seq_file logics will take care of growing the buffer and redoing
the call of -&gt;show() just fine).  However, if it gets path not reachable
from root, it returns SEQ_SKIP.  The only caller adjusted (i.e. stopped
ignoring the return value as it used to do).

Reviewed-by: John Johansen &lt;john.johansen@canonical.com&gt;
ACKed-by: John Johansen &lt;john.johansen@canonical.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>fs: take dcache_lock inside __d_path</title>
<updated>2010-10-26T01:26:12Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@infradead.org</email>
</author>
<published>2010-10-10T09:36:21Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=be148247cfbe2422f5709e77d9c3e10b8a6394da'/>
<id>urn:sha1:be148247cfbe2422f5709e77d9c3e10b8a6394da</id>
<content type='text'>
All callers take dcache_lock just around the call to __d_path, so
take the lock into it in preparation of getting rid of dcache_lock.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>fs/seq_file.c: Remove unnecessary casts of private_data</title>
<updated>2010-09-23T11:28:23Z</updated>
<author>
<name>Joe Perches</name>
<email>joe@perches.com</email>
</author>
<published>2010-09-05T01:52:49Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=8209e2f46752914e94f65469b8312c42dc5d7d8f'/>
<id>urn:sha1:8209e2f46752914e94f65469b8312c42dc5d7d8f</id>
<content type='text'>
Signed-off-by: Joe Perches &lt;joe@perches.com&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
<entry>
<title>seq_file: fix new kernel-doc warnings</title>
<updated>2010-03-07T23:48:26Z</updated>
<author>
<name>Randy Dunlap</name>
<email>randy.dunlap@oracle.com</email>
</author>
<published>2010-03-04T17:37:12Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=138860b95359feee49a31fb12be87825e4cd84ac'/>
<id>urn:sha1:138860b95359feee49a31fb12be87825e4cd84ac</id>
<content type='text'>
Fix kernel-doc notation in new seq-file functions and
correct spelling.

Signed-off-by: Randy Dunlap &lt;randy.dunlap@oracle.com&gt;
Cc: Li Zefan &lt;lizf@cn.fujitsu.com&gt;
Cc: Alexander Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>seq_file: add RCU versions of new hlist/list iterators (v3)</title>
<updated>2010-02-22T23:45:54Z</updated>
<author>
<name>stephen hemminger</name>
<email>shemminger@vyatta.com</email>
</author>
<published>2010-02-22T07:57:17Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1cc523271ef0b6305c565a143e3d48f6fff826dd'/>
<id>urn:sha1:1cc523271ef0b6305c565a143e3d48f6fff826dd</id>
<content type='text'>
Many usages of seq_file use RCU protected lists, so non RCU
iterators will not work safely.

Signed-off-by: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>seq_file: Add helpers for iteration over a hlist</title>
<updated>2010-02-10T19:12:06Z</updated>
<author>
<name>Li Zefan</name>
<email>lizf@cn.fujitsu.com</email>
</author>
<published>2010-02-08T23:18:22Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=66655de6d132b726be64c324bc3f9ea366d20697'/>
<id>urn:sha1:66655de6d132b726be64c324bc3f9ea366d20697</id>
<content type='text'>
Some places in kernel need to iterate over a hlist in seq_file,
so provide some common helpers.

Signed-off-by: Li Zefan &lt;lizf@cn.fujitsu.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>vfs: seq_file: add helpers for data filling</title>
<updated>2009-09-24T11:47:35Z</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2009-09-21T12:48:36Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=f84398068d9c2babe41500504ef247ae07081857'/>
<id>urn:sha1:f84398068d9c2babe41500504ef247ae07081857</id>
<content type='text'>
Add two helpers that allow access to the seq_file's own buffer, but
hide the internal details of seq_files.

This allows easier implementation of special purpose filling
functions.  It also cleans up some existing functions which duplicated
the seq_file logic.

Make these inline functions in seq_file.h, as suggested by Al.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Acked-by: Hugh Dickins &lt;hugh.dickins@tiscali.co.uk&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>seq_file: return a negative error code when seq_path_root() fails.</title>
<updated>2009-09-24T11:47:29Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@i-love.sakura.ne.jp</email>
</author>
<published>2009-09-18T20:05:59Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7a62cc10215838286c747f86766063d5f01fcbd6'/>
<id>urn:sha1:7a62cc10215838286c747f86766063d5f01fcbd6</id>
<content type='text'>
seq_path_root() is returning a return value of successful __d_path()
instead of returning a negative value when mangle_path() failed.

This is not a bug so far because nobody is using return value of
seq_path_root().

Signed-off-by: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&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: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>seq_file: add function to write binary data</title>
<updated>2009-06-18T20:03:57Z</updated>
<author>
<name>Peter Oberparleiter</name>
<email>oberpar@linux.vnet.ibm.com</email>
</author>
<published>2009-06-17T23:28:05Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=0b923606e75f1ab672e25b14ac039a1cdcfa382f'/>
<id>urn:sha1:0b923606e75f1ab672e25b14ac039a1cdcfa382f</id>
<content type='text'>
seq_write() can be used to construct seq_files containing arbitrary data.
Required by the gcov-profiling interface to synthesize binary profiling
data files.

Signed-off-by: Peter Oberparleiter &lt;oberpar@linux.vnet.ibm.com&gt;
Cc: Andi Kleen &lt;andi@firstfloor.org&gt;
Cc: Huang Ying &lt;ying.huang@intel.com&gt;
Cc: Li Wei &lt;W.Li@Sun.COM&gt;
Cc: Michael Ellerman &lt;michaele@au1.ibm.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Heiko Carstens &lt;heicars2@linux.vnet.ibm.com&gt;
Cc: Martin Schwidefsky &lt;mschwid2@linux.vnet.ibm.com&gt;
Cc: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
Cc: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Cc: Sam Ravnborg &lt;sam@ravnborg.org&gt;
Cc: Jeff Dike &lt;jdike@addtoit.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>
</entry>
<entry>
<title>cpumask: fix seq_bitmap_*() functions.</title>
<updated>2009-03-30T11:35:11Z</updated>
<author>
<name>Rusty Russell</name>
<email>rusty@rustcorp.com.au</email>
</author>
<published>2009-03-31T04:05:11Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=af76aba00fdcfb21535c9f9872245d14097a4561'/>
<id>urn:sha1:af76aba00fdcfb21535c9f9872245d14097a4561</id>
<content type='text'>
1) seq_bitmap_list() should take a const.
2) All the seq_bitmap should use cpumask_bits().

Signed-off-by: Rusty Russell &lt;rusty@rustcorp.com.au&gt;
</content>
</entry>
</feed>
