<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/include/linux/kernfs.h, branch v3.15.3</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>kernfs: move the last knowledge of sysfs out from kernfs</title>
<updated>2014-06-03T15:11:18+00:00</updated>
<author>
<name>Jianyu Zhan</name>
<email>nasa4836@gmail.com</email>
</author>
<published>2014-04-26T07:40:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=c9482a5bdcc09be9096f40e858c5fe39c389cd52'/>
<id>c9482a5bdcc09be9096f40e858c5fe39c389cd52</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;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs, sysfs, cgroup: restrict extra perm check on open to sysfs</title>
<updated>2014-05-13T11:21:40+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-12T17:56:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=555724a831b4a146e7bdf16ecc989cda032b076d'/>
<id>555724a831b4a146e7bdf16ecc989cda032b076d</id>
<content type='text'>
The kernfs open method - kernfs_fop_open() - inherited extra
permission checks from sysfs.  While the vfs layer allows ignoring the
read/write permissions checks if the issuer has CAP_DAC_OVERRIDE,
sysfs explicitly denied open regardless of the cap if the file doesn't
have any of the UGO perms of the requested access or doesn't implement
the requested operation.  It can be debated whether this was a good
idea or not but the behavior is too subtle and dangerous to change at
this point.

After cgroup got converted to kernfs, this extra perm check also got
applied to cgroup breaking libcgroup which opens write-only files with
O_RDWR as root.  This patch gates the extra open permission check with
a new flag KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK and enables it for sysfs.
For sysfs, nothing changes.  For cgroup, root now can perform any
operation regardless of the permissions as it was before kernfs
conversion.  Note that kernfs still fails unimplemented operations
with -EINVAL.

While at it, add comments explaining KERNFS_ROOT flags.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Andrey Wagin &lt;avagin@gmail.com&gt;
Tested-by: Andrey Wagin &lt;avagin@gmail.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
References: http://lkml.kernel.org/g/CANaxB-xUm3rJ-Cbp72q-rQJO5mZe1qK6qXsQM=vh0U8upJ44+A@mail.gmail.com
Fixes: 2bd59d48ebfb ("cgroup: convert to kernfs")
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The kernfs open method - kernfs_fop_open() - inherited extra
permission checks from sysfs.  While the vfs layer allows ignoring the
read/write permissions checks if the issuer has CAP_DAC_OVERRIDE,
sysfs explicitly denied open regardless of the cap if the file doesn't
have any of the UGO perms of the requested access or doesn't implement
the requested operation.  It can be debated whether this was a good
idea or not but the behavior is too subtle and dangerous to change at
this point.

After cgroup got converted to kernfs, this extra perm check also got
applied to cgroup breaking libcgroup which opens write-only files with
O_RDWR as root.  This patch gates the extra open permission check with
a new flag KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK and enables it for sysfs.
For sysfs, nothing changes.  For cgroup, root now can perform any
operation regardless of the permissions as it was before kernfs
conversion.  Note that kernfs still fails unimplemented operations
with -EINVAL.

While at it, add comments explaining KERNFS_ROOT flags.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Andrey Wagin &lt;avagin@gmail.com&gt;
Tested-by: Andrey Wagin &lt;avagin@gmail.com&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
References: http://lkml.kernel.org/g/CANaxB-xUm3rJ-Cbp72q-rQJO5mZe1qK6qXsQM=vh0U8upJ44+A@mail.gmail.com
Fixes: 2bd59d48ebfb ("cgroup: convert to kernfs")
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: cache atomic_write_len in kernfs_open_file</title>
<updated>2014-03-09T06:08:29+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-03-04T20:38:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=b7ce40cff0b9f6597f8318fd761accd92727f61f'/>
<id>b7ce40cff0b9f6597f8318fd761accd92727f61f</id>
<content type='text'>
While implementing atomic_write_len, 4d3773c4bb41 ("kernfs: implement
kernfs_ops-&gt;atomic_write_len") moved data copy from userland inside
kernfs_get_active() and kernfs_open_file-&gt;mutex so that
kernfs_ops-&gt;atomic_write_len can be accessed before copying buffer
from userland; unfortunately, this could lead to locking order
inversion involving mmap_sem if copy_from_user() takes a page fault.

  ======================================================
  [ INFO: possible circular locking dependency detected ]
  3.14.0-rc4-next-20140228-sasha-00011-g4077c67-dirty #26 Tainted: G        W
  -------------------------------------------------------
  trinity-c236/10658 is trying to acquire lock:
   (&amp;of-&gt;mutex#2){+.+.+.}, at: [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120

  but task is already holding lock:
   (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;mm/util.c:397&gt;] vm_mmap_pgoff+0x6e/0xe0

  which lock already depends on the new lock.

  the existing dependency chain (in reverse order) is:

 -&gt; #1 (&amp;mm-&gt;mmap_sem){++++++}:
	 [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
	 [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
	 [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
	 [&lt;mm/memory.c:4188&gt;] might_fault+0x7e/0xb0
	 [&lt;arch/x86/include/asm/uaccess.h:713 fs/kernfs/file.c:291&gt;] kernfs_fop_write+0xd8/0x190
	 [&lt;fs/read_write.c:473&gt;] vfs_write+0xe3/0x1d0
	 [&lt;fs/read_write.c:523 fs/read_write.c:515&gt;] SyS_write+0x5d/0xa0
	 [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

 -&gt; #0 (&amp;of-&gt;mutex#2){+.+.+.}:
	 [&lt;kernel/locking/lockdep.c:1840&gt;] check_prev_add+0x13f/0x560
	 [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
	 [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
	 [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
	 [&lt;kernel/locking/mutex.c:470 kernel/locking/mutex.c:571&gt;] mutex_lock_nested+0x6a/0x510
	 [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120
	 [&lt;mm/mmap.c:1573&gt;] mmap_region+0x310/0x5c0
	 [&lt;mm/mmap.c:1365&gt;] do_mmap_pgoff+0x385/0x430
	 [&lt;mm/util.c:399&gt;] vm_mmap_pgoff+0x8f/0xe0
	 [&lt;mm/mmap.c:1416 mm/mmap.c:1374&gt;] SyS_mmap_pgoff+0x1b0/0x210
	 [&lt;arch/x86/kernel/sys_x86_64.c:72&gt;] SyS_mmap+0x1d/0x20
	 [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

  other info that might help us debug this:

   Possible unsafe locking scenario:

	 CPU0                    CPU1
	 ----                    ----
    lock(&amp;mm-&gt;mmap_sem);
				 lock(&amp;of-&gt;mutex#2);
				 lock(&amp;mm-&gt;mmap_sem);
    lock(&amp;of-&gt;mutex#2);

   *** DEADLOCK ***

  1 lock held by trinity-c236/10658:
   #0:  (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;mm/util.c:397&gt;] vm_mmap_pgoff+0x6e/0xe0

  stack backtrace:
  CPU: 2 PID: 10658 Comm: trinity-c236 Tainted: G        W 3.14.0-rc4-next-20140228-sasha-00011-g4077c67-dirty #26
   0000000000000000 ffff88011911fa48 ffffffff8438e945 0000000000000000
   0000000000000000 ffff88011911fa98 ffffffff811a0109 ffff88011911fab8
   ffff88011911fab8 ffff88011911fa98 ffff880119128cc0 ffff880119128cf8
  Call Trace:
   [&lt;lib/dump_stack.c:52&gt;] dump_stack+0x52/0x7f
   [&lt;kernel/locking/lockdep.c:1213&gt;] print_circular_bug+0x129/0x160
   [&lt;kernel/locking/lockdep.c:1840&gt;] check_prev_add+0x13f/0x560
   [&lt;include/linux/spinlock.h:343 mm/slub.c:1933&gt;] ? deactivate_slab+0x511/0x550
   [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
   [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
   [&lt;mm/mmap.c:1552&gt;] ? mmap_region+0x24a/0x5c0
   [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;kernel/locking/mutex.c:470 kernel/locking/mutex.c:571&gt;] mutex_lock_nested+0x6a/0x510
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;kernel/sched/core.c:2477&gt;] ? get_parent_ip+0x11/0x50
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120
   [&lt;mm/mmap.c:1573&gt;] mmap_region+0x310/0x5c0
   [&lt;mm/mmap.c:1365&gt;] do_mmap_pgoff+0x385/0x430
   [&lt;mm/util.c:397&gt;] ? vm_mmap_pgoff+0x6e/0xe0
   [&lt;mm/util.c:399&gt;] vm_mmap_pgoff+0x8f/0xe0
   [&lt;kernel/rcu/update.c:97&gt;] ? __rcu_read_unlock+0x44/0xb0
   [&lt;fs/file.c:641&gt;] ? dup_fd+0x3c0/0x3c0
   [&lt;mm/mmap.c:1416 mm/mmap.c:1374&gt;] SyS_mmap_pgoff+0x1b0/0x210
   [&lt;arch/x86/kernel/sys_x86_64.c:72&gt;] SyS_mmap+0x1d/0x20
   [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

Fix it by caching atomic_write_len in kernfs_open_file during open so
that it can be determined without accessing kernfs_ops in
kernfs_fop_write().  This restores the structure of kernfs_fop_write()
before 4d3773c4bb41 with updated @len determination logic.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
References: http://lkml.kernel.org/g/53113485.2090407@oracle.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While implementing atomic_write_len, 4d3773c4bb41 ("kernfs: implement
kernfs_ops-&gt;atomic_write_len") moved data copy from userland inside
kernfs_get_active() and kernfs_open_file-&gt;mutex so that
kernfs_ops-&gt;atomic_write_len can be accessed before copying buffer
from userland; unfortunately, this could lead to locking order
inversion involving mmap_sem if copy_from_user() takes a page fault.

  ======================================================
  [ INFO: possible circular locking dependency detected ]
  3.14.0-rc4-next-20140228-sasha-00011-g4077c67-dirty #26 Tainted: G        W
  -------------------------------------------------------
  trinity-c236/10658 is trying to acquire lock:
   (&amp;of-&gt;mutex#2){+.+.+.}, at: [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120

  but task is already holding lock:
   (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;mm/util.c:397&gt;] vm_mmap_pgoff+0x6e/0xe0

  which lock already depends on the new lock.

  the existing dependency chain (in reverse order) is:

 -&gt; #1 (&amp;mm-&gt;mmap_sem){++++++}:
	 [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
	 [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
	 [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
	 [&lt;mm/memory.c:4188&gt;] might_fault+0x7e/0xb0
	 [&lt;arch/x86/include/asm/uaccess.h:713 fs/kernfs/file.c:291&gt;] kernfs_fop_write+0xd8/0x190
	 [&lt;fs/read_write.c:473&gt;] vfs_write+0xe3/0x1d0
	 [&lt;fs/read_write.c:523 fs/read_write.c:515&gt;] SyS_write+0x5d/0xa0
	 [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

 -&gt; #0 (&amp;of-&gt;mutex#2){+.+.+.}:
	 [&lt;kernel/locking/lockdep.c:1840&gt;] check_prev_add+0x13f/0x560
	 [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
	 [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
	 [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
	 [&lt;kernel/locking/mutex.c:470 kernel/locking/mutex.c:571&gt;] mutex_lock_nested+0x6a/0x510
	 [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120
	 [&lt;mm/mmap.c:1573&gt;] mmap_region+0x310/0x5c0
	 [&lt;mm/mmap.c:1365&gt;] do_mmap_pgoff+0x385/0x430
	 [&lt;mm/util.c:399&gt;] vm_mmap_pgoff+0x8f/0xe0
	 [&lt;mm/mmap.c:1416 mm/mmap.c:1374&gt;] SyS_mmap_pgoff+0x1b0/0x210
	 [&lt;arch/x86/kernel/sys_x86_64.c:72&gt;] SyS_mmap+0x1d/0x20
	 [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

  other info that might help us debug this:

   Possible unsafe locking scenario:

	 CPU0                    CPU1
	 ----                    ----
    lock(&amp;mm-&gt;mmap_sem);
				 lock(&amp;of-&gt;mutex#2);
				 lock(&amp;mm-&gt;mmap_sem);
    lock(&amp;of-&gt;mutex#2);

   *** DEADLOCK ***

  1 lock held by trinity-c236/10658:
   #0:  (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;mm/util.c:397&gt;] vm_mmap_pgoff+0x6e/0xe0

  stack backtrace:
  CPU: 2 PID: 10658 Comm: trinity-c236 Tainted: G        W 3.14.0-rc4-next-20140228-sasha-00011-g4077c67-dirty #26
   0000000000000000 ffff88011911fa48 ffffffff8438e945 0000000000000000
   0000000000000000 ffff88011911fa98 ffffffff811a0109 ffff88011911fab8
   ffff88011911fab8 ffff88011911fa98 ffff880119128cc0 ffff880119128cf8
  Call Trace:
   [&lt;lib/dump_stack.c:52&gt;] dump_stack+0x52/0x7f
   [&lt;kernel/locking/lockdep.c:1213&gt;] print_circular_bug+0x129/0x160
   [&lt;kernel/locking/lockdep.c:1840&gt;] check_prev_add+0x13f/0x560
   [&lt;include/linux/spinlock.h:343 mm/slub.c:1933&gt;] ? deactivate_slab+0x511/0x550
   [&lt;kernel/locking/lockdep.c:1945 kernel/locking/lockdep.c:2131&gt;] validate_chain+0x6c5/0x7b0
   [&lt;kernel/locking/lockdep.c:3182&gt;] __lock_acquire+0x4cd/0x5a0
   [&lt;mm/mmap.c:1552&gt;] ? mmap_region+0x24a/0x5c0
   [&lt;arch/x86/include/asm/current.h:14 kernel/locking/lockdep.c:3602&gt;] lock_acquire+0x182/0x1d0
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;kernel/locking/mutex.c:470 kernel/locking/mutex.c:571&gt;] mutex_lock_nested+0x6a/0x510
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;kernel/sched/core.c:2477&gt;] ? get_parent_ip+0x11/0x50
   [&lt;fs/kernfs/file.c:487&gt;] ? kernfs_fop_mmap+0x54/0x120
   [&lt;fs/kernfs/file.c:487&gt;] kernfs_fop_mmap+0x54/0x120
   [&lt;mm/mmap.c:1573&gt;] mmap_region+0x310/0x5c0
   [&lt;mm/mmap.c:1365&gt;] do_mmap_pgoff+0x385/0x430
   [&lt;mm/util.c:397&gt;] ? vm_mmap_pgoff+0x6e/0xe0
   [&lt;mm/util.c:399&gt;] vm_mmap_pgoff+0x8f/0xe0
   [&lt;kernel/rcu/update.c:97&gt;] ? __rcu_read_unlock+0x44/0xb0
   [&lt;fs/file.c:641&gt;] ? dup_fd+0x3c0/0x3c0
   [&lt;mm/mmap.c:1416 mm/mmap.c:1374&gt;] SyS_mmap_pgoff+0x1b0/0x210
   [&lt;arch/x86/kernel/sys_x86_64.c:72&gt;] SyS_mmap+0x1d/0x20
   [&lt;arch/x86/kernel/entry_64.S:749&gt;] tracesys+0xdd/0xe2

Fix it by caching atomic_write_len in kernfs_open_file during open so
that it can be determined without accessing kernfs_ops in
kernfs_fop_write().  This restores the structure of kernfs_fop_write()
before 4d3773c4bb41 with updated @len determination logic.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
References: http://lkml.kernel.org/g/53113485.2090407@oracle.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge 3.14-rc5 into driver-core-next</title>
<updated>2014-03-03T04:09:08+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2014-03-03T04:09:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=13df7977431e3b906a23bb75f29e0f40a8d73f87'/>
<id>13df7977431e3b906a23bb75f29e0f40a8d73f87</id>
<content type='text'>
We want the fixes in here.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We want the fixes in here.
</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: fix namespace refcnt leak</title>
<updated>2014-02-25T15:37:52+00:00</updated>
<author>
<name>Li Zefan</name>
<email>lizefan@huawei.com</email>
</author>
<published>2014-02-25T11:28:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=fed95bab8d29b928fcf6225be72d37ded452e8a2'/>
<id>fed95bab8d29b928fcf6225be72d37ded452e8a2</id>
<content type='text'>
As mount() and kill_sb() is not a one-to-one match, we shoudn't get
ns refcnt unconditionally in sysfs_mount(), and instead we should
get the refcnt only when kernfs_mount() allocated a new superblock.

v2:
- Changed the name of the new argument, suggested by Tejun.
- Made the argument optional, suggested by Tejun.

v3:
- Make the new argument as second-to-last arg, suggested by Tejun.

Signed-off-by: Li Zefan &lt;lizefan@huawei.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
 ---
 fs/kernfs/mount.c      | 8 +++++++-
 fs/sysfs/mount.c       | 5 +++--
 include/linux/kernfs.h | 9 +++++----
 3 files changed, 15 insertions(+), 7 deletions(-)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As mount() and kill_sb() is not a one-to-one match, we shoudn't get
ns refcnt unconditionally in sysfs_mount(), and instead we should
get the refcnt only when kernfs_mount() allocated a new superblock.

v2:
- Changed the name of the new argument, suggested by Tejun.
- Made the argument optional, suggested by Tejun.

v3:
- Make the new argument as second-to-last arg, suggested by Tejun.

Signed-off-by: Li Zefan &lt;lizefan@huawei.com&gt;
Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
 ---
 fs/kernfs/mount.c      | 8 +++++++-
 fs/sysfs/mount.c       | 5 +++--
 include/linux/kernfs.h | 9 +++++----
 3 files changed, 15 insertions(+), 7 deletions(-)
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: add CONFIG_KERNFS</title>
<updated>2014-02-08T00:08:57+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-03T19:09:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ba341d55a420ab4fdd1a53fd395fd59bd65de880'/>
<id>ba341d55a420ab4fdd1a53fd395fd59bd65de880</id>
<content type='text'>
As sysfs was kernfs's only user, kernfs has been piggybacking on
CONFIG_SYSFS; however, kernfs is scheduled to grow a new user very
soon.  Introduce a separate config option CONFIG_KERNFS which is to be
selected by kernfs users.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As sysfs was kernfs's only user, kernfs has been piggybacking on
CONFIG_SYSFS; however, kernfs is scheduled to grow a new user very
soon.  Introduce a separate config option CONFIG_KERNFS which is to be
selected by kernfs users.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: implement kernfs_get_parent(), kernfs_name/path() and friends</title>
<updated>2014-02-08T00:05:35+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-07T18:32:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3eef34ad7dc369b7183ec383908aff3da2f6e5ec'/>
<id>3eef34ad7dc369b7183ec383908aff3da2f6e5ec</id>
<content type='text'>
kernfs_node-&gt;parent and -&gt;name are currently marked as "published"
indicating that kernfs users may access them directly; however, those
fields may get updated by kernfs_rename[_ns]() and unrestricted access
may lead to erroneous values or oops.

Protect -&gt;parent and -&gt;name updates with a irq-safe spinlock
kernfs_rename_lock and implement the following accessors for these
fields.

* kernfs_name()		- format the node's name into the specified buffer
* kernfs_path()		- format the node's path into the specified buffer
* pr_cont_kernfs_name()	- pr_cont a node's name (doesn't need buffer)
* pr_cont_kernfs_path()	- pr_cont a node's path (doesn't need buffer)
* kernfs_get_parent()	- pin and return a node's parent

All can be called under any context.  The recursive sysfs_pathname()
in fs/sysfs/dir.c is replaced with kernfs_path() and
sysfs_rename_dir_ns() is updated to use kernfs_get_parent() instead of
dereferencing parent directly.

v2: Dummy definition of kernfs_path() for !CONFIG_KERNFS was missing
    static inline making it cause a lot of build warnings.  Add it.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
kernfs_node-&gt;parent and -&gt;name are currently marked as "published"
indicating that kernfs users may access them directly; however, those
fields may get updated by kernfs_rename[_ns]() and unrestricted access
may lead to erroneous values or oops.

Protect -&gt;parent and -&gt;name updates with a irq-safe spinlock
kernfs_rename_lock and implement the following accessors for these
fields.

* kernfs_name()		- format the node's name into the specified buffer
* kernfs_path()		- format the node's path into the specified buffer
* pr_cont_kernfs_name()	- pr_cont a node's name (doesn't need buffer)
* pr_cont_kernfs_path()	- pr_cont a node's path (doesn't need buffer)
* kernfs_get_parent()	- pin and return a node's parent

All can be called under any context.  The recursive sysfs_pathname()
in fs/sysfs/dir.c is replaced with kernfs_path() and
sysfs_rename_dir_ns() is updated to use kernfs_get_parent() instead of
dereferencing parent directly.

v2: Dummy definition of kernfs_path() for !CONFIG_KERNFS was missing
    static inline making it cause a lot of build warnings.  Add it.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: implement kernfs_node_from_dentry(), kernfs_root_from_sb() and kernfs_rename()</title>
<updated>2014-02-08T00:00:41+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-03T19:09:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=0c23b2259a4850494e2c53e864ea840597c6cdd3'/>
<id>0c23b2259a4850494e2c53e864ea840597c6cdd3</id>
<content type='text'>
Implement helpers to determine node from dentry and root from
super_block.  Also add a kernfs_rename_ns() wrapper which assumes NULL
namespace.  These generally make sense and will be used by cgroup.

v2: Some dummy implementations for !CONFIG_SYSFS was missing.  Fixed.
    Reported by kbuild test robot.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: kbuild test robot &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement helpers to determine node from dentry and root from
super_block.  Also add a kernfs_rename_ns() wrapper which assumes NULL
namespace.  These generally make sense and will be used by cgroup.

v2: Some dummy implementations for !CONFIG_SYSFS was missing.  Fixed.
    Reported by kbuild test robot.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: kbuild test robot &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: add kernfs_open_file-&gt;priv</title>
<updated>2014-02-08T00:00:40+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-03T19:09:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=2536390da0d300b2734c721235c082498879841d'/>
<id>2536390da0d300b2734c721235c082498879841d</id>
<content type='text'>
Add a private data field to be used by kernfs file operations.  This
generally makes sense and will be used by cgroup.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a private data field to be used by kernfs file operations.  This
generally makes sense and will be used by cgroup.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kernfs: implement kernfs_ops-&gt;atomic_write_len</title>
<updated>2014-02-07T23:52:48+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-03T19:09:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4d3773c4bb41ed5228f1ab7a4a52b79e17b10515'/>
<id>4d3773c4bb41ed5228f1ab7a4a52b79e17b10515</id>
<content type='text'>
A write to a kernfs_node is buffered through a kernel buffer.  Writes
&lt;= PAGE_SIZE are performed atomically, while larger ones are executed
in PAGE_SIZE chunks.  While this is enough for sysfs, cgroup which is
scheduled to be converted to use kernfs needs a bit more control over
it.

This patch adds kernfs_ops-&gt;atomic_write_len.  If not set (zero), the
behavior stays the same.  If set, writes upto the size are executed
atomically and larger writes are rejected with -E2BIG.

A different implementation strategy would be allowing configuring
chunking size while making the original write size available to the
write method; however, such strategy, while being more complicated,
doesn't really buy anything.  If the write implementation has to
handle chunking, the specific chunk size shouldn't matter all that
much.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A write to a kernfs_node is buffered through a kernel buffer.  Writes
&lt;= PAGE_SIZE are performed atomically, while larger ones are executed
in PAGE_SIZE chunks.  While this is enough for sysfs, cgroup which is
scheduled to be converted to use kernfs needs a bit more control over
it.

This patch adds kernfs_ops-&gt;atomic_write_len.  If not set (zero), the
behavior stays the same.  If set, writes upto the size are executed
atomically and larger writes are rejected with -E2BIG.

A different implementation strategy would be allowing configuring
chunking size while making the original write size available to the
write method; however, such strategy, while being more complicated,
doesn't really buy anything.  If the write implementation has to
handle chunking, the specific chunk size shouldn't matter all that
much.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
