<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/ipc/namespace.c, branch v6.6.132</title>
<subtitle>Clone of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git</subtitle>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/'/>
<entry>
<title>ipc: fix memleak if msg_init_ns failed in create_ipc_ns</title>
<updated>2024-12-09T09:32:54+00:00</updated>
<author>
<name>Ma Wupeng</name>
<email>mawupeng1@huawei.com</email>
</author>
<published>2024-10-23T09:31:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=10209665b5bf199f8065b2e7d2b2dc6cdf227117'/>
<id>10209665b5bf199f8065b2e7d2b2dc6cdf227117</id>
<content type='text'>
commit bc8f5921cd69188627c08041276238de222ab466 upstream.

Percpu memory allocation may failed during create_ipc_ns however this
fail is not handled properly since ipc sysctls and mq sysctls is not
released properly. Fix this by release these two resource when failure.

Here is the kmemleak stack when percpu failed:

unreferenced object 0xffff88819de2a600 (size 512):
  comm "shmem_2nstest", pid 120711, jiffies 4300542254
  hex dump (first 32 bytes):
    60 aa 9d 84 ff ff ff ff fc 18 48 b2 84 88 ff ff  `.........H.....
    04 00 00 00 a4 01 00 00 20 e4 56 81 ff ff ff ff  ........ .V.....
  backtrace (crc be7cba35):
    [&lt;ffffffff81b43f83&gt;] __kmalloc_node_track_caller_noprof+0x333/0x420
    [&lt;ffffffff81a52e56&gt;] kmemdup_noprof+0x26/0x50
    [&lt;ffffffff821b2f37&gt;] setup_mq_sysctls+0x57/0x1d0
    [&lt;ffffffff821b29cc&gt;] copy_ipcs+0x29c/0x3b0
    [&lt;ffffffff815d6a10&gt;] create_new_namespaces+0x1d0/0x920
    [&lt;ffffffff815d7449&gt;] copy_namespaces+0x2e9/0x3e0
    [&lt;ffffffff815458f3&gt;] copy_process+0x29f3/0x7ff0
    [&lt;ffffffff8154b080&gt;] kernel_clone+0xc0/0x650
    [&lt;ffffffff8154b6b1&gt;] __do_sys_clone+0xa1/0xe0
    [&lt;ffffffff843df8ff&gt;] do_syscall_64+0xbf/0x1c0
    [&lt;ffffffff846000b0&gt;] entry_SYSCALL_64_after_hwframe+0x4b/0x53

Link: https://lkml.kernel.org/r/20241023093129.3074301-1-mawupeng1@huawei.com
Fixes: 72d1e611082e ("ipc/msg: mitigate the lock contention with percpu counter")
Signed-off-by: Ma Wupeng &lt;mawupeng1@huawei.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.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>
commit bc8f5921cd69188627c08041276238de222ab466 upstream.

Percpu memory allocation may failed during create_ipc_ns however this
fail is not handled properly since ipc sysctls and mq sysctls is not
released properly. Fix this by release these two resource when failure.

Here is the kmemleak stack when percpu failed:

unreferenced object 0xffff88819de2a600 (size 512):
  comm "shmem_2nstest", pid 120711, jiffies 4300542254
  hex dump (first 32 bytes):
    60 aa 9d 84 ff ff ff ff fc 18 48 b2 84 88 ff ff  `.........H.....
    04 00 00 00 a4 01 00 00 20 e4 56 81 ff ff ff ff  ........ .V.....
  backtrace (crc be7cba35):
    [&lt;ffffffff81b43f83&gt;] __kmalloc_node_track_caller_noprof+0x333/0x420
    [&lt;ffffffff81a52e56&gt;] kmemdup_noprof+0x26/0x50
    [&lt;ffffffff821b2f37&gt;] setup_mq_sysctls+0x57/0x1d0
    [&lt;ffffffff821b29cc&gt;] copy_ipcs+0x29c/0x3b0
    [&lt;ffffffff815d6a10&gt;] create_new_namespaces+0x1d0/0x920
    [&lt;ffffffff815d7449&gt;] copy_namespaces+0x2e9/0x3e0
    [&lt;ffffffff815458f3&gt;] copy_process+0x29f3/0x7ff0
    [&lt;ffffffff8154b080&gt;] kernel_clone+0xc0/0x650
    [&lt;ffffffff8154b6b1&gt;] __do_sys_clone+0xa1/0xe0
    [&lt;ffffffff843df8ff&gt;] do_syscall_64+0xbf/0x1c0
    [&lt;ffffffff846000b0&gt;] entry_SYSCALL_64_after_hwframe+0x4b/0x53

Link: https://lkml.kernel.org/r/20241023093129.3074301-1-mawupeng1@huawei.com
Fixes: 72d1e611082e ("ipc/msg: mitigate the lock contention with percpu counter")
Signed-off-by: Ma Wupeng &lt;mawupeng1@huawei.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc,namespace: batch free ipc_namespace structures</title>
<updated>2023-01-28T00:08:00+00:00</updated>
<author>
<name>Rik van Riel</name>
<email>riel@surriel.com</email>
</author>
<published>2023-01-27T18:46:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=da27f796a832122ee533c7685438dad1c4e338dd'/>
<id>da27f796a832122ee533c7685438dad1c4e338dd</id>
<content type='text'>
Instead of waiting for an RCU grace period between each ipc_namespace
structure that is being freed, wait an RCU grace period for every batch
of ipc_namespace structures.

Thanks to Al Viro for the suggestion of the helper function.

This speeds up the run time of the test case that allocates ipc_namespaces
in a loop from 6 minutes, to a little over 1 second:

real	0m1.192s
user	0m0.038s
sys	0m1.152s

Signed-off-by: Rik van Riel &lt;riel@surriel.com&gt;
Reported-by: Chris Mason &lt;clm@meta.com&gt;
Tested-by: Giuseppe Scrivano &lt;gscrivan@redhat.com&gt;
Suggested-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Instead of waiting for an RCU grace period between each ipc_namespace
structure that is being freed, wait an RCU grace period for every batch
of ipc_namespace structures.

Thanks to Al Viro for the suggestion of the helper function.

This speeds up the run time of the test case that allocates ipc_namespaces
in a loop from 6 minutes, to a little over 1 second:

real	0m1.192s
user	0m0.038s
sys	0m1.152s

Signed-off-by: Rik van Riel &lt;riel@surriel.com&gt;
Reported-by: Chris Mason &lt;clm@meta.com&gt;
Tested-by: Giuseppe Scrivano &lt;gscrivan@redhat.com&gt;
Suggested-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc,namespace: make ipc namespace allocation wait for pending free</title>
<updated>2023-01-28T00:07:59+00:00</updated>
<author>
<name>Rik van Riel</name>
<email>riel@surriel.com</email>
</author>
<published>2023-01-27T18:46:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=a80c4adcb574821e534779c48ae13953b7d1d996'/>
<id>a80c4adcb574821e534779c48ae13953b7d1d996</id>
<content type='text'>
Currently the ipc namespace allocation will fail when there are
ipc_namespace structures pending to be freed. This results in the
simple test case below, as well as some real world workloads, to
get allocation failures even when the number of ipc namespaces in
actual use is way below the limit.

int main()
{
	int i;

	for (i = 0; i &lt; 100000; i++) {
		if (unshare(CLONE_NEWIPC) &lt; 0)
			error(EXIT_FAILURE, errno, "unshare");
	}
}

Make the allocation of an ipc_namespace wait for pending frees,
so it will succeed.

real	6m19.197s
user	0m0.041s
sys	0m1.019s

Signed-off-by: Rik van Riel &lt;riel@surriel.com&gt;
Reported-by: Chris Mason &lt;clm@meta.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently the ipc namespace allocation will fail when there are
ipc_namespace structures pending to be freed. This results in the
simple test case below, as well as some real world workloads, to
get allocation failures even when the number of ipc namespaces in
actual use is way below the limit.

int main()
{
	int i;

	for (i = 0; i &lt; 100000; i++) {
		if (unshare(CLONE_NEWIPC) &lt; 0)
			error(EXIT_FAILURE, errno, "unshare");
	}
}

Make the allocation of an ipc_namespace wait for pending frees,
so it will succeed.

real	6m19.197s
user	0m0.041s
sys	0m1.019s

Signed-off-by: Rik van Riel &lt;riel@surriel.com&gt;
Reported-by: Chris Mason &lt;clm@meta.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc/msg: mitigate the lock contention with percpu counter</title>
<updated>2022-10-03T21:21:44+00:00</updated>
<author>
<name>Jiebin Sun</name>
<email>jiebin.sun@intel.com</email>
</author>
<published>2022-09-13T19:25:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=72d1e611082eda18689106a0c192f2827072713c'/>
<id>72d1e611082eda18689106a0c192f2827072713c</id>
<content type='text'>
The msg_bytes and msg_hdrs atomic counters are frequently updated when IPC
msg queue is in heavy use, causing heavy cache bounce and overhead. 
Change them to percpu_counter greatly improve the performance.  Since
there is one percpu struct per namespace, additional memory cost is
minimal.  Reading of the count done in msgctl call, which is infrequent. 
So the need to sum up the counts in each CPU is infrequent.

Apply the patch and test the pts/stress-ng-1.4.0
-- system v message passing (160 threads).

Score gain: 3.99x

CPU: ICX 8380 x 2 sockets
Core number: 40 x 2 physical cores
Benchmark: pts/stress-ng-1.4.0
-- system v message passing (160 threads)

[akpm@linux-foundation.org: coding-style cleanups]
[jiebin.sun@intel.com: avoid negative value by overflow in msginfo]
  Link: https://lkml.kernel.org/r/20220920150809.4014944-1-jiebin.sun@intel.com
[akpm@linux-foundation.org: fix min() warnings]
Link: https://lkml.kernel.org/r/20220913192538.3023708-3-jiebin.sun@intel.com
Signed-off-by: Jiebin Sun &lt;jiebin.sun@intel.com&gt;
Reviewed-by: Tim Chen &lt;tim.c.chen@linux.intel.com&gt;
Cc: Alexander Mikhalitsyn &lt;alexander.mikhalitsyn@virtuozzo.com&gt;
Cc: Alexey Gladkov &lt;legion@kernel.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Davidlohr Bueso &lt;dave@stgolabs.net&gt;
Cc: Dennis Zhou &lt;dennis@kernel.org&gt;
Cc: "Eric W . Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Vasily Averin &lt;vasily.averin@linux.dev&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The msg_bytes and msg_hdrs atomic counters are frequently updated when IPC
msg queue is in heavy use, causing heavy cache bounce and overhead. 
Change them to percpu_counter greatly improve the performance.  Since
there is one percpu struct per namespace, additional memory cost is
minimal.  Reading of the count done in msgctl call, which is infrequent. 
So the need to sum up the counts in each CPU is infrequent.

Apply the patch and test the pts/stress-ng-1.4.0
-- system v message passing (160 threads).

Score gain: 3.99x

CPU: ICX 8380 x 2 sockets
Core number: 40 x 2 physical cores
Benchmark: pts/stress-ng-1.4.0
-- system v message passing (160 threads)

[akpm@linux-foundation.org: coding-style cleanups]
[jiebin.sun@intel.com: avoid negative value by overflow in msginfo]
  Link: https://lkml.kernel.org/r/20220920150809.4014944-1-jiebin.sun@intel.com
[akpm@linux-foundation.org: fix min() warnings]
Link: https://lkml.kernel.org/r/20220913192538.3023708-3-jiebin.sun@intel.com
Signed-off-by: Jiebin Sun &lt;jiebin.sun@intel.com&gt;
Reviewed-by: Tim Chen &lt;tim.c.chen@linux.intel.com&gt;
Cc: Alexander Mikhalitsyn &lt;alexander.mikhalitsyn@virtuozzo.com&gt;
Cc: Alexey Gladkov &lt;legion@kernel.org&gt;
Cc: Christoph Lameter &lt;cl@linux.com&gt;
Cc: Davidlohr Bueso &lt;dave@stgolabs.net&gt;
Cc: Dennis Zhou &lt;dennis@kernel.org&gt;
Cc: "Eric W . Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Vasily Averin &lt;vasily.averin@linux.dev&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc: Free mq_sysctls if ipc namespace creation failed</title>
<updated>2022-06-22T22:47:41+00:00</updated>
<author>
<name>Alexey Gladkov</name>
<email>legion@kernel.org</email>
</author>
<published>2022-06-22T20:07:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=db7cfc380900bc4243b09623fd72fabe0a8ff23b'/>
<id>db7cfc380900bc4243b09623fd72fabe0a8ff23b</id>
<content type='text'>
The problem that Dmitry Vyukov pointed out is that if setup_ipc_sysctls fails,
mq_sysctls must be freed before return.

executing program
BUG: memory leak
unreferenced object 0xffff888112fc9200 (size 512):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    ef d3 60 85 ff ff ff ff 0c 9b d2 12 81 88 ff ff  ..`.............
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff814b6eb3&gt;] kmemdup+0x23/0x50 mm/util.c:129
    [&lt;ffffffff82219a9b&gt;] kmemdup include/linux/fortify-string.h:456 [inline]
    [&lt;ffffffff82219a9b&gt;] setup_mq_sysctls+0x4b/0x1c0 ipc/mq_sysctl.c:89
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fd5f00 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    00 92 fc 12 81 88 ff ff 00 00 00 00 01 00 00 00  ................
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fea1b&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fea1b&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fea1b&gt;] __register_sysctl_table+0x7b/0x7f0 fs/proc/proc_sysctl.c:1344
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fbba00 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    78 ba fb 12 81 88 ff ff 00 00 00 00 01 00 00 00  x...............
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fef49&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fef49&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fef49&gt;] new_dir fs/proc/proc_sysctl.c:978 [inline]
    [&lt;ffffffff816fef49&gt;] get_subdir fs/proc/proc_sysctl.c:1022 [inline]
    [&lt;ffffffff816fef49&gt;] __register_sysctl_table+0x5a9/0x7f0 fs/proc/proc_sysctl.c:1373
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fbb900 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    78 b9 fb 12 81 88 ff ff 00 00 00 00 01 00 00 00  x...............
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fef49&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fef49&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fef49&gt;] new_dir fs/proc/proc_sysctl.c:978 [inline]
    [&lt;ffffffff816fef49&gt;] get_subdir fs/proc/proc_sysctl.c:1022 [inline]
    [&lt;ffffffff816fef49&gt;] __register_sysctl_table+0x5a9/0x7f0 fs/proc/proc_sysctl.c:1373
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

Reported-by: syzbot+b4b0d1b35442afbf6fd2@syzkaller.appspotmail.com
Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/000000000000f5004705e1db8bad@google.com
Link: https://lkml.kernel.org/r/20220622200729.2639663-1-legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The problem that Dmitry Vyukov pointed out is that if setup_ipc_sysctls fails,
mq_sysctls must be freed before return.

executing program
BUG: memory leak
unreferenced object 0xffff888112fc9200 (size 512):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    ef d3 60 85 ff ff ff ff 0c 9b d2 12 81 88 ff ff  ..`.............
    04 00 00 00 a4 01 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff814b6eb3&gt;] kmemdup+0x23/0x50 mm/util.c:129
    [&lt;ffffffff82219a9b&gt;] kmemdup include/linux/fortify-string.h:456 [inline]
    [&lt;ffffffff82219a9b&gt;] setup_mq_sysctls+0x4b/0x1c0 ipc/mq_sysctl.c:89
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fd5f00 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    00 92 fc 12 81 88 ff ff 00 00 00 00 01 00 00 00  ................
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fea1b&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fea1b&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fea1b&gt;] __register_sysctl_table+0x7b/0x7f0 fs/proc/proc_sysctl.c:1344
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fbba00 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    78 ba fb 12 81 88 ff ff 00 00 00 00 01 00 00 00  x...............
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fef49&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fef49&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fef49&gt;] new_dir fs/proc/proc_sysctl.c:978 [inline]
    [&lt;ffffffff816fef49&gt;] get_subdir fs/proc/proc_sysctl.c:1022 [inline]
    [&lt;ffffffff816fef49&gt;] __register_sysctl_table+0x5a9/0x7f0 fs/proc/proc_sysctl.c:1373
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

BUG: memory leak
unreferenced object 0xffff888112fbb900 (size 256):
  comm "syz-executor237", pid 3648, jiffies 4294970469 (age 12.270s)
  hex dump (first 32 bytes):
    78 b9 fb 12 81 88 ff ff 00 00 00 00 01 00 00 00  x...............
    01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;ffffffff816fef49&gt;] kmalloc include/linux/slab.h:605 [inline]
    [&lt;ffffffff816fef49&gt;] kzalloc include/linux/slab.h:733 [inline]
    [&lt;ffffffff816fef49&gt;] new_dir fs/proc/proc_sysctl.c:978 [inline]
    [&lt;ffffffff816fef49&gt;] get_subdir fs/proc/proc_sysctl.c:1022 [inline]
    [&lt;ffffffff816fef49&gt;] __register_sysctl_table+0x5a9/0x7f0 fs/proc/proc_sysctl.c:1373
    [&lt;ffffffff82219b7a&gt;] setup_mq_sysctls+0x12a/0x1c0 ipc/mq_sysctl.c:112
    [&lt;ffffffff822197f2&gt;] create_ipc_ns ipc/namespace.c:63 [inline]
    [&lt;ffffffff822197f2&gt;] copy_ipcs+0x292/0x390 ipc/namespace.c:91
    [&lt;ffffffff8127de7c&gt;] create_new_namespaces+0xdc/0x4f0 kernel/nsproxy.c:90
    [&lt;ffffffff8127e89b&gt;] unshare_nsproxy_namespaces+0x9b/0x120 kernel/nsproxy.c:226
    [&lt;ffffffff8123f92e&gt;] ksys_unshare+0x2fe/0x600 kernel/fork.c:3165
    [&lt;ffffffff8123fc42&gt;] __do_sys_unshare kernel/fork.c:3236 [inline]
    [&lt;ffffffff8123fc42&gt;] __se_sys_unshare kernel/fork.c:3234 [inline]
    [&lt;ffffffff8123fc42&gt;] __x64_sys_unshare+0x12/0x20 kernel/fork.c:3234
    [&lt;ffffffff845aab45&gt;] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
    [&lt;ffffffff845aab45&gt;] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
    [&lt;ffffffff8460006a&gt;] entry_SYSCALL_64_after_hwframe+0x46/0xb0

Reported-by: syzbot+b4b0d1b35442afbf6fd2@syzkaller.appspotmail.com
Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/000000000000f5004705e1db8bad@google.com
Link: https://lkml.kernel.org/r/20220622200729.2639663-1-legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc: Store ipc sysctls in the ipc namespace</title>
<updated>2022-03-08T19:39:40+00:00</updated>
<author>
<name>Alexey Gladkov</name>
<email>legion@kernel.org</email>
</author>
<published>2022-02-14T18:18:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=1f5c135ee509e89e0cc274333a65f73c62cb16e5'/>
<id>1f5c135ee509e89e0cc274333a65f73c62cb16e5</id>
<content type='text'>
The ipc sysctls are not available for modification inside the user
namespace. Following the mqueue sysctls, we changed the implementation
to be more userns friendly.

So far, the changes do not provide additional access to files. This
will be done in a future patch.

Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/be6f9d014276f4dddd0c3aa05a86052856c1c555.1644862280.git.legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The ipc sysctls are not available for modification inside the user
namespace. Following the mqueue sysctls, we changed the implementation
to be more userns friendly.

So far, the changes do not provide additional access to files. This
will be done in a future patch.

Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/be6f9d014276f4dddd0c3aa05a86052856c1c555.1644862280.git.legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc: Store mqueue sysctls in the ipc namespace</title>
<updated>2022-03-08T19:39:40+00:00</updated>
<author>
<name>Alexey Gladkov</name>
<email>legion@kernel.org</email>
</author>
<published>2022-02-14T18:18:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=dc55e35f9e810f23dd69cfdc91a3d636023f57a2'/>
<id>dc55e35f9e810f23dd69cfdc91a3d636023f57a2</id>
<content type='text'>
Right now, the mqueue sysctls take ipc namespaces into account in a
rather hacky way. This works in most cases, but does not respect the
user namespace.

Within the user namespace, the user cannot change the /proc/sys/fs/mqueue/*
parametres. This poses a problem in the rootless containers.

To solve this I changed the implementation of the mqueue sysctls just
like some other sysctls.

So far, the changes do not provide additional access to files. This will
be done in a future patch.

v3:
* Don't implemenet set_permissions to keep the current behavior.

v2:
* Fixed compilation problem if CONFIG_POSIX_MQUEUE_SYSCTL is not
  specified.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/b0ccbb2489119f1f20c737cf1930c3a9c4e4243a.1644862280.git.legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Right now, the mqueue sysctls take ipc namespaces into account in a
rather hacky way. This works in most cases, but does not respect the
user namespace.

Within the user namespace, the user cannot change the /proc/sys/fs/mqueue/*
parametres. This poses a problem in the rootless containers.

To solve this I changed the implementation of the mqueue sysctls just
like some other sysctls.

So far, the changes do not provide additional access to files. This will
be done in a future patch.

v3:
* Don't implemenet set_permissions to keep the current behavior.

v2:
* Fixed compilation problem if CONFIG_POSIX_MQUEUE_SYSCTL is not
  specified.

Reported-by: kernel test robot &lt;lkp@intel.com&gt;
Signed-off-by: Alexey Gladkov &lt;legion@kernel.org&gt;
Link: https://lkml.kernel.org/r/b0ccbb2489119f1f20c737cf1930c3a9c4e4243a.1644862280.git.legion@kernel.org
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>memcg: enable accounting for new namesapces and struct nsproxy</title>
<updated>2021-09-03T16:58:12+00:00</updated>
<author>
<name>Vasily Averin</name>
<email>vvs@virtuozzo.com</email>
</author>
<published>2021-09-02T21:55:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=30acd0bdfb86548172168a0cc71d455944de0683'/>
<id>30acd0bdfb86548172168a0cc71d455944de0683</id>
<content type='text'>
Container admin can create new namespaces and force kernel to allocate up
to several pages of memory for the namespaces and its associated
structures.

Net and uts namespaces have enabled accounting for such allocations.  It
makes sense to account for rest ones to restrict the host's memory
consumption from inside the memcg-limited container.

Link: https://lkml.kernel.org/r/5525bcbf-533e-da27-79b7-158686c64e13@virtuozzo.com
Signed-off-by: Vasily Averin &lt;vvs@virtuozzo.com&gt;
Acked-by: Serge Hallyn &lt;serge@hallyn.com&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Acked-by: Kirill Tkhai &lt;ktkhai@virtuozzo.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Alexander Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Andrei Vagin &lt;avagin@gmail.com&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Borislav Petkov &lt;bp@suse.de&gt;
Cc: Dmitry Safonov &lt;0x7f454c46@gmail.com&gt;
Cc: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: "J. Bruce Fields" &lt;bfields@fieldses.org&gt;
Cc: Jeff Layton &lt;jlayton@kernel.org&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Jiri Slaby &lt;jirislaby@kernel.org&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@kernel.org&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Roman Gushchin &lt;guro@fb.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Vladimir Davydov &lt;vdavydov.dev@gmail.com&gt;
Cc: Yutian Yang &lt;nglaive@gmail.com&gt;
Cc: Zefan Li &lt;lizefan.x@bytedance.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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Container admin can create new namespaces and force kernel to allocate up
to several pages of memory for the namespaces and its associated
structures.

Net and uts namespaces have enabled accounting for such allocations.  It
makes sense to account for rest ones to restrict the host's memory
consumption from inside the memcg-limited container.

Link: https://lkml.kernel.org/r/5525bcbf-533e-da27-79b7-158686c64e13@virtuozzo.com
Signed-off-by: Vasily Averin &lt;vvs@virtuozzo.com&gt;
Acked-by: Serge Hallyn &lt;serge@hallyn.com&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Acked-by: Kirill Tkhai &lt;ktkhai@virtuozzo.com&gt;
Reviewed-by: Shakeel Butt &lt;shakeelb@google.com&gt;
Cc: Alexander Viro &lt;viro@zeniv.linux.org.uk&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Andrei Vagin &lt;avagin@gmail.com&gt;
Cc: Borislav Petkov &lt;bp@alien8.de&gt;
Cc: Borislav Petkov &lt;bp@suse.de&gt;
Cc: Dmitry Safonov &lt;0x7f454c46@gmail.com&gt;
Cc: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: "H. Peter Anvin" &lt;hpa@zytor.com&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: "J. Bruce Fields" &lt;bfields@fieldses.org&gt;
Cc: Jeff Layton &lt;jlayton@kernel.org&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Jiri Slaby &lt;jirislaby@kernel.org&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@kernel.org&gt;
Cc: Oleg Nesterov &lt;oleg@redhat.com&gt;
Cc: Roman Gushchin &lt;guro@fb.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Vladimir Davydov &lt;vdavydov.dev@gmail.com&gt;
Cc: Yutian Yang &lt;nglaive@gmail.com&gt;
Cc: Zefan Li &lt;lizefan.x@bytedance.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc: Use generic ns_common::count</title>
<updated>2020-08-19T12:13:52+00:00</updated>
<author>
<name>Kirill Tkhai</name>
<email>ktkhai@virtuozzo.com</email>
</author>
<published>2020-08-03T10:16:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=137ec390fad41928307216ea9f91acf5cf6f4204'/>
<id>137ec390fad41928307216ea9f91acf5cf6f4204</id>
<content type='text'>
Switch over ipc namespaces to use the newly introduced common lifetime
counter.

Currently every namespace type has its own lifetime counter which is stored
in the specific namespace struct. The lifetime counters are used
identically for all namespaces types. Namespaces may of course have
additional unrelated counters and these are not altered.

This introduces a common lifetime counter into struct ns_common. The
ns_common struct encompasses information that all namespaces share. That
should include the lifetime counter since its common for all of them.

It also allows us to unify the type of the counters across all namespaces.
Most of them use refcount_t but one uses atomic_t and at least one uses
kref. Especially the last one doesn't make much sense since it's just a
wrapper around refcount_t since 2016 and actually complicates cleanup
operations by having to use container_of() to cast the correct namespace
struct out of struct ns_common.

Having the lifetime counter for the namespaces in one place reduces
maintenance cost. Not just because after switching all namespaces over we
will have removed more code than we added but also because the logic is
more easily understandable and we indicate to the user that the basic
lifetime requirements for all namespaces are currently identical.

Signed-off-by: Kirill Tkhai &lt;ktkhai@virtuozzo.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Link: https://lore.kernel.org/r/159644978697.604812.16592754423881032385.stgit@localhost.localdomain
Signed-off-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Switch over ipc namespaces to use the newly introduced common lifetime
counter.

Currently every namespace type has its own lifetime counter which is stored
in the specific namespace struct. The lifetime counters are used
identically for all namespaces types. Namespaces may of course have
additional unrelated counters and these are not altered.

This introduces a common lifetime counter into struct ns_common. The
ns_common struct encompasses information that all namespaces share. That
should include the lifetime counter since its common for all of them.

It also allows us to unify the type of the counters across all namespaces.
Most of them use refcount_t but one uses atomic_t and at least one uses
kref. Especially the last one doesn't make much sense since it's just a
wrapper around refcount_t since 2016 and actually complicates cleanup
operations by having to use container_of() to cast the correct namespace
struct out of struct ns_common.

Having the lifetime counter for the namespaces in one place reduces
maintenance cost. Not just because after switching all namespaces over we
will have removed more code than we added but also because the logic is
more easily understandable and we indicate to the user that the basic
lifetime requirements for all namespaces are currently identical.

Signed-off-by: Kirill Tkhai &lt;ktkhai@virtuozzo.com&gt;
Reviewed-by: Kees Cook &lt;keescook@chromium.org&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Link: https://lore.kernel.org/r/159644978697.604812.16592754423881032385.stgit@localhost.localdomain
Signed-off-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipc/namespace.c: use a work queue to free_ipc</title>
<updated>2020-06-08T18:05:56+00:00</updated>
<author>
<name>Giuseppe Scrivano</name>
<email>gscrivan@redhat.com</email>
</author>
<published>2020-06-08T04:40:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.exis.tech/linux.git/commit/?id=e1eb26fa62d04ec0955432be1aa8722a97cb52e7'/>
<id>e1eb26fa62d04ec0955432be1aa8722a97cb52e7</id>
<content type='text'>
the reason is to avoid a delay caused by the synchronize_rcu() call in
kern_umount() when the mqueue mount is freed.

the code:

    #define _GNU_SOURCE
    #include &lt;sched.h&gt;
    #include &lt;error.h&gt;
    #include &lt;errno.h&gt;
    #include &lt;stdlib.h&gt;

    int main()
    {
        int i;

        for (i = 0; i &lt; 1000; i++)
            if (unshare(CLONE_NEWIPC) &lt; 0)
                error(EXIT_FAILURE, errno, "unshare");
    }

goes from

	Command being timed: "./ipc-namespace"
	User time (seconds): 0.00
	System time (seconds): 0.06
	Percent of CPU this job got: 0%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:08.05

to

	Command being timed: "./ipc-namespace"
	User time (seconds): 0.00
	System time (seconds): 0.02
	Percent of CPU this job got: 96%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.03

Signed-off-by: Giuseppe Scrivano &lt;gscrivan@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Reviewed-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Cc: Davidlohr Bueso &lt;dave@stgolabs.net&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Link: http://lkml.kernel.org/r/20200225145419.527994-1-gscrivan@redhat.com
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the reason is to avoid a delay caused by the synchronize_rcu() call in
kern_umount() when the mqueue mount is freed.

the code:

    #define _GNU_SOURCE
    #include &lt;sched.h&gt;
    #include &lt;error.h&gt;
    #include &lt;errno.h&gt;
    #include &lt;stdlib.h&gt;

    int main()
    {
        int i;

        for (i = 0; i &lt; 1000; i++)
            if (unshare(CLONE_NEWIPC) &lt; 0)
                error(EXIT_FAILURE, errno, "unshare");
    }

goes from

	Command being timed: "./ipc-namespace"
	User time (seconds): 0.00
	System time (seconds): 0.06
	Percent of CPU this job got: 0%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:08.05

to

	Command being timed: "./ipc-namespace"
	User time (seconds): 0.00
	System time (seconds): 0.02
	Percent of CPU this job got: 96%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.03

Signed-off-by: Giuseppe Scrivano &lt;gscrivan@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Reviewed-by: Paul E. McKenney &lt;paulmck@kernel.org&gt;
Reviewed-by: Waiman Long &lt;longman@redhat.com&gt;
Cc: Davidlohr Bueso &lt;dave@stgolabs.net&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Link: http://lkml.kernel.org/r/20200225145419.527994-1-gscrivan@redhat.com
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
