<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/sysfs/file.c, branch v3.2.31</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/fs/sysfs/file.c?h=v3.2.31</id>
<link rel='self' href='https://git.amat.us/linux/atom/fs/sysfs/file.c?h=v3.2.31'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2012-02-03T17:21:47Z</updated>
<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.amat.us/linux/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>sysfs: Reject with a warning invalid uses of tagged directories.</title>
<updated>2011-10-19T23:24:16Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-10-12T22:02:43Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=903e21e2eea036f6947f523f732e28b33a63ed0f'/>
<id>urn:sha1:903e21e2eea036f6947f523f732e28b33a63ed0f</id>
<content type='text'>
sysfs is a core piece of ifrastructure that many people use and
few people have all of the rules in their head on how to use
it correctly.  Add warnings for people using tagged directories
improperly to that any misuses can be caught and diagnosed quickly.

A single inexpensive test in sysfs_find_dirent is almost sufficient
to catch all possible misuses.  An additional warning is needed
in sysfs_add_dirent so that we actually fail when attempting to
add an untagged dirent in a tagged directory.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sysfs: Implement support for tagged files in sysfs.</title>
<updated>2011-10-19T23:24:14Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2011-10-12T21:53:38Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=487505c257021fc06a7d05753cf27b011487f1dc'/>
<id>urn:sha1:487505c257021fc06a7d05753cf27b011487f1dc</id>
<content type='text'>
Looking up files in sysfs is hard to understand and analyize because we
currently allow placing untagged files in tagged directories.  In the
implementation of that we have two subtly different meanings of NULL.
NULL meaning there is no tag on a directory entry and NULL meaning
we don't care which namespace the lookup is performed for.  This
multiple uses of NULL have resulted in subtle bugs (since fixed)
in the code.

Currently it is only the bonding driver that needs to have an untagged
file in a tagged directory.

To untagle this mess I am adding support for tagged files to sysfs.
Modifying the bonding driver to implement bonding_masters as a tagged
file.  Registering bonding_masters once for each network namespace.
Then I am removing support for untagged entries in tagged sysfs
directories.

Resulting in code that is much easier to reason about.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>sysfs: remove "last sysfs file:" line from the oops messages</title>
<updated>2011-05-13T23:05:51Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@suse.de</email>
</author>
<published>2011-05-12T23:01:02Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=82a3242e11d9e63c8195be46c954efaefee35e22'/>
<id>urn:sha1:82a3242e11d9e63c8195be46c954efaefee35e22</id>
<content type='text'>
On some arches (x86, sh, arm, unicore, powerpc) the oops message would
print out the last sysfs file accessed.

This was very useful in finding a number of sysfs and driver core bugs
in the 2.5 and early 2.6 development days, but it has been a number of
years since this file has actually helped in debugging anything that
couldn't also be trivially determined from the stack traceback.

So it's time to delete the line.  This is good as we need all the space
we can get for oops messages at times on consoles.

Acked-by: Phil Carmody &lt;ext-phil.2.carmody@nokia.com&gt;
Acked-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>sysfs: checking for NULL instead of ERR_PTR</title>
<updated>2010-09-04T00:26:28Z</updated>
<author>
<name>Dan Carpenter</name>
<email>error27@gmail.com</email>
</author>
<published>2010-08-25T07:12:29Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=57f9bdac2510cd7fda58e4a111d250861eb1ebeb'/>
<id>urn:sha1:57f9bdac2510cd7fda58e4a111d250861eb1ebeb</id>
<content type='text'>
d_path() returns an ERR_PTR and it doesn't return NULL.

Signed-off-by: Dan Carpenter &lt;error27@gmail.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Reviewed-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: sysfs_chmod_file's attr can be const</title>
<updated>2010-08-05T20:53:34Z</updated>
<author>
<name>Jean Delvare</name>
<email>khali@linux-fr.org</email>
</author>
<published>2010-07-02T14:54:05Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=49c19400f60bbe362202d7e7b3e68cc66040d0fa'/>
<id>urn:sha1:49c19400f60bbe362202d7e7b3e68cc66040d0fa</id>
<content type='text'>
sysfs_chmod_file doesn't change the attribute it operates on, so this
attribute can be marked const.

Signed-off-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>sysfs: Implement sysfs tagged directory support.</title>
<updated>2010-05-21T16:37:31Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2010-03-30T18:31:26Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=3ff195b011d7decf501a4d55aeed312731094796'/>
<id>urn:sha1:3ff195b011d7decf501a4d55aeed312731094796</id>
<content type='text'>
The problem.  When implementing a network namespace I need to be able
to have multiple network devices with the same name.  Currently this
is a problem for /sys/class/net/*, /sys/devices/virtual/net/*, and
potentially a few other directories of the form /sys/ ... /net/*.

What this patch does is to add an additional tag field to the
sysfs dirent structure.  For directories that should show different
contents depending on the context such as /sys/class/net/, and
/sys/devices/virtual/net/ this tag field is used to specify the
context in which those directories should be visible.  Effectively
this is the same as creating multiple distinct directories with
the same name but internally to sysfs the result is nicer.

I am calling the concept of a single directory that looks like multiple
directories all at the same path in the filesystem tagged directories.

For the networking namespace the set of directories whose contents I need
to filter with tags can depend on the presence or absence of hotplug
hardware or which modules are currently loaded.  Which means I need
a simple race free way to setup those directories as tagged.

To achieve a reace free design all tagged directories are created
and managed by sysfs itself.

Users of this interface:
- define a type in the sysfs_tag_type enumeration.
- call sysfs_register_ns_types with the type and it's operations
- sysfs_exit_ns when an individual tag is no longer valid

- Implement mount_ns() which returns the ns of the calling process
  so we can attach it to a sysfs superblock.
- Implement ktype.namespace() which returns the ns of a syfs kobject.

Everything else is left up to sysfs and the driver layer.

For the network namespace mount_ns and namespace() are essentially
one line functions, and look to remain that.

Tags are currently represented a const void * pointers as that is
both generic, prevides enough information for equality comparisons,
and is trivial to create for current users, as it is just the
existing namespace pointer.

The work needed in sysfs is more extensive.  At each directory
or symlink creating I need to check if the directory it is being
created in is a tagged directory and if so generate the appropriate
tag to place on the sysfs_dirent.  Likewise at each symlink or
directory removal I need to check if the sysfs directory it is
being removed from is a tagged directory and if so figure out
which tag goes along with the name I am deleting.

Currently only directories which hold kobjects, and
symlinks are supported.  There is not enough information
in the current file attribute interfaces to give us anything
to discriminate on which makes it useless, and there are
no potential users which makes it an uninteresting problem
to solve.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Benjamin Thery &lt;benjamin.thery@bull.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>sysfs: Only take active references on attributes.</title>
<updated>2010-03-08T01:04:51Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2010-02-11T23:20:00Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=a2db6842873c8e5a70652f278d469128cb52db70'/>
<id>urn:sha1:a2db6842873c8e5a70652f278d469128cb52db70</id>
<content type='text'>
If we exclude directories and symlinks from the set of sysfs
dirents where we need active references we are left with
sysfs attributes (binary or not).

- Tweak sysfs_deactivate to only do something on attributes
- Move lockdep initialization into sysfs_file_add_mode to
  limit it to just attributes.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>sysfs: Remove sysfs_get/put_active_two</title>
<updated>2010-03-08T01:04:51Z</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2010-02-11T23:18:38Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=e72ceb8ccac5f770b3e696e09bb673dca7024b20'/>
<id>urn:sha1:e72ceb8ccac5f770b3e696e09bb673dca7024b20</id>
<content type='text'>
It turns out that holding an active reference on a directory is
pointless.  The purpose of the active references are to allows us to
block when removing sysfs entries that have custom methods so we don't
remove modules while running modular code and to keep those custom
methods from accessing data structures after the files have been
removed.  Further sysfs_remove_dir remove all elements in the
directory before removing the directory itself, so there is no chance
we will remove a directory with active children.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>Driver core: Constify struct sysfs_ops in struct kobj_type</title>
<updated>2010-03-08T01:04:49Z</updated>
<author>
<name>Emese Revfy</name>
<email>re.emese@gmail.com</email>
</author>
<published>2010-01-19T01:58:23Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=52cf25d0ab7f78eeecc59ac652ed5090f69b619e'/>
<id>urn:sha1:52cf25d0ab7f78eeecc59ac652ed5090f69b619e</id>
<content type='text'>
Constify struct sysfs_ops.

This is part of the ops structure constification
effort started by Arjan van de Ven et al.

Benefits of this constification:

 * prevents modification of data that is shared
   (referenced) by many other structure instances
   at runtime

 * detects/prevents accidental (but not intentional)
   modification attempts on archs that enforce
   read-only kernel data at runtime

 * potentially better optimized code as the compiler
   can assume that the const data cannot be changed

 * the compiler/linker move const data into .rodata
   and therefore exclude them from false sharing

Signed-off-by: Emese Revfy &lt;re.emese@gmail.com&gt;
Acked-by: David Teigland &lt;teigland@redhat.com&gt;
Acked-by: Matt Domsch &lt;Matt_Domsch@dell.com&gt;
Acked-by: Maciej Sosnowski &lt;maciej.sosnowski@intel.com&gt;
Acked-by: Hans J. Koch &lt;hjk@linutronix.de&gt;
Acked-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Acked-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Acked-by: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
</feed>
