<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/fs/sysfs, branch v3.2.52</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.52</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.2.52'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-05-13T14:02:13Z</updated>
<entry>
<title>sysfs: fix use after free in case of concurrent read/write and readdir</title>
<updated>2013-05-13T14:02:13Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2013-04-02T02:12:26Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3a8aad02f417b5aecafdc785c39c0e2259995c69'/>
<id>urn:sha1:3a8aad02f417b5aecafdc785c39c0e2259995c69</id>
<content type='text'>
commit f7db5e7660b122142410dcf36ba903c73d473250 upstream.

The inode-&gt;i_mutex isn't hold when updating filp-&gt;f_pos
in read()/write(), so the filp-&gt;f_pos might be read as
0 or 1 in readdir() when there is concurrent read()/write()
on this same file, then may cause use after free in readdir().

The bug can be reproduced with Li Zefan's test code on the
link:

	https://patchwork.kernel.org/patch/2160771/

This patch fixes the use after free under this situation.

Reported-by: Li Zefan &lt;lizefan@huawei.com&gt;
Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
[bwh: Backported to 3.2: file position is child inode number, not hash]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>sysfs: handle failure path correctly for readdir()</title>
<updated>2013-04-10T02:20:01Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2013-03-20T15:25:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4f9347e4b59bdc29b17ff6c4b377195f208402b2'/>
<id>urn:sha1:4f9347e4b59bdc29b17ff6c4b377195f208402b2</id>
<content type='text'>
commit e5110f411d2ee35bf8d202ccca2e89c633060dca upstream.

In case of 'if (filp-&gt;f_pos ==  0 or 1)' of sysfs_readdir(),
the failure from filldir() isn't handled, and the reference counter
of the sysfs_dirent object pointed by filp-&gt;private_data will be
released without clearing filp-&gt;private_data, so use after free
bug will be triggered later.

This patch returns immeadiately under the situation for fixing the bug,
and it is reasonable to return from readdir() when filldir() fails.

Reported-by: Dave Jones &lt;davej@redhat.com&gt;
Tested-by: Sasha Levin &lt;levinsasha928@gmail.com&gt;
Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>sysfs: fix race between readdir and lseek</title>
<updated>2013-04-10T02:20:00Z</updated>
<author>
<name>Ming Lei</name>
<email>ming.lei@canonical.com</email>
</author>
<published>2013-03-20T15:25:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=76bfc5ab57137d351a9046a002ee39a220d0e012'/>
<id>urn:sha1:76bfc5ab57137d351a9046a002ee39a220d0e012</id>
<content type='text'>
commit 991f76f837bf22c5bb07261cfd86525a0a96650c upstream.

While readdir() is running, lseek() may set filp-&gt;f_pos as zero,
then may leave filp-&gt;private_data pointing to one sysfs_dirent
object without holding its reference counter, so the sysfs_dirent
object may be used after free in next readdir().

This patch holds inode-&gt;i_mutex to avoid the problem since
the lock is always held in readdir path.

Reported-by: Dave Jones &lt;davej@redhat.com&gt;
Tested-by: Sasha Levin &lt;levinsasha928@gmail.com&gt;
Signed-off-by: Ming Lei &lt;ming.lei@canonical.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
[bwh: Backported to 3.2: open-code file_inode() which we don't have]
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()</title>
<updated>2012-10-30T23:26:59Z</updated>
<author>
<name>Geert Uytterhoeven</name>
<email>geert@linux-m68k.org</email>
</author>
<published>2012-09-29T20:23:19Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6a026352765b0830d1e6f1fa2a8c1c0499fc1508'/>
<id>urn:sha1:6a026352765b0830d1e6f1fa2a8c1c0499fc1508</id>
<content type='text'>
commit 66081a72517a131430dcf986775f3268aafcb546 upstream.

The warning check for duplicate sysfs entries can cause a buffer overflow
when printing the warning, as strcat() doesn't check buffer sizes.
Use strlcat() instead.

Since strlcat() doesn't return a pointer to the passed buffer, unlike
strcat(), I had to convert the nested concatenation in sysfs_add_one() to
an admittedly more obscure comma operator construct, to avoid emitting code
for the concatenation if CONFIG_BUG is disabled.

Signed-off-by: Geert Uytterhoeven &lt;geert@linux-m68k.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Ben Hutchings &lt;ben@decadent.org.uk&gt;
</content>
</entry>
<entry>
<title>sysfs: Fix memory leak in sysfs_sd_setsecdata().</title>
<updated>2012-04-02T16:52:30Z</updated>
<author>
<name>Masami Ichikawa</name>
<email>masami256@gmail.com</email>
</author>
<published>2012-02-20T22:43:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=cbdbd450211dd493262c0573e7143e1bb0bf7892'/>
<id>urn:sha1:cbdbd450211dd493262c0573e7143e1bb0bf7892</id>
<content type='text'>
commit 93518dd2ebafcc761a8637b2877008cfd748c202 upstream.

This patch fixies follwing two memory leak patterns that reported by kmemleak.
sysfs_sd_setsecdata() is called during sys_lsetxattr() operation.
It checks sd-&gt;s_iattr is NULL or not. Then if it is NULL, it calls
sysfs_init_inode_attrs() to allocate memory.
That code is this.

iattrs = sd-&gt;s_iattr;
if (!iattrs)
                iattrs = sysfs_init_inode_attrs(sd);

The iattrs recieves sysfs_init_inode_attrs()'s result,  but sd-&gt;s_iattr
doesn't know the address. so it needs to set correct address to
sd-&gt;s_iattr to free memory in other function.

unreferenced object 0xffff880250b73e60 (size 32):
  comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
  hex dump (first 32 bytes):
    73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f  system_u:object_
    72 3a 73 79 73 66 73 5f 74 3a 73 30 00 00 00 00  r:sysfs_t:s0....
  backtrace:
    [&lt;ffffffff814cb1d0&gt;] kmemleak_alloc+0x73/0x98
    [&lt;ffffffff811270ab&gt;] __kmalloc+0x100/0x12c
    [&lt;ffffffff8120775a&gt;] context_struct_to_string+0x106/0x210
    [&lt;ffffffff81207cc1&gt;] security_sid_to_context_core+0x10b/0x129
    [&lt;ffffffff812090ef&gt;] security_sid_to_context+0x10/0x12
    [&lt;ffffffff811fb0da&gt;] selinux_inode_getsecurity+0x7d/0xa8
    [&lt;ffffffff811fb127&gt;] selinux_inode_getsecctx+0x22/0x2e
    [&lt;ffffffff811f4d62&gt;] security_inode_getsecctx+0x16/0x18
    [&lt;ffffffff81191dad&gt;] sysfs_setxattr+0x96/0x117
    [&lt;ffffffff811542f0&gt;] __vfs_setxattr_noperm+0x73/0xd9
    [&lt;ffffffff811543d9&gt;] vfs_setxattr+0x83/0xa1
    [&lt;ffffffff811544c6&gt;] setxattr+0xcf/0x101
    [&lt;ffffffff81154745&gt;] sys_lsetxattr+0x6a/0x8f
    [&lt;ffffffff814efda9&gt;] system_call_fastpath+0x16/0x1b
    [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff
unreferenced object 0xffff88024163c5a0 (size 96):
  comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
  hex dump (first 32 bytes):
    00 00 00 00 ed 41 00 00 00 00 00 00 00 00 00 00  .....A..........
    00 00 00 00 00 00 00 00 0c 64 42 4f 00 00 00 00  .........dBO....
  backtrace:
    [&lt;ffffffff814cb1d0&gt;] kmemleak_alloc+0x73/0x98
    [&lt;ffffffff81127402&gt;] kmem_cache_alloc_trace+0xc4/0xee
    [&lt;ffffffff81191cbe&gt;] sysfs_init_inode_attrs+0x2a/0x83
    [&lt;ffffffff81191dd6&gt;] sysfs_setxattr+0xbf/0x117
    [&lt;ffffffff811542f0&gt;] __vfs_setxattr_noperm+0x73/0xd9
    [&lt;ffffffff811543d9&gt;] vfs_setxattr+0x83/0xa1
    [&lt;ffffffff811544c6&gt;] setxattr+0xcf/0x101
    [&lt;ffffffff81154745&gt;] sys_lsetxattr+0x6a/0x8f
    [&lt;ffffffff814efda9&gt;] system_call_fastpath+0x16/0x1b
    [&lt;ffffffffffffffff&gt;] 0xffffffffffffffff
`

Signed-off-by: Masami Ichikawa &lt;masami256@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>sysfs: Complain bitterly about attempts to remove files from nonexistent directories.</title>
<updated>2012-02-03T17:21:47Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2012-01-14T05:32:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bfd534c72bec682cbf1017e54f0749aac24840eb'/>
<id>urn:sha1:bfd534c72bec682cbf1017e54f0749aac24840eb</id>
<content type='text'>
commit ce597919361dcec97341151690e780eade2a9cf4 upstream.

Recently an OOPS was observed from the usb serial io_ti driver when it tried to remove
sysfs directories.  Upon investigation it turns out this driver was always buggy
and that a recent sysfs change had stopped guarding itself against removing attributes
from sysfs directories that had already been removed. :(

Historically we have been silent about attempting to files from nonexistent sysfs
directories and have politely returned error codes.  That has resulted in people writing
broken code that ignores the error codes.

Issue a kernel WARNING and a stack backtrace to make it clear in no uncertain
terms that abusing sysfs is not ok, and the callers need to fix their code.

This change transforms the io_ti OOPS into a more comprehensible error message
and stack backtrace.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Reported-by: Wolfgang Frisch &lt;wfpub@roembden.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>filesystems: add set_nlink()</title>
<updated>2011-11-02T11:53:43Z</updated>
<author>
<name>Miklos Szeredi</name>
<email>mszeredi@suse.cz</email>
</author>
<published>2011-10-28T12:13:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bfe8684869601dacfcb2cd69ef8cfd9045f62170'/>
<id>urn:sha1:bfe8684869601dacfcb2cd69ef8cfd9045f62170</id>
<content type='text'>
Replace remaining direct i_nlink updates with a new set_nlink()
updater function.

Signed-off-by: Miklos Szeredi &lt;mszeredi@suse.cz&gt;
Tested-by: Toshiyuki Okajima &lt;toshi.okajima@jp.fujitsu.com&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
</content>
</entry>
<entry>
<title>sysfs: Make sysfs_rename safe with sysfs_dirents in rbtrees.</title>
<updated>2011-11-01T16:16:14Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-11-01T14:06:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f6d90b4f9ce018bff429d6e01ee672de712b8641'/>
<id>urn:sha1:f6d90b4f9ce018bff429d6e01ee672de712b8641</id>
<content type='text'>
In sysfs_rename we need to remove the optimization of not calling
sysfs_unlink_sibling and sysfs_link_sibling if the renamed parent
directory is not changing.  This optimization is no longer valid now
that sysfs dirents are stored in an rbtree sorted by name.

Move the assignment of s_ns before the call of sysfs_link_sibling.  With
no sysfs_dirent fields changing after the call of sysfs_link_sibling
this allows sysfs_link_sibling to take any of the directory entries into
account when it builds the rbtrees, and s_ns looks like a prime canidate
to be used in the rbtree in the future.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Jiri Slaby &lt;jirislaby@gmail.com&gt;
Cc: Greg KH &lt;gregkh@suse.de&gt;
Cc: David Miller &lt;davem@davemloft.net&gt;
Cc: Mikulas Patocka &lt;mpatocka@redhat.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs: Remove support for tagged directories with untagged members (again)</title>
<updated>2011-10-25T13:10:28Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-10-25T12:38:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b9e2780d576a010d4aba1e69f247170bf3718d6b'/>
<id>urn:sha1:b9e2780d576a010d4aba1e69f247170bf3718d6b</id>
<content type='text'>
In commit 8a9ea3237e7e ("Merge git://.../davem/net-next") where my sysfs
changes from the net tree merged with the sysfs rbtree changes from
Mickulas Patocka the conflict resolution failed to preserve the
simplified property that was the point of my changes.

That is sysfs_find_dirent can now say something is a match if and only
s_name and s_ns match what we are looking for, and sysfs_readdir can
simply return all of the directory entries where s_ns matches the
directory that we should be returning.

Now that we are back to exact matches we can tweak sysfs_find_dirent and
the name rb_tree to order sysfs_dirents by s_ns s_name and remove the
second loop in sysfs_find_dirent.  However that change seems a bit much
for a conflict resolution so it can come later.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next</title>
<updated>2011-10-25T11:25:22Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2011-10-25T11:25:22Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8a9ea3237e7eb5c25f09e429ad242ae5a3d5ea22'/>
<id>urn:sha1:8a9ea3237e7eb5c25f09e429ad242ae5a3d5ea22</id>
<content type='text'>
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1745 commits)
  dp83640: free packet queues on remove
  dp83640: use proper function to free transmit time stamping packets
  ipv6: Do not use routes from locally generated RAs
  |PATCH net-next] tg3: add tx_dropped counter
  be2net: don't create multiple RX/TX rings in multi channel mode
  be2net: don't create multiple TXQs in BE2
  be2net: refactor VF setup/teardown code into be_vf_setup/clear()
  be2net: add vlan/rx-mode/flow-control config to be_setup()
  net_sched: cls_flow: use skb_header_pointer()
  ipv4: avoid useless call of the function check_peer_pmtu
  TCP: remove TCP_DEBUG
  net: Fix driver name for mdio-gpio.c
  ipv4: tcp: fix TOS value in ACK messages sent from TIME_WAIT
  rtnetlink: Add missing manual netlink notification in dev_change_net_namespaces
  ipv4: fix ipsec forward performance regression
  jme: fix irq storm after suspend/resume
  route: fix ICMP redirect validation
  net: hold sock reference while processing tx timestamps
  tcp: md5: add more const attributes
  Add ethtool -g support to virtio_net
  ...

Fix up conflicts in:
 - drivers/net/Kconfig:
	The split-up generated a trivial conflict with removal of a
	stale reference to Documentation/networking/net-modules.txt.
	Remove it from the new location instead.
 - fs/sysfs/dir.c:
	Fairly nasty conflicts with the sysfs rb-tree usage, conflicting
	with Eric Biederman's changes for tagged directories.
</content>
</entry>
</feed>
