<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/sysfs, branch v4.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.1</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2015-03-25T12:27:57Z</updated>
<entry>
<title>sysfs: Only accept read/write permissions for file attributes</title>
<updated>2015-03-25T12:27:57Z</updated>
<author>
<name>Vivien Didelot</name>
<email>vivien.didelot@savoirfairelinux.com</email>
</author>
<published>2015-03-12T13:58:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d8bf8c92e80fed9119eb222c7e5cc88acf57c12c'/>
<id>urn:sha1:d8bf8c92e80fed9119eb222c7e5cc88acf57c12c</id>
<content type='text'>
For sysfs file attributes, only read and write permissions make sense.
Mask provided attribute permissions accordingly and send a warning
to the console if invalid permission bits are set.

This patch is originally from Guenter [1] and includes the fixup
explained in the thread, that is printing permissions in octal format
and limiting the scope of attributes to SYSFS_PREALLOC | 0664.

[1] https://lkml.org/lkml/2015/1/19/599

Signed-off-by: Vivien Didelot &lt;vivien.didelot@savoirfairelinux.com&gt;
Reviewed-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs: Use only return value from is_visible for the file mode</title>
<updated>2015-03-25T12:27:57Z</updated>
<author>
<name>Guenter Roeck</name>
<email>linux@roeck-us.net</email>
</author>
<published>2015-03-12T13:58:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=da4759c73b0f1aac79f37bdb39ad2124439c30e7'/>
<id>urn:sha1:da4759c73b0f1aac79f37bdb39ad2124439c30e7</id>
<content type='text'>
Up to now, is_visible can only be used to either remove visibility
of a file entirely or to add permissions, but not to reduce permissions.
This makes it impossible, for example, to use DEVICE_ATTR_RW to define
file attributes and reduce permissions to read-only.

This behavior is undesirable and unnecessarily complicates code which
needs to reduce permissions; instead of just returning the desired
permissions, it has to ensure that the permissions in the attribute
variable declaration only reflect the minimal permissions ever needed.

Change semantics of is_visible to only use the permissions returned
from it instead of oring the returned value with the hard-coded
permissions.

Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Vivien Didelot &lt;vivien.didelot@savoirfairelinux.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'driver-core-3.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core</title>
<updated>2015-02-15T19:11:47Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2015-02-15T19:11:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9682ec9692e5ac11c6caebd079324e727b19e7ce'/>
<id>urn:sha1:9682ec9692e5ac11c6caebd079324e727b19e7ce</id>
<content type='text'>
Pull driver core patches from Greg KH:
 "Really tiny set of patches for this kernel.  Nothing major, all
  described in the shortlog and have been in linux-next for a while"

* tag 'driver-core-3.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core:
  sysfs: fix warning when creating a sysfs group without attributes
  firmware_loader: handle timeout via wait_for_completion_interruptible_timeout()
  firmware_loader: abort request if wait_for_completion is interrupted
  firmware: Correct function name in comment
  device: Change dev_&lt;level&gt; logging functions to return void
  device: Fix dev_dbg_once macro
</content>
</entry>
<entry>
<title>kernfs: remove KERNFS_STATIC_NAME</title>
<updated>2015-02-14T05:21:36Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2015-02-13T22:36:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dfeb0750b630b72b5d4fb2461bc7179eceb54666'/>
<id>urn:sha1:dfeb0750b630b72b5d4fb2461bc7179eceb54666</id>
<content type='text'>
When a new kernfs node is created, KERNFS_STATIC_NAME is used to avoid
making a separate copy of its name.  It's currently only used for sysfs
attributes whose filenames are required to stay accessible and unchanged.
There are rare exceptions where these names are allocated and formatted
dynamically but for the vast majority of cases they're consts in the
rodata section.

Now that kernfs is converted to use kstrdup_const() and kfree_const(),
there's little point in keeping KERNFS_STATIC_NAME around.  Remove it.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Andrzej Hajda &lt;a.hajda@samsung.com&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>sysfs: fix warning when creating a sysfs group without attributes</title>
<updated>2015-02-03T23:50:31Z</updated>
<author>
<name>Javi Merino</name>
<email>javi.merino@arm.com</email>
</author>
<published>2015-01-15T16:17:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=adf305f77878880fa5868a7179979da93be68d83'/>
<id>urn:sha1:adf305f77878880fa5868a7179979da93be68d83</id>
<content type='text'>
When attempting to create a gropu without attrs, the warning prints the
name of the group.  However, the check for name being a NULL pointer is
wrong: it uses the pointer to the name when it's NULL.  Fix it to use
the name if present, otherwise just put an empty string.

Cc: Bruno Prémont &lt;bonbons@linux-vserver.org&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Javi Merino &lt;javi.merino@arm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs/kernfs: make read requests on pre-alloc files use the buffer.</title>
<updated>2014-11-07T18:54:38Z</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2014-10-14T05:57:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4ef67a8c95f32ed0c8c6ed5fe01d1dd16358350e'/>
<id>urn:sha1:4ef67a8c95f32ed0c8c6ed5fe01d1dd16358350e</id>
<content type='text'>
To match the previous patch which used the pre-alloc buffer for
writes, this patch causes reads to use the same buffer.
This is not strictly necessary as the current seq_read() will allocate
on first read, so user-space can trigger the required pre-alloc.  But
consistency is valuable.

The read function is somewhat simpler than seq_read() and, for example,
does not support reading from an offset into the file: reads must be
at the start of the file.

As seq_read() does not use the prealloc buffer, -&gt;seq_show is
incompatible with -&gt;prealloc and caused an EINVAL return from open().
sysfs code which calls into kernfs always chooses the correct function.

As the buffer is shared with writes and other reads, the mutex is
extended to cover the copy_to_user.

Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Reviewed-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs/kernfs: allow attributes to request write buffer be pre-allocated.</title>
<updated>2014-11-07T18:53:25Z</updated>
<author>
<name>NeilBrown</name>
<email>neilb@suse.de</email>
</author>
<published>2014-10-13T05:41:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b75869bba676c248d8d25ae6d2bd9221dfffdb6'/>
<id>urn:sha1:2b75869bba676c248d8d25ae6d2bd9221dfffdb6</id>
<content type='text'>
md/raid allows metadata management to be performed in user-space.
A various times, particularly on device failure, the metadata needs
to be updated before further writes can be permitted.
This means that the user-space program which updates metadata much
not block on writeout, and so must not allocate memory.

mlockall(MCL_CURRENT|MCL_FUTURE) and pre-allocation can avoid all
memory allocation issues for user-memory, but that does not help
kernel memory.
Several kernel objects can be pre-allocated.  e.g. files opened before
any writes to the array are permitted.
However some kernel allocation happens in places that cannot be
pre-allocated.
In particular, writes to sysfs files (to tell md that it can now
allow writes to the array) allocate a buffer using GFP_KERNEL.

This patch allows attributes to be marked as "PREALLOC".  In that case
the maximal buffer is allocated when the file is opened, and then used
on each write instead of allocating a new buffer.

As the same buffer is now shared for all writes on the same file
description, the mutex is extended to cover full use of the buffer
including the copy_from_user().

The new __ATTR_PREALLOC() 'or's a new flag in to the 'mode', which is
inspected by sysfs_add_file_mode_ns() to determine if the file should be
marked as requiring prealloc.

Despite the comment, we *do* use -&gt;seq_show together with -&gt;prealloc
in this patch.  The next patch fixes that.

Signed-off-by: NeilBrown  &lt;neilb@suse.de&gt;
Reviewed-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>fs: sysfs: return EGBIG on write if offset is larger than file size</title>
<updated>2014-11-07T18:52:20Z</updated>
<author>
<name>Vladimir Zapolskiy</name>
<email>vladimir_zapolskiy@mentor.com</email>
</author>
<published>2014-09-24T15:21:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=0936896056365349afa867c16e9f9100a6707cbf'/>
<id>urn:sha1:0936896056365349afa867c16e9f9100a6707cbf</id>
<content type='text'>
According to the user expectations common utilities like dd or sh
redirection operator &gt; should work correctly over binary files from
sysfs. At the moment doing excessive write can not be completed:

  write(1, "\0\0\0\0\0\0\0\0", 8)         = 4
  write(1, "\0\0\0\0", 4)                 = 0
  write(1, "\0\0\0\0", 4)                 = 0
  write(1, "\0\0\0\0", 4)                 = 0
  ...

Fix the problem by returning EFBIG described in man 2 write.

Signed-off-by: Vladimir Zapolskiy &lt;vladimir_zapolskiy@mentor.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kernfs: move the last knowledge of sysfs out from kernfs</title>
<updated>2014-05-27T21:33:17Z</updated>
<author>
<name>Jianyu Zhan</name>
<email>nasa4836@gmail.com</email>
</author>
<published>2014-04-26T07:40:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=26fc9cd200ec839e0b3095e05ae018f27314e7aa'/>
<id>urn:sha1:26fc9cd200ec839e0b3095e05ae018f27314e7aa</id>
<content type='text'>
There is still one residue of sysfs remaining: the sb_magic
SYSFS_MAGIC. However this should be kernfs user specific,
so this patch moves it out. Kerrnfs user should specify their
magic number while mouting.

Signed-off-by: Jianyu Zhan &lt;nasa4836@gmail.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sysfs: fix attribute_group bin file path on removal</title>
<updated>2014-05-27T21:33:17Z</updated>
<author>
<name>Robert ABEL</name>
<email>rabel@cit-ec.uni-bielefeld.de</email>
</author>
<published>2014-05-05T13:17:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9f70a40128a4ddceffb6d21dd490f6ab4bc34c97'/>
<id>urn:sha1:9f70a40128a4ddceffb6d21dd490f6ab4bc34c97</id>
<content type='text'>
Cody Schafer already fixed binary file creation for attribute groups, see [1].
This patch makes the appropriate changes for binary file removal
of attribute groups.
[1]: http://lkml.org/lkml/2014/2/27/832

Signed-off-by: Robert ABEL &lt;rabel@cit-ec.uni-bielefeld.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
