<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/sysfs/dir.c, branch v3.4.19</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/fs/sysfs/dir.c?h=v3.4.19</id>
<link rel='self' href='https://git.amat.us/linux/atom/fs/sysfs/dir.c?h=v3.4.19'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-10-31T17:02:57Z</updated>
<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.amat.us/linux/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.amat.us/linux/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: 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.amat.us/linux/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>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.amat.us/linux/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>
<entry>
<title>sysfs: Update the name hash when renaming sysfs entries</title>
<updated>2012-01-31T19:30:48Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2012-01-31T14:40:26Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=d5c38b137ac8a6e3dbed13bc494d60df5b69dfc4'/>
<id>urn:sha1:d5c38b137ac8a6e3dbed13bc494d60df5b69dfc4</id>
<content type='text'>
This fixes a bug introduced with sysfs name hashes where renaming a
network device appears to succeed but silently makes the sysfs files for
that network device inaccessible.

In at least one configuration this bug has stopped networking from
coming up during boot.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Tested-by: Jiri Slaby &lt;jslaby@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>sysfs: Kill nlink counting.</title>
<updated>2012-01-24T20:41:46Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-12-19T04:09:31Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=524b6c5b39b931311dfe5a2f5abae2f5c9731676'/>
<id>urn:sha1:524b6c5b39b931311dfe5a2f5abae2f5c9731676</id>
<content type='text'>
Tracking the number of subdirectories requires an extra field that increases
the size of sysfs_dirent.  nlinks are not particularly interesting for sysfs
and the nlink counts are wrong when network namespaces are involved so stop
counting them, and always return nlink == 1.  Userspace already knows that
directories with nlink == 1 have an nlink count they can't use to count
subdirectories.

This reduces the size of sysfs_dirent by 8 bytes on 64bit platforms.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>sysfs: Store the sysfs inode in an unsigned int.</title>
<updated>2012-01-24T20:41:46Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-12-19T04:08:16Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=cafa6b5dd7ce4f0e0a30be301be4efed587a7808'/>
<id>urn:sha1:cafa6b5dd7ce4f0e0a30be301be4efed587a7808</id>
<content type='text'>
Store the sysfs inode number in an unsided int because
ida inode allocator can return at most a 31 bit number,
reducing the size of struct sysfs_dirent by 8 bytes
on 64bit platforms.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>sysfs: Add s_hash to sysfs_dirent and order directory entries by hash</title>
<updated>2012-01-24T20:36:17Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-12-19T04:05:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=4e4d6d860b9393c5395ba5920edb5b4c5d43a3a3'/>
<id>urn:sha1:4e4d6d860b9393c5395ba5920edb5b4c5d43a3a3</id>
<content type='text'>
Compute a 31 bit hash of directory entries (that can fit in a signed
32bit off_t) and index the sysfs directory entries by that hash,
replacing the per directory indexes by name and by inode.  Because we
now only use a single rbtree this reduces the size of sysfs_dirent by 2
pointers.  Because we have fewer cases to deal with the code is now
simpler.

For now I use the simple hash that the dcache uses as that is easy to
use and seems simple enough.

In addition to makeing the code simpler using a hash for the file
position in readdir brings sysfs in line with other filesystems that
have non-trivial directory structures.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.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.amat.us/linux/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.amat.us/linux/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>
</feed>
