<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/fs/sysfs, branch stable/3.4.y</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=stable%2F3.4.y</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=stable%2F3.4.y'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-05-08T02:51:54Z</updated>
<entry>
<title>sysfs: fix use after free in case of concurrent read/write and readdir</title>
<updated>2013-05-08T02:51:54Z</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=6615e6db12bf29ab3d1062c9144c4e0828d2c588'/>
<id>urn:sha1:6615e6db12bf29ab3d1062c9144c4e0828d2c588</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;

</content>
</entry>
<entry>
<title>sysfs: handle failure path correctly for readdir()</title>
<updated>2013-04-05T17:04:16Z</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=cde9833c97c4ad06e569e1f0e7e6b1c84c948aa3'/>
<id>urn:sha1:cde9833c97c4ad06e569e1f0e7e6b1c84c948aa3</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;

</content>
</entry>
<entry>
<title>sysfs: fix race between readdir and lseek</title>
<updated>2013-04-05T17:04:16Z</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=01fadbb46b6da196c594ac2266674136cda465a6'/>
<id>urn:sha1:01fadbb46b6da196c594ac2266674136cda465a6</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;

</content>
</entry>
<entry>
<title>sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()</title>
<updated>2012-10-31T17:02:57Z</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=fa3b39b05f40bf7273bcd6c152f0b59005b83480'/>
<id>urn:sha1:fa3b39b05f40bf7273bcd6c152f0b59005b83480</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;

</content>
</entry>
<entry>
<title>sysfs: handle 'parent deleted before child added'</title>
<updated>2012-04-10T21:48:51Z</updated>
<author>
<name>Dan Williams</name>
<email>dan.j.williams@intel.com</email>
</author>
<published>2012-04-06T20:41:06Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=3a198886ab5f228fcbebb9ace803d8b99721d49a'/>
<id>urn:sha1:3a198886ab5f228fcbebb9ace803d8b99721d49a</id>
<content type='text'>
In scsi at least two cases of the parent device being deleted before the
child is added have been observed.

1/ scsi is performing async scans and the device is removed prior to the
   async can thread running (can happen with an in-opportune / unlikely
   unplug during initial scan).

2/ libsas discovery event running after the parent port has been torn
   down (this is a bug in libsas).

Result in crash signatures like:
 BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
 IP: [&lt;ffffffff8115e100&gt;] sysfs_create_dir+0x32/0xb6
 ...
 Process scsi_scan_8 (pid: 5417, threadinfo ffff88080bd16000, task ffff880801b8a0b0)
 Stack:
  00000000fffffffe ffff880813470628 ffff88080bd17cd0 ffff88080614b7e8
  ffff88080b45c108 00000000fffffffe ffff88080bd17d20 ffffffff8125e4a8
  ffff88080bd17cf0 ffffffff81075149 ffff88080bd17d30 ffff88080614b7e8
 Call Trace:
  [&lt;ffffffff8125e4a8&gt;] kobject_add_internal+0x120/0x1e3
  [&lt;ffffffff81075149&gt;] ? trace_hardirqs_on+0xd/0xf
  [&lt;ffffffff8125e641&gt;] kobject_add_varg+0x41/0x50
  [&lt;ffffffff8125e70b&gt;] kobject_add+0x64/0x66
  [&lt;ffffffff8131122b&gt;] device_add+0x12d/0x63a

In this scenario the parent is still valid (because we have a
reference), but it has been device_del()'d which means its kobj-&gt;sd
pointer is NULL'd via:

 device_del()-&gt;kobject_del()-&gt;sysfs_remove_dir()

...and then sysfs_create_dir() (without this fix) goes ahead and
de-references parent_sd via sysfs_ns_type():

 return (sd-&gt;s_flags &amp; SYSFS_NS_TYPE_MASK) &gt;&gt; SYSFS_NS_TYPE_SHIFT;

This scenario is being fixed in scsi/libsas, but if other subsystems
present the same ordering the system need not immediately crash.

Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: James Bottomley &lt;JBottomley@parallels.com&gt;
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs: Prevent crash on unset sysfs group attributes</title>
<updated>2012-04-10T21:48:51Z</updated>
<author>
<name>Bruno Prémont</name>
<email>bonbons@linux-vserver.org</email>
</author>
<published>2012-04-03T07:59:48Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5631f2c18f4b2845b3e97df1c659c5094a17605f'/>
<id>urn:sha1:5631f2c18f4b2845b3e97df1c659c5094a17605f</id>
<content type='text'>
Do not let the kernel crash when a device is registered with
sysfs while group attributes are not set (aka NULL).

Warn about the offender with some information about the offending
device.

This would warn instead of trying NULL pointer deref like:
 BUG: unable to handle kernel NULL pointer dereference at (null)
 IP: [&lt;ffffffff81152673&gt;] internal_create_group+0x83/0x1a0
 PGD 0
 Oops: 0000 [#1] SMP
 CPU 0
 Modules linked in:

 Pid: 1, comm: swapper/0 Not tainted 3.4.0-rc1-x86_64 #3 HP ProLiant DL360 G4
 RIP: 0010:[&lt;ffffffff81152673&gt;]  [&lt;ffffffff81152673&gt;] internal_create_group+0x83/0x1a0
 RSP: 0018:ffff88019485fd70  EFLAGS: 00010202
 RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000001
 RDX: ffff880192e99908 RSI: ffff880192e99630 RDI: ffffffff81a26c60
 RBP: ffff88019485fdc0 R08: 0000000000000000 R09: 0000000000000000
 R10: ffff880192e99908 R11: 0000000000000000 R12: ffffffff81a16a00
 R13: ffff880192e99908 R14: ffffffff81a16900 R15: 0000000000000000
 FS:  0000000000000000(0000) GS:ffff88019bc00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
 CR2: 0000000000000000 CR3: 0000000001a0c000 CR4: 00000000000007f0
 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
 Process swapper/0 (pid: 1, threadinfo ffff88019485e000, task ffff880194878000)
 Stack:
  ffff88019485fdd0 ffff880192da9d60 0000000000000000 ffff880192e99908
  ffff880192e995d8 0000000000000001 ffffffff81a16a00 ffff880192da9d60
  0000000000000000 0000000000000000 ffff88019485fdd0 ffffffff811527be
 Call Trace:
  [&lt;ffffffff811527be&gt;] sysfs_create_group+0xe/0x10
  [&lt;ffffffff81376ca6&gt;] device_add_groups+0x46/0x80
  [&lt;ffffffff81377d3d&gt;] device_add+0x46d/0x6a0
  ...

Signed-off-by: Bruno Prémont &lt;bonbons@linux-vserver.org&gt;
Acked-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs: Update the name hash for an entry after changing the namespace</title>
<updated>2012-04-09T22:33:00Z</updated>
<author>
<name>Tom Goff</name>
<email>thomas.goff@boeing.com</email>
</author>
<published>2012-04-04T19:06:20Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=70fa4a62e913dde2d100e0be2711562742f58bee'/>
<id>urn:sha1:70fa4a62e913dde2d100e0be2711562742f58bee</id>
<content type='text'>
This is needed to allow renaming network devices that have been moved
to another network namespace.

Signed-off-by: Tom Goff &lt;thomas.goff@boeing.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs</title>
<updated>2012-03-21T20:36:41Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2012-03-21T20:36:41Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=e2a0883e4071237d09b604a342c28b96b44a04b3'/>
<id>urn:sha1:e2a0883e4071237d09b604a342c28b96b44a04b3</id>
<content type='text'>
Pull vfs pile 1 from Al Viro:
 "This is _not_ all; in particular, Miklos' and Jan's stuff is not there
  yet."

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (64 commits)
  ext4: initialization of ext4_li_mtx needs to be done earlier
  debugfs-related mode_t whack-a-mole
  hfsplus: add an ioctl to bless files
  hfsplus: change finder_info to u32
  hfsplus: initialise userflags
  qnx4: new helper - try_extent()
  qnx4: get rid of qnx4_bread/qnx4_getblk
  take removal of PF_FORKNOEXEC to flush_old_exec()
  trim includes in inode.c
  um: uml_dup_mmap() relies on -&gt;mmap_sem being held, but activate_mm() doesn't hold it
  um: embed -&gt;stub_pages[] into mmu_context
  gadgetfs: list_for_each_safe() misuse
  ocfs2: fix leaks on failure exits in module_init
  ecryptfs: make register_filesystem() the last potential failure exit
  ntfs: forgets to unregister sysctls on register_filesystem() failure
  logfs: missing cleanup on register_filesystem() failure
  jfs: mising cleanup on register_filesystem() failure
  make configfs_pin_fs() return root dentry on success
  configfs: configfs_create_dir() has parent dentry in dentry-&gt;d_parent
  configfs: sanitize configfs_create()
  ...
</content>
</entry>
<entry>
<title>switch open-coded instances of d_make_root() to new helper</title>
<updated>2012-03-21T01:29:35Z</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2012-01-09T03:15:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=48fde701aff662559b38d9a609574068f22d00fe'/>
<id>urn:sha1:48fde701aff662559b38d9a609574068f22d00fe</id>
<content type='text'>
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Revert "sysfs: Kill nlink counting."</title>
<updated>2012-03-08T21:03:10Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2012-03-08T21:03:10Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=54d20f006ceff1f2f1e69d0e54049b6c0765c039'/>
<id>urn:sha1:54d20f006ceff1f2f1e69d0e54049b6c0765c039</id>
<content type='text'>
This reverts commit 524b6c5b39b931311dfe5a2f5abae2f5c9731676.

It has shown to break userspace tools, which is not acceptable.

Reported-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
