<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/kernel, branch v4.9.7</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>perf/core: Fix concurrent sys_perf_event_open() vs. 'move_group' race</title>
<updated>2017-02-01T07:33:14+00:00</updated>
<author>
<name>Peter Zijlstra</name>
<email>peterz@infradead.org</email>
</author>
<published>2017-01-11T20:09:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=922813f4d66fb317e8602d058d03a1619af1ffd0'/>
<id>922813f4d66fb317e8602d058d03a1619af1ffd0</id>
<content type='text'>
commit 321027c1fe77f892f4ea07846aeae08cefbbb290 upstream.

Di Shen reported a race between two concurrent sys_perf_event_open()
calls where both try and move the same pre-existing software group
into a hardware context.

The problem is exactly that described in commit:

  f63a8daa5812 ("perf: Fix event-&gt;ctx locking")

... where, while we wait for a ctx-&gt;mutex acquisition, the event-&gt;ctx
relation can have changed under us.

That very same commit failed to recognise sys_perf_event_context() as an
external access vector to the events and thereby didn't apply the
established locking rules correctly.

So while one sys_perf_event_open() call is stuck waiting on
mutex_lock_double(), the other (which owns said locks) moves the group
about. So by the time the former sys_perf_event_open() acquires the
locks, the context we've acquired is stale (and possibly dead).

Apply the established locking rules as per perf_event_ctx_lock_nested()
to the mutex_lock_double() for the 'move_group' case. This obviously means
we need to validate state after we acquire the locks.

Reported-by: Di Shen (Keen Lab)
Tested-by: John Dias &lt;joaodias@google.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Jiri Olsa &lt;jolsa@redhat.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Min Chong &lt;mchong@google.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Stephane Eranian &lt;eranian@google.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Fixes: f63a8daa5812 ("perf: Fix event-&gt;ctx locking")
Link: http://lkml.kernel.org/r/20170106131444.GZ3174@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar &lt;mingo@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>
commit 321027c1fe77f892f4ea07846aeae08cefbbb290 upstream.

Di Shen reported a race between two concurrent sys_perf_event_open()
calls where both try and move the same pre-existing software group
into a hardware context.

The problem is exactly that described in commit:

  f63a8daa5812 ("perf: Fix event-&gt;ctx locking")

... where, while we wait for a ctx-&gt;mutex acquisition, the event-&gt;ctx
relation can have changed under us.

That very same commit failed to recognise sys_perf_event_context() as an
external access vector to the events and thereby didn't apply the
established locking rules correctly.

So while one sys_perf_event_open() call is stuck waiting on
mutex_lock_double(), the other (which owns said locks) moves the group
about. So by the time the former sys_perf_event_open() acquires the
locks, the context we've acquired is stale (and possibly dead).

Apply the established locking rules as per perf_event_ctx_lock_nested()
to the mutex_lock_double() for the 'move_group' case. This obviously means
we need to validate state after we acquire the locks.

Reported-by: Di Shen (Keen Lab)
Tested-by: John Dias &lt;joaodias@google.com&gt;
Signed-off-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Jiri Olsa &lt;jolsa@redhat.com&gt;
Cc: Kees Cook &lt;keescook@chromium.org&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Min Chong &lt;mchong@google.com&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Stephane Eranian &lt;eranian@google.com&gt;
Cc: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Fixes: f63a8daa5812 ("perf: Fix event-&gt;ctx locking")
Link: http://lkml.kernel.org/r/20170106131444.GZ3174@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysctl: fix proc_doulongvec_ms_jiffies_minmax()</title>
<updated>2017-02-01T07:33:05+00:00</updated>
<author>
<name>Eric Dumazet</name>
<email>edumazet@google.com</email>
</author>
<published>2017-01-26T02:20:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=03707d6c36f9c7355c22e43039c09804e96a02b6'/>
<id>03707d6c36f9c7355c22e43039c09804e96a02b6</id>
<content type='text'>
commit ff9f8a7cf935468a94d9927c68b00daae701667e upstream.

We perform the conversion between kernel jiffies and ms only when
exporting kernel value to user space.

We need to do the opposite operation when value is written by user.

Only matters when HZ != 1000

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@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 ff9f8a7cf935468a94d9927c68b00daae701667e upstream.

We perform the conversion between kernel jiffies and ms only when
exporting kernel value to user space.

We need to do the opposite operation when value is written by user.

Only matters when HZ != 1000

Signed-off-by: Eric Dumazet &lt;edumazet@google.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>userns: Make ucounts lock irq-safe</title>
<updated>2017-02-01T07:33:05+00:00</updated>
<author>
<name>Nikolay Borisov</name>
<email>n.borisov.lkml@gmail.com</email>
</author>
<published>2017-01-20T13:21:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=c7556867782ee8ae0383a1e99df09222f1f01332'/>
<id>c7556867782ee8ae0383a1e99df09222f1f01332</id>
<content type='text'>
commit 880a38547ff08715ce4f1daf9a4bb30c87676e68 upstream.

The ucounts_lock is being used to protect various ucounts lifecycle
management functionalities. However, those services can also be invoked
when a pidns is being freed in an RCU callback (e.g. softirq context).
This can lead to deadlocks. There were already efforts trying to
prevent similar deadlocks in add7c65ca426 ("pid: fix lockdep deadlock
warning due to ucount_lock"), however they just moved the context
from hardirq to softrq. Fix this issue once and for all by explictly
making the lock disable irqs altogether.

Dmitry Vyukov &lt;dvyukov@google.com&gt; reported:

&gt; I've got the following deadlock report while running syzkaller fuzzer
&gt; on eec0d3d065bfcdf9cd5f56dd2a36b94d12d32297 of linux-next (on odroid
&gt; device if it matters):
&gt;
&gt; =================================
&gt; [ INFO: inconsistent lock state ]
&gt; 4.10.0-rc3-next-20170112-xc2-dirty #6 Not tainted
&gt; ---------------------------------
&gt; inconsistent {SOFTIRQ-ON-W} -&gt; {IN-SOFTIRQ-W} usage.
&gt; swapper/2/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
&gt;  (ucounts_lock){+.?...}, at: [&lt;     inline     &gt;] spin_lock
&gt; ./include/linux/spinlock.h:302
&gt;  (ucounts_lock){+.?...}, at: [&lt;ffff2000081678c8&gt;]
&gt; put_ucounts+0x60/0x138 kernel/ucount.c:162
&gt; {SOFTIRQ-ON-W} state was registered at:
&gt; [&lt;ffff2000081c82d8&gt;] mark_lock+0x220/0xb60 kernel/locking/lockdep.c:3054
&gt; [&lt;     inline     &gt;] mark_irqflags kernel/locking/lockdep.c:2941
&gt; [&lt;ffff2000081c97a8&gt;] __lock_acquire+0x388/0x3260 kernel/locking/lockdep.c:3295
&gt; [&lt;ffff2000081cce24&gt;] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753
&gt; [&lt;     inline     &gt;] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144
&gt; [&lt;ffff200009798128&gt;] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151
&gt; [&lt;     inline     &gt;] spin_lock ./include/linux/spinlock.h:302
&gt; [&lt;     inline     &gt;] get_ucounts kernel/ucount.c:131
&gt; [&lt;ffff200008167c28&gt;] inc_ucount+0x80/0x6c8 kernel/ucount.c:189
&gt; [&lt;     inline     &gt;] inc_mnt_namespaces fs/namespace.c:2818
&gt; [&lt;ffff200008481850&gt;] alloc_mnt_ns+0x78/0x3a8 fs/namespace.c:2849
&gt; [&lt;ffff200008487298&gt;] create_mnt_ns+0x28/0x200 fs/namespace.c:2959
&gt; [&lt;     inline     &gt;] init_mount_tree fs/namespace.c:3199
&gt; [&lt;ffff200009bd6674&gt;] mnt_init+0x258/0x384 fs/namespace.c:3251
&gt; [&lt;ffff200009bd60bc&gt;] vfs_caches_init+0x6c/0x80 fs/dcache.c:3626
&gt; [&lt;ffff200009bb1114&gt;] start_kernel+0x414/0x460 init/main.c:648
&gt; [&lt;ffff200009bb01e8&gt;] __primary_switched+0x6c/0x70 arch/arm64/kernel/head.S:456
&gt; irq event stamp: 2316924
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2911
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; hardirqs last  enabled at (2316924): [&lt;ffff200008210414&gt;]
&gt; rcu_process_callbacks+0x7a4/0xc28 kernel/rcu/tree.c:3166
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2900
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; hardirqs last disabled at (2316923): [&lt;ffff20000820fe80&gt;]
&gt; rcu_process_callbacks+0x210/0xc28 kernel/rcu/tree.c:3166
&gt; softirqs last  enabled at (2316912): [&lt;ffff20000811b4c4&gt;]
&gt; _local_bh_enable+0x4c/0x80 kernel/softirq.c:155
&gt; softirqs last disabled at (2316913): [&lt;     inline     &gt;]
&gt; do_softirq_own_stack ./include/linux/interrupt.h:488
&gt; softirqs last disabled at (2316913): [&lt;     inline     &gt;]
&gt; invoke_softirq kernel/softirq.c:371
&gt; softirqs last disabled at (2316913): [&lt;ffff20000811c994&gt;]
&gt; irq_exit+0x264/0x308 kernel/softirq.c:405
&gt;
&gt; other info that might help us debug this:
&gt;  Possible unsafe locking scenario:
&gt;
&gt;        CPU0
&gt;        ----
&gt;   lock(ucounts_lock);
&gt;   &lt;Interrupt&gt;
&gt;     lock(ucounts_lock);
&gt;
&gt;  *** DEADLOCK ***
&gt;
&gt; 1 lock held by swapper/2/0:
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;] __rcu_reclaim
&gt; kernel/rcu/rcu.h:108
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2919
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt;  #0:  (rcu_callback){......}, at: [&lt;ffff200008210390&gt;]
&gt; rcu_process_callbacks+0x720/0xc28 kernel/rcu/tree.c:3166
&gt;
&gt; stack backtrace:
&gt; CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.10.0-rc3-next-20170112-xc2-dirty #6
&gt; Hardware name: Hardkernel ODROID-C2 (DT)
&gt; Call trace:
&gt; [&lt;ffff20000808fa60&gt;] dump_backtrace+0x0/0x440 arch/arm64/kernel/traps.c:500
&gt; [&lt;ffff20000808fec0&gt;] show_stack+0x20/0x30 arch/arm64/kernel/traps.c:225
&gt; [&lt;ffff2000088a99e0&gt;] dump_stack+0x110/0x168
&gt; [&lt;ffff2000082fa2b4&gt;] print_usage_bug.part.27+0x49c/0x4bc
&gt; kernel/locking/lockdep.c:2387
&gt; [&lt;     inline     &gt;] print_usage_bug kernel/locking/lockdep.c:2357
&gt; [&lt;     inline     &gt;] valid_state kernel/locking/lockdep.c:2400
&gt; [&lt;     inline     &gt;] mark_lock_irq kernel/locking/lockdep.c:2617
&gt; [&lt;ffff2000081c89ec&gt;] mark_lock+0x934/0xb60 kernel/locking/lockdep.c:3065
&gt; [&lt;     inline     &gt;] mark_irqflags kernel/locking/lockdep.c:2923
&gt; [&lt;ffff2000081c9a60&gt;] __lock_acquire+0x640/0x3260 kernel/locking/lockdep.c:3295
&gt; [&lt;ffff2000081cce24&gt;] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753
&gt; [&lt;     inline     &gt;] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144
&gt; [&lt;ffff200009798128&gt;] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151
&gt; [&lt;     inline     &gt;] spin_lock ./include/linux/spinlock.h:302
&gt; [&lt;ffff2000081678c8&gt;] put_ucounts+0x60/0x138 kernel/ucount.c:162
&gt; [&lt;ffff200008168364&gt;] dec_ucount+0xf4/0x158 kernel/ucount.c:214
&gt; [&lt;     inline     &gt;] dec_pid_namespaces kernel/pid_namespace.c:89
&gt; [&lt;ffff200008293dc8&gt;] delayed_free_pidns+0x40/0xe0 kernel/pid_namespace.c:156
&gt; [&lt;     inline     &gt;] __rcu_reclaim kernel/rcu/rcu.h:118
&gt; [&lt;     inline     &gt;] rcu_do_batch kernel/rcu/tree.c:2919
&gt; [&lt;     inline     &gt;] invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; [&lt;     inline     &gt;] __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; [&lt;ffff2000082103d8&gt;] rcu_process_callbacks+0x768/0xc28 kernel/rcu/tree.c:3166
&gt; [&lt;ffff2000080821dc&gt;] __do_softirq+0x324/0x6e0 kernel/softirq.c:284
&gt; [&lt;     inline     &gt;] do_softirq_own_stack ./include/linux/interrupt.h:488
&gt; [&lt;     inline     &gt;] invoke_softirq kernel/softirq.c:371
&gt; [&lt;ffff20000811c994&gt;] irq_exit+0x264/0x308 kernel/softirq.c:405
&gt; [&lt;ffff2000081ecc28&gt;] __handle_domain_irq+0xc0/0x150 kernel/irq/irqdesc.c:636
&gt; [&lt;ffff200008081c80&gt;] gic_handle_irq+0x68/0xd8
&gt; Exception stack(0xffff8000648e7dd0 to 0xffff8000648e7f00)
&gt; 7dc0:                                   ffff8000648d4b3c 0000000000000007
&gt; 7de0: 0000000000000000 1ffff0000c91a967 1ffff0000c91a967 1ffff0000c91a967
&gt; 7e00: ffff20000a4b6b68 0000000000000001 0000000000000007 0000000000000001
&gt; 7e20: 1fffe4000149ae90 ffff200009d35000 0000000000000000 0000000000000002
&gt; 7e40: 0000000000000000 0000000000000000 0000000002624a1a 0000000000000000
&gt; 7e60: 0000000000000000 ffff200009cbcd88 000060006d2ed000 0000000000000140
&gt; 7e80: ffff200009cff000 ffff200009cb6000 ffff200009cc2020 ffff200009d2159d
&gt; 7ea0: 0000000000000000 ffff8000648d4380 0000000000000000 ffff8000648e7f00
&gt; 7ec0: ffff20000820a478 ffff8000648e7f00 ffff20000820a47c 0000000010000145
&gt; 7ee0: 0000000000000140 dfff200000000000 ffffffffffffffff ffff20000820a478
&gt; [&lt;ffff2000080837f8&gt;] el1_irq+0xb8/0x130 arch/arm64/kernel/entry.S:486
&gt; [&lt;     inline     &gt;] arch_local_irq_restore
&gt; ./arch/arm64/include/asm/irqflags.h:81
&gt; [&lt;ffff20000820a47c&gt;] rcu_idle_exit+0x64/0xa8 kernel/rcu/tree.c:1030
&gt; [&lt;     inline     &gt;] cpuidle_idle_call kernel/sched/idle.c:200
&gt; [&lt;ffff2000081bcbfc&gt;] do_idle+0x1dc/0x2d0 kernel/sched/idle.c:243
&gt; [&lt;ffff2000081bd1cc&gt;] cpu_startup_entry+0x24/0x28 kernel/sched/idle.c:345
&gt; [&lt;ffff200008099f8c&gt;] secondary_start_kernel+0x2cc/0x358
&gt; arch/arm64/kernel/smp.c:276
&gt; [&lt;000000000279f1a4&gt;] 0x279f1a4

Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Tested-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Fixes: add7c65ca426 ("pid: fix lockdep deadlock warning due to ucount_lock")
Fixes: f333c700c610 ("pidns: Add a limit on the number of pid namespaces")
Link: https://www.spinics.net/lists/kernel/msg2426637.html
Signed-off-by: Nikolay Borisov &lt;n.borisov.lkml@gmail.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.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>
commit 880a38547ff08715ce4f1daf9a4bb30c87676e68 upstream.

The ucounts_lock is being used to protect various ucounts lifecycle
management functionalities. However, those services can also be invoked
when a pidns is being freed in an RCU callback (e.g. softirq context).
This can lead to deadlocks. There were already efforts trying to
prevent similar deadlocks in add7c65ca426 ("pid: fix lockdep deadlock
warning due to ucount_lock"), however they just moved the context
from hardirq to softrq. Fix this issue once and for all by explictly
making the lock disable irqs altogether.

Dmitry Vyukov &lt;dvyukov@google.com&gt; reported:

&gt; I've got the following deadlock report while running syzkaller fuzzer
&gt; on eec0d3d065bfcdf9cd5f56dd2a36b94d12d32297 of linux-next (on odroid
&gt; device if it matters):
&gt;
&gt; =================================
&gt; [ INFO: inconsistent lock state ]
&gt; 4.10.0-rc3-next-20170112-xc2-dirty #6 Not tainted
&gt; ---------------------------------
&gt; inconsistent {SOFTIRQ-ON-W} -&gt; {IN-SOFTIRQ-W} usage.
&gt; swapper/2/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
&gt;  (ucounts_lock){+.?...}, at: [&lt;     inline     &gt;] spin_lock
&gt; ./include/linux/spinlock.h:302
&gt;  (ucounts_lock){+.?...}, at: [&lt;ffff2000081678c8&gt;]
&gt; put_ucounts+0x60/0x138 kernel/ucount.c:162
&gt; {SOFTIRQ-ON-W} state was registered at:
&gt; [&lt;ffff2000081c82d8&gt;] mark_lock+0x220/0xb60 kernel/locking/lockdep.c:3054
&gt; [&lt;     inline     &gt;] mark_irqflags kernel/locking/lockdep.c:2941
&gt; [&lt;ffff2000081c97a8&gt;] __lock_acquire+0x388/0x3260 kernel/locking/lockdep.c:3295
&gt; [&lt;ffff2000081cce24&gt;] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753
&gt; [&lt;     inline     &gt;] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144
&gt; [&lt;ffff200009798128&gt;] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151
&gt; [&lt;     inline     &gt;] spin_lock ./include/linux/spinlock.h:302
&gt; [&lt;     inline     &gt;] get_ucounts kernel/ucount.c:131
&gt; [&lt;ffff200008167c28&gt;] inc_ucount+0x80/0x6c8 kernel/ucount.c:189
&gt; [&lt;     inline     &gt;] inc_mnt_namespaces fs/namespace.c:2818
&gt; [&lt;ffff200008481850&gt;] alloc_mnt_ns+0x78/0x3a8 fs/namespace.c:2849
&gt; [&lt;ffff200008487298&gt;] create_mnt_ns+0x28/0x200 fs/namespace.c:2959
&gt; [&lt;     inline     &gt;] init_mount_tree fs/namespace.c:3199
&gt; [&lt;ffff200009bd6674&gt;] mnt_init+0x258/0x384 fs/namespace.c:3251
&gt; [&lt;ffff200009bd60bc&gt;] vfs_caches_init+0x6c/0x80 fs/dcache.c:3626
&gt; [&lt;ffff200009bb1114&gt;] start_kernel+0x414/0x460 init/main.c:648
&gt; [&lt;ffff200009bb01e8&gt;] __primary_switched+0x6c/0x70 arch/arm64/kernel/head.S:456
&gt; irq event stamp: 2316924
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2911
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; hardirqs last  enabled at (2316924): [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; hardirqs last  enabled at (2316924): [&lt;ffff200008210414&gt;]
&gt; rcu_process_callbacks+0x7a4/0xc28 kernel/rcu/tree.c:3166
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2900
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; hardirqs last disabled at (2316923): [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; hardirqs last disabled at (2316923): [&lt;ffff20000820fe80&gt;]
&gt; rcu_process_callbacks+0x210/0xc28 kernel/rcu/tree.c:3166
&gt; softirqs last  enabled at (2316912): [&lt;ffff20000811b4c4&gt;]
&gt; _local_bh_enable+0x4c/0x80 kernel/softirq.c:155
&gt; softirqs last disabled at (2316913): [&lt;     inline     &gt;]
&gt; do_softirq_own_stack ./include/linux/interrupt.h:488
&gt; softirqs last disabled at (2316913): [&lt;     inline     &gt;]
&gt; invoke_softirq kernel/softirq.c:371
&gt; softirqs last disabled at (2316913): [&lt;ffff20000811c994&gt;]
&gt; irq_exit+0x264/0x308 kernel/softirq.c:405
&gt;
&gt; other info that might help us debug this:
&gt;  Possible unsafe locking scenario:
&gt;
&gt;        CPU0
&gt;        ----
&gt;   lock(ucounts_lock);
&gt;   &lt;Interrupt&gt;
&gt;     lock(ucounts_lock);
&gt;
&gt;  *** DEADLOCK ***
&gt;
&gt; 1 lock held by swapper/2/0:
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;] __rcu_reclaim
&gt; kernel/rcu/rcu.h:108
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;] rcu_do_batch
&gt; kernel/rcu/tree.c:2919
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;]
&gt; invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt;  #0:  (rcu_callback){......}, at: [&lt;     inline     &gt;]
&gt; __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt;  #0:  (rcu_callback){......}, at: [&lt;ffff200008210390&gt;]
&gt; rcu_process_callbacks+0x720/0xc28 kernel/rcu/tree.c:3166
&gt;
&gt; stack backtrace:
&gt; CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.10.0-rc3-next-20170112-xc2-dirty #6
&gt; Hardware name: Hardkernel ODROID-C2 (DT)
&gt; Call trace:
&gt; [&lt;ffff20000808fa60&gt;] dump_backtrace+0x0/0x440 arch/arm64/kernel/traps.c:500
&gt; [&lt;ffff20000808fec0&gt;] show_stack+0x20/0x30 arch/arm64/kernel/traps.c:225
&gt; [&lt;ffff2000088a99e0&gt;] dump_stack+0x110/0x168
&gt; [&lt;ffff2000082fa2b4&gt;] print_usage_bug.part.27+0x49c/0x4bc
&gt; kernel/locking/lockdep.c:2387
&gt; [&lt;     inline     &gt;] print_usage_bug kernel/locking/lockdep.c:2357
&gt; [&lt;     inline     &gt;] valid_state kernel/locking/lockdep.c:2400
&gt; [&lt;     inline     &gt;] mark_lock_irq kernel/locking/lockdep.c:2617
&gt; [&lt;ffff2000081c89ec&gt;] mark_lock+0x934/0xb60 kernel/locking/lockdep.c:3065
&gt; [&lt;     inline     &gt;] mark_irqflags kernel/locking/lockdep.c:2923
&gt; [&lt;ffff2000081c9a60&gt;] __lock_acquire+0x640/0x3260 kernel/locking/lockdep.c:3295
&gt; [&lt;ffff2000081cce24&gt;] lock_acquire+0xa4/0x138 kernel/locking/lockdep.c:3753
&gt; [&lt;     inline     &gt;] __raw_spin_lock ./include/linux/spinlock_api_smp.h:144
&gt; [&lt;ffff200009798128&gt;] _raw_spin_lock+0x90/0xd0 kernel/locking/spinlock.c:151
&gt; [&lt;     inline     &gt;] spin_lock ./include/linux/spinlock.h:302
&gt; [&lt;ffff2000081678c8&gt;] put_ucounts+0x60/0x138 kernel/ucount.c:162
&gt; [&lt;ffff200008168364&gt;] dec_ucount+0xf4/0x158 kernel/ucount.c:214
&gt; [&lt;     inline     &gt;] dec_pid_namespaces kernel/pid_namespace.c:89
&gt; [&lt;ffff200008293dc8&gt;] delayed_free_pidns+0x40/0xe0 kernel/pid_namespace.c:156
&gt; [&lt;     inline     &gt;] __rcu_reclaim kernel/rcu/rcu.h:118
&gt; [&lt;     inline     &gt;] rcu_do_batch kernel/rcu/tree.c:2919
&gt; [&lt;     inline     &gt;] invoke_rcu_callbacks kernel/rcu/tree.c:3182
&gt; [&lt;     inline     &gt;] __rcu_process_callbacks kernel/rcu/tree.c:3149
&gt; [&lt;ffff2000082103d8&gt;] rcu_process_callbacks+0x768/0xc28 kernel/rcu/tree.c:3166
&gt; [&lt;ffff2000080821dc&gt;] __do_softirq+0x324/0x6e0 kernel/softirq.c:284
&gt; [&lt;     inline     &gt;] do_softirq_own_stack ./include/linux/interrupt.h:488
&gt; [&lt;     inline     &gt;] invoke_softirq kernel/softirq.c:371
&gt; [&lt;ffff20000811c994&gt;] irq_exit+0x264/0x308 kernel/softirq.c:405
&gt; [&lt;ffff2000081ecc28&gt;] __handle_domain_irq+0xc0/0x150 kernel/irq/irqdesc.c:636
&gt; [&lt;ffff200008081c80&gt;] gic_handle_irq+0x68/0xd8
&gt; Exception stack(0xffff8000648e7dd0 to 0xffff8000648e7f00)
&gt; 7dc0:                                   ffff8000648d4b3c 0000000000000007
&gt; 7de0: 0000000000000000 1ffff0000c91a967 1ffff0000c91a967 1ffff0000c91a967
&gt; 7e00: ffff20000a4b6b68 0000000000000001 0000000000000007 0000000000000001
&gt; 7e20: 1fffe4000149ae90 ffff200009d35000 0000000000000000 0000000000000002
&gt; 7e40: 0000000000000000 0000000000000000 0000000002624a1a 0000000000000000
&gt; 7e60: 0000000000000000 ffff200009cbcd88 000060006d2ed000 0000000000000140
&gt; 7e80: ffff200009cff000 ffff200009cb6000 ffff200009cc2020 ffff200009d2159d
&gt; 7ea0: 0000000000000000 ffff8000648d4380 0000000000000000 ffff8000648e7f00
&gt; 7ec0: ffff20000820a478 ffff8000648e7f00 ffff20000820a47c 0000000010000145
&gt; 7ee0: 0000000000000140 dfff200000000000 ffffffffffffffff ffff20000820a478
&gt; [&lt;ffff2000080837f8&gt;] el1_irq+0xb8/0x130 arch/arm64/kernel/entry.S:486
&gt; [&lt;     inline     &gt;] arch_local_irq_restore
&gt; ./arch/arm64/include/asm/irqflags.h:81
&gt; [&lt;ffff20000820a47c&gt;] rcu_idle_exit+0x64/0xa8 kernel/rcu/tree.c:1030
&gt; [&lt;     inline     &gt;] cpuidle_idle_call kernel/sched/idle.c:200
&gt; [&lt;ffff2000081bcbfc&gt;] do_idle+0x1dc/0x2d0 kernel/sched/idle.c:243
&gt; [&lt;ffff2000081bd1cc&gt;] cpu_startup_entry+0x24/0x28 kernel/sched/idle.c:345
&gt; [&lt;ffff200008099f8c&gt;] secondary_start_kernel+0x2cc/0x358
&gt; arch/arm64/kernel/smp.c:276
&gt; [&lt;000000000279f1a4&gt;] 0x279f1a4

Reported-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Tested-by: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Fixes: add7c65ca426 ("pid: fix lockdep deadlock warning due to ucount_lock")
Fixes: f333c700c610 ("pidns: Add a limit on the number of pid namespaces")
Link: https://www.spinics.net/lists/kernel/msg2426637.html
Signed-off-by: Nikolay Borisov &lt;n.borisov.lkml@gmail.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>rcu: Narrow early boot window of illegal synchronous grace periods</title>
<updated>2017-01-26T07:24:37+00:00</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@linux.vnet.ibm.com</email>
</author>
<published>2017-01-10T10:28:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=90687fc3c8c386a16326089d68cf616b8049440f'/>
<id>90687fc3c8c386a16326089d68cf616b8049440f</id>
<content type='text'>
commit 52d7e48b86fc108e45a656d8e53e4237993c481d upstream.

The current preemptible RCU implementation goes through three phases
during bootup.  In the first phase, there is only one CPU that is running
with preemption disabled, so that a no-op is a synchronous grace period.
In the second mid-boot phase, the scheduler is running, but RCU has
not yet gotten its kthreads spawned (and, for expedited grace periods,
workqueues are not yet running.  During this time, any attempt to do
a synchronous grace period will hang the system (or complain bitterly,
depending).  In the third and final phase, RCU is fully operational and
everything works normally.

This has been OK for some time, but there has recently been some
synchronous grace periods showing up during the second mid-boot phase.
This code worked "by accident" for awhile, but started failing as soon
as expedited RCU grace periods switched over to workqueues in commit
8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue").
Note that the code was buggy even before this commit, as it was subject
to failure on real-time systems that forced all expedited grace periods
to run as normal grace periods (for example, using the rcu_normal ksysfs
parameter).  The callchain from the failure case is as follows:

early_amd_iommu_init()
|-&gt; acpi_put_table(ivrs_base);
|-&gt; acpi_tb_put_table(table_desc);
|-&gt; acpi_tb_invalidate_table(table_desc);
|-&gt; acpi_tb_release_table(...)
|-&gt; acpi_os_unmap_memory
|-&gt; acpi_os_unmap_iomem
|-&gt; acpi_os_map_cleanup
|-&gt; synchronize_rcu_expedited

The kernel showing this callchain was built with CONFIG_PREEMPT_RCU=y,
which caused the code to try using workqueues before they were
initialized, which did not go well.

This commit therefore reworks RCU to permit synchronous grace periods
to proceed during this mid-boot phase.  This commit is therefore a
fix to a regression introduced in v4.9, and is therefore being put
forward post-merge-window in v4.10.

This commit sets a flag from the existing rcu_scheduler_starting()
function which causes all synchronous grace periods to take the expedited
path.  The expedited path now checks this flag, using the requesting task
to drive the expedited grace period forward during the mid-boot phase.
Finally, this flag is updated by a core_initcall() function named
rcu_exp_runtime_mode(), which causes the runtime codepaths to be used.

Note that this arrangement assumes that tasks are not sent POSIX signals
(or anything similar) from the time that the first task is spawned
through core_initcall() time.

Fixes: 8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue")
Reported-by: "Zheng, Lv" &lt;lv.zheng@intel.com&gt;
Reported-by: Borislav Petkov &lt;bp@alien8.de&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Tested-by: Stan Kain &lt;stan.kain@gmail.com&gt;
Tested-by: Ivan &lt;waffolz@hotmail.com&gt;
Tested-by: Emanuel Castelo &lt;emanuel.castelo@gmail.com&gt;
Tested-by: Bruno Pesavento &lt;bpesavento@infinito.it&gt;
Tested-by: Borislav Petkov &lt;bp@suse.de&gt;
Tested-by: Frederic Bezies &lt;fredbezies@gmail.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>
commit 52d7e48b86fc108e45a656d8e53e4237993c481d upstream.

The current preemptible RCU implementation goes through three phases
during bootup.  In the first phase, there is only one CPU that is running
with preemption disabled, so that a no-op is a synchronous grace period.
In the second mid-boot phase, the scheduler is running, but RCU has
not yet gotten its kthreads spawned (and, for expedited grace periods,
workqueues are not yet running.  During this time, any attempt to do
a synchronous grace period will hang the system (or complain bitterly,
depending).  In the third and final phase, RCU is fully operational and
everything works normally.

This has been OK for some time, but there has recently been some
synchronous grace periods showing up during the second mid-boot phase.
This code worked "by accident" for awhile, but started failing as soon
as expedited RCU grace periods switched over to workqueues in commit
8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue").
Note that the code was buggy even before this commit, as it was subject
to failure on real-time systems that forced all expedited grace periods
to run as normal grace periods (for example, using the rcu_normal ksysfs
parameter).  The callchain from the failure case is as follows:

early_amd_iommu_init()
|-&gt; acpi_put_table(ivrs_base);
|-&gt; acpi_tb_put_table(table_desc);
|-&gt; acpi_tb_invalidate_table(table_desc);
|-&gt; acpi_tb_release_table(...)
|-&gt; acpi_os_unmap_memory
|-&gt; acpi_os_unmap_iomem
|-&gt; acpi_os_map_cleanup
|-&gt; synchronize_rcu_expedited

The kernel showing this callchain was built with CONFIG_PREEMPT_RCU=y,
which caused the code to try using workqueues before they were
initialized, which did not go well.

This commit therefore reworks RCU to permit synchronous grace periods
to proceed during this mid-boot phase.  This commit is therefore a
fix to a regression introduced in v4.9, and is therefore being put
forward post-merge-window in v4.10.

This commit sets a flag from the existing rcu_scheduler_starting()
function which causes all synchronous grace periods to take the expedited
path.  The expedited path now checks this flag, using the requesting task
to drive the expedited grace period forward during the mid-boot phase.
Finally, this flag is updated by a core_initcall() function named
rcu_exp_runtime_mode(), which causes the runtime codepaths to be used.

Note that this arrangement assumes that tasks are not sent POSIX signals
(or anything similar) from the time that the first task is spawned
through core_initcall() time.

Fixes: 8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue")
Reported-by: "Zheng, Lv" &lt;lv.zheng@intel.com&gt;
Reported-by: Borislav Petkov &lt;bp@alien8.de&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Tested-by: Stan Kain &lt;stan.kain@gmail.com&gt;
Tested-by: Ivan &lt;waffolz@hotmail.com&gt;
Tested-by: Emanuel Castelo &lt;emanuel.castelo@gmail.com&gt;
Tested-by: Bruno Pesavento &lt;bpesavento@infinito.it&gt;
Tested-by: Borislav Petkov &lt;bp@suse.de&gt;
Tested-by: Frederic Bezies &lt;fredbezies@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>rcu: Remove cond_resched() from Tiny synchronize_sched()</title>
<updated>2017-01-26T07:24:37+00:00</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@linux.vnet.ibm.com</email>
</author>
<published>2017-01-10T07:23:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=bdeaa468e22171497b289c2f31d20ab6b318d53c'/>
<id>bdeaa468e22171497b289c2f31d20ab6b318d53c</id>
<content type='text'>
commit f466ae66fa6a599f9a53b5f9bafea4b8cfffa7fb upstream.

It is now legal to invoke synchronize_sched() at early boot, which causes
Tiny RCU's synchronize_sched() to emit spurious splats.  This commit
therefore removes the cond_resched() from Tiny RCU's synchronize_sched().

Fixes: 8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue")
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.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>
commit f466ae66fa6a599f9a53b5f9bafea4b8cfffa7fb upstream.

It is now legal to invoke synchronize_sched() at early boot, which causes
Tiny RCU's synchronize_sched() to emit spurious splats.  This commit
therefore removes the cond_resched() from Tiny RCU's synchronize_sched().

Fixes: 8b355e3bc140 ("rcu: Drive expedited grace periods from workqueue")
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>pid: fix lockdep deadlock warning due to ucount_lock</title>
<updated>2017-01-19T19:18:03+00:00</updated>
<author>
<name>Andrei Vagin</name>
<email>avagin@openvz.org</email>
</author>
<published>2017-01-05T03:28:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=52fd0ab07676b295abc54eeb1cef7a06d49c9847'/>
<id>52fd0ab07676b295abc54eeb1cef7a06d49c9847</id>
<content type='text'>
commit add7c65ca426b7a37184dd3d2172394e23d585d6 upstream.

=========================================================
[ INFO: possible irq lock inversion dependency detected ]
4.10.0-rc2-00024-g4aecec9-dirty #118 Tainted: G        W
---------------------------------------------------------
swapper/1/0 just changed the state of lock:
 (&amp;(&amp;sighand-&gt;siglock)-&gt;rlock){-.....}, at: [&lt;ffffffffbd0a1bc6&gt;] __lock_task_sighand+0xb6/0x2c0
but this lock took another, HARDIRQ-unsafe lock in the past:
 (ucounts_lock){+.+...}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of:                 &amp;(&amp;sighand-&gt;siglock)-&gt;rlock --&gt; &amp;(&amp;tty-&gt;ctrl_lock)-&gt;rlock --&gt; ucounts_lock
 Possible interrupt unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(ucounts_lock);
                               local_irq_disable();
                               lock(&amp;(&amp;sighand-&gt;siglock)-&gt;rlock);
                               lock(&amp;(&amp;tty-&gt;ctrl_lock)-&gt;rlock);
  &lt;Interrupt&gt;
    lock(&amp;(&amp;sighand-&gt;siglock)-&gt;rlock);

 *** DEADLOCK ***

This patch removes a dependency between rlock and ucount_lock.

Fixes: f333c700c610 ("pidns: Add a limit on the number of pid namespaces")
Signed-off-by: Andrei Vagin &lt;avagin@openvz.org&gt;
Acked-by: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.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>
commit add7c65ca426b7a37184dd3d2172394e23d585d6 upstream.

=========================================================
[ INFO: possible irq lock inversion dependency detected ]
4.10.0-rc2-00024-g4aecec9-dirty #118 Tainted: G        W
---------------------------------------------------------
swapper/1/0 just changed the state of lock:
 (&amp;(&amp;sighand-&gt;siglock)-&gt;rlock){-.....}, at: [&lt;ffffffffbd0a1bc6&gt;] __lock_task_sighand+0xb6/0x2c0
but this lock took another, HARDIRQ-unsafe lock in the past:
 (ucounts_lock){+.+...}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of:                 &amp;(&amp;sighand-&gt;siglock)-&gt;rlock --&gt; &amp;(&amp;tty-&gt;ctrl_lock)-&gt;rlock --&gt; ucounts_lock
 Possible interrupt unsafe locking scenario:
       CPU0                    CPU1
       ----                    ----
  lock(ucounts_lock);
                               local_irq_disable();
                               lock(&amp;(&amp;sighand-&gt;siglock)-&gt;rlock);
                               lock(&amp;(&amp;tty-&gt;ctrl_lock)-&gt;rlock);
  &lt;Interrupt&gt;
    lock(&amp;(&amp;sighand-&gt;siglock)-&gt;rlock);

 *** DEADLOCK ***

This patch removes a dependency between rlock and ucount_lock.

Fixes: f333c700c610 ("pidns: Add a limit on the number of pid namespaces")
Signed-off-by: Andrei Vagin &lt;avagin@openvz.org&gt;
Acked-by: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>jump_labels: API for flushing deferred jump label updates</title>
<updated>2017-01-19T19:17:59+00:00</updated>
<author>
<name>David Matlack</name>
<email>dmatlack@google.com</email>
</author>
<published>2016-12-16T22:30:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=483ecebb22c16369ecb607e4bfd5f9767b56555f'/>
<id>483ecebb22c16369ecb607e4bfd5f9767b56555f</id>
<content type='text'>
commit b6416e61012429e0277bd15a229222fd17afc1c1 upstream.

Modules that use static_key_deferred need a way to synchronize with
any delayed work that is still pending when the module is unloaded.
Introduce static_key_deferred_flush() which flushes any pending
jump label updates.

Signed-off-by: David Matlack &lt;dmatlack@google.com&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.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>
commit b6416e61012429e0277bd15a229222fd17afc1c1 upstream.

Modules that use static_key_deferred need a way to synchronize with
any delayed work that is still pending when the module is unloaded.
Introduce static_key_deferred_flush() which flushes any pending
jump label updates.

Signed-off-by: David Matlack &lt;dmatlack@google.com&gt;
Acked-by: Peter Zijlstra (Intel) &lt;peterz@infradead.org&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>mm: fix devm_memremap_pages crash, use mem_hotplug_{begin, done}</title>
<updated>2017-01-19T19:17:58+00:00</updated>
<author>
<name>Dan Williams</name>
<email>dan.j.williams@intel.com</email>
</author>
<published>2017-01-11T00:57:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=692755b1006d1e603ae7b86e40a90fcdfb166209'/>
<id>692755b1006d1e603ae7b86e40a90fcdfb166209</id>
<content type='text'>
commit f931ab479dd24cf7a2c6e2df19778406892591fb upstream.

Both arch_add_memory() and arch_remove_memory() expect a single threaded
context.

For example, arch/x86/mm/init_64.c::kernel_physical_mapping_init() does
not hold any locks over this check and branch:

    if (pgd_val(*pgd)) {
    	pud = (pud_t *)pgd_page_vaddr(*pgd);
    	paddr_last = phys_pud_init(pud, __pa(vaddr),
    				   __pa(vaddr_end),
    				   page_size_mask);
    	continue;
    }

    pud = alloc_low_page();
    paddr_last = phys_pud_init(pud, __pa(vaddr), __pa(vaddr_end),
    			   page_size_mask);

The result is that two threads calling devm_memremap_pages()
simultaneously can end up colliding on pgd initialization.  This leads
to crash signatures like the following where the loser of the race
initializes the wrong pgd entry:

    BUG: unable to handle kernel paging request at ffff888ebfff0000
    IP: memcpy_erms+0x6/0x10
    PGD 2f8e8fc067 PUD 0 /* &lt;---- Invalid PUD */
    Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
    CPU: 54 PID: 3818 Comm: systemd-udevd Not tainted 4.6.7+ #13
    task: ffff882fac290040 ti: ffff882f887a4000 task.ti: ffff882f887a4000
    RIP: memcpy_erms+0x6/0x10
    [..]
    Call Trace:
      ? pmem_do_bvec+0x205/0x370 [nd_pmem]
      ? blk_queue_enter+0x3a/0x280
      pmem_rw_page+0x38/0x80 [nd_pmem]
      bdev_read_page+0x84/0xb0

Hold the standard memory hotplug mutex over calls to
arch_{add,remove}_memory().

Fixes: 41e94a851304 ("add devm_memremap_pages")
Link: http://lkml.kernel.org/r/148357647831.9498.12606007370121652979.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@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 f931ab479dd24cf7a2c6e2df19778406892591fb upstream.

Both arch_add_memory() and arch_remove_memory() expect a single threaded
context.

For example, arch/x86/mm/init_64.c::kernel_physical_mapping_init() does
not hold any locks over this check and branch:

    if (pgd_val(*pgd)) {
    	pud = (pud_t *)pgd_page_vaddr(*pgd);
    	paddr_last = phys_pud_init(pud, __pa(vaddr),
    				   __pa(vaddr_end),
    				   page_size_mask);
    	continue;
    }

    pud = alloc_low_page();
    paddr_last = phys_pud_init(pud, __pa(vaddr), __pa(vaddr_end),
    			   page_size_mask);

The result is that two threads calling devm_memremap_pages()
simultaneously can end up colliding on pgd initialization.  This leads
to crash signatures like the following where the loser of the race
initializes the wrong pgd entry:

    BUG: unable to handle kernel paging request at ffff888ebfff0000
    IP: memcpy_erms+0x6/0x10
    PGD 2f8e8fc067 PUD 0 /* &lt;---- Invalid PUD */
    Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
    CPU: 54 PID: 3818 Comm: systemd-udevd Not tainted 4.6.7+ #13
    task: ffff882fac290040 ti: ffff882f887a4000 task.ti: ffff882f887a4000
    RIP: memcpy_erms+0x6/0x10
    [..]
    Call Trace:
      ? pmem_do_bvec+0x205/0x370 [nd_pmem]
      ? blk_queue_enter+0x3a/0x280
      pmem_rw_page+0x38/0x80 [nd_pmem]
      bdev_read_page+0x84/0xb0

Hold the standard memory hotplug mutex over calls to
arch_{add,remove}_memory().

Fixes: 41e94a851304 ("add devm_memremap_pages")
Link: http://lkml.kernel.org/r/148357647831.9498.12606007370121652979.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>tick/broadcast: Prevent NULL pointer dereference</title>
<updated>2017-01-12T10:39:45+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2016-12-15T11:10:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=cf365b117388a50902d56988e69dd6f70b7662fc'/>
<id>cf365b117388a50902d56988e69dd6f70b7662fc</id>
<content type='text'>
commit c1a9eeb938b5433947e5ea22f89baff3182e7075 upstream.

When a disfunctional timer, e.g. dummy timer, is installed, the tick core
tries to setup the broadcast timer.

If no broadcast device is installed, the kernel crashes with a NULL pointer
dereference in tick_broadcast_setup_oneshot() because the function has no
sanity check.

Reported-by: Mason &lt;slash.tmp@free.fr&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Mark Rutland &lt;mark.rutland@arm.com&gt;
Cc: Anna-Maria Gleixner &lt;anna-maria@linutronix.de&gt;
Cc: Richard Cochran &lt;rcochran@linutronix.de&gt;
Cc: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Cc: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;,
Cc: Sebastian Frias &lt;sf84@laposte.net&gt;
Cc: Thibaud Cornic &lt;thibaud_cornic@sigmadesigns.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Link: http://lkml.kernel.org/r/1147ef90-7877-e4d2-bb2b-5c4fa8d3144b@free.fr
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 c1a9eeb938b5433947e5ea22f89baff3182e7075 upstream.

When a disfunctional timer, e.g. dummy timer, is installed, the tick core
tries to setup the broadcast timer.

If no broadcast device is installed, the kernel crashes with a NULL pointer
dereference in tick_broadcast_setup_oneshot() because the function has no
sanity check.

Reported-by: Mason &lt;slash.tmp@free.fr&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Mark Rutland &lt;mark.rutland@arm.com&gt;
Cc: Anna-Maria Gleixner &lt;anna-maria@linutronix.de&gt;
Cc: Richard Cochran &lt;rcochran@linutronix.de&gt;
Cc: Sebastian Andrzej Siewior &lt;bigeasy@linutronix.de&gt;
Cc: Daniel Lezcano &lt;daniel.lezcano@linaro.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;,
Cc: Sebastian Frias &lt;sf84@laposte.net&gt;
Cc: Thibaud Cornic &lt;thibaud_cornic@sigmadesigns.com&gt;
Cc: Robin Murphy &lt;robin.murphy@arm.com&gt;
Link: http://lkml.kernel.org/r/1147ef90-7877-e4d2-bb2b-5c4fa8d3144b@free.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>genirq/affinity: Fix node generation from cpumask</title>
<updated>2017-01-12T10:39:31+00:00</updated>
<author>
<name>Guilherme G. Piccoli</name>
<email>gpiccoli@linux.vnet.ibm.com</email>
</author>
<published>2016-12-14T18:01:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=74e365e69687bb250fa71ba5ba389cd2680d843f'/>
<id>74e365e69687bb250fa71ba5ba389cd2680d843f</id>
<content type='text'>
commit c0af52437254fda8b0cdbaae5a9b6d9327f1fcd5 upstream.

Commit 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading
infrastructure") introduced a better IRQ spreading mechanism, taking
account of the available NUMA nodes in the machine.

Problem is that the algorithm of retrieving the nodemask iterates
"linearly" based on the number of online nodes - some architectures
present non-linear node distribution among the nodemask, like PowerPC.
If this is the case, the algorithm lead to a wrong node count number
and therefore to a bad/incomplete IRQ affinity distribution.

For example, this problem were found in a machine with 128 CPUs and two
nodes, namely nodes 0 and 8 (instead of 0 and 1, if it was linearly
distributed). This led to a wrong affinity distribution which then led to
a bad mq allocation for nvme driver.

Finally, we take the opportunity to fix a comment regarding the affinity
distribution when we have _more_ nodes than vectors.

Fixes: 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading infrastructure")
Reported-by: Gabriel Krisman Bertazi &lt;gabriel@krisman.be&gt;
Signed-off-by: Guilherme G. Piccoli &lt;gpiccoli@linux.vnet.ibm.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Gabriel Krisman Bertazi &lt;gabriel@krisman.be&gt;
Reviewed-by: Gavin Shan &lt;gwshan@linux.vnet.ibm.com&gt;
Cc: linux-pci@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: hch@lst.de
Link: http://lkml.kernel.org/r/1481738472-2671-1-git-send-email-gpiccoli@linux.vnet.ibm.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&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 c0af52437254fda8b0cdbaae5a9b6d9327f1fcd5 upstream.

Commit 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading
infrastructure") introduced a better IRQ spreading mechanism, taking
account of the available NUMA nodes in the machine.

Problem is that the algorithm of retrieving the nodemask iterates
"linearly" based on the number of online nodes - some architectures
present non-linear node distribution among the nodemask, like PowerPC.
If this is the case, the algorithm lead to a wrong node count number
and therefore to a bad/incomplete IRQ affinity distribution.

For example, this problem were found in a machine with 128 CPUs and two
nodes, namely nodes 0 and 8 (instead of 0 and 1, if it was linearly
distributed). This led to a wrong affinity distribution which then led to
a bad mq allocation for nvme driver.

Finally, we take the opportunity to fix a comment regarding the affinity
distribution when we have _more_ nodes than vectors.

Fixes: 34c3d9819fda ("genirq/affinity: Provide smarter irq spreading infrastructure")
Reported-by: Gabriel Krisman Bertazi &lt;gabriel@krisman.be&gt;
Signed-off-by: Guilherme G. Piccoli &lt;gpiccoli@linux.vnet.ibm.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Gabriel Krisman Bertazi &lt;gabriel@krisman.be&gt;
Reviewed-by: Gavin Shan &lt;gwshan@linux.vnet.ibm.com&gt;
Cc: linux-pci@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: hch@lst.de
Link: http://lkml.kernel.org/r/1481738472-2671-1-git-send-email-gpiccoli@linux.vnet.ibm.com
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</pre>
</div>
</content>
</entry>
</feed>
