4.10.8-stable review
Greg Kroah-Hartman
maintainercover 4.10.8-stable review
This is the start of the stable review cycle for the 4.10.8 release. There are 17 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:59:07 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.10.8-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.10.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.10.8-rc1
Bin Liu <[email protected]>
usb: musb: fix possible spinlock deadlock
Sebastian Andrzej Siewior <[email protected]>
sched/rt: Add a missing rescheduling point
Joe Carnuccio <[email protected]>
qla2xxx: Allow vref count to timeout on vport delete.
Dave Martin <[email protected]>
metag/ptrace: Reject partial NT_METAG_RPIPE writes
Dave Martin <[email protected]>
metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
Dave Martin <[email protected]>
metag/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
sparc/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
mips/ptrace: Preserve previous registers for short regset write
Dave Martin <[email protected]>
h8300/ptrace: Fix incorrect register transfer count
Dave Martin <[email protected]>
c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
Bjorn Andersson <[email protected]>
pinctrl: qcom: Don't clear status bit on irq_unmask
Ladi Prosek <[email protected]>
virtio_balloon: init 1st buffer in stats vq
Paolo Bonzini <[email protected]>
KVM: x86: cleanup the page tracking SRCU instance
Wanpeng Li <[email protected]>
KVM: nVMX: Fix nested VPID vmx exec control
Andy Whitcroft <[email protected]>
xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
Andy Whitcroft <[email protected]>
xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
Florian Westphal <[email protected]>
xfrm: policy: init locks early
-------------
Diffstat:
Makefile | 4 ++-- arch/c6x/kernel/ptrace.c | 41 ----------------------------------- arch/h8300/kernel/ptrace.c | 8 ++++--- arch/metag/kernel/ptrace.c | 19 ++++++++++++---- arch/mips/kernel/ptrace.c | 3 ++- arch/sparc/kernel/ptrace_64.c | 2 +- arch/x86/include/asm/kvm_page_track.h | 1 + arch/x86/kvm/page_track.c | 8 +++++++ arch/x86/kvm/vmx.c | 7 +++--- arch/x86/kvm/x86.c | 1 + drivers/pinctrl/qcom/pinctrl-msm.c | 4 ---- drivers/scsi/qla2xxx/qla_attr.c | 4 +--- drivers/scsi/qla2xxx/qla_def.h | 6 ++++- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 14 +++++++----- drivers/scsi/qla2xxx/qla_os.c | 1 + drivers/usb/musb/musb_core.c | 2 +- drivers/virtio/virtio_balloon.c | 2 ++ kernel/sched/deadline.c | 3 +-- kernel/sched/rt.c | 3 +-- net/xfrm/xfrm_policy.c | 10 ++++----- net/xfrm/xfrm_user.c | 9 +++++++- 22 files changed, 73 insertions(+), 80 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/17 xfrm: policy: init locks early
4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
commit c282222a45cb9503cbfbebfdb60491f06ae84b49 upstream.
Dmitry reports following splat:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
CPU: 0 PID: 13059 Comm: syz-executor1 Not tainted 4.10.0-rc7-next-20170207 #1 [..] spin_lock_bh include/linux/spinlock.h:304 [inline] xfrm_policy_flush+0x32/0x470 net/xfrm/xfrm_policy.c:963 xfrm_policy_fini+0xbf/0x560 net/xfrm/xfrm_policy.c:3041 xfrm_net_init+0x79f/0x9e0 net/xfrm/xfrm_policy.c:3091 ops_init+0x10a/0x530 net/core/net_namespace.c:115 setup_net+0x2ed/0x690 net/core/net_namespace.c:291 copy_net_ns+0x26c/0x530 net/core/net_namespace.c:396 create_new_namespaces+0x409/0x860 kernel/nsproxy.c:106 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205 SYSC_unshare kernel/fork.c:2281 [inline]
Problem is that when we get error during xfrm_net_init we will call xfrm_policy_fini which will acquire xfrm_policy_lock before it was initialized. Just move it around so locks get set up first.
--- net/xfrm/xfrm_policy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/xfrm/xfrm_policy.c +5 -5
@@ -3062,6 +3062,11 @@ static int __net_init xfrm_net_init(stru {int rv; +/* Initialize the per-net locks here */ +spin_lock_init (&net->xfrm.xfrm_state_lock); +spin_lock_init (&net->xfrm.xfrm_policy_lock); +mutex_init (&net->xfrm.xfrm_cfg_mutex); + rv =xfrm_statistics_init (net);if (rv <0 ) goto out_statistics;
@@ -3078,11 +3083,6 @@ static int __net_init xfrm_net_init(struif (rv <0 ) goto out; -/* Initialize the per-net locks here */ -spin_lock_init (&net->xfrm.xfrm_state_lock); -spin_lock_init (&net->xfrm.xfrm_policy_lock); -mutex_init (&net->xfrm.xfrm_cfg_mutex); -return 0 ; out:
Greg Kroah-Hartman
maintainerPATCH 2/17 xfrm_user: validate XFRM_MSG_NEWAE XFRMA_REPLAY_ESN_VAL replay_window
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Whitcroft <[email protected]>
commit 677e806da4d916052585301785d847c3b3e6186a upstream.
When a new xfrm state is created during an XFRM_MSG_NEWSA call we validate the user supplied replay_esn to ensure that the size is valid and to ensure that the replay_window size is within the allocated buffer. However later it is possible to update this replay_esn via a XFRM_MSG_NEWAE call. There we again validate the size of the supplied buffer matches the existing state and if so inject the contents. We do not at this point check that the replay_window is within the allocated memory. This leads to out-of-bounds reads and writes triggered by netlink packets. This leads to memory corruption and the potential for priviledge escalation.
We already attempt to validate the incoming replay information in xfrm_new_ae() via xfrm_replay_verify_len(). This confirms that the user is not trying to change the size of the replay state buffer which includes the replay_esn. It however does not check the replay_window remains within that buffer. Add validation of the contained replay_window.
CVE-2017-7184
--- net/xfrm/xfrm_user.c | 3 +++ 1 file changed, 3 insertions(+)
net/xfrm/xfrm_user.c +3 -0
@@ -415,6 +415,9 @@ static inline int xfrm_replay_verify_lenif (nla_len (rp) < ulen ||xfrm_replay_state_esn_len (replay_esn) != ulen)return -EINVAL ; +if (up->replay_window > up->bmp_len *sizeof (__u32) *8 ) +return -EINVAL ; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 3/17 xfrm_user: validate XFRM_MSG_NEWAE incoming ESN size harder
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Whitcroft <[email protected]>
commit f843ee6dd019bcece3e74e76ad9df0155655d0df upstream.
Kees Cook has pointed out that xfrm_replay_state_esn_len() is subject to wrapping issues. To ensure we are correctly ensuring that the two ESN structures are the same size compare both the overall size as reported by xfrm_replay_state_esn_len() and the internal length are the same.
CVE-2017-7184
--- net/xfrm/xfrm_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +5 -1
@@ -412,7 +412,11 @@ static inline int xfrm_replay_verify_len up =nla_data (rp); ulen =xfrm_replay_state_esn_len (up); -if (nla_len (rp) < ulen ||xfrm_replay_state_esn_len (replay_esn) != ulen) +/* Check the overall length and the internal bitmap length to avoid +* potential overflow. */ +if (nla_len (rp) < ulen || +xfrm_replay_state_esn_len (replay_esn) != ulen || + replay_esn->bmp_len != up->bmp_len)return -EINVAL ;if (up->replay_window > up->bmp_len *sizeof (__u32) *8 )
Greg Kroah-Hartman
maintainerPATCH 5/17 KVM: x86: cleanup the page tracking SRCU instance
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 2beb6dad2e8f95d710159d5befb390e4f62ab5cf upstream.
SRCU uses a delayed work item. Skip cleaning it up, and the result is use-after-free in the work item callbacks.
--- arch/x86/include/asm/kvm_page_track.h | 1 + arch/x86/kvm/page_track.c | 8 ++++++++ arch/x86/kvm/x86.c | 1 + 3 files changed, 10 insertions(+)
arch/x86/include/asm/kvm_page_track.h +1 -0
@@ -46,6 +46,7 @@ struct kvm_page_track_notifier_node { };void kvm_page_track_init (struct kvm *kvm); +void kvm_page_track_cleanup (struct kvm *kvm);void kvm_page_track_free_memslot (struct kvm_memory_slot *free,struct kvm_memory_slot *dont);
arch/x86/kvm/page_track.c +8 -0
@@ -158,6 +158,14 @@ bool kvm_page_track_is_active(struct kvmreturn !!ACCESS_ONCE (slot->arch.gfn_track[mode][index]); } +void kvm_page_track_cleanup (struct kvm *kvm) +{ +struct kvm_page_track_notifier_head *head; + + head = &kvm->arch.track_notifier_head; +cleanup_srcu_struct (&head->track_srcu); +} +void kvm_page_track_init (struct kvm *kvm) {struct kvm_page_track_notifier_head *head;
arch/x86/kvm/x86.c +1 -0
@@ -8052,6 +8052,7 @@ void kvm_arch_destroy_vm(struct kvm *kvmkvm_free_vcpus (kvm);kvfree (rcu_dereference_check (kvm->arch.apic_map,1 ));kvm_mmu_uninit_vm (kvm); +kvm_page_track_cleanup (kvm); } void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
Greg Kroah-Hartman
maintainerPATCH 6/17 virtio_balloon: init 1st buffer in stats vq
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ladi Prosek <[email protected]>
commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.
When init_vqs runs, virtio_balloon.stats is either uninitialized or contains stale values. The host updates its state with garbage data because it has no way of knowing that this is just a marker buffer used for signaling.
This patch updates the stats before pushing the initial buffer.
Alternative fixes:
* Push an empty buffer in init_vqs. Not easily done with the current virtio implementation and violates the spec "Driver MUST supply the same subset of statistics in all buffers submitted to the statsq".
* Push a buffer with invalid tags in init_vqs. Violates the same spec clause, plus "invalid tag" is not really defined.
Note: the spec says:
When using the legacy interface, the device SHOULD ignore all values in the first buffer in the statsq supplied by the driver after device initialization. Note: Historically, drivers supplied an uninitialized buffer in the first buffer.
Unfortunately QEMU does not seem to implement the recommendation even for the legacy interface.
--- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/virtio/virtio_balloon.c +2 -0
@@ -427,6 +427,8 @@ static int init_vqs(struct virtio_balloo* Prime this virtqueue with one buffer so the hypervisor can * use it to signal us later (it can't be broken yet!). */ +update_balloon_stats (vb); +sg_init_one (&sg, vb->stats,sizeof vb->stats);if (virtqueue_add_outbuf (vb->stats_vq, &sg,1 , vb,GFP_KERNEL ) <0 )
Greg Kroah-Hartman
maintainerPATCH 7/17 pinctrl: qcom: Dont clear status bit on irq_unmask
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit a6566710adaa4a7dd5e0d99820ff9c9c30ee5951 upstream.
Clearing the status bit on irq_unmask will discard any pending interrupt that did arrive after the irq_ack, i.e. while the IRQ handler function was executing.
--- drivers/pinctrl/qcom/pinctrl-msm.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/pinctrl/qcom/pinctrl-msm.c +0 -4
@@ -594,10 +594,6 @@ static void msm_gpio_irq_unmask(struct ispin_lock_irqsave (&pctrl->lock, flags); - val =readl (pctrl->regs + g->intr_status_reg); - val &= ~BIT (g->intr_status_bit); -writel (val, pctrl->regs + g->intr_status_reg); - val =readl (pctrl->regs + g->intr_cfg_reg); val |=BIT (g->intr_enable_bit);writel (val, pctrl->regs + g->intr_cfg_reg);
Greg Kroah-Hartman
maintainerPATCH 8/17 c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit fb411b837b587a32046dc4f369acb93a10b1def8 upstream.
gpr_set won't work correctly and can never have been tested, and the correct behaviour is not clear due to the endianness-dependent task layout.
So, just remove it. The core code will now return -EOPNOTSUPPORT when trying to set NT_PRSTATUS on this architecture until/unless a correct implementation is supplied.
--- arch/c6x/kernel/ptrace.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-)
arch/c6x/kernel/ptrace.c +0 -41
@@ -69,46 +69,6 @@ static int gpr_get(struct task_struct *t 0, sizeof(*regs)); } -static int gpr_set (struct task_struct *target, -const struct user_regset *regset, -unsigned int pos,unsigned int count, -const void *kbuf,const void __user *ubuf) -{ -int ret; -struct pt_regs *regs =task_pt_regs (target); - -/* Don't copyin TSR or CSR */ - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, -0 ,PT_TSR *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, -PT_TSR *sizeof (long ), - (PT_TSR +1 ) *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, - (PT_TSR +1 ) *sizeof (long ), -PT_CSR *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin_ignore (&pos, &count, &kbuf, &ubuf, -PT_CSR *sizeof (long ), - (PT_CSR +1 ) *sizeof (long )); -if (ret) -return ret; - - ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, - ®s, - (PT_CSR +1 ) *sizeof (long ),-1 ); -return ret; -} -enum c6x_regset {REGSET_GPR , };
@@ -120,7 +80,6 @@ static const struct user_regset c6x_regs .size = sizeof(u32), .align = sizeof(u32), .get = gpr_get, - .set = gpr_set }, };
Greg Kroah-Hartman
maintainerPATCH 9/17 h8300/ptrace: Fix incorrect register transfer count
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 502585c7555083d4a949c08350306b9ec196779e upstream.
regs_set() and regs_get() are vulnerable to an off-by-1 buffer overrun if CONFIG_CPU_H8S is set, since this adds an extra entry to register_offset[] but not to user_regs_struct.
So, iterate over user_regs_struct based on its actual size, not based on the length of register_offset[].
--- arch/h8300/kernel/ptrace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/h8300/kernel/ptrace.c +5 -3
@@ -95,7 +95,8 @@ static int regs_get(struct task_struct *long *reg = (long *)®s;/* build user regs in buffer */ -for (r =0 ; r <ARRAY_SIZE (register_offset); r++) +BUILD_BUG_ON (sizeof (regs) %sizeof (long ) !=0 ); +for (r =0 ; r <sizeof (regs) /sizeof (long ); r++) *reg++ =h8300_get_reg (target, r); return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
@@ -113,7 +114,8 @@ static int regs_set(struct task_struct *long *reg;/* build user regs in buffer */ -for (reg = (long *)®s, r =0 ; r <ARRAY_SIZE (register_offset); r++) +BUILD_BUG_ON (sizeof (regs) %sizeof (long ) !=0 ); +for (reg = (long *)®s, r =0 ; r <sizeof (regs) /sizeof (long ); r++) *reg++ =h8300_get_reg (target, r); ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
@@ -122,7 +124,7 @@ static int regs_set(struct task_struct *return ret;/* write back to pt_regs */ -for (reg = (long *)®s, r =0 ; r <ARRAY_SIZE (register_offset); r++) +for (reg = (long *)®s, r =0 ; r <sizeof (regs) /sizeof (long ); r++)h8300_put_reg (target, r, *reg++);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 10/17 mips/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/mips/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/kernel/ptrace.c +2 -1
@@ -485,7 +485,8 @@ static int fpr_set(struct task_struct *t &target->thread.fpu, 0, sizeof(elf_fpregset_t)); -for (i =0 ; i <NUM_FPU_REGS ; i++) { +BUILD_BUG_ON (sizeof (fpr_val) !=sizeof (elf_fpreg_t)); +for (i =0 ; i <NUM_FPU_REGS && count >=sizeof (elf_fpreg_t); i++) { err =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &fpr_val, i *sizeof (elf_fpreg_t), (i +1 ) *sizeof (elf_fpreg_t));
Greg Kroah-Hartman
maintainerPATCH 11/17 sparc/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit d3805c546b275c8cc7d40f759d029ae92c7175f2 upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/sparc/kernel/ptrace_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/ptrace_64.c +1 -1
@@ -350,7 +350,7 @@ static int genregs64_set(struct task_str }if (!ret) { -unsigned long y; +unsigned long y = regs->y; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &y,
Greg Kroah-Hartman
maintainerPATCH 12/17 metag/ptrace: Preserve previous registers for short regset write
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit a78ce80d2c9178351b34d78fec805140c29c193e upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill all the registers, the thread's old registers are preserved.
--- arch/metag/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/metag/kernel/ptrace.c +1 -1
@@ -303,7 +303,7 @@ static int metag_tls_set(struct task_str const void *kbuf, const void __user *ubuf) { int ret; -void __user *tls; +void __user *tls = target->thread.tls_ptr; ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &tls,0 ,-1 );if (ret)
Greg Kroah-Hartman
maintainerPATCH 13/17 metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 5fe81fe98123ce41265c65e95d34418d30d005d1 upstream.
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill TXSTATUS, a well-defined default value is used, based on the task's current value.
--- arch/metag/kernel/ptrace.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/metag/kernel/ptrace.c +12 -3
@@ -24,6 +24,16 @@* user_regset definitions. */ +static unsigned long user_txstatus (const struct pt_regs *regs) +{ +unsigned long data = (unsigned long )regs->ctx.Flags; + +if (regs->ctx.SaveMask &TBICTX_CBUF_BIT ) + data |=USER_GP_REGS_STATUS_CATCH_BIT ; + +return data; +} +int metag_gp_regs_copyout (const struct pt_regs *regs,unsigned int pos,unsigned int count,void *kbuf,void __user *ubuf)
@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pif (ret) goto out;/* TXSTATUS */ - data = (unsigned long )regs->ctx.Flags; -if (regs->ctx.SaveMask &TBICTX_CBUF_BIT ) - data |=USER_GP_REGS_STATUS_CATCH_BIT ; + data =user_txstatus (regs); ret =user_regset_copyout (&pos, &count, &kbuf, &ubuf, &data,4 *25 ,4 *26 );if (ret)
@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regsif (ret) goto out;/* TXSTATUS */ + data =user_txstatus (regs); ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &data,4 *25 ,4 *26 );if (ret)
Greg Kroah-Hartman
maintainerPATCH 14/17 metag/ptrace: Reject partial NT_METAG_RPIPE writes
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Martin <[email protected]>
commit 7195ee3120d878259e8d94a5d9f808116f34d5ea upstream.
It's not clear what behaviour is sensible when doing partial write of NT_METAG_RPIPE, so just don't bother.
This patch assumes that userspace will never rely on a partial SETREGSET in this case, since it's not clear what should happen anyway.
--- arch/metag/kernel/ptrace.c | 2 ++ 1 file changed, 2 insertions(+)
arch/metag/kernel/ptrace.c +2 -0
@@ -253,6 +253,8 @@ int metag_rp_state_copyin(struct pt_regsunsigned long long *ptr;int ret, i; +if (count <4 *13 ) +return -EINVAL ;/* Read the entire pipeline before making any changes */ ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &rp,0 ,4 *13 );
Greg Kroah-Hartman
maintainerPATCH 15/17 qla2xxx: Allow vref count to timeout on vport delete.
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Carnuccio <[email protected]>
commit c4a9b538ab2a109c5f9798bea1f8f4bf93aadfb9 upstream.
--- drivers/scsi/qla2xxx/qla_attr.c | 4 +--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 14 ++++++++------ drivers/scsi/qla2xxx/qla_os.c | 1 + 5 files changed, 16 insertions(+), 10 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +1 -3
@@ -2154,8 +2154,6 @@ qla24xx_vport_delete(struct fc_vport *fc "Timer for the VP[%d] has stopped\n", vha->vp_idx); } -BUG_ON (atomic_read (&vha->vref_count)); -qla2x00_free_fcports (vha);mutex_lock (&ha->vport_lock);
@@ -2163,7 +2161,7 @@ qla24xx_vport_delete(struct fc_vport *fcclear_bit (vha->vp_idx, ha->vp_idx_map);mutex_unlock (&ha->vport_lock); -if (vha->qpair->vp_idx == vha->vp_idx) { +if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) {if (qla2xxx_delete_qpair (vha, vha->qpair) !=QLA_SUCCESS )ql_log (ql_log_warn, vha,0x7087 ,"Queue Pair delete failed.\n" );
drivers/scsi/qla2xxx/qla_def.h +5 -1
@@ -3788,6 +3788,7 @@ typedef struct scsi_qla_host {struct qla8044_reset_template reset_tmplt;struct qla_tgt_counters tgt_counters;uint16_t bbcr; +wait_queue_head_t vref_waitq; } scsi_qla_host_t;struct qla27xx_image_status {
@@ -3843,14 +3844,17 @@ struct qla2_sgx {mb (); \if (__vha->flags.delete_progress) { \atomic_dec (&__vha->vref_count); \ +wake_up (&__vha->vref_waitq); \ __bail =1 ; \ }else { \ __bail =0 ; \ } \ } while (0) -#define QLA_VHA_MARK_NOT_BUSY (__vha) \ +#define QLA_VHA_MARK_NOT_BUSY (__vha) do { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ +} while (0) \#define QLA_QPAIR_MARK_BUSY (__qpair, __bail) do { \ atomic_inc(&__qpair->ref_count); \
drivers/scsi/qla2xxx/qla_init.c +1 -0
@@ -4352,6 +4352,7 @@ qla2x00_update_fcports(scsi_qla_host_t * } }atomic_dec (&vha->vref_count); +wake_up (&vha->vref_waitq); }spin_unlock_irqrestore (&ha->vport_slock, flags); }
drivers/scsi/qla2xxx/qla_mid.c +8 -6
@@ -74,13 +74,14 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t* ensures no active vp_list traversal while the vport is removed * from the queue) */ -spin_lock_irqsave (&ha->vport_slock, flags); -while (atomic_read (&vha->vref_count)) { -spin_unlock_irqrestore (&ha->vport_slock, flags); - -msleep (500 ); +wait_event_timeout (vha->vref_waitq,atomic_read (&vha->vref_count), +10 *HZ ); -spin_lock_irqsave (&ha->vport_slock, flags); +spin_lock_irqsave (&ha->vport_slock, flags); +if (atomic_read (&vha->vref_count)) { +ql_dbg (ql_dbg_vport, vha,0xfffa , +"vha->vref_count=%u timeout\n" , vha->vref_count.counter); + vha->vref_count = (atomic_t )ATOMIC_INIT (0 ); }list_del (&vha->list);qlt_update_vp_map (vha,RESET_VP_IDX );
@@ -269,6 +270,7 @@ qla2x00_alert_all_vps(struct rsp_que *rsspin_lock_irqsave (&ha->vport_slock, flags);atomic_dec (&vha->vref_count); +wake_up (&vha->vref_waitq); } i++; }
drivers/scsi/qla2xxx/qla_os.c +1 -0
@@ -4215,6 +4215,7 @@ struct scsi_qla_host *qla2x00_create_hosspin_lock_init (&vha->work_lock);spin_lock_init (&vha->cmd_list_lock); +init_waitqueue_head (&vha->vref_waitq);sprintf (vha->host_str,"%s_%ld" ,QLA2XXX_DRIVER_NAME , vha->host_no); ql_dbg(ql_dbg_init, vha, 0x0041,
Re: [PATCH 4.10 15/17] qla2xxx: Allow vref count to timeout on vport delete.
Hi Joe + Himanshu,
Thanks for backporting this patch to apply to v4.10.y.
I haven't seen it queued to v4.9.y yet though, would you be so kind to send out a v4.9.y backport as well to Greg-KH + stable team so it can be picked up for earlier stable versions too..?
Thank you,
Quoted 123 lines · Greg Kroah-Hartman
4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Carnuccio <[email protected]>
commit
c4a9b538ab2a109c5f9798bea1f8f4bf93aadfb9upstream.Signed-off-by Joe Carnuccio <[email protected]>Signed-off-by Himanshu Madhani <[email protected]>Signed-off-by Nicholas Bellinger <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/scsi/qla2xxx/qla_attr.c | 4 +--- drivers/scsi/qla2xxx/qla_def.h | 6 +++++- drivers/scsi/qla2xxx/qla_init.c | 1 + drivers/scsi/qla2xxx/qla_mid.c | 14 ++++++++------ drivers/scsi/qla2xxx/qla_os.c | 1 + 5 files changed, 16 insertions(+), 10 deletions(-)drivers/scsi/qla2xxx/qla_attr.c +1
-3@@ -2154,8 +2154,6 @@ qla24xx_vport_delete(struct fc_vport *fc "Timer for the VP[%d] has stopped\n", vha->vp_idx); } -BUG_ON (atomic_read (&vha->vref_count)); -qla2x00_free_fcports (vha);mutex_lock (&ha->vport_lock);@@ -2163,7 +2161,7 @@ qla24xx_vport_delete(struct fc_vport *fcclear_bit (vha->vp_idx, ha->vp_idx_map);mutex_unlock (&ha->vport_lock); -if (vha->qpair->vp_idx == vha->vp_idx) { +if (vha->qpair && vha->qpair->vp_idx == vha->vp_idx) {if (qla2xxx_delete_qpair (vha, vha->qpair) !=QLA_SUCCESS )ql_log (ql_log_warn, vha,0x7087 ,"Queue Pair delete failed.\n" );drivers/scsi/qla2xxx/qla_def.h +5
-1@@ -3788,6 +3788,7 @@ typedef struct scsi_qla_host {struct qla8044_reset_template reset_tmplt;struct qla_tgt_counters tgt_counters;uint16_t bbcr; +wait_queue_head_t vref_waitq; } scsi_qla_host_t;struct qla27xx_image_status {@@ -3843,14 +3844,17 @@ struct qla2_sgx {mb (); \if (__vha->flags.delete_progress) { \atomic_dec (&__vha->vref_count); \ +wake_up (&__vha->vref_waitq); \ __bail =1 ; \ }else { \ __bail =0 ; \ } \ } while (0) -#define QLA_VHA_MARK_NOT_BUSY (__vha) \ +#define QLA_VHA_MARK_NOT_BUSY (__vha) do { \ atomic_dec(&__vha->vref_count); \ + wake_up(&__vha->vref_waitq); \ +} while (0) \#define QLA_QPAIR_MARK_BUSY (__qpair, __bail) do { \ atomic_inc(&__qpair->ref_count); \drivers/scsi/qla2xxx/qla_init.c +1
-0@@ -4352,6 +4352,7 @@ qla2x00_update_fcports(scsi_qla_host_t * } }atomic_dec (&vha->vref_count); +wake_up (&vha->vref_waitq); }spin_unlock_irqrestore (&ha->vport_slock, flags); }drivers/scsi/qla2xxx/qla_mid.c +8
-6@@ -74,13 +74,14 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t* ensures no active vp_list traversal while the vport is removed * from the queue) */ -spin_lock_irqsave (&ha->vport_slock, flags); -while (atomic_read (&vha->vref_count)) { -spin_unlock_irqrestore (&ha->vport_slock, flags); - -msleep (500 ); +wait_event_timeout (vha->vref_waitq,atomic_read (&vha->vref_count), +10 *HZ ); -spin_lock_irqsave (&ha->vport_slock, flags); +spin_lock_irqsave (&ha->vport_slock, flags); +if (atomic_read (&vha->vref_count)) { +ql_dbg (ql_dbg_vport, vha,0xfffa , +"vha->vref_count=%u timeout\n" , vha->vref_count.counter); + vha->vref_count = (atomic_t )ATOMIC_INIT (0 ); }list_del (&vha->list);qlt_update_vp_map (vha,RESET_VP_IDX );@@ -269,6 +270,7 @@ qla2x00_alert_all_vps(struct rsp_que *rsspin_lock_irqsave (&ha->vport_slock, flags);atomic_dec (&vha->vref_count); +wake_up (&vha->vref_waitq); } i++; }drivers/scsi/qla2xxx/qla_os.c +1
-0@@ -4215,6 +4215,7 @@ struct scsi_qla_host *qla2x00_create_hosspin_lock_init (&vha->work_lock);spin_lock_init (&vha->cmd_list_lock); +init_waitqueue_head (&vha->vref_waitq);sprintf (vha->host_str,"%s_%ld" ,QLA2XXX_DRIVER_NAME , vha->host_no); ql_dbg(ql_dbg_init, vha, 0x0041,
Greg Kroah-Hartman
maintainerPATCH 16/17 sched/rt: Add a missing rescheduling point
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
commit 619bd4a71874a8fd78eb6ccf9f272c5e98bcc7b7 upstream.
Since the change in commit:
fd7a4bed1835 ("sched, rt: Convert switched_{from, to}_rt() / prio_changed_rt() to balance callbacks")
... we don't reschedule a task under certain circumstances:
Lets say task-A, SCHED_OTHER, is running on CPU0 (and it may run only on CPU0) and holds a PI lock. This task is removed from the CPU because it used up its time slice and another SCHED_OTHER task is running. Task-B on CPU1 runs at RT priority and asks for the lock owned by task-A. This results in a priority boost for task-A. Task-B goes to sleep until the lock has been made available. Task-A is already runnable (but not active), so it receives no wake up.
The reality now is that task-A gets on the CPU once the scheduler decides to remove the current task despite the fact that a high priority task is enqueued and waiting. This may take a long time.
The desired behaviour is that CPU0 immediately reschedules after the priority boost which made task-A the task with the lowest priority.
--- kernel/sched/deadline.c | 3 +-- kernel/sched/rt.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
kernel/sched/deadline.c +1 -2
@@ -1729,12 +1729,11 @@ static void switched_to_dl(struct rq *rq#ifdef CONFIG_SMP if (tsk_nr_cpus_allowed (p) >1 && rq->dl.overloaded)queue_push_tasks (rq); -#else +#endif if (dl_task (rq->curr))check_preempt_curr_dl (rq, p,0 );else resched_curr (rq); -#endif } }
kernel/sched/rt.c +1 -2
@@ -2198,10 +2198,9 @@ static void switched_to_rt(struct rq *rq#ifdef CONFIG_SMP if (tsk_nr_cpus_allowed (p) >1 && rq->rt.overloaded)queue_push_tasks (rq); -#else +#endif /* CONFIG_SMP */ if (p->prio < rq->curr->prio)resched_curr (rq); -#endif /* CONFIG_SMP */ } }
Greg Kroah-Hartman
maintainerPATCH 17/17 usb: musb: fix possible spinlock deadlock
In reply to Greg Kroah-Hartman4.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bin Liu <[email protected]>
commit bc1e2154542071e3cfe1734b143af9b8bdacf8bd upstream.
The DSPS glue calls del_timer_sync() in its musb_platform_disable() implementation, which requires the caller to not hold a lock. But musb_remove() calls musb_platform_disable() will musb->lock held. This could causes spinlock deadlock.
So change musb_remove() to call musb_platform_disable() without holds musb->lock. This doesn't impact the musb_platform_disable implementation in other glue drivers.
root@am335x-evm:~# modprobe -r musb-dsps
[ 126.134879] musb-hdrc musb-hdrc.1: remove, state 1
[ 126.140465] usb usb2: USB disconnect, device number 1
[ 126.146178] usb 2-1: USB disconnect, device number 2
[ 126.416985] musb-hdrc musb-hdrc.1: USB bus 2 deregistered
[ 126.423943]
[ 126.425525] ======================================================
[ 126.431997] [ INFO: possible circular locking dependency detected ]
[ 126.438564] 4.11.0-rc1-00003-g1557f13bca04-dirty #77 Not tainted
[ 126.444852] -------------------------------------------------------
[ 126.451414] modprobe/778 is trying to acquire lock:
[ 126.456523] (((&glue->timer))){+.-...}, at: [<c01b8788>] del_timer_sync+0x0/0xd0
[ 126.464403]
[ 126.464403] but task is already holding lock:
[ 126.470511] (&(&musb->lock)->rlock){-.-...}, at: [<bf30b7f8>] musb_remove+0x50/0x1
30 [musb_hdrc]
[ 126.479965]
[ 126.479965] which lock already depends on the new lock.
[ 126.479965]
[ 126.488531]
[ 126.488531] the existing dependency chain (in reverse order) is:
[ 126.496368]
[ 126.496368] -> #1 (&(&musb->lock)->rlock){-.-...}:
[ 126.502968] otg_timer+0x80/0xec [musb_dsps]
[ 126.507990] call_timer_fn+0xb4/0x390
[ 126.512372] expire_timers+0xf0/0x1fc
[ 126.516754] run_timer_softirq+0x80/0x178
[ 126.521511] __do_softirq+0xc4/0x554
[ 126.525802] irq_exit+0xe8/0x158
[ 126.529735] __handle_domain_irq+0x58/0xb8
[ 126.534583] __irq_usr+0x54/0x80
[ 126.538507]
[ 126.538507] -> #0 (((&glue->timer))){+.-...}:
[ 126.544636] del_timer_sync+0x40/0xd0
[ 126.549066] musb_remove+0x6c/0x130 [musb_hdrc]
[ 126.554370] platform_drv_remove+0x24/0x3c
[ 126.559206] device_release_driver_internal+0x14c/0x1e0
[ 126.565225] bus_remove_device+0xd8/0x108
[ 126.569970] device_del+0x1e4/0x308
[ 126.574170] platform_device_del+0x24/0x8c
[ 126.579006] platform_device_unregister+0xc/0x20
[ 126.584394] dsps_remove+0x14/0x30 [musb_dsps]
[ 126.589595] platform_drv_remove+0x24/0x3c
[ 126.594432] device_release_driver_internal+0x14c/0x1e0
[ 126.600450] driver_detach+0x38/0x6c
[ 126.604740] bus_remove_driver+0x4c/0xa0
[ 126.609407] SyS_delete_module+0x11c/0x1e4
[ 126.614252] __sys_trace_return+0x0/0x10--- drivers/usb/musb/musb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/musb/musb_core.c +1 -1
@@ -2497,8 +2497,8 @@ static int musb_remove(struct platform_dpm_runtime_get_sync (musb->controller);musb_host_cleanup (musb);musb_gadget_cleanup (musb); -spin_lock_irqsave (&musb->lock, flags);musb_platform_disable (musb); +spin_lock_irqsave (&musb->lock, flags);musb_generic_disable (musb);spin_unlock_irqrestore (&musb->lock, flags);musb_writeb (musb->mregs,MUSB_DEVCTL ,0 );
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.10.8 release. There are 17 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:59:07 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.10.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.10.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Greg Kroah-Hartman
maintainerQuoted 15 lines · Shuah Khan
Quoted 14 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.10.8 release. There are 17 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:59:07 UTC 2017. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.10.8-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.10.y
and the diffstat can be found below.
Quoted 6 lines
Quoted 4 lines
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
Thanks for testing all of these and letting me know.
greg k-h
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.10.8 release. There are 17 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:59:07 UTC 2017. Anything received after that time might be too late.
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 122 pass: 122 fail: 0
Details are available at http://kerneltests.org/builders.
Guenter
Greg Kroah-Hartman
maintainerQuoted 10 lines · Guenter Roeck
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.10.8 release. There are 17 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat Apr 1 09:59:07 UTC 2017. Anything received after that time might be too late.
Quoted 6 lines
Build results:
total: 149 pass: 149 fail: 0 Qemu test results: total: 122 pass: 122 fail: 0Details are available at http://kerneltests.org/builders.
Thanks for testing all of these and letting me know.
greg k-h