scsi: don't BUG_ON() empty DMA transfers
Subsystems (145)
[added to the 4.1 stable tree] module: set __jump_table alignment to 8
In reply to Sasha LevinFrom: David Daney <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ab42632156becd35d3884ee5c14da2bedbf3149a ]
For powerpc the __jump_table section in modules is not aligned, this causes a WARN_ON() splat when loading a module containing a __jump_table.
Strict alignment became necessary with commit 3821fd35b58d ("jump_label: Reduce the size of struct static_key"), currently in linux-next, which uses the two least significant bits of pointers to __jump_table elements.
Fix by forcing __jump_table to 8, which is the same alignment used for this section in the kernel proper.
--- scripts/module-common.lds | 2 ++ 1 file changed, 2 insertions(+)
scripts/module-common.lds +2 -0
@@ -19,4 +19,6 @@ SECTIONS { . = ALIGN(8); .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) } + + __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] usb: gadget: configs: plug memory leak
In reply to Sasha LevinFrom: John Keeping <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 38355b2a44776c25b0f2ad466e8c51bb805b3032 ]
When binding a gadget to a device, "name" is stored in gi->udc_name, but this does not happen when unregistering and the string is leaked.
--- drivers/usb/gadget/configfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/configfs.c +1 -0
@@ -266,6 +266,7 @@ static ssize_t gadget_dev_desc_UDC_store(struct gadget_info *gi, ret =unregister_gadget (gi);if (ret) goto err; +kfree (name); }else {if (gi->udc_name) { ret = -EBUSY ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] USB: gadgetfs: Fix a potential memory leak in 'dev_config()'
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b6e7aeeaf235901c42ec35de4633c7c69501d303 ]
'kbuf' is allocated just a few lines above using 'memdup_user()'. If the 'if (dev->buf)' test fails, this memory is never released.
--- drivers/usb/gadget/legacy/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/inode.c +3 -1
@@ -1834,8 +1834,10 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)spin_lock_irq (&dev->lock); value = -EINVAL ; -if (dev->buf) +if (dev->buf) { +kfree (kbuf); goto fail; + } dev->buf = kbuf;/* full or low speed config */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] libata: drop WARN from protocol error in ata_sff_qc_issue()
In reply to Sasha LevinFrom: Tejun Heo <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0580b762a4d6b70817476b90042813f8573283fa ]
ata_sff_qc_issue() expects upper layers to never issue commands on a command protocol that it doesn't implement. While the assumption holds fine with the usual IO path, nothing filters based on the command protocol in the passthrough path (which was added later), allowing the warning to be tripped with a passthrough command with the right (well, wrong) protocol.
Failing with AC_ERR_SYSTEM is the right thing to do anyway. Remove the unnecessary WARN.
--- drivers/ata/libata-sff.c | 1 - 1 file changed, 1 deletion(-)
drivers/ata/libata-sff.c +0 -1
@@ -1480,7 +1480,6 @@ unsigned int ata_sff_qc_issue(struct ata_queued_cmd *qc)break ;default : -WARN_ON_ONCE (1 );return AC_ERR_SYSTEM ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] workqueue: trigger WARN if queue_delayed_work() is called with NULL @wq
In reply to Sasha LevinFrom: Tejun Heo <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 637fdbae60d6cb9f6e963c1079d7e0445c86ff7d ]
If queue_delayed_work() gets called with NULL @wq, the kernel will oops asynchronuosly on timer expiration which isn't too helpful in tracking down the offender. This actually happened with smc.
__queue_delayed_work() already does several input sanity checks synchronously. Add NULL @wq check.
--- kernel/workqueue.c | 1 + 1 file changed, 1 insertion(+)
kernel/workqueue.c +1 -0
@@ -1484,6 +1484,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,struct timer_list *timer = &dwork->timer;struct work_struct *work = &dwork->work; +WARN_ON_ONCE (!wq);WARN_ON_ONCE (timer->function != delayed_work_timer_fn || timer->data != (unsigned long )dwork);WARN_ON_ONCE (timer_pending (timer));
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] KVM: nVMX: reset nested_run_pending if the vCPU is going to be reset
In reply to Sasha LevinFrom: Wanpeng Li <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2f707d97982286b307ef2a9b034e19aabc1abb56 ]
Reported by syzkaller:
WARNING: CPU: 1 PID: 27742 at arch/x86/kvm/vmx.c:11029
nested_vmx_vmexit+0x5c35/0x74d0 arch/x86/kvm/vmx.c:11029
CPU: 1 PID: 27742 Comm: a.out Not tainted 4.10.0+ #229
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:15 [inline]
dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
panic+0x1fb/0x412 kernel/panic.c:179
__warn+0x1c4/0x1e0 kernel/panic.c:540
warn_slowpath_null+0x2c/0x40 kernel/panic.c:583
nested_vmx_vmexit+0x5c35/0x74d0 arch/x86/kvm/vmx.c:11029
vmx_leave_nested arch/x86/kvm/vmx.c:11136 [inline]
vmx_set_msr+0x1565/0x1910 arch/x86/kvm/vmx.c:3324
kvm_set_msr+0xd4/0x170 arch/x86/kvm/x86.c:1099
do_set_msr+0x11e/0x190 arch/x86/kvm/x86.c:1128
__msr_io arch/x86/kvm/x86.c:2577 [inline]
msr_io+0x24b/0x450 arch/x86/kvm/x86.c:2614
kvm_arch_vcpu_ioctl+0x35b/0x46a0 arch/x86/kvm/x86.c:3497
kvm_vcpu_ioctl+0x232/0x1120 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2721
vfs_ioctl fs/ioctl.c:43 [inline]
do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:683
SYSC_ioctl fs/ioctl.c:698 [inline]
SyS_ioctl+0x8f/0xc0 fs/ioctl.c:689
entry_SYSCALL_64_fastpath+0x1f/0xc2The syzkaller folks reported a nested_run_pending warning during userspace clear VMX capability which is exposed to L1 before.
The warning gets thrown while doing
(*(uint32_t*)0x20aecfe8 = (uint32_t)0x1);
(*(uint32_t*)0x20aecfec = (uint32_t)0x0);
(*(uint32_t*)0x20aecff0 = (uint32_t)0x3a);
(*(uint32_t*)0x20aecff4 = (uint32_t)0x0);
(*(uint64_t*)0x20aecff8 = (uint64_t)0x0);
r[29] = syscall(__NR_ioctl, r[4], 0x4008ae89ul,
0x20aecfe8ul, 0, 0, 0, 0, 0, 0);
i.e. KVM_SET_MSR ioctl with
struct kvm_msrs {
.nmsrs = 1,
.pad = 0,
.entries = {
{.index = MSR_IA32_FEATURE_CONTROL,
.reserved = 0,
.data = 0}
}
}The VMLANCH/VMRESUME emulation should be stopped since the CPU is going to reset here. This patch resets the nested_run_pending since the CPU is going to be reset hence there should be nothing pending.
--- arch/x86/kvm/vmx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kvm/vmx.c +3 -1
@@ -10135,8 +10135,10 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,*/ static void vmx_leave_nested (struct kvm_vcpu *vcpu) { -if (is_guest_mode (vcpu)) +if (is_guest_mode (vcpu)) { +to_vmx (vcpu)->nested.nested_run_pending =0 ;nested_vmx_vmexit (vcpu,-1 ,0 ,0 ); + }free_nested (to_vmx (vcpu)); }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] scsi: lpfc: Fix crash during Hardware error recovery on SLI3 adapters
In reply to Sasha LevinFrom: James Smart <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5d181531bc6169e19a02a27d202cf0e982db9d0e ]
if REG_VPI fails, the driver was incorrectly issuing INIT_VFI (a SLI4 command) on a SLI3 adapter.
--- drivers/scsi/lpfc/lpfc_els.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +10 -4
@@ -7286,11 +7286,17 @@ lpfc_cmpl_reg_new_vport(struct lpfc_hba *phba, LPFC_MBOXQ_t *pmb)spin_lock_irq (shost->host_lock); vport->fc_flag |=FC_VPORT_NEEDS_REG_VPI ;spin_unlock_irq (shost->host_lock); -if (vport->port_type ==LPFC_PHYSICAL_PORT - && !(vport->fc_flag &FC_LOGO_RCVD_DID_CHNG )) -lpfc_issue_init_vfi (vport); -else +if (mb->mbxStatus ==MBX_NOT_FINISHED ) +break ; +if ((vport->port_type ==LPFC_PHYSICAL_PORT ) && + !(vport->fc_flag &FC_LOGO_RCVD_DID_CHNG )) { +if (phba->sli_rev ==LPFC_SLI_REV4 ) +lpfc_issue_init_vfi (vport); +else +lpfc_initial_flogi (vport); + }else {lpfc_initial_fdisc (vport); + }break ; } }else {
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] arm: KVM: Survive unknown traps from guests
In reply to Sasha LevinFrom: Mark Rutland <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f050fe7a9164945dd1c28be05bf00e8cfb082ccf ]
Currently we BUG() if we see a HSR.EC value we don't recognise. As configurable disables/enables are added to the architecture (controlled by RES1/RES0 bits respectively), with associated synchronous exceptions, it may be possible for a guest to trigger exceptions with classes that we don't recognise.
While we can't service these exceptions in a manner useful to the guest, we can avoid bringing down the host. Per ARM DDI 0406C.c, all currently unallocated HSR EC encodings are reserved, and per ARM DDI 0487A.k_iss10775, page G6-4395, EC values within the range 0x00 - 0x2c are reserved for future use with synchronous exceptions, and EC values within the range 0x2d - 0x3f may be used for either synchronous or asynchronous exceptions.
The patch makes KVM handle any unknown EC by injecting an UNDEFINED exception into the guest, with a corresponding (ratelimited) warning in the host dmesg. We could later improve on this with with a new (opt-in) exit to the host userspace.
--- arch/arm/include/asm/kvm_arm.h | 1 + arch/arm/kvm/handle_exit.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-)
arch/arm/include/asm/kvm_arm.h +1 -0
@@ -209,6 +209,7 @@#define HSR_EC_IABT_HYP (0x21)#define HSR_EC_DABT (0x24)#define HSR_EC_DABT_HYP (0x25) +#define HSR_EC_MAX (0x3f)#define HSR_WFI_IS_WFE (1U << 0)
arch/arm/kvm/handle_exit.c +12 -7
@@ -100,7 +100,19 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run)return 1 ; } +static int kvm_handle_unknown_ec (struct kvm_vcpu *vcpu,struct kvm_run *run) +{ +u32 hsr =kvm_vcpu_get_hsr (vcpu); + +kvm_pr_unimpl ("Unknown exception class: hsr: %#08x\n" , + hsr); + +kvm_inject_undefined (vcpu); +return 1 ; +} +static exit_handle_fn arm_exit_handlers[] = { + [0 ...HSR_EC_MAX ] = kvm_handle_unknown_ec, [HSR_EC_WFI ] = kvm_handle_wfx, [HSR_EC_CP15_32 ] = kvm_handle_cp15_32, [HSR_EC_CP15_64 ] = kvm_handle_cp15_64,
@@ -122,13 +134,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) {u8 hsr_ec =kvm_vcpu_trap_get_class (vcpu); -if (hsr_ec >=ARRAY_SIZE (arm_exit_handlers) || - !arm_exit_handlers[hsr_ec]) { -kvm_err ("Unknown exception class: hsr: %#08x\n" , - (unsigned int )kvm_vcpu_get_hsr (vcpu)); -BUG (); - } -return arm_exit_handlers[hsr_ec]; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] irqchip/crossbar: Fix incorrect type of register size
In reply to Sasha LevinFrom: Franck Demathieu <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4b9de5da7e120c7f02395da729f0ec77ce7a6044 ]
The 'size' variable is unsigned according to the dt-bindings. As this variable is used as integer in other places, create a new variable that allows to fix the following sparse issue (-Wtypesign):
drivers/irqchip/irq-crossbar.c:279:52: warning: incorrect type in argument 3 (different signedness)
drivers/irqchip/irq-crossbar.c:279:52: expected unsigned int [usertype] *out_value
drivers/irqchip/irq-crossbar.c:279:52: got int *<noident>
--- drivers/irqchip/irq-crossbar.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/irqchip/irq-crossbar.c +4 -4
@@ -194,7 +194,7 @@ static const struct irq_domain_ops crossbar_domain_ops = {static int __init crossbar_of_init (struct device_node *node) {int i, size, reserved =0 ; -u32 max =0 , entry; +u32 max =0 , entry, reg_size;const __be32 *irqsr;int ret = -ENOMEM ;
@@ -271,9 +271,9 @@ static int __init crossbar_of_init(struct device_node *node)if (!cb->register_offsets) goto err_irq_map; -of_property_read_u32 (node,"ti,reg-size" , &size); +of_property_read_u32 (node,"ti,reg-size" , ®_size); -switch (size) { +switch (reg_size) {case 1 : cb->write = crossbar_writeb;break ;
@@ -299,7 +299,7 @@ static int __init crossbar_of_init(struct device_node *node)continue ; cb->register_offsets[i] = reserved; - reserved += size; + reserved += reg_size; }of_property_read_u32 (node,"ti,irqs-safe-map" , &cb->safe_map);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] spi_ks8995: fix "BUG: key accdaa28 not in .data!"
In reply to Sasha LevinFrom: "Blomme, Maarten" <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4342696df764ec65dcdfbd0c10d90ea52505f8ba ]
--- drivers/net/phy/spi_ks8995.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/spi_ks8995.c +1 -0
@@ -332,6 +332,7 @@ static int ks8995_probe(struct spi_device *spi)if (err)return err; +sysfs_attr_init (&ks->regs_attr.attr); err =sysfs_create_bin_file (&spi->dev.kobj, &ks->regs_attr);if (err) { dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] bnx2x: prevent crash when accessing PTP with interface down
In reply to Sasha LevinFrom: Michal Schmidt <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 466e8bf10ac104d96e1ea813e8126e11cb72ea20 ]
It is possible to crash the kernel by accessing a PTP device while its associated bnx2x interface is down. Before the interface is brought up, the timecounter is not initialized, so accessing it results in NULL dereference.
Fix it by checking if the interface is up.
Use -ENETDOWN as the error code when the interface is down.
-EFAULT in bnx2x_ptp_adjfreq() did not seem right.
Tested using phc_ctl get/set/adj/freq commands.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +19 -1
@@ -13227,7 +13227,7 @@ static int bnx2x_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)if (!netif_running (bp->dev)) {DP (BNX2X_MSG_PTP ,"PTP adjfreq called while the interface is down\n" ); -return -EFAULT ; +return -ENETDOWN ; }if (ppb <0 ) {
@@ -13286,6 +13286,12 @@ static int bnx2x_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) { struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info); +if (!netif_running (bp->dev)) { +DP (BNX2X_MSG_PTP , +"PTP adjtime called while the interface is down\n" ); +return -ENETDOWN ; + } +DP (BNX2X_MSG_PTP ,"PTP adjtime called, delta = %llx\n" , delta);timecounter_adjtime (&bp->timecounter, delta);
@@ -13298,6 +13304,12 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);u64 ns; +if (!netif_running (bp->dev)) { +DP (BNX2X_MSG_PTP , +"PTP gettime called while the interface is down\n" ); +return -ENETDOWN ; + } + ns =timecounter_read (&bp->timecounter);DP (BNX2X_MSG_PTP ,"PTP gettime called, ns = %llu\n" , ns);
@@ -13313,6 +13325,12 @@ static int bnx2x_ptp_settime(struct ptp_clock_info *ptp, struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);u64 ns; +if (!netif_running (bp->dev)) { +DP (BNX2X_MSG_PTP , +"PTP settime called while the interface is down\n" ); +return -ENETDOWN ; + } + ns =timespec64_to_ns (ts);DP (BNX2X_MSG_PTP ,"PTP settime called, ns = %llu\n" , ns);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] bnx2x: fix possible overrun of VFPF multicast addresses array
In reply to Sasha LevinFrom: Michal Schmidt <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 22118d861cec5da6ed525aaf12a3de9bfeffc58f ]
It is too late to check for the limit of the number of VF multicast addresses after they have already been copied to the req->multicast[] array, possibly overflowing it.
Do the check before copying.
Also fix the error path to not skip unlocking vf2pf_mutex.
--- drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c +11 -12
@@ -852,7 +852,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)struct bnx2x *bp =netdev_priv (dev);struct vfpf_set_q_filters_tlv *req = &bp->vf2pf_mbox->req.set_q_filters;struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp; -int rc, i =0 ; +int rc =0 , i =0 ;struct netdev_hw_addr *ha;if (bp->state !=BNX2X_STATE_OPEN ) {
@@ -867,6 +867,15 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev)/* Get Rx mode requested */ DP (NETIF_MSG_IFUP ,"dev->flags = %x\n" , dev->flags); +/* We support PFVF_MAX_MULTICAST_PER_VF mcast addresses tops */ +if (netdev_mc_count (dev) >PFVF_MAX_MULTICAST_PER_VF ) { +DP (NETIF_MSG_IFUP , +"VF supports not more than %d multicast MAC addresses\n" , +PFVF_MAX_MULTICAST_PER_VF ); + rc = -EINVAL ; + goto out; + } +netdev_for_each_mc_addr (ha, dev) {DP (NETIF_MSG_IFUP ,"Adding mcast MAC: %pM\n" ,bnx2x_mc_addr (ha));
@@ -874,16 +883,6 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev) i++; } -/* We support four PFVF_MAX_MULTICAST_PER_VF mcast -* addresses tops -*/ -if (i >=PFVF_MAX_MULTICAST_PER_VF ) { -DP (NETIF_MSG_IFUP , -"VF supports not more than %d multicast MAC addresses\n" , -PFVF_MAX_MULTICAST_PER_VF ); -return -EINVAL ; - } - req->n_multicast = i; req->flags |=VFPF_SET_Q_FILTERS_MULTICAST_CHANGED ; req->vf_qid =0 ;
@@ -908,7 +907,7 @@ int bnx2x_vfpf_set_mcast(struct net_device *dev) out:bnx2x_vfpf_finalize (bp, &req->first_tlv); -return 0 ; +return rc; }int bnx2x_vfpf_storm_rx_mode (struct bnx2x *bp)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ipv6: reorder icmpv6_init() and ip6_mr_init()
In reply to Sasha LevinFrom: WANG Cong <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 15e668070a64bb97f102ad9cf3bccbca0545cda8 ]
Andrey reported the following kernel crash:
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 0 PID: 14446 Comm: syz-executor6 Not tainted 4.10.0+ #82 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 task: ffff88001f311700 task.stack: ffff88001f6e8000 RIP: 0010:ip6mr_sk_done+0x15a/0x3d0 net/ipv6/ip6mr.c:1618 RSP: 0018:ffff88001f6ef418 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 1ffff10003edde8c RCX: ffffc900043ee000 RDX: 0000000000000004 RSI: ffffffff83e3b3f8 RDI: 0000000000000020 RBP: ffff88001f6ef508 R08: fffffbfff0dcc5d8 R09: 0000000000000000 R10: ffffffff86e62ec0 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffff88001f6ef4e0 R15: ffff8800380a0040 FS: 00007f7a52cec700(0000) GS:ffff88003ec00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000061c500 CR3: 000000001f1ae000 CR4: 00000000000006f0 DR0: 0000000020000000 DR1: 0000000020000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600 Call Trace: rawv6_close+0x4c/0x80 net/ipv6/raw.c:1217 inet_release+0xed/0x1c0 net/ipv4/af_inet.c:425 inet6_release+0x50/0x70 net/ipv6/af_inet6.c:432 sock_release+0x8d/0x1e0 net/socket.c:597 __sock_create+0x39d/0x880 net/socket.c:1226 sock_create_kern+0x3f/0x50 net/socket.c:1243 inet_ctl_sock_create+0xbb/0x280 net/ipv4/af_inet.c:1526 icmpv6_sk_init+0x163/0x500 net/ipv6/icmp.c:954 ops_init+0x10a/0x550 net/core/net_namespace.c:115 setup_net+0x261/0x660 net/core/net_namespace.c:291 copy_net_ns+0x27e/0x540 net/core/net_namespace.c:396 9pnet_virtio: no channels available for device ./file1 create_new_namespaces+0x437/0x9b0 kernel/nsproxy.c:106 unshare_nsproxy_namespaces+0xae/0x1e0 kernel/nsproxy.c:205 SYSC_unshare kernel/fork.c:2281 [inline] SyS_unshare+0x64e/0x1000 kernel/fork.c:2231 entry_SYSCALL_64_fastpath+0x1f/0xc2
This is because net->ipv6.mr6_tables is not initialized at that point, ip6mr_rules_init() is not called yet, therefore on the error path when we iterator the list, we trigger this oops. Fix this by reordering ip6mr_rules_init() before icmpv6_sk_init().
--- net/ipv6/af_inet6.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/ipv6/af_inet6.c +5 -5
@@ -889,12 +889,12 @@ static int __init inet6_init(void) err =register_pernet_subsys (&inet6_net_ops);if (err) goto register_pernet_fail; - err =icmpv6_init (); -if (err) - goto icmp_fail; err =ip6_mr_init ();if (err) goto ipmr_fail; + err =icmpv6_init (); +if (err) + goto icmp_fail; err =ndisc_init ();if (err) goto ndisc_fail;
@@ -1012,10 +1012,10 @@ static int __init inet6_init(void)ndisc_cleanup (); ndisc_fail:ip6_mr_cleanup (); -ipmr_fail: -icmpv6_cleanup (); icmp_fail:unregister_pernet_subsys (&inet6_net_ops); +ipmr_fail: +icmpv6_cleanup (); register_pernet_fail:sock_unregister (PF_INET6 );rtnl_unregister_all (PF_INET6 );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] crypto: s5p-sss - Fix completing crypto request in IRQ handler
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 07de4bc88ce6a4d898cad9aa4c99c1df7e87702d ]
In a regular interrupt handler driver was finishing the crypt/decrypt request by calling complete on crypto request. This is disallowed since converting to skcipher in commit b286d8b1a690 ("crypto: skcipher - Add skcipher walk interface") and causes a warning:
WARNING: CPU: 0 PID: 0 at crypto/skcipher.c:430 skcipher_walk_first+0x13c/0x14c
The interrupt is marked shared but in fact there are no other users sharing it. Thus the simplest solution seems to be to just use a threaded interrupt handler, after converting it to oneshot.
--- drivers/crypto/s5p-sss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/crypto/s5p-sss.c +3 -2
@@ -682,8 +682,9 @@ static int s5p_aes_probe(struct platform_device *pdev)dev_warn (dev,"feed control interrupt is not available.\n" ); goto err_irq; } - err =devm_request_irq (dev, pdata->irq_fc, s5p_aes_interrupt, -IRQF_SHARED , pdev->name, pdev); + err =devm_request_threaded_irq (dev, pdata->irq_fc,NULL , + s5p_aes_interrupt,IRQF_ONESHOT , + pdev->name, pdev);if (err <0 ) {dev_warn (dev,"feed control interrupt is not available.\n" ); goto err_irq;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] i2c: riic: fix restart condition
In reply to Sasha LevinFrom: Chris Brandt <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2501c1bb054290679baad0ff7f4f07c714251f4c ]
While modifying the driver to use the STOP interrupt, the completion of the intermediate transfers need to wake the driver back up in order to initiate the next transfer (restart condition). Otherwise you get never ending interrupts and only the first transfer sent.
--- drivers/i2c/busses/i2c-riic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-riic.c +5 -1
@@ -218,8 +218,12 @@ static irqreturn_t riic_tend_isr(int irq, void *data) }if (riic->is_last || riic->err) { -riic_clear_set_bit (riic,0 ,ICIER_SPIE ,RIIC_ICIER ); +riic_clear_set_bit (riic,ICIER_TEIE ,ICIER_SPIE ,RIIC_ICIER );writeb (ICCR2_SP , riic->base +RIIC_ICCR2 ); + }else { +/* Transfer is complete, but do not send STOP */ +riic_clear_set_bit (riic,ICIER_TEIE ,0 ,RIIC_ICIER ); +complete (&riic->msg_done); }return IRQ_HANDLED ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] axonram: Fix gendisk handling
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 672a2c87c83649fb0167202342ce85af9a3b4f1c ]
It is invalid to call del_gendisk() when disk->queue is NULL. Fix error handling in axon_ram_probe() to avoid doing that.
Also del_gendisk() does not drop a reference to gendisk allocated by alloc_disk(). That has to be done by put_disk(). Add that call where needed.
--- arch/powerpc/sysdev/axonram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/powerpc/sysdev/axonram.c +4 -1
@@ -274,7 +274,9 @@ static int axon_ram_probe(struct platform_device *device)if (bank->disk->major >0 )unregister_blkdev (bank->disk->major, bank->disk->disk_name); -del_gendisk (bank->disk); +if (bank->disk->flags &GENHD_FL_UP ) +del_gendisk (bank->disk); +put_disk (bank->disk); } device->dev.platform_data =NULL ;if (bank->io_addr !=0 )
@@ -299,6 +301,7 @@ axon_ram_remove(struct platform_device *device)device_remove_file (&device->dev, &dev_attr_ecc);free_irq (bank->irq_id, device);del_gendisk (bank->disk); +put_disk (bank->disk);iounmap ((void __iomem *) bank->io_addr);kfree (bank);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] EDAC, i5000, i5400: Fix use of MTR_DRAM_WIDTH macro
In reply to Sasha LevinFrom: Jérémy Lefaure <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e61555c29c28a4a3b6ba6207f4a0883ee236004d ]
The MTR_DRAM_WIDTH macro returns the data width. It is sometimes used as if it returned a boolean true if the width if 8. Fix the tests where MTR_DRAM_WIDTH is misused.
--- drivers/edac/i5000_edac.c | 2 +- drivers/edac/i5400_edac.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/edac/i5000_edac.c +1 -1
@@ -1293,7 +1293,7 @@ static int i5000_init_csrows(struct mem_ctl_info *mci) dimm->mtype =MEM_FB_DDR2 ;/* ask what device type on this row */ -if (MTR_DRAM_WIDTH (mtr)) +if (MTR_DRAM_WIDTH (mtr) ==8 ) dimm->dtype =DEV_X8 ;else dimm->dtype =DEV_X4 ;
drivers/edac/i5400_edac.c +3 -2
@@ -1207,13 +1207,14 @@ static int i5400_init_dimms(struct mem_ctl_info *mci) dimm->nr_pages = size_mb <<8 ; dimm->grain =8 ; - dimm->dtype =MTR_DRAM_WIDTH (mtr) ?DEV_X8 :DEV_X4 ; + dimm->dtype =MTR_DRAM_WIDTH (mtr) ==8 ? +DEV_X8 :DEV_X4 ; dimm->mtype =MEM_FB_DDR2 ;/* * The eccc mechanism is SDDC (aka SECC), with * is similar to Chipkill. */ - dimm->edac_mode =MTR_DRAM_WIDTH (mtr) ? + dimm->edac_mode =MTR_DRAM_WIDTH (mtr) ==8 ?EDAC_S8ECD8ED :EDAC_S4ECD4ED ; ndimms++; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] EDAC, i5000, i5400: Fix definition of NRECMEMB register
In reply to Sasha LevinFrom: Jérémy Lefaure <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a8c8261425649da58bdf08221570e5335ad33a31 ]
In the i5000 and i5400 drivers, the NRECMEMB register is defined as a 16-bit value, which results in wrong shifts in the code, as reported by sparse.
In the datasheets ([1], section 3.9.22.20 and [2], section 3.9.22.21), this register is a 32-bit register. A u32 value for the register fixes the wrong shifts warnings and matches the datasheet.
Also fix the mask to access to the CAS bits [27:16] in the i5000 driver.
[1]: https://www.intel.com/content/dam/doc/datasheet/5000p-5000v-5000z-chipset-memory-controller-hub-datasheet.pdf
[2]: https://www.intel.se/content/dam/doc/datasheet/5400-chipset-memory-controller-hub-datasheet.pdf
--- drivers/edac/i5000_edac.c | 6 +++--- drivers/edac/i5400_edac.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/edac/i5000_edac.c +3 -3
@@ -227,7 +227,7 @@#define NREC_RDWR (x) (((x)>>11) & 1)#define NREC_RANK (x) (((x)>>8) & 0x7)#define NRECMEMB 0xC0 -#define NREC_CAS (x) (((x)>>16) & 0xFFFFFF) +#define NREC_CAS (x) (((x)>>16) & 0xFFF)#define NREC_RAS (x) ((x) & 0x7FFF)#define NRECFGLOG 0xC4#define NREEECFBDA 0xC8
@@ -371,7 +371,7 @@ struct i5000_error_info {/* These registers are input ONLY if there was a * Non-Recoverable Error */ u16 nrecmema;/* Non-Recoverable Mem log A */ -u16 nrecmemb;/* Non-Recoverable Mem log B */ +u32 nrecmemb;/* Non-Recoverable Mem log B */ };
@@ -407,7 +407,7 @@ static void i5000_get_error_info(struct mem_ctl_info *mci, NERR_FAT_FBD, &info->nerr_fat_fbd);pci_read_config_word (pvt->branchmap_werrors,NRECMEMA , &info->nrecmema); -pci_read_config_word (pvt->branchmap_werrors, +pci_read_config_dword (pvt->branchmap_werrors,NRECMEMB , &info->nrecmemb);/* Clear the error bits, by writing them back */
drivers/edac/i5400_edac.c +2 -2
@@ -368,7 +368,7 @@ struct i5400_error_info {/* These registers are input ONLY if there was a Non-Rec Error */ u16 nrecmema;/* Non-Recoverable Mem log A */ -u16 nrecmemb;/* Non-Recoverable Mem log B */ +u32 nrecmemb;/* Non-Recoverable Mem log B */ };
@@ -458,7 +458,7 @@ static void i5400_get_error_info(struct mem_ctl_info *mci, NERR_FAT_FBD, &info->nerr_fat_fbd);pci_read_config_word (pvt->branchmap_werrors,NRECMEMA , &info->nrecmema); -pci_read_config_word (pvt->branchmap_werrors, +pci_read_config_dword (pvt->branchmap_werrors,NRECMEMB , &info->nrecmemb);/* Clear the error bits, by writing them back */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] mac80211_hwsim: Fix memory leak in hwsim_new_radio_nl()
In reply to Sasha LevinFrom: Ben Hutchings <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 67bd52386125ce1159c0581cbcd2740addf33cd4 ]
hwsim_new_radio_nl() now copies the name attribute in order to add a null-terminator. mac80211_hwsim_new_radio() (indirectly) copies it again into the net_device structure, so the first copy is not used or freed later. Free the first copy before returning.
--- drivers/net/wireless/mac80211_hwsim.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/wireless/mac80211_hwsim.c +4 -1
@@ -2884,6 +2884,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) {struct hwsim_new_radio_params param = {0 };const char *hwname =NULL ; +int ret; param.reg_strict = info->attrs[HWSIM_ATTR_REG_STRICT_REG ]; param.p2p_device = info->attrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE ];
@@ -2923,7 +2924,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) param.regd = hwsim_world_regdom_custom[idx]; } -return mac80211_hwsim_new_radio (info, ¶m); + ret =mac80211_hwsim_new_radio (info, ¶m); +kfree (hwname); +return ret; }static int hwsim_del_radio_nl (struct sk_buff *msg,struct genl_info *info)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] route: also update fnhe_genid when updating a route cache
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cebe84c6190d741045a322f5343f717139993c08 ]
Now when ip route flush cache and it turn out all fnhe_genid != genid. If a redirect/pmtu icmp packet comes and the old fnhe is found and all it's members but fnhe_genid will be updated.
Then next time when it looks up route and tries to rebind this fnhe to the new dst, the fnhe will be flushed due to fnhe_genid != genid. It causes this redirect/pmtu icmp packet acutally not to be applied.
This patch is to also reset fnhe_genid when updating a route cache.
--- net/ipv4/route.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/route.c +7 -2
@@ -622,9 +622,12 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,struct fnhe_hash_bucket *hash;struct fib_nh_exception *fnhe;struct rtable *rt; +u32 genid, hval;unsigned int i;int depth; -u32 hval =fnhe_hashfun (daddr); + + genid =fnhe_genid (dev_net (nh->nh_dev)); + hval =fnhe_hashfun (daddr);spin_lock_bh (&fnhe_lock);
@@ -647,6 +650,8 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, }if (fnhe) { +if (fnhe->fnhe_genid != genid) + fnhe->fnhe_genid = genid;if (gw) fnhe->fnhe_gw = gw;if (pmtu) {
@@ -671,7 +676,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, fnhe->fnhe_next = hash->chain;rcu_assign_pointer (hash->chain, fnhe); } - fnhe->fnhe_genid =fnhe_genid (dev_net (nh->nh_dev)); + fnhe->fnhe_genid = genid; fnhe->fnhe_daddr = daddr; fnhe->fnhe_gw = gw; fnhe->fnhe_pmtu = pmtu;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] route: update fnhe_expires for redirect when the fnhe exists
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e39d5246111399dbc6e11cd39fd8580191b86c47 ]
Now when creating fnhe for redirect, it sets fnhe_expires for this new route cache. But when updating the exist one, it doesn't do it. It will cause this fnhe never to be expired.
Paolo already noticed it before, in Jianlin's test case, it became even worse:
When ip route flush cache, the old fnhe is not to be removed, but only clean it's members. When redirect comes again, this fnhe will be found and updated, but never be expired due to fnhe_expires not being set.
So fix it by simply updating fnhe_expires even it's for redirect.
--- net/ipv4/route.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/ipv4/route.c +2 -3
@@ -654,10 +654,9 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, fnhe->fnhe_genid = genid;if (gw) fnhe->fnhe_gw = gw; -if (pmtu) { +if (pmtu) fnhe->fnhe_pmtu = pmtu; - fnhe->fnhe_expires =max (1UL , expires); - } + fnhe->fnhe_expires =max (1UL , expires);/* Update all cached dsts too */ rt =rcu_dereference (fnhe->fnhe_rth_input);if (rt)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] lib/genalloc.c: make the avail variable an atomic_long_t
In reply to Sasha LevinFrom: Stephen Bates <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 36a3d1dd4e16bcd0d2ddfb4a2ec7092f0ae0d931 ]
If the amount of resources allocated to a gen_pool exceeds 2^32 then the avail atomic overflows and this causes problems when clients try and borrow resources from the pool. This is only expected to be an issue on 64 bit systems.
Add the <linux/atomic.h> header to pull in atomic_long* operations. So that 32 bit systems continue to use atomic32_t but 64 bit systems can use atomic64_t.
--- include/linux/genalloc.h | 3 ++- lib/genalloc.c | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-)
include/linux/genalloc.h +2 -1
@@ -31,6 +31,7 @@#define __GENALLOC_H__#include <linux/spinlock_types.h> +#include <linux/atomic.h> struct device ;struct device_node ;
@@ -66,7 +67,7 @@ struct gen_pool {*/ struct gen_pool_chunk {struct list_head next_chunk;/* next chunk in pool */ -atomic_t avail; +atomic_long_t avail;phys_addr_t phys_addr;/* physical starting address of memory chunk */ unsigned long start_addr;/* start address of memory chunk */ unsigned long end_addr;/* end address of memory chunk (inclusive) */
lib/genalloc.c +5 -5
@@ -193,7 +193,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy chunk->phys_addr = phys; chunk->start_addr = virt; chunk->end_addr = virt + size -1 ; -atomic_set (&chunk->avail, size); +atomic_long_set (&chunk->avail, size);spin_lock (&pool->lock);list_add_rcu (&chunk->next_chunk, &pool->chunks);
@@ -284,7 +284,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size) nbits = (size + (1UL << order) -1 ) >> order;rcu_read_lock ();list_for_each_entry_rcu (chunk, &pool->chunks, next_chunk) { -if (size >atomic_read (&chunk->avail)) +if (size >atomic_long_read (&chunk->avail))continue ; end_bit =chunk_size (chunk) >> order;
@@ -303,7 +303,7 @@ unsigned long gen_pool_alloc(struct gen_pool *pool, size_t size) addr = chunk->start_addr + ((unsigned long )start_bit << order); size = nbits << order; -atomic_sub (size, &chunk->avail); +atomic_long_sub (size, &chunk->avail);break ; }rcu_read_unlock ();
@@ -369,7 +369,7 @@ void gen_pool_free(struct gen_pool *pool, unsigned long addr, size_t size) remain =bitmap_clear_ll (chunk->bits, start_bit, nbits);BUG_ON (remain); size = nbits << order; -atomic_add (size, &chunk->avail); +atomic_long_add (size, &chunk->avail);rcu_read_unlock ();return ; }
@@ -443,7 +443,7 @@ size_t gen_pool_avail(struct gen_pool *pool)rcu_read_lock ();list_for_each_entry_rcu (chunk, &pool->chunks, next_chunk) - avail +=atomic_read (&chunk->avail); + avail +=atomic_long_read (&chunk->avail);rcu_read_unlock ();return avail; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] dynamic-debug-howto: fix optional/omitted ending line number to be LARGE instead of 0
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1f3c790bd5989fcfec9e53ad8fa09f5b740c958f ]
line-range is supposed to treat "1-" as "1-endoffile", so handle the special case by setting last_lineno to UINT_MAX.
Fixes this error:
dynamic_debug:ddebug_parse_query: last-line:0 < 1st-line:1 dynamic_debug:ddebug_exec_query: query parse failed
--- lib/dynamic_debug.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/dynamic_debug.c +4 -0
@@ -353,6 +353,10 @@ static int ddebug_parse_query(char *words[], int nwords,if (parse_lineno (last, &query->last_lineno) <0 )return -EINVAL ; +/* special case for last lineno not specified */ +if (query->last_lineno ==0 ) + query->last_lineno =UINT_MAX ; +if (query->last_lineno < query->first_lineno) { pr_err("last-line:%d < 1st-line:%d\n", query->last_lineno,
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sctp: do not free asoc when it is already dead in sctp_sendmsg
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ca3af4dd28cff4e7216e213ba3b671fbf9f84758 ]
Now in sctp_sendmsg sctp_wait_for_sndbuf could schedule out without holding sock sk. It means the current asoc can be freed elsewhere, like when receiving an abort packet.
If the asoc is just created in sctp_sendmsg and sctp_wait_for_sndbuf returns err, the asoc will be freed again due to new_asoc is not nil. An use-after-free issue would be triggered by this.
This patch is to fix it by setting new_asoc with nil if the asoc is already dead when cpu schedules back, so that it will not be freed again in sctp_sendmsg.
v1->v2:
set new_asoc as nil in sctp_sendmsg instead of sctp_wait_for_sndbuf.
--- net/sctp/socket.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
net/sctp/socket.c +14 -3
@@ -1948,8 +1948,14 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT );if (!sctp_wspace (asoc)) { err =sctp_wait_for_sndbuf (asoc, &timeo, msg_len); -if (err) +if (err) { +if (err == -ESRCH ) { +/* asoc is already dead. */ + new_asoc =NULL ; + err = -EPIPE ; + } goto out_free; + } }/* If an address is passed with the sendto/sendmsg call, it is used
@@ -6989,10 +6995,11 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,for (;;) {prepare_to_wait_exclusive (&asoc->wait, &wait,TASK_INTERRUPTIBLE ); +if (asoc->base.dead) + goto do_dead;if (!*timeo_p) goto do_nonblock; -if (sk->sk_err || asoc->state >=SCTP_STATE_SHUTDOWN_PENDING || - asoc->base.dead) +if (sk->sk_err || asoc->state >=SCTP_STATE_SHUTDOWN_PENDING ) goto do_error;if (signal_pending (current)) goto do_interrupted;
@@ -7018,6 +7025,10 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,return err; +do_dead: + err = -ESRCH ; + goto out; + do_error: err = -EPIPE ; goto out;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] NFS: Fix a typo in nfs_rename()
In reply to Sasha LevinFrom: Trond Myklebust <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d803224c84be067754db7fa58a93f36f61566493 ]
On successful rename, the "old_dentry" is retained and is attached to the "new_dir", so we need to call nfs_set_verifier() accordingly.
--- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/dir.c +1 -1
@@ -2076,7 +2076,7 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,if (new_inode !=NULL )nfs_drop_nlink (new_inode);d_move (old_dentry, new_dentry); -nfs_set_verifier (new_dentry, +nfs_set_verifier (old_dentry,nfs_save_change_attribute (new_dir)); }else if (error == -ENOENT )nfs_dentry_handle_enoent (old_dentry);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sctp: use the right sk after waking up from wait_buf sleep
In reply to Sasha LevinFrom: Xin Long <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cea0cc80a6777beb6eb643d4ad53690e1ad1d4ff ]
Commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads sleeping on it") fixed the race between peeloff and wait sndbuf by checking waitqueue_active(&asoc->wait) in sctp_do_peeloff().
But it actually doesn't work, as even if waitqueue_active returns false the waiting sndbuf thread may still not yet hold sk lock. After asoc is peeled off, sk is not asoc->base.sk any more, then to hold the old sk lock couldn't make assoc safe to access.
This patch is to fix this by changing to hold the new sk lock if sk is not asoc->base.sk, meanwhile, also set the sk in sctp_sendmsg with the new sk.
With this fix, there is no more race between peeloff and waitbuf, the check 'waitqueue_active' in sctp_do_peeloff can be removed.
Thanks Marcelo and Neil for making this clear.
v1->v2:
fix it by changing to lock the new sock instead of adding a flag in asoc.
--- net/sctp/socket.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/sctp/socket.c +11 -4
@@ -82,8 +82,8 @@/* Forward declarations for internal helper functions. */ static int sctp_writeable (struct sock *sk);static void sctp_wfree (struct sk_buff *skb); -static int sctp_wait_for_sndbuf (struct sctp_association *,long *timeo_p, -size_t msg_len); +static int sctp_wait_for_sndbuf (struct sctp_association *asoc,long *timeo_p, +size_t msg_len,struct sock **orig_sk);static int sctp_wait_for_packet (struct sock *sk,int *err,long *timeo_p);static int sctp_wait_for_connect (struct sctp_association *,long *timeo_p);static int sctp_wait_for_accept (struct sock *sk,long timeo);
@@ -1947,7 +1947,8 @@ static int sctp_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len) timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT );if (!sctp_wspace (asoc)) { - err =sctp_wait_for_sndbuf (asoc, &timeo, msg_len); +/* sk can be changed by peel off when waiting for buf. */ + err =sctp_wait_for_sndbuf (asoc, &timeo, msg_len, &sk);if (err) {if (err == -ESRCH ) {/* asoc is already dead. */
@@ -6978,7 +6979,7 @@ void sctp_sock_rfree(struct sk_buff *skb)/* Helper function to wait for space in the sndbuf. */ static int sctp_wait_for_sndbuf (struct sctp_association *asoc,long *timeo_p, -size_t msg_len) +size_t msg_len,struct sock **orig_sk) {struct sock *sk = asoc->base.sk;int err =0 ;
@@ -7013,11 +7014,17 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p, current_timeo =schedule_timeout (current_timeo);BUG_ON (sk != asoc->base.sk);lock_sock (sk); +if (sk != asoc->base.sk) { +release_sock (sk); + sk = asoc->base.sk; +lock_sock (sk); + } *timeo_p = current_timeo; } out: + *orig_sk = sk;finish_wait (&asoc->wait, &wait);/* Release the association's refcnt. */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sunrpc: Fix rpc_task_begin trace point
In reply to Sasha LevinFrom: Chuck Lever <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b2bfe5915d5fe7577221031a39ac722a0a2a1199 ]
The rpc_task_begin trace point always display a task ID of zero. Move the trace point call site so that it picks up the new task ID.
--- net/sunrpc/sched.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/sunrpc/sched.c +1 -2
@@ -273,10 +273,9 @@ static inline void rpc_task_set_debuginfo(struct rpc_task *task)static void rpc_set_active (struct rpc_task *task) { -trace_rpc_task_begin (task->tk_client, task,NULL ); -rpc_task_set_debuginfo (task);set_bit (RPC_TASK_ACTIVE , &task->tk_runstate); +trace_rpc_task_begin (task->tk_client, task,NULL ); }/*
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sparc64/mm: set fields in deferred pages
In reply to Sasha LevinFrom: Pavel Tatashin <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2a20aa171071a334d80c4e5d5af719d8374702fc ]
Without deferred struct page feature (CONFIG_DEFERRED_STRUCT_PAGE_INIT), flags and other fields in "struct page"es are never changed prior to first initializing struct pages by going through __init_single_page().
With deferred struct page feature enabled there is a case where we set some fields prior to initializing:
mem_init() {
register_page_bootmem_info();
free_all_bootmem();
...
}When register_page_bootmem_info() is called only non-deferred struct pages are initialized. But, this function goes through some reserved pages which might be part of the deferred, and thus are not yet initialized.
mem_initregister_page_bootmem_inforegister_page_bootmem_info_node
get_page_bootmem
.. setting fields here ..
such as: page->freelist = (void *)type;
free_all_bootmem()free_low_memory_core_early()
for_each_reserved_mem_region()
reserve_bootmem_region()
init_reserved_page() <- Only if this is deferred reserved page
__init_single_pfn()
__init_single_page()
memset(0) <-- Loose the set fields hereWe end up with similar issue as in the previous patch, where currently we do not observe problem as memory is zeroed. But, if flag asserts are changed we can start hitting issues.
Also, because in this patch series we will stop zeroing struct page memory during allocation, we must make sure that struct pages are properly initialized prior to using them.
The deferred-reserved pages are initialized in free_all_bootmem(). Therefore, the fix is to switch the above calls.
--- arch/sparc/mm/init_64.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/sparc/mm/init_64.c +8 -1
@@ -2285,10 +2285,17 @@ void __init mem_init(void) { high_memory =__va (last_valid_pfn <<PAGE_SHIFT ); -register_page_bootmem_info ();free_all_bootmem ();/* +* Must be done after boot memory is put on freelist, because here we +* might set fields in deferred struct pages that have not yet been +* initialized, and free_all_bootmem() initializes all the reserved +* deferred pages for us. +*/ +register_page_bootmem_info (); + +/* * Set up the zero page, mark it reserved, so that page count * is not manipulated when freeing the page from user ptes. */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] atm: horizon: Fix irq release error
In reply to Sasha LevinFrom: Arvind Yadav <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bde533f2ea607cbbbe76ef8738b36243939a7bc2 ]
atm_dev_register() can fail here and passed parameters to free irq which is not initialised. Initialization of 'dev->irq' happened after the 'goto out_free_irq'. So using 'irq' insted of 'dev->irq' in free_irq().
--- drivers/atm/horizon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/atm/horizon.c +1 -1
@@ -2804,7 +2804,7 @@ static int hrz_probe(struct pci_dev *pci_dev,return err; out_free_irq: -free_irq (dev->irq, dev); +free_irq (irq, dev); out_free:kfree (dev); out_release:
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] xfrm: Copy policy family in clone_policy
In reply to Sasha LevinFrom: Herbert Xu <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 0e74aa1d79a5bbc663e03a2804399cae418a0321 ]
The syzbot found an ancient bug in the IPsec code. When we cloned a socket policy (for example, for a child TCP socket derived from a listening socket), we did not copy the family field. This results in a live policy with a zero family field. This triggers a BUG_ON check in the af_key code when the cloned policy is retrieved.
This patch fixes it by copying the family field over.
--- net/xfrm/xfrm_policy.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_policy.c +1 -0
@@ -1352,6 +1352,7 @@ static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir) newp->xfrm_nr = old->xfrm_nr; newp->index = old->index; newp->type = old->type; + newp->family = old->family;memcpy (newp->xfrm_vec, old->xfrm_vec, newp->xfrm_nr*sizeof (struct xfrm_tmpl ));write_lock_bh (&net->xfrm.xfrm_policy_lock);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] IB/mlx4: Increase maximal message size under UD QP
In reply to Sasha LevinFrom: Mark Bloch <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5f22a1d87c5315a98981ecf93cd8de226cffe6ca ]
Maximal message should be used as a limit to the max message payload allowed, without the headers. The ConnectX-3 check is done against this value includes the headers. When the payload is 4K this will cause the NIC to drop packets.
Increase maximal message to 8K as workaround, this shouldn't change current behaviour because we continue to set the MTU to 4k.
To reproduce;
set MTU to 4296 on the corresponding interface, for example:
ifconfig eth0 mtu 4296 (both server and client)
On server:ib_send_bw -c UD -d mlx4_0 -s 4096 -n 1000000 -i1 -m 4096
On client:ib_send_bw -d mlx4_0 -c UD <server_ip> -s 4096 -n 1000000 -i 1 -m 4096
--- drivers/infiniband/hw/mlx4/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/qp.c +1 -1
@@ -1496,7 +1496,7 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp, context->mtu_msgmax = (IB_MTU_4096 <<5 ) |ilog2 (dev->dev->caps.max_gso_sz); else - context->mtu_msgmax = (IB_MTU_4096 << 5) | 12; + context->mtu_msgmax = (IB_MTU_4096 << 5) | 13; }else if (attr_mask &IB_QP_PATH_MTU ) {if (attr->path_mtu <IB_MTU_256 || attr->path_mtu >IB_MTU_4096 ) { pr_err("path MTU (%u) is invalid\n",
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] IB/mlx5: Assign send CQ and recv CQ of UMR QP
In reply to Sasha LevinFrom: Majd Dibbiny <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 31fde034a8bd964a5c7c1a5663fc87a913158db2 ]
The UMR's QP is created by calling mlx5_ib_create_qp directly, and therefore the send CQ and the recv CQ on the ibqp weren't assigned.
Assign them right after calling the mlx5_ib_create_qp to assure that any access to those pointers will work as expected and won't crash the system as might happen as part of reset flow.
--- drivers/infiniband/hw/mlx5/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -1020,6 +1020,8 @@ static int create_umr_res(struct mlx5_ib_dev *dev) qp->real_qp = qp; qp->uobject =NULL ; qp->qp_type =MLX5_IB_QPT_REG_UMR ; + qp->send_cq = init_attr->send_cq; + qp->recv_cq = init_attr->recv_cq; attr->qp_state =IB_QPS_INIT ; attr->port_num =1 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Connect up the CB.ProbeUuid
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f4b3526d83c40dd8bf5948b9d7a1b2c340f0dcc8 ]
The handler for the CB.ProbeUuid operation in the cache manager is implemented, but isn't listed in the switch-statement of operation selection, so won't be used. Fix this by adding it.
--- fs/afs/cmservice.c | 3 +++ 1 file changed, 3 insertions(+)
fs/afs/cmservice.c +3 -0
@@ -115,6 +115,9 @@ bool afs_cm_incoming_call(struct afs_call *call)case CBProbe: call->type = &afs_SRXCBProbe;return true; +case CBProbeUuid: + call->type = &afs_SRXCBProbeUuid; +return true;case CBTellMeAboutYourself: call->type = &afs_SRXCBTellMeAboutYourself;return true;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] audit: ensure that 'audit=1' actually enables audit for PID 1
In reply to Sasha LevinFrom: Paul Moore <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 173743dd99a49c956b124a74c8aacb0384739a4c ]
Prior to this patch we enabled audit in audit_init(), which is too late for PID 1 as the standard initcalls are run after the PID 1 task is forked. This means that we never allocate an audit_context (see audit_alloc()) for PID 1 and therefore miss a lot of audit events generated by PID 1.
This patch enables audit as early as possible to help ensure that when PID 1 is forked it can allocate an audit_context if required.
--- kernel/audit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
kernel/audit.c +5 -5
@@ -80,13 +80,13 @@ static int audit_initialized;#define AUDIT_OFF 0#define AUDIT_ON 1#define AUDIT_LOCKED 2 -u32 audit_enabled; -u32 audit_ever_enabled; +u32 audit_enabled =AUDIT_OFF ; +u32 audit_ever_enabled = !!AUDIT_OFF ;EXPORT_SYMBOL_GPL (audit_enabled);/* Default state when kernel boots without any parameters. */ -static u32 audit_default; +static u32 audit_default =AUDIT_OFF ;/* If auditing cannot proceed, audit_failure selects what happens. */ static u32 audit_failure =AUDIT_FAIL_PRINTK ;
@@ -1165,8 +1165,6 @@ static int __init audit_init(void)skb_queue_head_init (&audit_skb_queue);skb_queue_head_init (&audit_skb_hold_queue); audit_initialized =AUDIT_INITIALIZED ; - audit_enabled = audit_default; - audit_ever_enabled |= !!audit_default;audit_log (NULL ,GFP_KERNEL ,AUDIT_KERNEL ,"initialized" );
@@ -1183,6 +1181,8 @@ static int __init audit_enable(char *str) audit_default = !!simple_strtol (str,NULL ,0 );if (!audit_default) audit_initialized =AUDIT_DISABLED ; + audit_enabled = audit_default; + audit_ever_enabled = !!audit_enabled;pr_info ("%s\n" , audit_default ?"enabled (after initialization)" :"disabled (until reboot)" );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] rds: Fix NULL pointer dereference in __rds_rdma_map
In reply to Sasha LevinFrom: Håkon Bugge <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f3069c6d33f6ae63a1668737bc78aaaa51bff7ca ]
This is a fix for syzkaller719569, where memory registration was attempted without any underlying transport being loaded.
Analysis of the case reveals that it is the setsockopt() RDS_GET_MR
(2) and RDS_GET_MR_FOR_DEST (7) that are vulnerable.
Here is an example stack trace when the bug is hit:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000c0 IP: __rds_rdma_map+0x36/0x440 [rds] PGD 2f93d03067 P4D 2f93d03067 PUD 2f93d02067 PMD 0 Oops: 0000 [#1] SMP Modules linked in: bridge stp llc tun rpcsec_gss_krb5 nfsv4
dns_resolver nfs fscache rds binfmt_misc sb_edac intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul c rc32_pclmul ghash_clmulni_intel pcbc aesni_intel crypto_simd glue_helper cryptd iTCO_wdt mei_me sg iTCO_vendor_support ipmi_si mei ipmi_devintf nfsd shpchp pcspkr i2c_i801 ioatd ma ipmi_msghandler wmi lpc_ich mfd_core auth_rpcgss nfs_acl lockd grace sunrpc ip_tables ext4 mbcache jbd2 mgag200 i2c_algo_bit drm_kms_helper ixgbe syscopyarea ahci sysfillrect sysimgblt libahci mdio fb_sys_fops ttm ptp libata sd_mod mlx4_core drm crc32c_intel pps_core megaraid_sas i2c_core dca dm_mirror dm_region_hash dm_log dm_mod
CPU: 48 PID: 45787 Comm: repro_set2 Not tainted 4.14.2-3.el7uek.x86_64 #2 Hardware name: Oracle Corporation ORACLE SERVER X5-2L/ASM,MOBO TRAY,2U, BIOS 31110000 03/03/2017 task: ffff882f9190db00 task.stack: ffffc9002b994000 RIP: 0010:__rds_rdma_map+0x36/0x440 [rds] RSP: 0018:ffffc9002b997df0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff882fa2182580 RCX: 0000000000000000 RDX: 0000000000000000 RSI: ffffc9002b997e40 RDI: ffff882fa2182580 RBP: ffffc9002b997e30 R08: 0000000000000000 R09: 0000000000000002 R10: ffff885fb29e3838 R11: 0000000000000000 R12: ffff882fa2182580 R13: ffff882fa2182580 R14: 0000000000000002 R15: 0000000020000ffc FS: 00007fbffa20b700(0000) GS:ffff882fbfb80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000000c0 CR3: 0000002f98a66006 CR4: 00000000001606e0 Call Trace: rds_get_mr+0x56/0x80 [rds] rds_setsockopt+0x172/0x340 [rds] ? __fget_light+0x25/0x60 ? __fdget+0x13/0x20 SyS_setsockopt+0x80/0xe0 do_syscall_64+0x67/0x1b0 entry_SYSCALL64_slow_path+0x25/0x25 RIP: 0033:0x7fbff9b117f9 RSP: 002b:00007fbffa20aed8 EFLAGS: 00000293 ORIG_RAX: 0000000000000036 RAX: ffffffffffffffda RBX: 00000000000c84a4 RCX: 00007fbff9b117f9 RDX: 0000000000000002 RSI: 0000400000000114 RDI: 000000000000109b RBP: 00007fbffa20af10 R08: 0000000000000020 R09: 00007fbff9dd7860 R10: 0000000020000ffc R11: 0000000000000293 R12: 0000000000000000 R13: 00007fbffa20b9c0 R14: 00007fbffa20b700 R15: 0000000000000021 Code: 41 56 41 55 49 89 fd 41 54 53 48 83 ec 18 8b 87 f0 02 00 00 48
89 55 d0 48 89 4d c8 85 c0 0f 84 2d 03 00 00 48 8b 87 00 03 00 00 <48> 83 b8 c0 00 00 00 00 0f 84 25 03 00 0 0 48 8b 06 48 8b 56 08
The fix is to check the existence of an underlying transport in __rds_rdma_map().
--- net/rds/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/rds/rdma.c +1 -1
@@ -184,7 +184,7 @@ static int __rds_rdma_map(struct rds_sock *rs, struct rds_get_mr_args *args,long i;int ret; -if (rs->rs_bound_addr ==0 ) { +if (rs->rs_bound_addr ==0 || !rs->rs_transport) { ret = -ENOTCONN ;/* XXX not a great errno */ goto out; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sit: update frag_off info
In reply to Sasha LevinFrom: Hangbin Liu <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f859b4af1c52493ec21173ccc73d0b60029b5b88 ]
After parsing the sit netlink change info, we forget to update frag_off in ipip6_tunnel_update(). Fix it by assigning frag_off with new value.
--- net/ipv6/sit.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/sit.c +1 -0
@@ -1092,6 +1092,7 @@ static void ipip6_tunnel_update(struct ip_tunnel *t, struct ip_tunnel_parm *p)ipip6_tunnel_link (sitn, t); t->parms.iph.ttl = p->iph.ttl; t->parms.iph.tos = p->iph.tos; + t->parms.iph.frag_off = p->iph.frag_off;if (t->parms.link != p->link) { t->parms.link = p->link;ipip6_tunnel_bind_dev (t->dev);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net/packet: fix a race in packet_bind() and packet_notifier()
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 15fe076edea787807a7cdc168df832544b58eba6 ]
syzbot reported crashes [1] and provided a C repro easing bug hunting.
When/if packet_do_bind() calls __unregister_prot_hook() and releases po->bind_lock, another thread can run packet_notifier() and process an NETDEV_UP event.
This calls register_prot_hook() and hooks again the socket right before first thread is able to grab again po->bind_lock.
Fixes this issue by temporarily setting po->num to 0, as suggested by David Miller.
[1]dev_remove_pack: ffff8801bf16fa80 not found
------------[ cut here ]------------ kernel BUG at net/core/dev.c:7945! ( BUG_ON(!list_empty(&dev->ptype_all)); ) invalid opcode: 0000 [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: device syz0 entered promiscuous mode CPU: 0 PID: 3161 Comm: syzkaller404108 Not tainted 4.14.0+ #190 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: ffff8801cc57a500 task.stack: ffff8801cc588000 RIP: 0010:netdev_run_todo+0x772/0xae0 net/core/dev.c:7945 RSP: 0018:ffff8801cc58f598 EFLAGS: 00010293 RAX: ffff8801cc57a500 RBX: dffffc0000000000 RCX: ffffffff841f75b2 RDX: 0000000000000000 RSI: 1ffff100398b1ede RDI: ffff8801bf1f8810 device syz0 entered promiscuous mode RBP: ffff8801cc58f898 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801bf1f8cd8 R13: ffff8801cc58f870 R14: ffff8801bf1f8780 R15: ffff8801cc58f7f0 FS: 0000000001716880(0000) GS:ffff8801db400000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000020b13000 CR3: 0000000005e25000 CR4: 00000000001406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: rtnl_unlock+0xe/0x10 net/core/rtnetlink.c:106 tun_detach drivers/net/tun.c:670 [inline] tun_chr_close+0x49/0x60 drivers/net/tun.c:2845 __fput+0x333/0x7f0 fs/file_table.c:210 ____fput+0x15/0x20 fs/file_table.c:244 task_work_run+0x199/0x270 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x9bb/0x1ae0 kernel/exit.c:865 do_group_exit+0x149/0x400 kernel/exit.c:968 SYSC_exit_group kernel/exit.c:979 [inline] SyS_exit_group+0x1d/0x20 kernel/exit.c:977 entry_SYSCALL_64_fastpath+0x1f/0x96 RIP: 0033:0x44ad19
--- net/packet/af_packet.c | 5 +++++ 1 file changed, 5 insertions(+)
net/packet/af_packet.c +5 -0
@@ -2730,6 +2730,10 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex,if (need_rehook) {if (po->running) {rcu_read_unlock (); +/* prevents packet_notifier() from calling +* register_prot_hook() +*/ + po->num =0 ;__unregister_prot_hook (sk, true);rcu_read_lock (); dev_curr = po->prot_hook.dev;
@@ -2738,6 +2742,7 @@ static int packet_do_bind(struct sock *sk, const char *name, int ifindex, dev->ifindex); } +BUG_ON (po->running); po->num = proto; po->prot_hook.type = proto;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] usb: gadget: ffs: Forbid usb_ep_alloc_request from sleeping
In reply to Sasha LevinFrom: Vincent Pelletier <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 30bf90ccdec1da9c8198b161ecbff39ce4e5a9ba ]
Found using DEBUG_ATOMIC_SLEEP while submitting an AIO read operation:
[ 100.853642] BUG: sleeping function called from invalid context at mm/slab.h:421
[ 100.861148] in_atomic(): 1, irqs_disabled(): 1, pid: 1880, name: python
[ 100.867954] 2 locks held by python/1880:
[ 100.867961] #0: (&epfile->mutex){....}, at: [<f8188627>] ffs_mutex_lock+0x27/0x30 [usb_f_fs]
[ 100.868020] #1: (&(&ffs->eps_lock)->rlock){....}, at: [<f818ad4b>] ffs_epfile_io.isra.17+0x24b/0x590 [usb_f_fs]
[ 100.868076] CPU: 1 PID: 1880 Comm: python Not tainted 4.14.0-edison+ #118
[ 100.868085] Hardware name: Intel Corporation Merrifield/BODEGA BAY, BIOS 542 2015.01.21:18.19.48
[ 100.868093] Call Trace:
[ 100.868122] dump_stack+0x47/0x62
[ 100.868156] ___might_sleep+0xfd/0x110
[ 100.868182] __might_sleep+0x68/0x70
[ 100.868217] kmem_cache_alloc_trace+0x4b/0x200
[ 100.868248] ? dwc3_gadget_ep_alloc_request+0x24/0xe0 [dwc3]
[ 100.868302] dwc3_gadget_ep_alloc_request+0x24/0xe0 [dwc3]
[ 100.868343] usb_ep_alloc_request+0x16/0xc0 [udc_core]
[ 100.868386] ffs_epfile_io.isra.17+0x444/0x590 [usb_f_fs]
[ 100.868424] ? _raw_spin_unlock_irqrestore+0x27/0x40
[ 100.868457] ? kiocb_set_cancel_fn+0x57/0x60
[ 100.868477] ? ffs_ep0_poll+0xc0/0xc0 [usb_f_fs]
[ 100.868512] ffs_epfile_read_iter+0xfe/0x157 [usb_f_fs]
[ 100.868551] ? security_file_permission+0x9c/0xd0
[ 100.868587] ? rw_verify_area+0xac/0x120
[ 100.868633] aio_read+0x9d/0x100
[ 100.868692] ? __fget+0xa2/0xd0
[ 100.868727] ? __might_sleep+0x68/0x70
[ 100.868763] SyS_io_submit+0x471/0x680
[ 100.868878] do_int80_syscall_32+0x4e/0xd0
[ 100.868921] entry_INT80_32+0x2a/0x2a
[ 100.868932] EIP: 0xb7fbb676
[ 100.868941] EFLAGS: 00000292 CPU: 1
[ 100.868951] EAX: ffffffda EBX: b7aa2000 ECX: 00000002 EDX: b7af8368
[ 100.868961] ESI: b7fbb660 EDI: b7aab000 EBP: bfb6c658 ESP: bfb6c638
[ 100.868973] DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b--- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/function/f_fs.c +1 -1
@@ -791,7 +791,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data) }if (io_data->aio) { - req =usb_ep_alloc_request (ep->ep,GFP_KERNEL ); + req =usb_ep_alloc_request (ep->ep,GFP_ATOMIC );if (unlikely (!req)) goto error_lock;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] crypto: hmac - require that the underlying hash algorithm is unkeyed
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit af3ff8045bbf3e32f1a448542e73abb4c8ceb6f1 ]
Because the HMAC template didn't check that its underlying hash algorithm is unkeyed, trying to use "hmac(hmac(sha3-512-generic))" through AF_ALG or through KEYCTL_DH_COMPUTE resulted in the inner HMAC being used without having been keyed, resulting in sha3_update() being called without sha3_init(), causing a stack buffer overflow.
This is a very old bug, but it seems to have only started causing real problems when SHA-3 support was added (requires CONFIG_CRYPTO_SHA3) because the innermost hash's state is ->import()ed from a zeroed buffer, and it just so happens that other hash algorithms are fine with that, but SHA-3 is not. However, there could be arch or hardware-dependent hash algorithms also affected; I couldn't test everything.
Fix the bug by introducing a function crypto_shash_alg_has_setkey() which tests whether a shash algorithm is keyed. Then update the HMAC template to require that its underlying hash algorithm is unkeyed.
Here is a reproducer:
#include <linux/if_alg.h>
#include <sys/socket.h>
int main()
{
int algfd;
struct sockaddr_alg addr = {
.salg_type = "hash",
.salg_name = "hmac(hmac(sha3-512-generic))",
};
char key[4096] = { 0 };
algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
bind(algfd, (const struct sockaddr *)&addr, sizeof(addr));
setsockopt(algfd, SOL_ALG, ALG_SET_KEY, key, sizeof(key));
}Here was the KASAN report from syzbot:
BUG: KASAN: stack-out-of-bounds in memcpy include/linux/string.h:341 [inline]
BUG: KASAN: stack-out-of-bounds in sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
Write of size 4096 at addr ffff8801cca07c40 by task syzkaller076574/3044
CPU: 1 PID: 3044 Comm: syzkaller076574 Not tainted 4.14.0-mm1+ #25
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x194/0x257 lib/dump_stack.c:53
print_address_description+0x73/0x250 mm/kasan/report.c:252
kasan_report_error mm/kasan/report.c:351 [inline]
kasan_report+0x25b/0x340 mm/kasan/report.c:409
check_memory_region_inline mm/kasan/kasan.c:260 [inline]
check_memory_region+0x137/0x190 mm/kasan/kasan.c:267
memcpy+0x37/0x50 mm/kasan/kasan.c:303
memcpy include/linux/string.h:341 [inline]
sha3_update+0xdf/0x2e0 crypto/sha3_generic.c:161
crypto_shash_update+0xcb/0x220 crypto/shash.c:109
shash_finup_unaligned+0x2a/0x60 crypto/shash.c:151
crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
hmac_finup+0x182/0x330 crypto/hmac.c:152
crypto_shash_finup+0xc4/0x120 crypto/shash.c:165
shash_digest_unaligned+0x9e/0xd0 crypto/shash.c:172
crypto_shash_digest+0xc4/0x120 crypto/shash.c:186
hmac_setkey+0x36a/0x690 crypto/hmac.c:66
crypto_shash_setkey+0xad/0x190 crypto/shash.c:64
shash_async_setkey+0x47/0x60 crypto/shash.c:207
crypto_ahash_setkey+0xaf/0x180 crypto/ahash.c:200
hash_setkey+0x40/0x90 crypto/algif_hash.c:446
alg_setkey crypto/af_alg.c:221 [inline]
alg_setsockopt+0x2a1/0x350 crypto/af_alg.c:254
SYSC_setsockopt net/socket.c:1851 [inline]
SyS_setsockopt+0x189/0x360 net/socket.c:1830
entry_SYSCALL_64_fastpath+0x1f/0x96--- crypto/hmac.c | 6 +++++- crypto/shash.c | 5 +++-- include/crypto/internal/hash.h | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-)
crypto/hmac.c +5 -1
@@ -194,11 +194,15 @@ static int hmac_create(struct crypto_template *tmpl, struct rtattr **tb) salg =shash_attr_alg (tb[1 ],0 ,0 );if (IS_ERR (salg))return PTR_ERR (salg); + alg = &salg->base; +/* The underlying hash algorithm must be unkeyed */ err = -EINVAL ; +if (crypto_shash_alg_has_setkey (salg)) + goto out_put_alg; + ds = salg->digestsize; ss = salg->statesize; - alg = &salg->base;if (ds > alg->cra_blocksize || ss < alg->cra_blocksize) goto out_put_alg;
crypto/shash.c +3 -2
@@ -24,11 +24,12 @@static const struct crypto_type crypto_shash_type; -static int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, -unsigned int keylen) +int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, +unsigned int keylen) {return -ENOSYS ; } +EXPORT_SYMBOL_GPL (shash_no_setkey);static int shash_setkey_unaligned (struct crypto_shash *tfm,const u8 *key,unsigned int keylen)
include/crypto/internal/hash.h +8 -0
@@ -83,6 +83,14 @@ int ahash_register_instance(struct crypto_template *tmpl, struct ahash_instance *inst);void ahash_free_instance (struct crypto_instance *inst); +int shash_no_setkey (struct crypto_shash *tfm,const u8 *key, +unsigned int keylen); + +static inline bool crypto_shash_alg_has_setkey (struct shash_alg *alg) +{ +return alg->setkey != shash_no_setkey; +} +int crypto_init_ahash_spawn (struct crypto_ahash_spawn *spawn,struct hash_alg_common *alg,struct crypto_instance *inst);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] crypto: salsa20 - fix blkcipher_walk API usage
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ecaaab5649781c5a0effdaf298a925063020500e ]
When asked to encrypt or decrypt 0 bytes, both the generic and x86 implementations of Salsa20 crash in blkcipher_walk_done(), either when doing 'kfree(walk->buffer)' or 'free_page((unsigned long)walk->page)', because walk->buffer and walk->page have not been initialized.
The bug is that Salsa20 is calling blkcipher_walk_done() even when nothing is in 'walk.nbytes'. But blkcipher_walk_done() is only meant to be called when a nonzero number of bytes have been provided.
The broken code is part of an optimization that tries to make only one call to salsa20_encrypt_bytes() to process inputs that are not evenly divisible by 64 bytes. To fix the bug, just remove this "optimization" and use the blkcipher_walk API the same way all the other users do.
Reproducer:
#include <linux/if_alg.h>
#include <sys/socket.h>
#include <unistd.h>
int main()
{
int algfd, reqfd;
struct sockaddr_alg addr = {
.salg_type = "skcipher",
.salg_name = "salsa20",
};
char key[16] = { 0 };
algfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
bind(algfd, (void *)&addr, sizeof(addr));
reqfd = accept(algfd, 0, 0);
setsockopt(algfd, SOL_ALG, ALG_SET_KEY, key, sizeof(key));
read(reqfd, key, sizeof(key));
}--- arch/x86/crypto/salsa20_glue.c | 7 ------- crypto/salsa20_generic.c | 7 ------- 2 files changed, 14 deletions(-)
arch/x86/crypto/salsa20_glue.c +0 -7
@@ -59,13 +59,6 @@ static int encrypt(struct blkcipher_desc *desc,salsa20_ivsetup (ctx, walk.iv); -if (likely (walk.nbytes == nbytes)) - { -salsa20_encrypt_bytes (ctx, walk.src.virt.addr, - walk.dst.virt.addr, nbytes); -return blkcipher_walk_done (desc, &walk,0 ); - } -while (walk.nbytes >=64 ) { salsa20_encrypt_bytes(ctx, walk.src.virt.addr, walk.dst.virt.addr,
crypto/salsa20_generic.c +0 -7
@@ -188,13 +188,6 @@ static int encrypt(struct blkcipher_desc *desc,salsa20_ivsetup (ctx, walk.iv); -if (likely (walk.nbytes == nbytes)) - { -salsa20_encrypt_bytes (ctx, walk.dst.virt.addr, - walk.src.virt.addr, nbytes); -return blkcipher_walk_done (desc, &walk,0 ); - } -while (walk.nbytes >=64 ) { salsa20_encrypt_bytes(ctx, walk.dst.virt.addr, walk.src.virt.addr,
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] tracing: Allocate mask_str buffer dynamically
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 90e406f96f630c07d631a021fd4af10aac913e77 ]
The default NR_CPUS can be very large, but actual possible nr_cpu_ids usually is very small. For my x86 distribution, the NR_CPUS is 8192 and nr_cpu_ids is 4. About 2 pages are wasted.
Most machines don't have so many CPUs, so define a array with NR_CPUS just wastes memory. So let's allocate the buffer dynamically when need.
With this change, the mutext tracing_cpumask_update_lock also can be removed now, which was used to protect mask_str.
--- kernel/trace/trace.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
kernel/trace/trace.c +9 -20
@@ -3376,37 +3376,30 @@ static const struct file_operations show_traces_fops = { .llseek = seq_lseek, }; -/* -* The tracer itself will not take this lock, but still we want -* to provide a consistent cpumask to user-space: -*/ -static DEFINE_MUTEX (tracing_cpumask_update_lock); - -/* -* Temporary storage for the character representation of the -* CPU bitmask (and one more byte for the newline): -*/ -static char mask_str[NR_CPUS +1 ]; -static ssize_t tracing_cpumask_read (struct file *filp,char __user *ubuf,size_t count,loff_t *ppos) {struct trace_array *tr =file_inode (filp)->i_private; +char *mask_str;int len; -mutex_lock (&tracing_cpumask_update_lock); + len =snprintf (NULL ,0 ,"%*pb\n" , +cpumask_pr_args (tr->tracing_cpumask)) +1 ; + mask_str =kmalloc (len,GFP_KERNEL ); +if (!mask_str) +return -ENOMEM ; - len =snprintf (mask_str, count,"%*pb\n" , + len =snprintf (mask_str, len,"%*pb\n" ,cpumask_pr_args (tr->tracing_cpumask));if (len >= count) { count = -EINVAL ; goto out_err; } - count =simple_read_from_buffer (ubuf, count, ppos, mask_str,NR_CPUS +1 ); + count =simple_read_from_buffer (ubuf, count, ppos, mask_str, len); out_err: -mutex_unlock (&tracing_cpumask_update_lock); +kfree (mask_str);return count; }
@@ -3426,8 +3419,6 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,if (err) goto err_unlock; -mutex_lock (&tracing_cpumask_update_lock); -local_irq_disable ();arch_spin_lock (&tr->max_lock);for_each_tracing_cpu (cpu) {
@@ -3450,8 +3441,6 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,local_irq_enable ();cpumask_copy (tr->tracing_cpumask, tracing_cpumask_new); - -mutex_unlock (&tracing_cpumask_update_lock);free_cpumask_var (tracing_cpumask_new);return count;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] USB: uas and storage: Add US_FL_BROKEN_FUA for another JMicron JMS567 ID
In reply to Sasha LevinFrom: David Kozub <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 62354454625741f0569c2cbe45b2d192f8fd258e ]
There is another JMS567-based USB3 UAS enclosure (152d:0578) that fails with the following error:
[sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE [sda] tag#0 Sense Key : Illegal Request [current]
[sda] tag#0 Add. Sense: Invalid field in cdb
The issue occurs both with UAS (occasionally) and mass storage (immediately after mounting a FS on a disk in the enclosure).
Enabling US_FL_BROKEN_FUA quirk solves this issue.
This patch adds an UNUSUAL_DEV with US_FL_BROKEN_FUA for the enclosure for both UAS and mass storage.
--- drivers/usb/storage/unusual_devs.h | 7 +++++++ drivers/usb/storage/unusual_uas.h | 7 +++++++ 2 files changed, 14 insertions(+)
drivers/usb/storage/unusual_devs.h +7 -0
@@ -2138,6 +2138,13 @@ UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NO_REPORT_OPCODES), +/* Reported by David Kozub <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x0578 ,0x0000 ,0x9999 , +"JMicron" , +"JMS567" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , + US_FL_BROKEN_FUA), +/* * Patch by Constantin Baranov <[email protected]> * Report by Andreas Koenecke.
drivers/usb/storage/unusual_uas.h +7 -0
@@ -141,6 +141,13 @@ UNUSUAL_DEV(0x152d, 0x0567, 0x0000, 0x9999, USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_BROKEN_FUA | US_FL_NO_REPORT_OPCODES), +/* Reported-by: David Kozub <[email protected]> */ +UNUSUAL_DEV (0x152d ,0x0578 ,0x0000 ,0x9999 , +"JMicron" , +"JMS567" , +USB_SC_DEVICE ,USB_PR_DEVICE ,NULL , +US_FL_BROKEN_FUA ), +/* Reported-by: Hans de Goede <[email protected]> */ UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999, "VIA",
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] autofs: fix careless error in recent commit
In reply to Sasha LevinFrom: NeilBrown <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 302ec300ef8a545a7fc7f667e5fd743b091c2eeb ]
Commit ecc0c469f277 ("autofs: don't fail mount for transient error") was meant to replace an 'if' with a 'switch', but instead added the 'switch' leaving the case in place.
--- fs/autofs4/waitq.c | 1 - 1 file changed, 1 deletion(-)
fs/autofs4/waitq.c +0 -1
@@ -174,7 +174,6 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,mutex_unlock (&sbi->wq_mutex); -if (autofs4_write (sbi, pipe, &pkt, pktsz))switch (ret =autofs4_write (sbi, pipe, &pkt, pktsz)) {case 0 :break ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] USB: core: prevent malicious bNumInterfaces overflow
In reply to Sasha LevinFrom: Alan Stern <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 48a4ff1c7bb5a32d2e396b03132d20d552c0eca7 ]
A malicious USB device with crafted descriptors can cause the kernel to access unallocated memory by setting the bNumInterfaces value too high in a configuration descriptor. Although the value is adjusted during parsing, this adjustment is skipped in one of the error return paths.
This patch prevents the problem by setting bNumInterfaces to 0 initially. The existing code already sets it to the proper value after parsing is complete.
--- drivers/usb/core/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/core/config.c +3 -1
@@ -460,6 +460,9 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx,unsigned iad_num =0 ;memcpy (&config->desc, buffer,USB_DT_CONFIG_SIZE ); + nintf = nintf_orig = config->desc.bNumInterfaces; + config->desc.bNumInterfaces =0 ;// Adjusted later +if (config->desc.bDescriptorType !=USB_DT_CONFIG || config->desc.bLength <USB_DT_CONFIG_SIZE || config->desc.bLength > size) {
@@ -473,7 +476,6 @@ static int usb_parse_configuration(struct usb_device *dev, int cfgidx, buffer += config->desc.bLength; size -= config->desc.bLength; - nintf = nintf_orig = config->desc.bNumInterfaces;if (nintf >USB_MAXINTERFACES ) { dev_warn(ddev, "config %d has too many interfaces: %d, " "using maximum allowed: %d\n",
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] usbip: fix stub_send_ret_submit() vulnerability to null transfer_buffer
In reply to Sasha LevinFrom: Shuah Khan <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit be6123df1ea8f01ee2f896a16c2b7be3e4557a5a ]
stub_send_ret_submit() handles urb with a potential null transfer_buffer, when it replays a packet with potential malicious data that could contain a null buffer. Add a check for the condition when actual_length > 0 and transfer_buffer is null.
--- drivers/usb/usbip/stub_tx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/usbip/stub_tx.c +7 -0
@@ -178,6 +178,13 @@ static int stub_send_ret_submit(struct stub_device *sdev)memset (&pdu_header,0 ,sizeof (pdu_header));memset (&msg,0 ,sizeof (msg)); +if (urb->actual_length >0 && !urb->transfer_buffer) { +dev_err (&sdev->udev->dev, +"urb: actual_length %d transfer_buffer null\n" , + urb->actual_length); +return -1 ; + } +if (usb_pipetype (urb->pipe) ==PIPE_ISOCHRONOUS ) iovnum =2 + urb->number_of_packets;else
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] Bluetooth: btusb: driver to enable the usb-wakeup feature
In reply to Sasha LevinFrom: Sukumar Ghorai <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a0085f2510e8976614ad8f766b209448b385492f ]
BT-Controller connected as platform non-root-hub device and usb-driver initialize such device with wakeup disabled, Ref. usb_new_device().
At present wakeup-capability get enabled by hid-input device from usb function driver(e.g. BT HID device) at runtime. Again some functional driver does not set usb-wakeup capability(e.g LE HID device implement as HID-over-GATT), and can't wakeup the host on USB.
Most of the device operation (such as mass storage) initiated from host (except HID) and USB wakeup aligned with host resume procedure. For BT device, usb-wakeup capability need to enable form btusc driver as a generic solution for multiple profile use case and required for USB remote wakeup (in-bus wakeup) while host is suspended. Also usb-wakeup feature need to enable/disable with HCI interface up and down.
--- drivers/bluetooth/btusb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/bluetooth/btusb.c +5 -0
@@ -945,6 +945,10 @@ static int btusb_open(struct hci_dev *hdev)return err; data->intf->needs_remote_wakeup =1 ; +/* device specific wakeup source enabled and required for USB +* remote wakeup while host is suspended +*/ +device_wakeup_enable (&data->udev->dev);if (test_and_set_bit (HCI_RUNNING , &hdev->flags)) goto done;
@@ -1008,6 +1012,7 @@ static int btusb_close(struct hci_dev *hdev) goto failed; data->intf->needs_remote_wakeup =0 ; +device_wakeup_disable (&data->udev->dev);usb_autopm_put_interface (data->intf); failed:
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ext4: fix crash when a directory's i_size is too small
In reply to Sasha LevinFrom: Chandan Rajendra <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9d5afec6b8bd46d6ed821aa1579634437f58ef1f ]
On a ppc64 machine, when mounting a fuzzed ext2 image (generated by fsfuzzer) the following call trace is seen,
VFS: brelse: Trying to free free buffer
WARNING: CPU: 1 PID: 6913 at /root/repos/linux/fs/buffer.c:1165 .__brelse.part.6+0x24/0x40 .__brelse.part.6+0x20/0x40 (unreliable) .ext4_find_entry+0x384/0x4f0 .ext4_lookup+0x84/0x250 .lookup_slow+0xdc/0x230 .walk_component+0x268/0x400 .path_lookupat+0xec/0x2d0 .filename_lookup+0x9c/0x1d0 .vfs_statx+0x98/0x140 .SyS_newfstatat+0x48/0x80 system_call+0x58/0x6c
This happens because the directory that ext4_find_entry() looks up has inode->i_size that is less than the block size of the filesystem. This causes 'nblocks' to have a value of zero. ext4_bread_batch() ends up not reading any of the directory file's blocks. This renders the entries in bh_use[] array to continue to have garbage data. buffer_uptodate() on bh_use[0] can then return a zero value upon which brelse() function is invoked.
This commit fixes the bug by returning -ENOENT when the directory file has no associated blocks.
--- fs/ext4/namei.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/namei.c +4 -0
@@ -1412,6 +1412,10 @@ static struct buffer_head * ext4_find_entry (struct inode *dir, "falling back\n")); } nblocks = dir->i_size >>EXT4_BLOCK_SIZE_BITS (sb); +if (!nblocks) { + ret =NULL ; + goto cleanup_and_exit; + } start =EXT4_I (dir)->i_dir_start_lookup;if (start >= nblocks) start =0 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] xhci: Don't add a virt_dev to the devs array before it's fully allocated
In reply to Sasha LevinFrom: Mathias Nyman <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5d9b70f7d52eb14bb37861c663bae44de9521c35 ]
Avoid null pointer dereference if some function is walking through the devs array accessing members of a new virt_dev that is mid allocation.
Add the virt_dev to xhci->devs[i] _after_ the virt_device and all its members are properly allocated.
issue found by KASAN: null-ptr-deref in xhci_find_slot_id_by_port
"Quick analysis suggests that xhci_alloc_virt_device() is not mutex protected. If so, there is a time frame where xhci->devs[slot_id] is set but not fully initialized. Specifically, xhci->devs[i]->udev can be NULL."
--- drivers/usb/host/xhci-mem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-mem.c +11 -4
@@ -1017,10 +1017,9 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id,return 0 ; } - xhci->devs[slot_id] =kzalloc (sizeof (*xhci->devs[slot_id]), flags); -if (!xhci->devs[slot_id]) + dev =kzalloc (sizeof (*dev), flags); +if (!dev)return 0 ; - dev = xhci->devs[slot_id];/* Allocate the (output) device context that will be used in the HC. */ dev->out_ctx =xhci_alloc_container_ctx (xhci,XHCI_CTX_TYPE_DEVICE , flags);
@@ -1068,9 +1067,17 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, &xhci->dcbaa->dev_context_ptrs[slot_id], le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); + xhci->devs[slot_id] = dev; +return 1 ; fail: -xhci_free_virt_device (xhci, slot_id); + +if (dev->in_ctx) +xhci_free_container_ctx (xhci, dev->in_ctx); +if (dev->out_ctx) +xhci_free_container_ctx (xhci, dev->out_ctx); +kfree (dev); +return 0 ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] dmaengine: dmatest: move callback wait queue to thread context
In reply to Sasha LevinFrom: Adam Wallis <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6f6a23a213be51728502b88741ba6a10cda2441d ]
Commit adfa543e7314 ("dmatest: don't use set_freezable_with_signal()") introduced a bug (that is in fact documented by the patch commit text) that leaves behind a dangling pointer. Since the done_wait structure is allocated on the stack, future invocations to the DMATEST can produce undesirable results (e.g., corrupted spinlocks).
Commit a9df21e34b42 ("dmaengine: dmatest: warn user when dma test times out") attempted to WARN the user that the stack was likely corrupted but did not fix the actual issue.
This patch fixes the issue by pushing the wait queue and callback structs into the the thread structure. If a failure occurs due to time, dmaengine_terminate_all will force the callback to safely call wake_up_all() without possibility of using a freed pointer.
--- drivers/dma/dmatest.c | 55 +++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 24 deletions(-)
drivers/dma/dmatest.c +31 -24
@@ -148,6 +148,12 @@ MODULE_PARM_DESC(run, "Run the test (default: false)");#define PATTERN_OVERWRITE 0x20#define PATTERN_COUNT_MASK 0x1f +/* poor man's completion - we want to use wait_event_freezable() on it */ +struct dmatest_done { +bool done; +wait_queue_head_t *wait; +}; +struct dmatest_thread {struct list_head node;struct dmatest_info *info;
@@ -156,6 +162,8 @@ struct dmatest_thread {u8 **srcs;u8 **dsts;enum dma_transaction_type type; +wait_queue_head_t done_wait; +struct dmatest_done test_done;bool done; };
@@ -316,18 +324,25 @@ static unsigned int dmatest_verify(u8 **bufs, unsigned int start,return error_count; } -/* poor man's completion - we want to use wait_event_freezable() on it */ -struct dmatest_done { -bool done; -wait_queue_head_t *wait; -};static void dmatest_callback (void *arg) {struct dmatest_done *done = arg; - - done->done = true; -wake_up_all (done->wait); +struct dmatest_thread *thread = + container_of(arg, struct dmatest_thread, done_wait); +if (!thread->done) { + done->done = true; +wake_up_all (done->wait); + }else { +/* +* If thread->done, it means that this callback occurred +* after the parent thread has cleaned up. This can +* happen in the case that driver doesn't implement +* the terminate_all() functionality and a dma operation +* did not occur within the timeout period +*/ +WARN (1 ,"dmatest: Kernel memory may be corrupted!!\n" ); + } }static unsigned int min_odd (unsigned int x,unsigned int y)
@@ -398,9 +413,8 @@ static unsigned long long dmatest_KBs(s64 runtime, unsigned long long len)*/ static int dmatest_func (void *data) { -DECLARE_WAIT_QUEUE_HEAD_ONSTACK (done_wait);struct dmatest_thread *thread = data; -struct dmatest_done done = { .wait = &done_wait }; +struct dmatest_done *done = &thread->test_done;struct dmatest_info *info;struct dmatest_params *params;struct dma_chan *chan;
@@ -605,9 +619,9 @@ static int dmatest_func(void *data)continue ; } - done.done = false; + done->done = false; tx->callback = dmatest_callback; - tx->callback_param = &done; + tx->callback_param = done; cookie = tx->tx_submit (tx);if (dma_submit_error (cookie)) {
@@ -620,21 +634,12 @@ static int dmatest_func(void *data) }dma_async_issue_pending (chan); -wait_event_freezable_timeout (done_wait, done.done, +wait_event_freezable_timeout (thread->done_wait, done->done,msecs_to_jiffies (params->timeout)); status =dma_async_is_tx_complete (chan, cookie,NULL ,NULL ); -if (!done.done) { -/* -* We're leaving the timed out dma operation with -* dangling pointer to done_wait. To make this -* correct, we'll need to allocate wait_done for -* each test iteration and perform "who's gonna -* free it this time?" dancing. For now, just -* leave it dangling. -*/ -WARN (1 ,"dmatest: Kernel stack may be corrupted!!\n" ); +if (!done->done) {dmaengine_unmap_put (um);result ("test timed out" , total_tests, src_off, dst_off, len,0 );
@@ -708,7 +713,7 @@ static int dmatest_func(void *data) dmatest_KBs(runtime, total_len), ret);/* terminate all transfers on specified channels */ -if (ret) +if (ret || failed_tests)dmaengine_terminate_all (chan); thread->done = true;
@@ -766,6 +771,8 @@ static int dmatest_add_threads(struct dmatest_info *info, thread->info = info; thread->chan = dtc->chan; thread->type = type; + thread->test_done.wait = &thread->done_wait; +init_waitqueue_head (&thread->done_wait);smp_wmb (); thread->task =kthread_create (dmatest_func, thread,"%s-%s%u" ,dma_chan_name (chan), op, i);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ext4: fix fdatasync(2) after fallocate(2) operation
In reply to Sasha LevinFrom: Eryu Guan <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c894aa97577e47d3066b27b32499ecf899bfa8b0 ]
Currently, fallocate(2) with KEEP_SIZE followed by a fdatasync(2) then crash, we'll see wrong allocated block number (stat -c %b), the blocks allocated beyond EOF are all lost. fstests generic/468 exposes this bug.
Commit 67a7d5f561f4 ("ext4: fix fdatasync(2) after extent manipulation operations") fixed all the other extent manipulation operation paths such as hole punch, zero range, collapse range etc., but forgot the fallocate case.
So similarly, fix it by recording the correct journal tid in ext4 inode in fallocate(2) path, so that ext4_sync_file() will wait for the right tid to be committed on fdatasync(2).
This addresses the test failure in xfstests test generic/468.
--- fs/ext4/extents.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/extents.c +1 -0
@@ -4723,6 +4723,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset, EXT4_INODE_EOFBLOCKS); }ext4_mark_inode_dirty (handle, inode); +ext4_update_inode_fsync_trans (handle, inode,1 ); ret2 =ext4_journal_stop (handle);if (ret2)break ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] mac80211: Fix addition of mesh configuration element
In reply to Sasha LevinFrom: Ilan peer <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 57629915d568c522ac1422df7bba4bee5b5c7a7c ]
The code was setting the capabilities byte to zero, after it was already properly set previously. Fix it.
The bug was found while debugging hwsim mesh tests failures that happened since the commit mentioned below.
--- net/mac80211/mesh.c | 2 -- 1 file changed, 2 deletions(-)
net/mac80211/mesh.c +0 -2
@@ -289,8 +289,6 @@ int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,/* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */ *pos |= ifmsh->ps_peers_deep_sleep ?IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL :0x00 ; - *pos++ =0x00 ; -return 0 ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] usb: phy: isp1301: Add OF device ID table
In reply to Sasha LevinFrom: Javier Martinez Canillas <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit fd567653bdb908009b650f079bfd4b63169e2ac4 ]
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>.
But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF.
--- drivers/usb/phy/phy-isp1301.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/usb/phy/phy-isp1301.c +7 -0
@@ -32,6 +32,12 @@ static const struct i2c_device_id isp1301_id[] = { { } }; +static const struct of_device_id isp1301_of_match[] = { + {.compatible ="nxp,isp1301" }, + { }, +}; +MODULE_DEVICE_TABLE (of, isp1301_of_match); +static struct i2c_client *isp1301_i2c_client;static int __isp1301_write (struct isp1301 *isp,u8 reg,u8 value,u8 clear)
@@ -129,6 +135,7 @@ static int isp1301_remove(struct i2c_client *client)static struct i2c_driver isp1301_driver = { .driver = { .name =DRV_NAME , + .of_match_table =of_match_ptr (isp1301_of_match), }, .probe = isp1301_probe, .remove = isp1301_remove,
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] md-cluster: free md_cluster_info if node leave cluster
In reply to Sasha LevinFrom: Guoqing Jiang <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9c8043f337f14d1743006dfc59c03e80a42e3884 ]
To avoid memory leak, we need to free the cinfo which is allocated when node join cluster.
--- drivers/md/md-cluster.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/md-cluster.c +1 -0
@@ -738,6 +738,7 @@ static int leave(struct mddev *mddev)lockres_free (cinfo->sb_lock);lockres_free (cinfo->bitmap_lockres);dlm_release_lockspace (cinfo->lockspace,2 ); +kfree (cinfo);return 0 ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: initialize msg.msg_flags in recvfrom
In reply to Sasha LevinFrom: Alexander Potapenko <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9f138fa609c47403374a862a08a41394be53d461 ]
KMSAN reports a use of uninitialized memory in put_cmsg() because msg.msg_flags in recvfrom haven't been initialized properly. The flag values don't affect the result on this path, but it's still a good idea to initialize them explicitly.
--- net/socket.c | 1 + 1 file changed, 1 insertion(+)
net/socket.c +1 -0
@@ -1706,6 +1706,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,/* We assume all kernel code knows the size of sockaddr_storage */ msg.msg_namelen =0 ; msg.msg_iocb =NULL ; + msg.msg_flags =0 ;if (sock->file->f_flags &O_NONBLOCK ) flags |=MSG_DONTWAIT ; err =sock_recvmsg (sock, &msg,iov_iter_count (&msg.msg_iter), flags);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] Input: i8042 - add TUXEDO BU1406 (N24_25BU) to the nomux list
In reply to Sasha LevinFrom: Dmitry Torokhov <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit a4c2a13129f7c5bcf81704c06851601593303fd5 ]
TUXEDO BU1406 does not implement active multiplexing mode properly, and takes around 550 ms in i8042_set_mux_mode(). Given that the device does not have external AUX port, there is no downside in disabling the MUX mode.
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -514,6 +514,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"), }, }, + { + /* TUXEDO BU1406 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Notebook"), + DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"), + }, + }, { } };
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: bcmgenet: correct the RBUF_OVFL_CNT and RBUF_ERR_CNT MIB values
In reply to Sasha LevinFrom: Doug Berger <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ffff71328a3c321f7c14cc1edd33577717037744 ]
The location of the RBUF overflow and error counters has moved between different version of the GENET MAC. This commit corrects the driver to read from the correct locations depending on the version of the GENET MAC.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 60 +++++++++++++++++++++++--- drivers/net/ethernet/broadcom/genet/bcmgenet.h | 10 +++-- 2 files changed, 60 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +53 -7
@@ -1,7 +1,7 @@/* * Broadcom GENET (Gigabit Ethernet) controller driver * -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -631,8 +631,9 @@ static const struct bcmgenet_stats bcmgenet_gstrings_stats[] = {STAT_GENET_RUNT ("rx_runt_bytes" , mib.rx_runt_bytes),/* Misc UniMAC counters */ STAT_GENET_MISC ("rbuf_ovflow_cnt" , mib.rbuf_ovflow_cnt, -UMAC_RBUF_OVFL_CNT ), -STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt,UMAC_RBUF_ERR_CNT ), +UMAC_RBUF_OVFL_CNT_V1 ), +STAT_GENET_MISC ("rbuf_err_cnt" , mib.rbuf_err_cnt, +UMAC_RBUF_ERR_CNT_V1 ),STAT_GENET_MISC ("mdf_err_cnt" , mib.mdf_err_cnt,UMAC_MDF_ERR_CNT ),STAT_GENET_SOFT_MIB ("alloc_rx_buff_failed" , mib.alloc_rx_buff_failed), STAT_GENET_SOFT_MIB("rx_dma_failed", mib.rx_dma_failed),
@@ -675,6 +676,45 @@ static void bcmgenet_get_strings(struct net_device *dev, u32 stringset, } } +static u32 bcmgenet_update_stat_misc (struct bcmgenet_priv *priv,u16 offset) +{ +u16 new_offset; +u32 val; + +switch (offset) { +case UMAC_RBUF_OVFL_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_OVFL_CNT_V2 ; +else + new_offset =RBUF_OVFL_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +case UMAC_RBUF_ERR_CNT_V1 : +if (GENET_IS_V2 (priv)) + new_offset =RBUF_ERR_CNT_V2 ; +else + new_offset =RBUF_ERR_CNT_V3PLUS ; + + val =bcmgenet_rbuf_readl (priv, new_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_rbuf_writel (priv,0 , new_offset); +break ; +default : + val =bcmgenet_umac_readl (priv, offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , offset); +break ; + } + +return val; +} +static void bcmgenet_update_mib_counters (struct bcmgenet_priv *priv) {int i, j =0 ;
@@ -699,10 +739,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv) UMAC_MIB_START + j + offset);break ;case BCMGENET_STAT_MISC : - val =bcmgenet_umac_readl (priv, s->reg_offset); -/* clear if overflowed */ -if (val == ~0 ) -bcmgenet_umac_writel (priv,0 , s->reg_offset); +if (GENET_IS_V1 (priv)) { + val =bcmgenet_umac_readl (priv, s->reg_offset); +/* clear if overflowed */ +if (val == ~0 ) +bcmgenet_umac_writel (priv,0 , + s->reg_offset); + }else { + val =bcmgenet_update_stat_misc (priv, + s->reg_offset); + }break ; }
drivers/net/ethernet/broadcom/genet/bcmgenet.h +7 -3
@@ -1,5 +1,5 @@/* -* Copyright (c) 2014 Broadcom Corporation +* Copyright (c) 2014-2017 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as
@@ -214,7 +214,9 @@ struct bcmgenet_mib_counters {#define MDIO_REG_SHIFT 16#define MDIO_REG_MASK 0x1F -#define UMAC_RBUF_OVFL_CNT 0x61C +#define UMAC_RBUF_OVFL_CNT_V1 0x61C +#define RBUF_OVFL_CNT_V2 0x80 +#define RBUF_OVFL_CNT_V3PLUS 0x94#define UMAC_MPD_CTRL 0x620#define MPD_EN (1 << 0)
@@ -224,7 +226,9 @@ struct bcmgenet_mib_counters {#define UMAC_MPD_PW_MS 0x624#define UMAC_MPD_PW_LS 0x628 -#define UMAC_RBUF_ERR_CNT 0x634 +#define UMAC_RBUF_ERR_CNT_V1 0x634 +#define RBUF_ERR_CNT_V2 0x84 +#define RBUF_ERR_CNT_V3PLUS 0x98#define UMAC_MDF_ERR_CNT 0x638#define UMAC_MDF_CTRL 0x650#define UMAC_MDF_ADDR 0x654
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: wimax/i2400m: fix NULL-deref at probe
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6e526fdff7be4f13b24f929a04c0e9ae6761291e ]
Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer or accessing memory beyond the endpoint array should a malicious device lack the expected endpoints.
The endpoints are specifically dereferenced in the i2400m_bootrom_init path during probe (e.g. in i2400mu_tx_bulk_out).
and reset backends")
Cc: Inaky Perez-Gonzalez <[email protected]>
--- drivers/net/wimax/i2400m/usb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wimax/i2400m/usb.c +3 -0
@@ -467,6 +467,9 @@ int i2400mu_probe(struct usb_interface *iface,struct i2400mu *i2400mu;struct usb_device *usb_dev =interface_to_usbdev (iface); +if (iface->cur_altsetting->desc.bNumEndpoints <4 ) +return -ENODEV ; +if (usb_dev->speed !=USB_SPEED_HIGH )dev_err (dev,"device not connected as high speed\n" );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: bcmgenet: correct MIB access of UniMAC RUNT counters
In reply to Sasha LevinFrom: Doug Berger <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1ad3d225e5a40ca6c586989b4baaca710544c15a ]
The gap between the Tx status counters and the Rx RUNT counters is now being added to allow correct reporting of the registers.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +7 -4
@@ -730,13 +730,16 @@ static void bcmgenet_update_mib_counters(struct bcmgenet_priv *priv)case BCMGENET_STAT_NETDEV :case BCMGENET_STAT_SOFT :continue ; -case BCMGENET_STAT_MIB_RX : -case BCMGENET_STAT_MIB_TX :case BCMGENET_STAT_RUNT : -if (s->type !=BCMGENET_STAT_MIB_RX ) - offset =BCMGENET_STAT_OFFSET ; + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_TX : + offset +=BCMGENET_STAT_OFFSET ; +/* fall through */ +case BCMGENET_STAT_MIB_RX : val =bcmgenet_umac_readl (priv,UMAC_MIB_START + j + offset); + offset =0 ;/* Reset Offset */ break ;case BCMGENET_STAT_MISC :if (GENET_IS_V1 (priv)) {
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: bcmgenet: reserved phy revisions must be checked first
In reply to Sasha LevinFrom: Doug Berger <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit eca4bad73409aedc6ff22f823c18b67a4f08c851 ]
The reserved gphy_rev value of 0x01ff must be tested before the old or new scheme for GPHY major versioning are tested, otherwise it will be treated as 0xff00 according to the old scheme.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +6 -6
@@ -3067,6 +3067,12 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)*/ gphy_rev = reg &0xffff ; +/* This is reserved so should require special treatment */ +if (gphy_rev ==0 || gphy_rev ==0x01ff ) { +pr_warn ("Invalid GPHY revision detected: 0x%04x\n" , gphy_rev); +return ; + } +/* This is the good old scheme, just GPHY major, no minor nor patch */ if ((gphy_rev &0xf0 ) !=0 ) priv->gphy_rev = gphy_rev <<8 ;
@@ -3075,12 +3081,6 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)else if ((gphy_rev &0xff00 ) !=0 ) priv->gphy_rev = gphy_rev; -/* This is reserved so should require special treatment */ -else if (gphy_rev ==0 || gphy_rev ==0x01ff ) { -pr_warn ("Invalid GPHY revision detected: 0x%04x\n" , gphy_rev); -return ; - } -#ifdef CONFIG_PHYS_ADDR_T_64BIT if (!(params->flags &GENET_HAS_40BITS ))pr_warn ("GENET does not support 40-bits PA\n" );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] dmaengine: Fix array index out of bounds warning in __get_unmap_pool()
In reply to Sasha LevinFrom: Matthias Kaehlcke <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 23f963e91fd81f44f6b316b1c24db563354c6be8 ]
This fixes the following warning when building with clang and CONFIG_DMA_ENGINE_RAID=n :
drivers/dma/dmaengine.c:1102:11: error: array index 2 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds]
return &unmap_pool[2];
^ ~drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here
static struct dmaengine_unmap_pool unmap_pool[] = {
^drivers/dma/dmaengine.c:1104:11: error: array index 3 is past the end of the array (which contains 1 element) [-Werror,-Warray-bounds]
return &unmap_pool[3];
^ ~drivers/dma/dmaengine.c:1083:1: note: array 'unmap_pool' declared here static struct dmaengine_unmap_pool unmap_pool[] = {
--- drivers/dma/dmaengine.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/dma/dmaengine.c +2 -0
@@ -1002,12 +1002,14 @@ static struct dmaengine_unmap_pool *__get_unmap_pool(int nr)switch (order) { case 0 ... 1:return &unmap_pool[0 ]; +#if IS_ENABLED (CONFIG_DMA_ENGINE_RAID ) case 2 ... 4:return &unmap_pool[1 ]; case 5 ... 7:return &unmap_pool[2 ];case 8 :return &unmap_pool[3 ]; +#endif default :BUG ();return NULL ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: Resend IGMP memberships upon peer notification.
In reply to Sasha LevinFrom: Vlad Yasevich <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 37c343b4f4e70e9dc328ab04903c0ec8d154c1a4 ]
When we notify peers of potential changes, it's also good to update IGMP memberships. For example, during VM migration, updating IGMP memberships will redirect existing multicast streams to the VM at the new location.
--- net/core/dev.c | 1 + 1 file changed, 1 insertion(+)
net/core/dev.c +1 -0
@@ -1268,6 +1268,7 @@ void netdev_notify_peers(struct net_device *dev) {rtnl_lock ();call_netdevice_notifiers (NETDEV_NOTIFY_PEERS , dev); +call_netdevice_notifiers (NETDEV_RESEND_IGMP , dev);rtnl_unlock (); }EXPORT_SYMBOL (netdev_notify_peers);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: bcmgenet: Power up the internal PHY before probing the MII
In reply to Sasha LevinFrom: Doug Berger <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6be371b053dc86f11465cc1abce2e99bda0a0574 ]
When using the internal PHY it must be powered up when the MII is probed or the PHY will not be detected. Since the PHY is powered up at reset this has not been a problem. However, when the kernel is restarted with kexec the PHY will likely be powered down when the kernel starts so it will not be detected and the Ethernet link will not be established.
This commit explicitly powers up the internal PHY when the GENET driver is probed to correct this behavior.
--- drivers/net/ethernet/broadcom/genet/bcmgenet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -0
@@ -3122,6 +3122,7 @@ static int bcmgenet_probe(struct platform_device *pdev)const void *macaddr;struct resource *r;int err = -EIO ; +const char *phy_mode_str;/* Up to GENET_MAX_MQ_CNT + 1 TX queues and RX queues */ dev = alloc_etherdev_mqs(sizeof(*priv), GENET_MAX_MQ_CNT + 1,
@@ -3224,6 +3225,13 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->clk_eee =NULL ; } +/* If this is an internal GPHY, power it on now, before UniMAC is +* brought out of reset as absolutely no UniMAC activity is allowed +*/ +if (dn && !of_property_read_string (dn,"phy-mode" , &phy_mode_str) && + !strcasecmp (phy_mode_str,"internal" )) +bcmgenet_power_up (priv,GENET_POWER_PASSIVE ); + err =reset_umac (priv);if (err) goto err_clk_disable;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] NFSD: fix nfsd_minorversion(.., NFSD_AVAIL)
In reply to Sasha LevinFrom: NeilBrown <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 928c6fb3a9bfd6c5b287aa3465226add551c13c0 ]
Current code will return 1 if the version is supported, and -1 if it isn't.
This is confusing and inconsistent with the one place where this is used.
So change to return 1 if it is supported, and zero if not. i.e. an error is never returned.
--- fs/nfsd/nfssvc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +2 -1
@@ -151,7 +151,8 @@ int nfsd_vers(int vers, enum vers_op change)int nfsd_minorversion (u32 minorversion,enum vers_op change) { -if (minorversion >NFSD_SUPPORTED_MINOR_VERSION ) +if (minorversion >NFSD_SUPPORTED_MINOR_VERSION && + change !=NFSD_AVAIL )return -1 ;switch (change) {case NFSD_SET :
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] openrisc: fix issue handling 8 byte get_user calls
In reply to Sasha LevinFrom: Stafford Horne <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 154e67cd8e8f964809d0e75e44bb121b169c75b3 ]
Was getting the following error with allmodconfig:
ERROR: "__get_user_bad" [lib/test_user_copy.ko] undefined!
This was simply a missing break statement, causing an unwanted fall through.
--- arch/openrisc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/openrisc/include/asm/uaccess.h +1 -1
@@ -215,7 +215,7 @@ do { \case 1 :__get_user_asm (x, ptr, retval,"l.lbz" );break ; \case 2 :__get_user_asm (x, ptr, retval,"l.lhz" );break ; \case 4 :__get_user_asm (x, ptr, retval,"l.lwz" );break ; \ -case 8 :__get_user_asm2 (x, ptr, retval); \ +case 8 :__get_user_asm2 (x, ptr, retval);break ; \default : (x) =__get_user_bad (); \ } \ }while (0 )
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] NFSD: fix nfsd_reset_versions for NFSv4.
In reply to Sasha LevinFrom: NeilBrown <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 800a938f0bf9130c8256116649c0cc5806bfb2fd ]
If you write "-2 -3 -4" to the "versions" file, it will notice that no versions are enabled, and nfsd_reset_versions() is called.
This enables all major versions, not no minor versions. So we lose the invariant that NFSv4 is only advertised when at least one minor is enabled.
Fix the code to explicitly enable minor versions for v4, change it to use nfsd_vers() to test and set, and simplify the code.
--- fs/nfsd/nfssvc.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
fs/nfsd/nfssvc.c +12 -15
@@ -330,23 +330,20 @@ static void nfsd_last_thread(struct svc_serv *serv, struct net *net)void nfsd_reset_versions (void ) { -int found_one =0 ;int i; -for (i =NFSD_MINVERS ; i <NFSD_NRVERS ; i++) { -if (nfsd_program.pg_vers[i]) - found_one =1 ; - } - -if (!found_one) { -for (i =NFSD_MINVERS ; i <NFSD_NRVERS ; i++) - nfsd_program.pg_vers[i] = nfsd_version[i]; -#if defined(CONFIG_NFSD_V2_ACL ) || defined(CONFIG_NFSD_V3_ACL ) -for (i =NFSD_ACL_MINVERS ; i <NFSD_ACL_NRVERS ; i++) - nfsd_acl_program.pg_vers[i] = - nfsd_acl_version[i]; -#endif - } +for (i =0 ; i <NFSD_NRVERS ; i++) +if (nfsd_vers (i,NFSD_TEST )) +return ; + +for (i =0 ; i <NFSD_NRVERS ; i++) +if (i !=4 ) +nfsd_vers (i,NFSD_SET ); +else { +int minor =0 ; +while (nfsd_minorversion (minor,NFSD_SET ) >=0 ) + minor++; + } }/*
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] sched/deadline: Use deadline instead of period when calculating overflow
In reply to Sasha LevinFrom: "Steven Rostedt (VMware)" <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 2317d5f1c34913bac5971d93d69fb6c31bb74670 ]
I was testing Daniel's changes with his test case, and tweaked it a little. Instead of having the runtime equal to the deadline, I increased the deadline ten fold.
Daniel's test case had:
attr.sched_runtime = 2 * 1000 * 1000; /* 2 ms */ attr.sched_deadline = 2 * 1000 * 1000; /* 2 ms */ attr.sched_period = 2 * 1000 * 1000 * 1000; /* 2 s */
To make it more interesting, I changed it to:
attr.sched_runtime = 2 * 1000 * 1000; /* 2 ms */ attr.sched_deadline = 20 * 1000 * 1000; /* 20 ms */ attr.sched_period = 2 * 1000 * 1000 * 1000; /* 2 s */
The results were rather surprising. The behavior that Daniel's patch was fixing came back. The task started using much more than .1% of the CPU. More like 20%.
Looking into this I found that it was due to the dl_entity_overflow() constantly returning true. That's because it uses the relative period against relative runtime vs the absolute deadline against absolute runtime.
runtime / (deadline - t) > dl_runtime / dl_period
There's even a comment mentioning this, and saying that when relative deadline equals relative period, that the equation is the same as using deadline instead of period. That comment is backwards! What we really want is:
runtime / (deadline - t) > dl_runtime / dl_deadline
We care about if the runtime can make its deadline, not its period. And then we can say "when the deadline equals the period, the equation is the same as using dl_period instead of dl_deadline".
After correcting this, now when the task gets enqueued, it can throttle correctly, and Daniel's fix to the throttling of sleeping deadline tasks works even when the runtime and deadline are not the same.
--- kernel/sched/deadline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sched/deadline.c +4 -4
@@ -419,13 +419,13 @@ static void replenish_dl_entity(struct sched_dl_entity *dl_se,* * This function returns true if: * -* runtime / (deadline - t) > dl_runtime / dl_period , +* runtime / (deadline - t) > dl_runtime / dl_deadline , * * IOW we can't recycle current parameters. * -* Notice that the bandwidth check is done against the period. For +* Notice that the bandwidth check is done against the deadline. For * task with deadline equal to period this is the same of using -* dl_deadline instead of dl_period in the equation above. +* dl_period instead of dl_deadline in the equation above. */ static bool dl_entity_overflow (struct sched_dl_entity *dl_se,struct sched_dl_entity *pi_se,u64 t)
@@ -450,7 +450,7 @@ static bool dl_entity_overflow(struct sched_dl_entity *dl_se,* of anything below microseconds resolution is actually fiction * (but still we want to give the user that illusion >;). */ - left = (pi_se->dl_period >>DL_SCALE ) * (dl_se->runtime >>DL_SCALE ); + left = (pi_se->dl_deadline >>DL_SCALE ) * (dl_se->runtime >>DL_SCALE ); right = ((dl_se->deadline - t) >>DL_SCALE ) * (pi_se->dl_runtime >>DL_SCALE );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] scsi: hpsa: limit outstanding rescans
In reply to Sasha LevinFrom: Don Brace <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 87b9e6aa87d9411f1059aa245c0c79976bc557ac ]
Avoid rescan storms. No need to queue another if one is pending.
--- drivers/scsi/hpsa.c | 16 +++++++++++++++- drivers/scsi/hpsa.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/hpsa.c +15 -1
@@ -4158,7 +4158,7 @@ static void hpsa_scan_complete(struct ctlr_info *h)spin_lock_irqsave (&h->scan_lock, flags); h->scan_finished =1 ; -wake_up_all (&h->scan_wait_queue); +wake_up (&h->scan_wait_queue);spin_unlock_irqrestore (&h->scan_lock, flags); }
@@ -4176,11 +4176,23 @@ static void hpsa_scan_start(struct Scsi_Host *sh)if (unlikely (lockup_detected (h)))return hpsa_scan_complete (h); +/* +* If a scan is already waiting to run, no need to add another +*/ +spin_lock_irqsave (&h->scan_lock, flags); +if (h->scan_waiting) { +spin_unlock_irqrestore (&h->scan_lock, flags); +return ; + } + +spin_unlock_irqrestore (&h->scan_lock, flags); +/* wait until any scan already in progress is finished. */ while (1 ) {spin_lock_irqsave (&h->scan_lock, flags);if (h->scan_finished)break ; + h->scan_waiting =1 ;spin_unlock_irqrestore (&h->scan_lock, flags);wait_event (h->scan_wait_queue, h->scan_finished);/* Note: We don't need to worry about a race between this
@@ -4190,6 +4202,7 @@ static void hpsa_scan_start(struct Scsi_Host *sh)*/ } h->scan_finished =0 ;/* mark scan as in progress */ + h->scan_waiting =0 ;spin_unlock_irqrestore (&h->scan_lock, flags);if (unlikely (lockup_detected (h)))
@@ -6936,6 +6949,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto clean4;init_waitqueue_head (&h->scan_wait_queue); h->scan_finished =1 ;/* no scan currently in progress */ + h->scan_waiting =0 ;pci_set_drvdata (pdev, h); h->ndevices =0 ;
drivers/scsi/hpsa.h +1 -0
@@ -166,6 +166,7 @@ struct ctlr_info {dma_addr_t errinfo_pool_dhandle;unsigned long *cmd_pool_bits;int scan_finished; + u8 scan_waiting : 1;spinlock_t scan_lock;wait_queue_head_t scan_wait_queue;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Fix missing put_page()
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 29c8bbbd6e21daa0997d1c3ee886b897ee7ad652 ]
In afs_writepages_region(), inside the loop where we find dirty pages to deal with, one of the if-statements is missing a put_page().
--- fs/afs/write.c | 1 + 1 file changed, 1 insertion(+)
fs/afs/write.c +1 -0
@@ -503,6 +503,7 @@ static int afs_writepages_region(struct address_space *mapping,if (PageWriteback (page) || !PageDirty (page)) {unlock_page (page); +put_page (page);continue ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Populate group ID from vnode status
In reply to Sasha LevinFrom: Marc Dionne <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6186f0788b31f44affceeedc7b48eb10faea120d ]
The group was hard coded to GLOBAL_ROOT_GID; use the group ID that was received from the server.
--- fs/afs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/inode.c +1 -1
@@ -69,7 +69,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key)set_nlink (inode, vnode->status.nlink); inode->i_uid = vnode->status.owner; - inode->i_gid =GLOBAL_ROOT_GID ; + inode->i_gid = vnode->status.group; inode->i_size = vnode->status.size; inode->i_ctime.tv_sec = vnode->status.mtime_server; inode->i_ctime.tv_nsec =0 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Adjust mode bits processing
In reply to Sasha LevinFrom: Marc Dionne <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 627f46943ff90bcc32ddeb675d881c043c6fa2ae ]
Mode bits for an afs file should not be enforced in the usual way.
For files, the absence of user bits can restrict file access with respect to what is granted by the server.
These bits apply regardless of the owner or the current uid; the rest of the mode bits (group, other) are ignored.
--- fs/afs/security.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/afs/security.c +6 -1
@@ -340,17 +340,22 @@ int afs_permission(struct inode *inode, int mask) }else {if (!(access &AFS_ACE_LOOKUP )) goto permission_denied; +if ((mask &MAY_EXEC ) && !(inode->i_mode &S_IXUSR )) + goto permission_denied;if (mask & (MAY_EXEC |MAY_READ )) {if (!(access &AFS_ACE_READ )) goto permission_denied; +if (!(inode->i_mode &S_IRUSR )) + goto permission_denied; }else if (mask &MAY_WRITE ) {if (!(access &AFS_ACE_WRITE )) goto permission_denied; +if (!(inode->i_mode &S_IWUSR )) + goto permission_denied; } }key_put (key); - ret =generic_permission (inode, mask);_leave (" = %d" , ret);return ret;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Flush outstanding writes when an fd is closed
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 58fed94dfb17e89556b5705f20f90e5b2971b6a1 ]
Flush outstanding writes in afs when an fd is closed. This is what NFS and CIFS do.
--- fs/afs/file.c | 1 + fs/afs/internal.h | 1 + fs/afs/write.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+)
fs/afs/file.c +1 -0
@@ -29,6 +29,7 @@ static int afs_readpages(struct file *filp, struct address_space *mapping,const struct file_operations afs_file_operations = { .open = afs_open, + .flush = afs_flush, .release = afs_release, .llseek = generic_file_llseek, .read_iter = generic_file_read_iter,
fs/afs/internal.h +1 -0
@@ -749,6 +749,7 @@ extern int afs_writepages(struct address_space *, struct writeback_control *);extern void afs_pages_written_back (struct afs_vnode *,struct afs_call *);extern ssize_t afs_file_write (struct kiocb *,struct iov_iter *);extern int afs_writeback_all (struct afs_vnode *); +extern int afs_flush (struct file *,fl_owner_t );extern int afs_fsync (struct file *,loff_t ,loff_t ,int );
fs/afs/write.c +14 -0
@@ -741,6 +741,20 @@ int afs_fsync(struct file *file, loff_t start, loff_t end, int datasync) }/* +* Flush out all outstanding writes on a file opened for writing when it is +* closed. +*/ +int afs_flush (struct file *file,fl_owner_t id) +{ +_enter ("" ); + +if ((file->f_mode &FMODE_WRITE ) ==0 ) +return 0 ; + +return vfs_fsync (file,0 ); +} + +/* * notification that a previously read-only page is about to become writable * - if it returns an error, the caller will deliver a bus error signal */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Migrate vlocation fields to 64-bit
In reply to Sasha LevinFrom: Tina Ruchandani <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8a79790bf0b7da216627ffb85f52cfb4adbf1e4e ]
get_seconds() returns real wall-clock seconds. On 32-bit systems this value will overflow in year 2038 and beyond. This patch changes afs's vlocation record to use ktime_get_real_seconds() instead, for the fields time_of_death and update_at.
--- fs/afs/callback.c | 7 ++++--- fs/afs/internal.h | 7 ++++--- fs/afs/server.c | 6 +++--- fs/afs/vlocation.c | 16 +++++++++------- 4 files changed, 20 insertions(+), 16 deletions(-)
fs/afs/callback.c +4 -3
@@ -362,7 +362,7 @@ static void afs_callback_updater(struct work_struct *work) {struct afs_server *server;struct afs_vnode *vnode, *xvnode; -time_t now; +time64_t now;long timeout;int ret;
@@ -370,7 +370,7 @@ static void afs_callback_updater(struct work_struct *work)_enter ("" ); - now =get_seconds (); + now =ktime_get_real_seconds ();/* find the first vnode to update */ spin_lock (&server->cb_lock);
@@ -424,7 +424,8 @@ static void afs_callback_updater(struct work_struct *work)/* and then reschedule */ _debug ("reschedule" ); - vnode->update_at =get_seconds () + afs_vnode_update_timeout; + vnode->update_at =ktime_get_real_seconds () + + afs_vnode_update_timeout;spin_lock (&server->cb_lock);
fs/afs/internal.h +4 -3
@@ -11,6 +11,7 @@#include <linux/compiler.h> #include <linux/kernel.h> +#include <linux/ktime.h> #include <linux/fs.h> #include <linux/pagemap.h> #include <linux/skbuff.h>
@@ -247,7 +248,7 @@ struct afs_cache_vhash {*/ struct afs_vlocation {atomic_t usage; -time_t time_of_death;/* time at which put reduced usage to 0 */ +time64_t time_of_death;/* time at which put reduced usage to 0 */ struct list_head link;/* link in cell volume location list */ struct list_head grave;/* link in master graveyard list */ struct list_head update;/* link in master update list */
@@ -258,7 +259,7 @@ struct afs_vlocation {struct afs_cache_vlocation vldb;/* volume information DB record */ struct afs_volume *vols[3 ];/* volume access record pointer (index by type) */ wait_queue_head_t waitq;/* status change waitqueue */ -time_t update_at;/* time at which record should be updated */ +time64_t update_at;/* time at which record should be updated */ spinlock_t lock;/* access lock */ afs_vlocation_state_t state;/* volume location state */ unsigned short upd_rej_cnt;/* ENOMEDIUM count during update */
@@ -271,7 +272,7 @@ struct afs_vlocation {*/ struct afs_server {atomic_t usage; -time_t time_of_death;/* time at which put reduced usage to 0 */ +time64_t time_of_death;/* time at which put reduced usage to 0 */ struct in_addr addr;/* server address */ struct afs_cell *cell;/* cell in which server resides */ struct list_head link;/* link in cell's server list */
fs/afs/server.c +3 -3
@@ -237,7 +237,7 @@ void afs_put_server(struct afs_server *server)spin_lock (&afs_server_graveyard_lock);if (atomic_read (&server->usage) ==0 ) {list_move_tail (&server->grave, &afs_server_graveyard); - server->time_of_death =get_seconds (); + server->time_of_death =ktime_get_real_seconds ();queue_delayed_work (afs_wq, &afs_server_reaper, afs_server_timeout *HZ ); }
@@ -272,9 +272,9 @@ static void afs_reap_server(struct work_struct *work)LIST_HEAD (corpses);struct afs_server *server;unsigned long delay, expiry; -time_t now; +time64_t now; - now =get_seconds (); + now =ktime_get_real_seconds ();spin_lock (&afs_server_graveyard_lock);while (!list_empty (&afs_server_graveyard)) {
fs/afs/vlocation.c +9 -7
@@ -340,7 +340,8 @@ static void afs_vlocation_queue_for_updates(struct afs_vlocation *vl)struct afs_vlocation *xvl;/* wait at least 10 minutes before updating... */ - vl->update_at =get_seconds () + afs_vlocation_update_timeout; + vl->update_at =ktime_get_real_seconds () + + afs_vlocation_update_timeout;spin_lock (&afs_vlocation_updates_lock);
@@ -506,7 +507,7 @@ void afs_put_vlocation(struct afs_vlocation *vl)if (atomic_read (&vl->usage) ==0 ) {_debug ("buried" );list_move_tail (&vl->grave, &afs_vlocation_graveyard); - vl->time_of_death =get_seconds (); + vl->time_of_death =ktime_get_real_seconds ();queue_delayed_work (afs_wq, &afs_vlocation_reap, afs_vlocation_timeout *HZ );
@@ -543,11 +544,11 @@ static void afs_vlocation_reaper(struct work_struct *work)LIST_HEAD (corpses);struct afs_vlocation *vl;unsigned long delay, expiry; -time_t now; +time64_t now;_enter ("" ); - now =get_seconds (); + now =ktime_get_real_seconds ();spin_lock (&afs_vlocation_graveyard_lock);while (!list_empty (&afs_vlocation_graveyard)) {
@@ -622,13 +623,13 @@ static void afs_vlocation_updater(struct work_struct *work) {struct afs_cache_vlocation vldb;struct afs_vlocation *vl, *xvl; -time_t now; +time64_t now;long timeout;int ret;_enter ("" ); - now =get_seconds (); + now =ktime_get_real_seconds ();/* find a record to update */ spin_lock (&afs_vlocation_updates_lock);
@@ -684,7 +685,8 @@ static void afs_vlocation_updater(struct work_struct *work)/* and then reschedule */ _debug ("reschedule" ); - vl->update_at =get_seconds () + afs_vlocation_update_timeout; + vl->update_at =ktime_get_real_seconds () + + afs_vlocation_update_timeout;spin_lock (&afs_vlocation_updates_lock);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Prevent callback expiry timer overflow
In reply to Sasha LevinFrom: Tina Ruchandani <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 56e714312e7dbd6bb83b2f78d3ec19a404c7649f ]
get_seconds() returns real wall-clock seconds. On 32-bit systems this value will overflow in year 2038 and beyond. This patch changes afs_vnode record to use ktime_get_real_seconds() instead, for the fields cb_expires and cb_expires_at.
--- fs/afs/fsclient.c | 2 +- fs/afs/inode.c | 7 ++++--- fs/afs/internal.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-)
fs/afs/fsclient.c +1 -1
@@ -139,7 +139,7 @@ static void xdr_decode_AFSCallBack(const __be32 **_bp, struct afs_vnode *vnode) vnode->cb_version =ntohl (*bp++); vnode->cb_expiry =ntohl (*bp++); vnode->cb_type =ntohl (*bp++); - vnode->cb_expires = vnode->cb_expiry +get_seconds (); + vnode->cb_expires = vnode->cb_expiry +ktime_get_real_seconds (); *_bp = bp; }
fs/afs/inode.c +4 -3
@@ -244,12 +244,13 @@ struct inode *afs_iget(struct super_block *sb, struct key *key, vnode->cb_version =0 ; vnode->cb_expiry =0 ; vnode->cb_type =0 ; - vnode->cb_expires =get_seconds (); + vnode->cb_expires =ktime_get_real_seconds (); }else { vnode->cb_version = cb->version; vnode->cb_expiry = cb->expiry; vnode->cb_type = cb->type; - vnode->cb_expires = vnode->cb_expiry +get_seconds (); + vnode->cb_expires = vnode->cb_expiry + +ktime_get_real_seconds (); } }
@@ -322,7 +323,7 @@ int afs_validate(struct afs_vnode *vnode, struct key *key) !test_bit(AFS_VNODE_CB_BROKEN, &vnode->flags) && !test_bit(AFS_VNODE_MODIFIED, &vnode->flags) && !test_bit(AFS_VNODE_ZAP_DATA, &vnode->flags)) { -if (vnode->cb_expires <get_seconds () +10 ) { +if (vnode->cb_expires <ktime_get_real_seconds () +10 ) {_debug ("callback expired" );set_bit (AFS_VNODE_CB_BROKEN , &vnode->flags); }else {
fs/afs/internal.h +2 -2
@@ -375,8 +375,8 @@ struct afs_vnode {struct rb_node server_rb;/* link in server->fs_vnodes */ struct rb_node cb_promise;/* link in server->cb_promises */ struct work_struct cb_broken_work;/* work to be done on callback break */ -time_t cb_expires;/* time at which callback expires */ -time_t cb_expires_at;/* time used to order cb_promise */ +time64_t cb_expires;/* time at which callback expires */ +time64_t cb_expires_at;/* time used to order cb_promise */ unsigned cb_version;/* callback version */ unsigned cb_expiry;/* callback expiry time */ afs_callback_type_t cb_type;/* type of callback */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Fix the maths in afs_fs_store_data()
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 146a1192783697810b63a1e41c4d59fc93387340 ]
afs_fs_store_data() works out of the size of the write it's going to make, but it uses 32-bit unsigned subtraction in one place that gets automatically cast to loff_t.
However, if to < offset, then the number goes negative, but as the result isn't signed, this doesn't get sign-extended to 64-bits when placed in a loff_t.
Fix by casting the operands to loff_t.
--- fs/afs/fsclient.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/afs/fsclient.c +1 -1
@@ -1225,7 +1225,7 @@ int afs_fs_store_data(struct afs_server *server, struct afs_writeback *wb,_enter (",%x,{%x:%u},," ,key_serial (wb->key), vnode->fid.vid, vnode->fid.vnode); - size = to - offset; + size = (loff_t )to - (loff_t )offset;if (first != last) size += (loff_t)(last - first) <<PAGE_SHIFT ; pos = (loff_t )first <<PAGE_SHIFT ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Fix page leak in afs_write_begin()
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6d06b0d25209c80e99c1e89700f1e09694a3766b ]
afs_write_begin() leaks a ref and a lock on a page if afs_fill_page() fails. Fix the leak by unlocking and releasing the page in the error path.
--- fs/afs/write.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/afs/write.c +5 -2
@@ -148,12 +148,12 @@ int afs_write_begin(struct file *file, struct address_space *mapping,kfree (candidate);return -ENOMEM ; } - *pagep = page; -/* page won't leak in error case: it eventually gets cleaned off LRU */ if (!PageUptodate (page) && len !=PAGE_CACHE_SIZE ) { ret =afs_fill_page (vnode, key, index <<PAGE_CACHE_SHIFT , page);if (ret <0 ) { +unlock_page (page); +put_page (page);kfree (candidate);_leave (" = %d [prep]" , ret);return ret;
@@ -161,6 +161,9 @@ int afs_write_begin(struct file *file, struct address_space *mapping,SetPageUptodate (page); } +/* page won't leak in error case: it eventually gets cleaned off LRU */ + *pagep = page; + try_again:spin_lock (&vnode->writeback_lock);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Populate and use client modification time
In reply to Sasha LevinFrom: Marc Dionne <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ab94f5d0dd6fd82e7eeca5e7c8096eaea0a0261f ]
The inode timestamps should be set from the client time in the status received from the server, rather than the server time which is meant for internal server use.
Set AFS_SET_MTIME and populate the mtime for operations that take an input status, such as file/dir creation and StoreData. If an input time is not provided the server will set the vnode times based on the current server time.
In a situation where the server has some skew with the client, this could lead to the client seeing a timestamp in the future for a file that it just created or wrote.
--- fs/afs/fsclient.c | 18 +++++++++--------- fs/afs/inode.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
fs/afs/fsclient.c +9 -9
@@ -105,7 +105,7 @@ static void xdr_decode_AFSFetchStatus(const __be32 **_bp, vnode->vfs_inode.i_mode = mode; } - vnode->vfs_inode.i_ctime.tv_sec = status->mtime_server; + vnode->vfs_inode.i_ctime.tv_sec = status->mtime_client; vnode->vfs_inode.i_mtime = vnode->vfs_inode.i_ctime; vnode->vfs_inode.i_atime = vnode->vfs_inode.i_ctime; vnode->vfs_inode.i_version = data_version;
@@ -703,8 +703,8 @@ int afs_fs_create(struct afs_server *server,memset (bp,0 , padsz); bp = (void *) bp + padsz; } - *bp++ =htonl (AFS_SET_MODE ); - *bp++ =0 ;/* mtime */ + *bp++ =htonl (AFS_SET_MODE |AFS_SET_MTIME ); + *bp++ =htonl (vnode->vfs_inode.i_mtime.tv_sec);/* mtime */ *bp++ =0 ;/* owner */ *bp++ =0 ;/* group */ *bp++ =htonl (mode &S_IALLUGO );/* unix mode */
@@ -981,8 +981,8 @@ int afs_fs_symlink(struct afs_server *server,memset (bp,0 , c_padsz); bp = (void *) bp + c_padsz; } - *bp++ =htonl (AFS_SET_MODE ); - *bp++ =0 ;/* mtime */ + *bp++ =htonl (AFS_SET_MODE |AFS_SET_MTIME ); + *bp++ =htonl (vnode->vfs_inode.i_mtime.tv_sec);/* mtime */ *bp++ =0 ;/* owner */ *bp++ =0 ;/* group */ *bp++ =htonl (S_IRWXUGO );/* unix mode */
@@ -1192,8 +1192,8 @@ static int afs_fs_store_data64(struct afs_server *server, *bp++ =htonl (vnode->fid.vnode); *bp++ =htonl (vnode->fid.unique); - *bp++ =0 ;/* mask */ - *bp++ =0 ;/* mtime */ + *bp++ =htonl (AFS_SET_MTIME );/* mask */ + *bp++ =htonl (vnode->vfs_inode.i_mtime.tv_sec);/* mtime */ *bp++ =0 ;/* owner */ *bp++ =0 ;/* group */ *bp++ =0 ;/* unix mode */
@@ -1269,8 +1269,8 @@ int afs_fs_store_data(struct afs_server *server, struct afs_writeback *wb, *bp++ =htonl (vnode->fid.vnode); *bp++ =htonl (vnode->fid.unique); - *bp++ =0 ;/* mask */ - *bp++ =0 ;/* mtime */ + *bp++ =htonl (AFS_SET_MTIME );/* mask */ + *bp++ =htonl (vnode->vfs_inode.i_mtime.tv_sec);/* mtime */ *bp++ =0 ;/* owner */ *bp++ =0 ;/* group */ *bp++ =0 ;/* unix mode */
fs/afs/inode.c +1 -1
@@ -71,7 +71,7 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key) inode->i_uid = vnode->status.owner; inode->i_gid = vnode->status.group; inode->i_size = vnode->status.size; - inode->i_ctime.tv_sec = vnode->status.mtime_server; + inode->i_ctime.tv_sec = vnode->status.mtime_client; inode->i_ctime.tv_nsec =0 ; inode->i_atime = inode->i_mtime = inode->i_ctime; inode->i_blocks =0 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] afs: Fix afs_kill_pages()
In reply to Sasha LevinFrom: David Howells <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 7286a35e893176169b09715096a4aca557e2ccd2 ]
Fix afs_kill_pages() in two ways:
(1) If a writeback has been partially flushed, then if we try and kill the pages it contains, some of them may no longer be undergoing writeback and end_page_writeback() will assert.
Fix this by checking to see whether the page in question is actually undergoing writeback before ending that writeback.
(2) The loop that scans for pages to kill doesn't increase the first page index, and so the loop may not terminate, but it will try to process the same pages over and over again.
Fix this by increasing the first page index to one after the last page we processed.
--- fs/afs/write.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/afs/write.c +7 -3
@@ -299,10 +299,14 @@ static void afs_kill_pages(struct afs_vnode *vnode, bool error, ASSERTCMP(pv.nr, ==, count);for (loop =0 ; loop < count; loop++) { -ClearPageUptodate (pv.pages[loop]); +struct page *page = pv.pages[loop]; +ClearPageUptodate (page);if (error) -SetPageError (pv.pages[loop]); -end_page_writeback (pv.pages[loop]); +SetPageError (page); +if (PageWriteback (page)) +end_page_writeback (page); +if (page->index >= first) + first = page->index +1 ; }__pagevec_release (&pv);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net/mlx4_core: Avoid delays during VF driver device shutdown
In reply to Sasha LevinFrom: Jack Morgenstein <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4cbe4dac82e423ecc9a0ba46af24a860853259f4 ]
Some Hypervisors detach VFs from VMs by instantly causing an FLR event to be generated for a VF.
In the mlx4 case, this will cause that VF's comm channel to be disabled before the VM has an opportunity to invoke the VF device's "shutdown" method.
For such Hypervisors, there is a race condition between the VF's shutdown method and its internal-error detection/reset thread.
The internal-error detection/reset thread (which runs every 5 seconds) also detects a disabled comm channel. If the internal-error detection/reset flow wins the race, we still get delays (while that flow tries repeatedly to detect comm-channel recovery).
The cited commit fixed the command timeout problem when the internal-error detection/reset flow loses the race.
This commit avoids the unneeded delays when the internal-error detection/reset flow wins.
--- drivers/net/ethernet/mellanox/mlx4/cmd.c | 11 +++++++++++ drivers/net/ethernet/mellanox/mlx4/main.c | 11 +++++++++++ include/linux/mlx4/device.h | 1 + 3 files changed, 23 insertions(+)
drivers/net/ethernet/mellanox/mlx4/cmd.c +11 -0
@@ -2262,6 +2262,17 @@ static int sync_toggles(struct mlx4_dev *dev) rd_toggle =swab32 (readl (&priv->mfunc.comm->slave_read));if (wr_toggle ==0xffffffff || rd_toggle ==0xffffffff ) {/* PCI might be offline */ + +/* If device removal has been requested, +* do not continue retrying. +*/ +if (dev->persist->interface_state & +MLX4_INTERFACE_STATE_NOWAIT ) { +mlx4_warn (dev, +"communication channel is offline\n" ); +return -EIO ; + } +msleep (100 ); wr_toggle =swab32 (readl (&priv->mfunc.comm-> slave_write));
drivers/net/ethernet/mellanox/mlx4/main.c +11 -0
@@ -1717,6 +1717,14 @@ static int mlx4_comm_check_offline(struct mlx4_dev *dev) (u32)(1 << COMM_CHAN_OFFLINE_OFFSET));if (!offline_bit)return 0 ; + +/* If device removal has been requested, +* do not continue retrying. +*/ +if (dev->persist->interface_state & +MLX4_INTERFACE_STATE_NOWAIT ) +break ; +/* There are cases as part of AER/Reset flow that PF needs * around 100 msec to load. We therefore sleep for 100 msec * to allow other tasks to make use of that CPU during this
@@ -3459,6 +3467,9 @@ static void mlx4_remove_one(struct pci_dev *pdev)struct mlx4_priv *priv =mlx4_priv (dev);int active_vfs =0 ; +if (mlx4_is_slave (dev)) + persist->interface_state |=MLX4_INTERFACE_STATE_NOWAIT ; +mutex_lock (&persist->interface_state_mutex); persist->interface_state |=MLX4_INTERFACE_STATE_DELETION ;mutex_unlock (&persist->interface_state_mutex);
include/linux/mlx4/device.h +1 -0
@@ -443,6 +443,7 @@ enum {enum {MLX4_INTERFACE_STATE_UP =1 <<0 ,MLX4_INTERFACE_STATE_DELETION =1 <<1 , +MLX4_INTERFACE_STATE_NOWAIT =1 <<2 , };#define MSTR_SM_CHANGE_MASK (MLX4_EQ_PORT_INFO_MSTR_SM_SL_CHANGE_MASK | \
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] target: Use system workqueue for ALUA transitions
In reply to Sasha LevinFrom: Mike Christie <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 207ee84133c00a8a2a5bdec94df4a5b37d78881c ]
If tcmu-runner is processing a STPG and needs to change the kernel's ALUA state then we cannot use the same work queue for task management requests and ALUA transitions, because we could deadlock. The problem occurs when a STPG times out before tcmu-runner is able to call into target_tg_pt_gp_alua_access_state_store-> core_alua_do_port_transition -> core_alua_do_transition_tg_pt -> queue_work. In this case, the tmr is on the work queue waiting for the STPG to complete, but the STPG transition is now queued behind the waiting tmr.
Note:
This bug will also be fixed by this patch:
http://www.spinics.net/lists/target-devel/msg14560.html
which switches the tmr code to use the system workqueues.
For both, I am not sure if we need a dedicated workqueue since it is not a performance path and I do not think we need WQ_MEM_RECLAIM to make forward progress to free up memory like the block layer does.
--- drivers/target/target_core_alua.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/target/target_core_alua.c +3 -5
@@ -1126,13 +1126,11 @@ static int core_alua_do_transition_tg_pt(unsigned long transition_tmo; transition_tmo = tg_pt_gp->tg_pt_gp_implicit_trans_secs *HZ ; -queue_delayed_work (tg_pt_gp->tg_pt_gp_dev->tmr_wq, - &tg_pt_gp->tg_pt_gp_transition_work, - transition_tmo); +schedule_delayed_work (&tg_pt_gp->tg_pt_gp_transition_work, + transition_tmo); }else { tg_pt_gp->tg_pt_gp_transition_complete = &wait; -queue_delayed_work (tg_pt_gp->tg_pt_gp_dev->tmr_wq, - &tg_pt_gp->tg_pt_gp_transition_work,0 ); +schedule_delayed_work (&tg_pt_gp->tg_pt_gp_transition_work,0 );wait_for_completion (&wait); tg_pt_gp->tg_pt_gp_transition_complete =NULL ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] perf symbols: Fix symbols__fixup_end heuristic for corner cases
In reply to Sasha LevinFrom: Daniel Borkmann <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e7ede72a6d40cb3a30c087142d79381ca8a31dab ]
The current symbols__fixup_end() heuristic for the last entry in the rb tree is suboptimal as it leads to not being able to recognize the symbol in the call graph in a couple of corner cases, for example:
i) If the symbol has a start address (f.e. exposed via kallsyms)
that is at a page boundary, then the roundup(curr->start, 4096)
for the last entry will result in curr->start == curr->end with
a symbol length of zero.ii) If the symbol has a start address that is shortly before a page
boundary, then also here, curr->end - curr->start will just be very few bytes, where it's unrealistic that we could perform a match against.
Instead, change the heuristic to roundup(curr->start, 4096) + 4096, so that we can catch such corner cases and have a better chance to find that specific symbol. It's still just best effort as the real end of the symbol is unknown to us (and could even be at a larger offset than the current range), but better than the current situation.
Alexei reported that he recently run into case i) with a JITed eBPF program (these are all page aligned) as the last symbol which wasn't properly shown in the call graph (while other eBPF program symbols in the rb tree were displayed correctly). Since this is a generic issue, lets try to improve the heuristic a bit.
--- tools/perf/util/symbol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol.c +1 -1
@@ -194,7 +194,7 @@ void symbols__fixup_end(struct rb_root *symbols)/* Last entry */ if (curr->end == curr->start) - curr->end =roundup (curr->start,4096 ); + curr->end =roundup (curr->start,4096 ) +4096 ; }void __map_groups__fixup_end (struct map_groups *mg,enum map_type type)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] fbdev: controlfb: Add missing modes to fix out of bounds access
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ac831a379d34109451b3c41a44a20ee10ecb615f ]
Dan's static analysis says:
drivers/video/fbdev/controlfb.c:560 control_setup()
error: buffer overflow 'control_mac_modes' 20 <= 21
Indeed, control_mac_modes[] has only 20 elements, while VMODE_MAX is 22, which may lead to an out of bounds read when parsing vmode commandline options.
The bug was introduced in v2.4.5.6, when 2 new modes were added to macmodes.h, but control_mac_modes[] wasn't updated:
Augment control_mac_modes[] with the two new video modes to fix this.
--- drivers/video/fbdev/controlfb.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/video/fbdev/controlfb.h +2 -0
@@ -141,5 +141,7 @@ static struct max_cmodes control_mac_modes[] = { {{ 1, 2}}, /* 1152x870, 75Hz */ {{ 0, 1}}, /* 1280x960, 75Hz */ {{ 0, 1}}, /* 1280x1024, 75Hz */ + {{ 1, 2}}, /* 1152x768, 60Hz */ + {{ 0, 1}}, /* 1600x1024, 60Hz */ };
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] NFSv4.1 respect server's max size in CREATE_SESSION
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 033853325fe3bdc70819a8b97915bd3bca41d3af ]
Currently client doesn't respect max sizes server returns in CREATE_SESSION. nfs4_session_set_rwsize() gets called and server->rsize, server->wsize are 0 so they never get set to the sizes returned by the server.
--- fs/nfs/nfs4client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4client.c +2 -2
@@ -899,9 +899,9 @@ static void nfs4_session_set_rwsize(struct nfs_server *server) server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; -if (server->rsize > server_resp_sz) +if (!server->rsize || server->rsize > server_resp_sz) server->rsize = server_resp_sz; -if (server->wsize > server_rqst_sz) +if (!server->wsize || server->wsize > server_rqst_sz) server->wsize = server_rqst_sz;#endif /* CONFIG_NFS_V4_1 */ }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] video: fbdev: au1200fb: Release some resources if a memory allocation fails
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 451f130602619a17c8883dd0b71b11624faffd51 ]
We should go through the error handling code instead of returning -ENOMEM directly.
--- drivers/video/fbdev/au1200fb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/au1200fb.c +2 -1
@@ -1699,7 +1699,8 @@ static int au1200fb_drv_probe(struct platform_device *dev)if (!fbdev->fb_mem) {print_err ("fail to allocate frambuffer (size: %dK))" , fbdev->fb_len /1024 ); -return -ENOMEM ; + ret = -ENOMEM ; + goto failed; }/*
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] btrfs: add missing memset while reading compressed inline extents
In reply to Sasha LevinFrom: Zygo Blaxell <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit e1699d2d7bf6e6cce3e1baff19f9dd4595a58664 ]
This is a story about 4 distinct (and very old) btrfs bugs.
Commit c8b978188c ("Btrfs: Add zlib compression support") added three data corruption bugs for inline extents (bugs #1-3).
Commit 93c82d5750 ("Btrfs: zero page past end of inline file items") fixed bug #1: uncompressed inline extents followed by a hole and more extents could get non-zero data in the hole as they were read. The fix was to add a memset in btrfs_get_extent to zero out the hole.
Commit 166ae5a418 ("btrfs: fix inline compressed read err corruption") fixed bug #2: compressed inline extents which contained non-zero bytes might be replaced with zero bytes in some cases. This patch removed an unhelpful memset from uncompress_inline, but the case where memset is required was missed.
There is also a memset in the decompression code, but this only covers decompressed data that is shorter than the ram_bytes from the extent ref record. This memset doesn't cover the region between the end of the decompressed data and the end of the page. It has also moved around a few times over the years, so there's no single patch to refer to.
This patch fixes bug #3: compressed inline extents followed by a hole and more extents could get non-zero data in the hole as they were read (i.e. bug #3 is the same as bug #1, but s/uncompressed/compressed/). The fix is the same: zero out the hole in the compressed case too, by putting a memset back in uncompress_inline, but this time with correct parameters.
The last and oldest bug, bug #0, is the cause of the offending inline extent/hole/extent pattern. Bug #0 is a subtle and mostly-harmless quirk of behavior somewhere in the btrfs write code. In a few special cases, an inline extent and hole are allowed to persist where they normally would be combined with later extents in the file.
A fast reproducer for bug #0 is presented below. A few offending extents are also created in the wild during large rsync transfers with the -S flag. A Linux kernel build (git checkout; make allyesconfig; make -j8) will produce a handful of offending files as well. Once an offending file is created, it can present different content to userspace each time it is read.
Bug #0 is at least 4 and possibly 8 years old. I verified every vX.Y kernel back to v3.5 has this behavior. There are fossil records of this bug's effects in commits all the way back to v2.6.32. I have no reason to believe bug #0 wasn't present at the beginning of btrfs compression support in v2.6.29, but I can't easily test kernels that old to be sure.
It is not clear whether bug #0 is worth fixing. A fix would likely require injecting extra reads into currently write-only paths, and most of the exceptional cases caused by bug #0 are already handled now.
Whether we like them or not, bug #0's inline extents followed by holes are part of the btrfs de-facto disk format now, and we need to be able to read them without data corruption or an infoleak. So enough about bug #0, let's get back to bug #3 (this patch).
An example of on-disk structure leading to data corruption found in the wild:
item 61 key (606890 INODE_ITEM 0) itemoff 9662 itemsize 160
inode generation 50 transid 50 size 47424 nbytes 49141
block group 0 mode 100644 links 1 uid 0 gid 0
rdev 0 flags 0x0(none)
item 62 key (606890 INODE_REF 603050) itemoff 9642 itemsize 20
inode ref index 3 namelen 10 name: DB_File.so
item 63 key (606890 EXTENT_DATA 0) itemoff 8280 itemsize 1362
inline extent data size 1341 ram 4085 compress(zlib)
item 64 key (606890 EXTENT_DATA 4096) itemoff 8227 itemsize 53
extent data disk byte 5367308288 nr 20480
extent data offset 0 nr 45056 ram 45056
extent compression(zlib)Different data appears in userspace during each read of the 11 bytes between 4085 and 4096. The extent in item 63 is not long enough to fill the first page of the file, so a memset is required to fill the space between item 63 (ending at 4085) and item 64 (beginning at 4096) with zero.
Here is a reproducer from Liu Bo, which demonstrates another method of creating the same inline extent and hole pattern:
Using 'page_poison=on' kernel command line (or enable CONFIG_PAGE_POISONING) run the following:
# touch foo # chattr +c foo # xfs_io -f -c "pwrite -W 0 1000" foo # xfs_io -f -c "falloc 4 8188" foo # od -x foo # echo 3 >/proc/sys/vm/drop_caches # od -x foo
This produce the following on my box:
Correct output: file contains 1000 data bytes followed by zeros:
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd * 0001740 cdcd cdcd cdcd cdcd 0000 0000 0000 0000 0001760 0000 0000 0000 0000 0000 0000 0000 0000 * 0020000
Actual output: the data after the first 1000 bytes will be different each run:
0000000 cdcd cdcd cdcd cdcd cdcd cdcd cdcd cdcd * 0001740 cdcd cdcd cdcd cdcd 6c63 7400 635f 006d 0001760 5f74 6f43 7400 435f 0053 5f74 7363 7400 0002000 435f 0056 5f74 6164 7400 645f 0062 5f74 (...)
--- fs/btrfs/inode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/inode.c +14 -0
@@ -6667,6 +6667,20 @@ static noinline int uncompress_inline(struct btrfs_path *path, max_size = min_t(unsigned long, PAGE_CACHE_SIZE, max_size); ret =btrfs_decompress (compress_type, tmp, page, extent_offset, inline_size, max_size); + +/* +* decompression code contains a memset to fill in any space between the end +* of the uncompressed data and the end of max_size in case the decompressed +* data ends up shorter than ram_bytes. That doesn't cover the hole between +* the end of an inline extent and the beginning of the next block, so we +* cover that region here. +*/ + +if (max_size + pg_offset <PAGE_SIZE ) { +char *map =kmap (page); +memset (map + pg_offset + max_size,0 ,PAGE_SIZE - max_size - pg_offset); +kunmap (page); + }kfree (tmp);return ret; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] video: fbdev: au1200fb: Return an error code if a memory allocation fails
In reply to Sasha LevinFrom: Christophe JAILLET <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 8cae353e6b01ac3f18097f631cdbceb5ff28c7f3 ]
'ret' is known to be 0 at this point.
In case of memory allocation error in 'framebuffer_alloc()', return -ENOMEM instead.
--- drivers/video/fbdev/au1200fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/au1200fb.c +3 -1
@@ -1680,8 +1680,10 @@ static int au1200fb_drv_probe(struct platform_device *dev) fbi =framebuffer_alloc (sizeof (struct au1200fb_device ), &dev->dev); -if (!fbi) +if (!fbi) { + ret = -ENOMEM ; goto failed; + } _au1200fb_infos[plane] = fbi; fbdev = fbi->par;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] video: udlfb: Fix read EDID timeout
In reply to Sasha LevinFrom: Ladislav Michl <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c98769475575c8a585f5b3952f4b5f90266f699b ]
While usb_control_msg function expects timeout in miliseconds, a value of HZ is used. Replace it with USB_CTRL_GET_TIMEOUT and also fix error message which looks like:
udlfb: Read EDID byte 78 failed err ffffff92
as error is either negative errno or number of bytes transferred use %d format specifier.
Returned EDID is in second byte, so return error when less than two bytes are received.
--- drivers/video/fbdev/udlfb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/video/fbdev/udlfb.c +5 -5
@@ -769,11 +769,11 @@ static int dlfb_get_edid(struct dlfb_data *dev, char *edid, int len)for (i =0 ; i < len; i++) { ret =usb_control_msg (dev->udev, -usb_rcvctrlpipe (dev->udev,0 ), (0x02 ), - (0x80 | (0x02 <<5 )), i <<8 ,0xA1 , rbuf,2 , -HZ ); -if (ret <1 ) { -pr_err ("Read EDID byte %d failed err %x\n" , i, ret); +usb_rcvctrlpipe (dev->udev,0 ),0x02 , + (0x80 | (0x02 <<5 )), i <<8 ,0xA1 , + rbuf,2 ,USB_CTRL_GET_TIMEOUT ); +if (ret <2 ) { +pr_err ("Read EDID byte %d failed: %d\n" , i, ret); i--;break ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] PCI/PME: Handle invalid data when reading Root Status
In reply to Sasha LevinFrom: Qiang <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3ad3f8ce50914288731a3018b27ee44ab803e170 ]
PCIe PME and native hotplug share the same interrupt number, so hotplug interrupts are also processed by PME. In some cases, e.g., a Link Down interrupt, a device may be present but unreachable, so when we try to read its Root Status register, the read fails and we get all ones data (0xffffffff).
Previously, we interpreted that data as PCI_EXP_RTSTA_PME being set, i.e., "some device has asserted PME," so we scheduled pcie_pme_work_fn(). This caused an infinite loop because pcie_pme_work_fn() tried to handle PME requests until PCI_EXP_RTSTA_PME is cleared, but with the link down, PCI_EXP_RTSTA_PME can't be cleared.
Check for the invalid 0xffffffff data everywhere we read the Root Status register.
1469d17dd341 ("PCI: pciehp: Handle invalid data when reading from non-existent devices") added similar checks in the hotplug driver.
[bhelgaas: changelog, also check in pcie_pme_work_fn(), use "~0" to follow other similar checks]
--- drivers/pci/pcie/pme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pci/pcie/pme.c +4 -1
@@ -233,6 +233,9 @@ static void pcie_pme_work_fn(struct work_struct *work)break ;pcie_capability_read_dword (port,PCI_EXP_RTSTA , &rtsta); +if (rtsta == (u32 ) ~0 ) +break ; +if (rtsta &PCI_EXP_RTSTA_PME ) {/* * Clear PME status of the port. If there are other
@@ -280,7 +283,7 @@ static irqreturn_t pcie_pme_irq(int irq, void *context)spin_lock_irqsave (&data->lock, flags);pcie_capability_read_dword (port,PCI_EXP_RTSTA , &rtsta); -if (!(rtsta &PCI_EXP_RTSTA_PME )) { +if (rtsta == (u32 ) ~0 || !(rtsta &PCI_EXP_RTSTA_PME )) {spin_unlock_irqrestore (&data->lock, flags);return IRQ_NONE ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] powerpc/powernv/cpufreq: Fix the frequency read by /proc/cpuinfo
In reply to Sasha LevinFrom: Shriya <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cd77b5ce208c153260ed7882d8910f2395bfaabd ]
The call to /proc/cpuinfo in turn calls cpufreq_quick_get() which returns the last frequency requested by the kernel, but may not reflect the actual frequency the processor is running at. This patch makes a call to cpufreq_get() instead which returns the current frequency reported by the hardware.
--- arch/powerpc/platforms/powernv/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/powernv/setup.c +1 -1
@@ -469,7 +469,7 @@ static unsigned long pnv_get_proc_freq(unsigned int cpu) {unsigned long ret_freq; - ret_freq =cpufreq_quick_get (cpu) *1000ul ; + ret_freq =cpufreq_get (cpu) *1000ul ;/* * If the backend cpufreq driver does not exist,
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] powerpc/opal: Fix EBUSY bug in acquiring tokens
In reply to Sasha LevinFrom: "William A. Kennington III" <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 71e24d7731a2903b1ae2bba2b2971c654d9c2aa6 ]
The current code checks the completion map to look for the first token that is complete. In some cases, a completion can come in but the token can still be on lease to the caller processing the completion. If this completed but unreleased token is the first token found in the bitmap by another tasks trying to acquire a token, then the __test_and_set_bit call will fail since the token will still be on lease. The acquisition will then fail with an EBUSY.
This patch reorganizes the acquisition code to look at the opal_async_token_map for an unleased token. If the token has no lease it must have no outstanding completions so we should never see an EBUSY, unless we have leased out too many tokens. Since opal_async_get_token_inrerruptible is protected by a semaphore, we will practically never see EBUSY anymore.
--- arch/powerpc/platforms/powernv/opal-async.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/platforms/powernv/opal-async.c +3 -3
@@ -39,18 +39,18 @@ int __opal_async_get_token(void)int token;spin_lock_irqsave (&opal_async_comp_lock, flags); - token =find_first_bit (opal_async_complete_map, opal_max_async_tokens); + token =find_first_zero_bit (opal_async_token_map, opal_max_async_tokens);if (token >= opal_max_async_tokens) { token = -EBUSY ; goto out; } -if (__test_and_set_bit (token, opal_async_token_map)) { +if (!__test_and_clear_bit (token, opal_async_complete_map)) { token = -EBUSY ; goto out; } -__clear_bit (token, opal_async_complete_map); +__set_bit (token, opal_async_token_map); out:spin_unlock_irqrestore (&opal_async_comp_lock, flags);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] powerpc/ipic: Fix status get and status clear
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 6b148a7ce72a7f87c81cbcde48af014abc0516a9 ]
IPIC Status is provided by register IPIC_SERSR and not by IPIC_SERMR which is the mask register.
--- arch/powerpc/sysdev/ipic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/sysdev/ipic.c +2 -2
@@ -843,12 +843,12 @@ void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq)u32 ipic_get_mcp_status (void ) { -return ipic_read (primary_ipic->regs,IPIC_SERMR ); +return ipic_read (primary_ipic->regs,IPIC_SERSR ); }void ipic_clear_mcp_status (u32 mask) { -ipic_write (primary_ipic->regs,IPIC_SERMR , mask); +ipic_write (primary_ipic->regs,IPIC_SERSR , mask); }/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] target/iscsi: Fix a race condition in iscsit_add_reject_from_cmd()
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cfe2b621bb18d86e93271febf8c6e37622da2d14 ]
Avoid that cmd->se_cmd.se_tfo is read after a command has already been freed.
--- drivers/target/iscsi/iscsi_target.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +2 -1
@@ -682,6 +682,7 @@ static int iscsit_add_reject_from_cmd( unsigned char *buf) {struct iscsi_conn *conn; +const bool do_put = cmd->se_cmd.se_tfo !=NULL ;if (!cmd->conn) { pr_err("cmd->conn is NULL for ITT: 0x%08x\n",
@@ -712,7 +713,7 @@ static int iscsit_add_reject_from_cmd(* Perform the kref_put now if se_cmd has already been setup by * scsit_setup_scsi_cmd() */ -if (cmd->se_cmd.se_tfo !=NULL ) { +if (do_put) {pr_debug ("iscsi reject: calling target_put_sess_cmd >>>>>>\n" );target_put_sess_cmd (&cmd->se_cmd); }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] iscsi-target: fix memory leak in lio_target_tiqn_addtpg()
In reply to Sasha LevinFrom: tangwenji <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 12d5a43b2dffb6cd28062b4e19024f7982393288 ]
tpg must free when call core_tpg_register() return fail
--- drivers/target/iscsi/iscsi_target_configfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target_configfs.c +2 -1
@@ -1466,7 +1466,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg( ret =core_tpg_register (&iscsi_ops, wwn, &tpg->tpg_se_tpg, tpg,TRANSPORT_TPG_TYPE_NORMAL );if (ret <0 ) -return NULL ; + goto free_out; ret =iscsit_tpg_add_portal_group (tiqn, tpg);if (ret !=0 )
@@ -1478,6 +1478,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(return &tpg->tpg_se_tpg; out:core_tpg_deregister (&tpg->tpg_se_tpg); +free_out:kfree (tpg);return NULL ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] target:fix condition return in core_pr_dump_initiator_port()
In reply to Sasha LevinFrom: tangwenji <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 24528f089d0a444070aa4f715ace537e8d6bf168 ]
When is pr_reg->isid_present_at_reg is false,this function should return.
This fixes a regression originally introduced by:
commit d2843c173ee53cf4c12e7dfedc069a5bc76f0ac5
Author: Andy Grover <[email protected]>
Date: Thu May 16 10:40:55 2013 -0700
target: Alter core_pr_dump_initiator_port for ease of use
--- drivers/target/target_core_pr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/target_core_pr.c +3 -1
@@ -58,8 +58,10 @@ void core_pr_dump_initiator_port( char *buf, u32 size) { -if (!pr_reg->isid_present_at_reg) +if (!pr_reg->isid_present_at_reg) { buf[0 ] ='\0' ; +return ; + }snprintf (buf, size,",i,0x%s" , pr_reg->pr_reg_isid); }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] target/file: Do not return error for UNMAP if length is zero
In reply to Sasha LevinFrom: Jiang Yi <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 594e25e73440863981032d76c9b1e33409ceff6e ]
The function fd_execute_unmap() in target_core_file.c calles
ret = file->f_op->fallocate(file, mode, pos, len);
Some filesystems implement fallocate() to return error if length is zero (e.g. btrfs) but according to SCSI Block Commands spec UNMAP should return success for zero length.
--- drivers/target/target_core_file.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/target/target_core_file.c +4 -0
@@ -539,6 +539,10 @@ fd_do_unmap(struct se_cmd *cmd, void *priv, sector_t lba, sector_t nolb)struct inode *inode = file->f_mapping->host;int ret; +if (!nolb) { +return 0 ; + } +if (cmd->se_dev->dev_attrib.pi_prot_type) { ret =fd_do_prot_unmap (cmd, lba, nolb);if (ret)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] arm-ccn: perf: Prevent module unload while PMU is in use
In reply to Sasha LevinFrom: Suzuki K Poulose <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c7f5828bf77dcbd61d51f4736c1d5aa35663fbb4 ]
When the PMU driver is built as a module, the perf expects the pmu->module to be valid, so that the driver is prevented from being unloaded while it is in use. Fix the CCN pmu driver to fill in this field.
--- drivers/bus/arm-ccn.c | 1 + 1 file changed, 1 insertion(+)
drivers/bus/arm-ccn.c +1 -0
@@ -1157,6 +1157,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)/* Perf driver registration */ ccn->dt.pmu = (struct pmu ) { + .module =THIS_MODULE , .attr_groups = arm_ccn_pmu_attr_groups, .task_ctx_nr = perf_invalid_context, .event_init = arm_ccn_pmu_event_init,
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] mm: Handle 0 flags in _calc_vm_trans() macro
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 592e254502041f953e84d091eae2c68cba04c10b ]
_calc_vm_trans() does not handle the situation when some of the passed flags are 0 (which can happen if these VM flags do not make sense for the architecture). Improve the _calc_vm_trans() macro to return 0 in such situation. Since all passed flags are constant, this does not add any runtime overhead.
--- include/linux/mman.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/mman.h +2 -1
@@ -63,8 +63,9 @@ static inline int arch_validate_prot(unsigned long prot)* ("bit1" and "bit2" must be single bits) */ #define _calc_vm_trans (x, bit1, bit2) \ + ((!(bit1) || !(bit2)) ? 0 : \ ((bit1) <= (bit2) ? ((x) & (bit1)) * ((bit2) / (bit1)) \ - : ((x) & (bit1)) / ((bit1) / (bit2))) + : ((x) & (bit1)) / ((bit1) / (bit2))))/* * Combine the mmap "prot" argument into "vm_flags" used internally.
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] clk: tegra: Fix cclk_lp divisor register
In reply to Sasha LevinFrom: Michał Mirosław <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 54eff2264d3e9fd7e3987de1d7eba1d3581c631e ]
According to comments in code and common sense, cclk_lp uses its own divisor, not cclk_g's.
--- drivers/clk/tegra/clk-tegra30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra30.c +1 -1
@@ -1064,7 +1064,7 @@ static void __init tegra30_super_clk_init(void)* U71 divider of cclk_lp. */ clk =tegra_clk_register_divider ("pll_p_out3_cclklp" ,"pll_p_out3" , - clk_base +SUPER_CCLKG_DIVIDER ,0 , + clk_base +SUPER_CCLKLP_DIVIDER ,0 ,TEGRA_DIVIDER_INT ,16 ,8 ,1 ,NULL );clk_register_clkdev (clk,"pll_p_out3_cclklp" ,NULL );
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] thermal/drivers/step_wise: Fix temperature regulation misbehavior
In reply to Sasha LevinFrom: Daniel Lezcano <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 07209fcf33542c1ff1e29df2dbdf8f29cdaacb10 ]
There is a particular situation when the cooling device is cpufreq and the heat dissipation is not efficient enough where the temperature increases little by little until reaching the critical threshold and leading to a SoC reset.
The behavior is reproducible on a hikey6220 with bad heat dissipation (eg. stacked with other boards).
Running a simple C program doing while(1); for each CPU of the SoC makes the temperature to reach the passive regulation trip point and ends up to the maximum allowed temperature followed by a reset.
This issue has been also reported by running the libhugetlbfs test suite.
What is observed is a ping pong between two cpu frequencies, 1.2GHz and 900MHz while the temperature continues to grow.
It appears the step wise governor calls get_target_state() the first time with the throttle set to true and the trend to 'raising'. The code selects logically the next state, so the cpu frequency decreases from 1.2GHz to 900MHz, so far so good. The temperature decreases immediately but still stays greater than the trip point, then get_target_state() is called again, this time with the throttle set to true *and* the trend to 'dropping'. From there the algorithm assumes we have to step down the state and the cpu frequency jumps back to 1.2GHz. But the temperature is still higher than the trip point, so get_target_state() is called with throttle=1 and trend='raising' again, we jump to 900MHz, then get_target_state() is called with throttle=1 and trend='dropping', we jump to 1.2GHz, etc ... but the temperature does not stabilizes and continues to increase.
[ 237.922654] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1 [ 237.922678] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1 [ 237.922690] thermal cooling_device0: cur_state=0 [ 237.922701] thermal cooling_device0: old_target=0, target=1 [ 238.026656] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1 [ 238.026680] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=1 [ 238.026694] thermal cooling_device0: cur_state=1 [ 238.026707] thermal cooling_device0: old_target=1, target=0 [ 238.134647] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1 [ 238.134667] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1 [ 238.134679] thermal cooling_device0: cur_state=0 [ 238.134690] thermal cooling_device0: old_target=0, target=1
In this situation the temperature continues to increase while the trend is oscillating between 'dropping' and 'raising'. We need to keep the current state untouched if the throttle is set, so the temperature can decrease or a higher state could be selected, thus preventing this oscillation.
Keeping the next_target untouched when 'throttle' is true at 'dropping' time fixes the issue.
The following traces show the governor does not change the next state if trend==2 (dropping) and throttle==1.
[ 2306.127987] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1 [ 2306.128009] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1 [ 2306.128021] thermal cooling_device0: cur_state=0 [ 2306.128031] thermal cooling_device0: old_target=0, target=1 [ 2306.231991] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1 [ 2306.232016] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=1 [ 2306.232030] thermal cooling_device0: cur_state=1 [ 2306.232042] thermal cooling_device0: old_target=1, target=1 [ 2306.335982] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1 [ 2306.336006] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=1 [ 2306.336021] thermal cooling_device0: cur_state=1 [ 2306.336034] thermal cooling_device0: old_target=1, target=1 [ 2306.439984] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1 [ 2306.440008] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=0 [ 2306.440022] thermal cooling_device0: cur_state=1 [ 2306.440034] thermal cooling_device0: old_target=1, target=0
[ ... ]
After a while, if the temperature continues to increase, the next state becomes 2 which is 720MHz on the hikey. That results in the temperature stabilizing around the trip point.
[ 2455.831982] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1 [ 2455.832006] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=0 [ 2455.832019] thermal cooling_device0: cur_state=1 [ 2455.832032] thermal cooling_device0: old_target=1, target=1 [ 2455.935985] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1 [ 2455.936013] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=0 [ 2455.936027] thermal cooling_device0: cur_state=1 [ 2455.936040] thermal cooling_device0: old_target=1, target=1 [ 2456.043984] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=0,throttle=1 [ 2456.044009] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=0,throttle=0 [ 2456.044023] thermal cooling_device0: cur_state=1 [ 2456.044036] thermal cooling_device0: old_target=1, target=1 [ 2456.148001] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=1,throttle=1 [ 2456.148028] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=1,throttle=1 [ 2456.148042] thermal cooling_device0: cur_state=1 [ 2456.148055] thermal cooling_device0: old_target=1, target=2 [ 2456.252009] thermal thermal_zone0: Trip0[type=1,temp=65000]:trend=2,throttle=1 [ 2456.252041] thermal thermal_zone0: Trip1[type=1,temp=75000]:trend=2,throttle=0 [ 2456.252058] thermal cooling_device0: cur_state=2 [ 2456.252075] thermal cooling_device0: old_target=2, target=1
IOW, this change is needed to keep the state for a cooling device if the temperature trend is oscillating while the temperature increases slightly.
Without this change, the situation above leads to a catastrophic crash by a hardware reset on hikey. This issue has been reported to happen on an OMAP dra7xx also.
--- drivers/thermal/step_wise.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/step_wise.c +6 -5
@@ -31,8 +31,7 @@* If the temperature is higher than a trip point, * a. if the trend is THERMAL_TREND_RAISING, use higher cooling * state for this trip point -* b. if the trend is THERMAL_TREND_DROPPING, use lower cooling -* state for this trip point +* b. if the trend is THERMAL_TREND_DROPPING, do nothing * c. if the trend is THERMAL_TREND_RAISE_FULL, use upper limit * for this trip point * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit
@@ -94,9 +93,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,if (!throttle) next_target =THERMAL_NO_TARGET ; }else { - next_target = cur_state -1 ; -if (next_target > instance->upper) - next_target = instance->upper; +if (!throttle) { + next_target = cur_state -1 ; +if (next_target > instance->upper) + next_target = instance->upper; + } }break ;case THERMAL_TREND_DROP_FULL :
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ppp: Destroy the mutex when cleanup
In reply to Sasha LevinFrom: Gao Feng <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f02b2320b27c16b644691267ee3b5c110846f49e ]
The mutex_destroy only makes sense when enable DEBUG_MUTEX. For the good readbility, it's better to invoke it in exit func when the init func invokes mutex_init.
--- drivers/net/ppp/ppp_generic.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ppp/ppp_generic.c +1 -0
@@ -918,6 +918,7 @@ static __net_exit void ppp_exit_net(struct net *net) {struct ppp_net *pn =net_generic (net, ppp_net_id); +mutex_destroy (&pn->all_ppp_mutex);idr_destroy (&pn->units_idr); }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] GFS2: Take inode off order_write list when setting jdata flag
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit cc555b09d8c3817aeebda43a14ab67049a5653f7 ]
This patch fixes a deadlock caused when the jdata flag is set for inodes that are already on the ordered write list. Since it is on the ordered write list, log_flush calls gfs2_ordered_write which calls filemap_fdatawrite. But since the inode had the jdata flag set, that calls gfs2_jdata_writepages, which tries to start a new transaction. A new transaction cannot be started because it tries to acquire the log_flush rwsem which is already locked by the log flush operation.
The bottom line is: We cannot switch an inode from ordered to jdata until we eliminate any ordered data pages (via log flush) or any log_flush operation afterward will create the circular dependency above. So we need to flush the log before setting the diskflags to switch the file mode, then we need to remove the inode from the ordered writes list.
Before this patch, the log flush was done for jdata->ordered, but that's wrong. If we're going from jdata to ordered, we don't need to call gfs2_log_flush because the call to filemap_fdatawrite will do it for us:
filemap_fdatawrite() -> __filemap_fdatawrite_range()
__filemap_fdatawrite_range() -> do_writepages()
do_writepages() -> gfs2_jdata_writepages()
gfs2_jdata_writepages() -> gfs2_log_flush()This patch modifies function do_gfs2_set_flags so that if a file has its jdata flag set, and it's already on the ordered write list, the log will be flushed and it will be removed from the list before setting the flag.
--- fs/gfs2/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/gfs2/file.c +3 -1
@@ -255,7 +255,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) goto out; }if ((flags ^ new_flags) &GFS2_DIF_JDATA ) { -if (flags &GFS2_DIF_JDATA ) +if (new_flags &GFS2_DIF_JDATA )gfs2_log_flush (sdp, ip->i_gl,NORMAL_FLUSH ); error =filemap_fdatawrite (inode->i_mapping);if (error)
@@ -263,6 +263,8 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask) error =filemap_fdatawait (inode->i_mapping);if (error) goto out; +if (new_flags &GFS2_DIF_JDATA ) +gfs2_ordered_del_inode (ip); } error =gfs2_trans_begin (sdp,RES_DINODE ,0 );if (error)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] bcache: explicitly destroy mutex while exiting
In reply to Sasha LevinFrom: Liang Chen <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 330a4db89d39a6b43f36da16824eaa7a7509d34d ]
mutex_destroy does nothing most of time, but it's better to call it to make the code future proof and it also has some meaning for like mutex debug.
As Coly pointed out in a previous review, bcache_exit() may not be able to handle all the references properly if userspace registers cache and backing devices right before bch_debug_init runs and bch_debug_init failes later. So not exposing userspace interface until everything is ready to avoid that issue.
--- drivers/md/bcache/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/bcache/super.c +4 -2
@@ -2122,6 +2122,7 @@ static void bcache_exit(void)if (bcache_major)unregister_blkdev (bcache_major,"bcache" );unregister_reboot_notifier (&reboot); +mutex_destroy (&bch_register_lock); }static int __init bcache_init (void )
@@ -2140,14 +2141,15 @@ static int __init bcache_init(void) bcache_major =register_blkdev (0 ,"bcache" );if (bcache_major <0 ) {unregister_reboot_notifier (&reboot); +mutex_destroy (&bch_register_lock);return bcache_major; }if (!(bcache_wq =create_workqueue ("bcache" )) || !(bcache_kobj =kobject_create_and_add ("bcache" , fs_kobj)) || -sysfs_create_files (bcache_kobj, files) ||bch_request_init () || -bch_debug_init (bcache_kobj)) +bch_debug_init (bcache_kobj) || +sysfs_create_files (bcache_kobj, files)) goto err;return 0 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] l2tp: cleanup l2tp_tunnel_delete calls
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 4dc12ffeaeac939097a3f55c881d3dc3523dff0c ]
l2tp_tunnel_delete does not return anything since commit 62b982eeb458 ("l2tp: fix race condition in l2tp_tunnel_delete"). But call sites of l2tp_tunnel_delete still do casts to void to avoid unused return value warnings.
Kill these now useless casts.
--- net/l2tp/l2tp_core.c | 2 +- net/l2tp/l2tp_netlink.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/l2tp/l2tp_core.c +1 -1
@@ -1859,7 +1859,7 @@ static __net_exit void l2tp_exit_net(struct net *net)rcu_read_lock_bh ();list_for_each_entry_rcu (tunnel, &pn->l2tp_tunnel_list, list) { - (void )l2tp_tunnel_delete (tunnel); +l2tp_tunnel_delete (tunnel); }rcu_read_unlock_bh (); }
net/l2tp/l2tp_netlink.c +1 -1
@@ -285,7 +285,7 @@ static int l2tp_nl_cmd_tunnel_delete(struct sk_buff *skb, struct genl_info *infol2tp_tunnel_notify (&l2tp_nl_family, info, tunnel,L2TP_CMD_TUNNEL_DELETE ); - (void )l2tp_tunnel_delete (tunnel); +l2tp_tunnel_delete (tunnel); out:return ret;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] xfs: fix log block underflow during recovery cycle verification
In reply to Sasha LevinFrom: Brian Foster <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 9f2a4505800607e537e9dd9dea4f55c4b0c30c7a ]
It is possible for mkfs to format very small filesystems with too small of an internal log with respect to the various minimum size and block count requirements. If this occurs when the log happens to be smaller than the scan window used for cycle verification and the scan wraps the end of the log, the start_blk calculation in xlog_find_head() underflows and leads to an attempt to scan an invalid range of log blocks. This results in log recovery failure and a failed mount.
Since there may be filesystems out in the wild with this kind of geometry, we cannot simply refuse to mount. Instead, cap the scan window for cycle verification to the size of the physical log. This ensures that the cycle verification proceeds as expected when the scan wraps the end of the log.
--- fs/xfs/xfs_log_recover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_log_recover.c +1 -1
@@ -738,7 +738,7 @@ xlog_find_head(* in the in-core log. The following number can be made tighter if * we actually look at the block size of the filesystem. */ - num_scan_bblks =XLOG_TOTAL_REC_SHIFT (log); + num_scan_bblks =min_t (int, log_bbnum,XLOG_TOTAL_REC_SHIFT (log));if (head_blk >= num_scan_bblks) {/* * We are guaranteed that the entire check can be performed
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] xfs: fix incorrect extent state in xfs_bmap_add_extent_unwritten_real
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 5e422f5e4fd71d18bc6b851eeb3864477b3d842e ]
There was one spot in xfs_bmap_add_extent_unwritten_real that didn't use the passed in new extent state but always converted to normal, leading to wrong behavior when converting from normal to unwritten.
Only found by code inspection, it seems like this code path to move partial extent from written to unwritten while merging it with the next extent is rarely exercised.
--- fs/xfs/libxfs/xfs_bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_bmap.c +1 -1
@@ -2671,7 +2671,7 @@ xfs_bmap_add_extent_unwritten_real( &i))) goto done;XFS_WANT_CORRUPTED_GOTO (mp, i ==0 , done); - cur->bc_rec.b.br_state =XFS_EXT_NORM ; + cur->bc_rec.b.br_state = new->br_state;if ((error =xfs_btree_insert (cur, &i))) goto done;XFS_WANT_CORRUPTED_GOTO (mp, i ==1 , done);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] PCI: Detach driver before procfs & sysfs teardown on device remove
In reply to Sasha LevinFrom: Alex Williamson <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 16b6c8bb687cc3bec914de09061fcb8411951fda ]
When removing a device, for example a VF being removed due to SR-IOV teardown, a "soft" hot-unplug via 'echo 1 > remove' in sysfs, or an actual hot-unplug, we first remove the procfs and sysfs attributes for the device before attempting to release the device from any driver bound to it. Unbinding the driver from the device can take time. The device might need to write out data or it might be actively in use. If it's in use by userspace through a vfio driver, the unbind might block until the user releases the device. This leads to a potentially non-trivial amount of time where the device exists, but we've torn down the interfaces that userspace uses to examine devices, for instance lspci might generate this sort of error:
pcilib: Cannot open /sys/bus/pci/devices/0000:01:0a.3/config
lspci: Unable to read the standard configuration space header of device 0000:01:0a.3
We don't seem to have any dependence on this teardown ordering in the kernel, so let's unbind the driver first, which is also more symmetric with the instantiation of the device in pci_bus_add_device().
--- drivers/pci/remove.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/remove.c +1 -1
@@ -20,9 +20,9 @@ static void pci_stop_dev(struct pci_dev *dev)pci_pme_active (dev, false);if (dev->is_added) { +device_release_driver (&dev->dev);pci_proc_detach_device (dev);pci_remove_sysfs_dev_files (dev); -device_release_driver (&dev->dev); dev->is_added =0 ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] powerpc/perf/hv-24x7: Fix incorrect comparison in memord
In reply to Sasha LevinFrom: Michael Ellerman <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 05c14c03138532a3cb2aa29c2960445c8753343b ]
In the hv-24x7 code there is a function memord() which tries to implement a sort function return -1, 0, 1. However one of the conditions is incorrect, such that it can never be true, because we will have already returned.
I don't believe there is a bug in practice though, because the comparisons are an optimisation prior to calling memcmp().
Fix it by swapping the second comparision, so it can be true.
--- arch/powerpc/perf/hv-24x7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/perf/hv-24x7.c +1 -1
@@ -503,7 +503,7 @@ static int memord(const void *d1, size_t s1, const void *d2, size_t s2) {if (s1 < s2)return 1 ; -if (s2 > s1) +if (s1 > s2)return -1 ;return memcmp (d1, d2, s1);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] tty fix oops when rmmod 8250
In reply to Sasha LevinFrom: nixiaoming <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c79dde629d2027ca80329c62854a7635e623d527 ]
After rmmod 8250.kotty_kref_put starts kwork (release_one_tty) to release proc interface oops when accessing driver->driver_name in proc_tty_unregister_driver
Use jprobe, found driver->driver_name point to 8250.ko static static struct uart_driver serial8250_reg .driver_name= serial,
Use name in proc_dir_entry instead of driver->driver_name to fix oops
test on linux 4.1.12:
BUG: unable to handle kernel paging request at ffffffffa01979de IP: [<ffffffff81310f40>] strchr+0x0/0x30 PGD 1a0d067 PUD 1a0e063 PMD 851c1f067 PTE 0 Oops: 0000 [#1] PREEMPT SMP Modules linked in: ... ... [last unloaded: 8250] CPU: 7 PID: 116 Comm: kworker/7:1 Tainted: G O 4.1.12 #1 Hardware name: Insyde RiverForest/Type2 - Board Product Name1, BIOS NE5KV904 12/21/2015 Workqueue: events release_one_tty task: ffff88085b684960 ti: ffff880852884000 task.ti: ffff880852884000 RIP: 0010:[<ffffffff81310f40>] [<ffffffff81310f40>] strchr+0x0/0x30 RSP: 0018:ffff880852887c90 EFLAGS: 00010282 RAX: ffffffff81a5eca0 RBX: ffffffffa01979de RCX: 0000000000000004 RDX: ffff880852887d10 RSI: 000000000000002f RDI: ffffffffa01979de RBP: ffff880852887cd8 R08: 0000000000000000 R09: ffff88085f5d94d0 R10: 0000000000000195 R11: 0000000000000000 R12: ffffffffa01979de R13: ffff880852887d00 R14: ffffffffa01979de R15: ffff88085f02e840 FS: 0000000000000000(0000) GS:ffff88085f5c0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa01979de CR3: 0000000001a0c000 CR4: 00000000001406e0 Stack: ffffffff812349b1 ffff880852887cb8 ffff880852887d10 ffff88085f5cd6c2 ffff880852800a80 ffffffffa01979de ffff880852800a84 0000000000000010 ffff88085bb28bd8 ffff880852887d38 ffffffff812354f0 ffff880852887d08 Call Trace: [<ffffffff812349b1>] ? __xlate_proc_name+0x71/0xd0 [<ffffffff812354f0>] remove_proc_entry+0x40/0x180 [<ffffffff815f6811>] ? _raw_spin_lock_irqsave+0x41/0x60 [<ffffffff813be520>] ? destruct_tty_driver+0x60/0xe0 [<ffffffff81237c68>] proc_tty_unregister_driver+0x28/0x40 [<ffffffff813be548>] destruct_tty_driver+0x88/0xe0 [<ffffffff813be5bd>] tty_driver_kref_put+0x1d/0x20 [<ffffffff813becca>] release_one_tty+0x5a/0xd0 [<ffffffff81074159>] process_one_work+0x139/0x420 [<ffffffff810745a1>] worker_thread+0x121/0x450 [<ffffffff81074480>] ? process_scheduled_works+0x40/0x40 [<ffffffff8107a16c>] kthread+0xec/0x110 [<ffffffff81080000>] ? tg_rt_schedulable+0x210/0x220 [<ffffffff8107a080>] ? kthread_freezable_should_stop+0x80/0x80 [<ffffffff815f7292>] ret_from_fork+0x42/0x70 [<ffffffff8107a080>] ? kthread_freezable_should_stop+0x80/0x80
--- fs/proc/proc_tty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/proc/proc_tty.c +2 -1
@@ -14,6 +14,7 @@#include <linux/tty.h> #include <linux/seq_file.h> #include <linux/bitops.h> +#include "internal.h" /* * The /proc/tty directory inodes...
@@ -164,7 +165,7 @@ void proc_tty_unregister_driver(struct tty_driver *driver)if (!ent)return ; -remove_proc_entry (driver->driver_name, proc_tty_driver); +remove_proc_entry (ent->name, proc_tty_driver); driver->proc_entry =NULL ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] udf: Avoid overflow when session starts at large offset
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit abdc0eb06964fe1d2fea6dd1391b734d0590365d ]
When session starts beyond offset 2^31 the arithmetics in udf_check_vsd() would overflow. Make sure the computation is done in large enough type.
--- fs/udf/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/udf/super.c +1 -1
@@ -705,7 +705,7 @@ static loff_t udf_check_vsd(struct super_block *sb)else sectorsize = sb->s_blocksize; - sector += (sbi->s_session << sb->s_blocksize_bits); + sector += (((loff_t )sbi->s_session) << sb->s_blocksize_bits); udf_debug("Starting at sector %u (%ld byte sectors)\n", (unsigned int)(sector >> sb->s_blocksize_bits),
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] usb: musb: da8xx: fix babble condition handling
In reply to Sasha LevinFrom: Bin Liu <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bd3486ded7a0c313a6575343e6c2b21d14476645 ]
When babble condition happens, the musb controller might automatically turns off VBUS. On DA8xx platform, the controller generates drvvbus interrupt for turning off VBUS along with the babble interrupt.
In this case, we should handle the babble interrupt first and recover from the babble condition.
This change ignores the drvvbus interrupt if babble interrupt is also generated at the same time, so the babble recovery routine works properly.
--- drivers/usb/musb/da8xx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/musb/da8xx.c +9 -1
@@ -350,7 +350,15 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) musb->xceiv->otg->state =OTG_STATE_A_WAIT_VRISE ;portstate (musb->port1_status |=USB_PORT_STAT_POWER );del_timer (&otg_workaround); - }else { + }else if (!(musb->int_usb &MUSB_INTR_BABBLE )){ +/* +* When babble condition happens, drvvbus interrupt +* is also generated. Ignore this drvvbus interrupt +* and let babble interrupt handler recovers the +* controller; otherwise, the host-mode flag is lost +* due to the MUSB_DEV_MODE() call below and babble +* recovery logic will not called. +*/ musb->is_active =0 ;MUSB_DEV_MODE (musb); otg->default_a =0 ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] gcov: add support for gcc version >= 6
In reply to Sasha LevinFrom: Florian Meier <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit d02038f972538b93011d78c068f44514fbde0a8c ]
--- kernel/gcov/gcc_4_7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/gcov/gcc_4_7.c +1 -1
@@ -18,7 +18,7 @@#include <linux/vmalloc.h> #include "gcov.h" -#if __GNUC__ ==5 && __GNUC_MINOR__ >=1 +#if (__GNUC__ >5 ) || (__GNUC__ ==5 && __GNUC_MINOR__ >=1 )#define GCOV_COUNTERS 10#elif __GNUC__ ==4 && __GNUC_MINOR__ >=9 #define GCOV_COUNTERS 9
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] macvlan: Only deliver one copy of the frame to the macvlan interface
In reply to Sasha LevinFrom: Alexander Duyck <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dd6b9c2c332b40f142740d1b11fb77c653ff98ea ]
This patch intoduces a slight adjustment for macvlan to address the fact that in source mode I was seeing two copies of any packet addressed to the macvlan interface being delivered where there should have been only one.
The issue appears to be that one copy was delivered based on the source MAC address and then the second copy was being delivered based on the destination MAC address. To fix it I am just treating a unicast address match as though it is not a match since source based macvlan isn't supposed to be matching based on the destination MAC anyway.
--- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macvlan.c +1 -1
@@ -440,7 +440,7 @@ static rx_handler_result_t macvlan_handle_frame(struct sk_buff **pskb) struct macvlan_dev, list); else vlan =macvlan_hash_lookup (port, eth->h_dest); -if (vlan ==NULL ) +if (!vlan || vlan->mode ==MACVLAN_MODE_SOURCE )return RX_HANDLER_PASS ; dev = vlan->dev;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] pinctrl: adi2: Fix Kconfig build problem
In reply to Sasha LevinFrom: Linus Walleij <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 1c363531dd814dc4fe10865722bf6b0f72ce4673 ]
The build robot is complaining on Blackfin:
drivers/pinctrl/pinctrl-adi2.c: In function 'port_setup':
Quoted 1 line
Quoted 1 line
drivers/pinctrl/pinctrl-adi2.c:221:21: error: dereferencing
pointer to incomplete type 'struct gpio_port_t'
writew(readw(®s->port_fer) & ~BIT(offset),
^~drivers/pinctrl/pinctrl-adi2.c: In function 'adi_gpio_ack_irq':
Quoted 1 line
Quoted 1 line
drivers/pinctrl/pinctrl-adi2.c:266:18: error: dereferencing
pointer to incomplete type 'struct bfin_pint_regs'
if (readl(®s->invert_set) & pintbit)
^~It seems the driver need to include <asm/gpio.h> and <asm/irq.h> to compile.
The Blackfin architecture was re-defining the Kconfig PINCTRL symbol which is not OK, so replaced this with PINCTRL_BLACKFIN_ADI2 which selects PINCTRL and PINCTRL_ADI2 just like most arches do.
Further, the old GPIO driver symbol GPIO_ADI was possible to select at the same time as selecting PINCTRL. This was not working because the arch-local <asm/gpio.h> header contains an explicit #ifndef PINCTRL clause making compilation break if you combine them. The same is true for DEBUG_MMRS.
Make sure the ADI2 pinctrl driver is not selected at the same time as the old GPIO implementation. (This should be converted to use gpiolib or pincontrol and move to drivers/...) Also make sure the old GPIO_ADI driver or DEBUG_MMRS is not selected at the same time as the new PINCTRL implementation, and only make PINCTRL_ADI2 selectable for the Blackfin families that actually have it.
This way it is still possible to add e.g. I2C-based pin control expanders on the Blackfin.
--- arch/blackfin/Kconfig | 7 +++++-- arch/blackfin/Kconfig.debug | 1 + drivers/pinctrl/Kconfig | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-)
arch/blackfin/Kconfig +5 -2
@@ -318,11 +318,14 @@ config BF53x config GPIO_ADI def_bool y + depends on !PINCTRL depends on (BF51x || BF52x || BF53x || BF538 || BF539 || BF561) -config PINCTRL +config PINCTRL_BLACKFIN_ADI2 def_bool y - depends on BF54x || BF60x + depends on (BF54x || BF60x) + select PINCTRL + select PINCTRL_ADI2 config MEM_MT48LC64M4A2FB_7E bool
arch/blackfin/Kconfig.debug +1 -0
@@ -17,6 +17,7 @@ config DEBUG_VERBOSE config DEBUG_MMRS tristate "Generate Blackfin MMR tree" + depends on !PINCTRL select DEBUG_FS help Create a tree of Blackfin MMRs via the debugfs tree. If
drivers/pinctrl/Kconfig +2 -1
@@ -28,7 +28,8 @@ config DEBUG_PINCTRL config PINCTRL_ADI2 bool "ADI pin controller driver" - depends on BLACKFIN + depends on (BF54x || BF60x) + depends on !GPIO_ADI select PINMUX select IRQ_DOMAIN help
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] IB/ipoib: Grab rtnl lock on heavy flush when calling ndo_open/stop
In reply to Sasha LevinFrom: Alex Vesker <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit b4b678b06f6eef18bff44a338c01870234db0bc9 ]
When ndo_open and ndo_stop are called RTNL lock should be held. In this specific case ipoib_ib_dev_open calls the offloaded ndo_open which re-sets the number of TX queue assuming RTNL lock is held. Since RTNL lock is not held, RTNL assert will fail.
--- drivers/infiniband/ulp/ipoib/ipoib_ib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/ipoib/ipoib_ib.c +6 -1
@@ -1052,10 +1052,15 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,ipoib_ib_dev_down (dev);if (level ==IPOIB_FLUSH_HEAVY ) { +rtnl_lock ();if (test_bit (IPOIB_FLAG_INITIALIZED , &priv->flags))ipoib_ib_dev_stop (dev); -if (ipoib_ib_dev_open (dev) !=0 ) + + result =ipoib_ib_dev_open (dev); +rtnl_unlock (); +if (result)return ; +if (netif_queue_stopped (dev))netif_start_queue (dev); }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] gcov: add support for GCC 5.1
In reply to Sasha LevinFrom: Lorenzo Stoakes <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3e44c471a2dab210f7e9b1e5f7d4d54d52df59eb ]
Fix kernel gcov support for GCC 5.1. Similar to commit a992bf836f9 ("gcov: add support for GCC 4.9"), this patch takes into account the existence of a new gcov counter (see gcc's gcc/gcov-counter.def.)
Firstly, it increments GCOV_COUNTERS (to 10), which makes the data structure struct gcov_info compatible with GCC 5.1.
Secondly, a corresponding counter function __gcov_merge_icall_topn (Top N value tracking for indirect calls) is included in base.c with the other gcov counters unused for kernel profiling.
--- kernel/gcov/base.c | 6 ++++++ kernel/gcov/gcc_4_7.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
kernel/gcov/base.c +6 -0
@@ -92,6 +92,12 @@ void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters) }EXPORT_SYMBOL (__gcov_merge_time_profile); +void __gcov_merge_icall_topn (gcov_type *counters,unsigned int n_counters) +{ +/* Unused. */ +} +EXPORT_SYMBOL (__gcov_merge_icall_topn); +/** * gcov_enable_events - enable event reporting through gcov_event() *
kernel/gcov/gcc_4_7.c +3 -1
@@ -18,7 +18,9 @@#include <linux/vmalloc.h> #include "gcov.h" -#if __GNUC__ ==4 && __GNUC_MINOR__ >=9 +#if __GNUC__ ==5 && __GNUC_MINOR__ >=1 +#define GCOV_COUNTERS 10 +#elif __GNUC__ ==4 && __GNUC_MINOR__ >=9 #define GCOV_COUNTERS 9#else #define GCOV_COUNTERS 8
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] raid5: Set R5_Expanded on parity devices as well as data.
In reply to Sasha LevinFrom: NeilBrown <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 235b6003fb28f0dd8e7ed8fbdb088bb548291766 ]
When reshaping a fully degraded raid5/raid6 to a larger nubmer of devices, the new device(s) are not in-sync and so that can make the newly grown stripe appear to be "failed".
To avoid this, we set the R5_Expanded flag to say "Even though this device is not fully in-sync, this block is safe so don't treat the device as failed for this stripe". This flag is set for data devices, not not for parity devices.
Consequently, if you have a RAID6 with two devices that are partly recovered and a spare, and start a reshape to include the spare, then when the reshape gets past the point where the recovery was up to, it will think the stripes are failed and will get into an infinite loop, failing to make progress.
So when contructing parity on an EXPAND_READY stripe, set R5_Expanded.
--- drivers/md/raid5.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/raid5.c +4 -1
@@ -1679,8 +1679,11 @@ static void ops_complete_reconstruct(void *stripe_head_ref)struct r5dev *dev = &sh->dev[i];if (dev->written || i == pd_idx || i == qd_idx) { -if (!discard && !test_bit (R5_SkipCopy, &dev->flags)) +if (!discard && !test_bit (R5_SkipCopy, &dev->flags)) {set_bit (R5_UPTODATE , &dev->flags); +if (test_bit (STRIPE_EXPAND_READY , &sh->state)) +set_bit (R5_Expanded, &dev->flags); + }if (fua)set_bit (R5_WantFUA, &dev->flags);if (sync)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] irda: fix overly long udelay()
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit c9bd28233b6d0d82ac3ba0215723be0a8262c39c ]
irda_get_mtt() returns a hardcoded '10000' in some cases, and with gcc-7, we get a build error because this triggers a compile-time check in udelay():
drivers/net/irda/w83977af_ir.o: In function `w83977af_hard_xmit':
w83977af_ir.c:(.text.w83977af_hard_xmit+0x14c): undefined reference to `__bad_udelay'
Older compilers did not run into this because they either did not completely inline the irda_get_mtt() or did not consider the 10000 value a constant expression.
The code has been wrong since the start of git history.
--- drivers/net/irda/w83977af_ir.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/irda/w83977af_ir.c +3 -1
@@ -518,7 +518,9 @@ static netdev_tx_t w83977af_hard_xmit(struct sk_buff *skb, mtt =irda_get_mtt (skb);pr_debug ("%s(%ld), mtt=%d\n" , __func__ , jiffies, mtt); -if (mtt) +if (mtt >1000 ) +mdelay (mtt/1000 ); +else if (mtt)udelay (mtt);/* Enable DMA interrupt */
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ath9k: fix tx99 potential info leak
In reply to Sasha LevinFrom: Miaoqing Pan <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit ee0a47186e2fa9aa1c56cadcea470ca0ba8c8692 ]
When the user sets count to zero the string buffer would remain completely uninitialized which causes the kernel to parse its own stack data, potentially leading to an info leak. In addition to that, the string might be not terminated properly when the user data does not contain a 0-terminator.
--- drivers/net/wireless/ath/ath9k/tx99.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/tx99.c +5 -0
@@ -180,6 +180,9 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,ssize_t len;int r; +if (count <1 ) +return -EINVAL ; +if (sc->cur_chan->nvifs >1 )return -EOPNOTSUPP ;
@@ -187,6 +190,8 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,if (copy_from_user (buf, user_buf, len))return -EFAULT ; + buf[len] ='\0' ; +if (strtobool (buf, &start))return -EINVAL ;
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] scsi: scsi_devinfo: Add REPORTLUN2 to EMC SYMMETRIX blacklist entry
In reply to Sasha LevinFrom: Kurt Garloff <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 909cf3e16a5274fe2127cf3cea5c8dba77b2c412 ]
All EMC SYMMETRIX support REPORT_LUNS, even if configured to report SCSI-2 for whatever reason.
--- drivers/scsi/scsi_devinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_devinfo.c +1 -1
@@ -160,7 +160,7 @@ static struct { {"DGC", "RAID", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, storage on LUN 0 */ {"DGC", "DISK", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, no storage on LUN 0 */ {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, - {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN}, + {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_REPORTLUN2}, {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN}, {"easyRAID", "16P", NULL, BLIST_NOREPORTLUN}, {"easyRAID", "X6P", NULL, BLIST_NOREPORTLUN},
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] disable new gcc-7.1.1 warnings for now
In reply to Sasha LevinFrom: Linus Torvalds <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit bd664f6b3e376a8ef4990f87d08271cc2d01ba9a ]
I made the mistake of upgrading my desktop to the new Fedora 26 that comes with gcc-7.1.1.
There's nothing wrong per se that I've noticed, but I now have 1500 lines of warnings, mostly from the new format-truncation warning triggering all over the tree.
We use 'snprintf()' and friends in a lot of places, and often know that the numbers are fairly small (ie a controller index or similar), but gcc doesn't know that, and sees an 'int', and thinks that it could be some huge number. And then complains when our buffers are not able to fit the name for the ten millionth controller.
These warnings aren't necessarily bad per se, and we probably want to look through them subsystem by subsystem, but at least during the merge window they just mean that I can't even see if somebody is introducing any *real* problems when I pull.
So warnings disabled for now.
--- Makefile | 4 ++++ 1 file changed, 4 insertions(+)
Makefile +4 -0
@@ -612,6 +612,10 @@ include arch/$(SRCARCH)/Makefile KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_AFLAGS += $(call cc-option,-fno-PIE) +KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) +KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] vt6655: Fix a possible sleep-in-atomic bug in vt6655_suspend
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 42c8eb3f6e15367981b274cb79ee4657e2c6949d ]
The driver may sleep under a spinlock, and the function call path is:vt6655_suspend (acquire the spinlock)
pci_set_power_state
__pci_start_power_transition (drivers/pci/pci.c)
msleep --> may sleepTo fix it, pci_set_power_state is called without having a spinlock.
This bug is found by my static analysis tool and my code review.
--- drivers/staging/vt6655/device_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/vt6655/device_main.c +2 -1
@@ -1838,10 +1838,11 @@ static int vt6655_suspend(struct pci_dev *pcid, pm_message_t state)MACbShutdown (priv->PortOffset);pci_disable_device (pcid); -pci_set_power_state (pcid,pci_choose_state (pcid, state));spin_unlock_irqrestore (&priv->lock, flags); +pci_set_power_state (pcid,pci_choose_state (pcid, state)); +return 0 ; }
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] net: tulip: turn compile-time warning into dev_warn()
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit de92718883ddbcd11b738d36ffcf57617b97fa12 ]
The tulip driver causes annoying build-time warnings for allmodconfig builds for all recent architectures:
dec/tulip/winbond-840.c:910:2: warning: #warning Processor architecture undefined dec/tulip/tulip_core.c:101:2: warning: #warning Processor architecture undefined!
This is the last remaining warning for arm64, and I'd like to get rid of it. We don't really know the cache line size, architecturally it would be at least 16 bytes, but all implementations I found have 64 or 128 bytes. Configuring tulip for 32-byte lines as we do on ARM32 seems to be the safe but slow default, and nobody who cares about performance these days would use a tulip chip anyway, so we can just use that.
To save the next person the job of trying to find out what this is for and picking a default for their architecture just to kill off the warning, I'm now removing the preprocessor #warning and turning it into a pr_warn or dev_warn that prints the equivalent information when the driver gets loaded.
--- drivers/net/ethernet/dec/tulip/tulip_core.c | 9 +++++++-- drivers/net/ethernet/dec/tulip/winbond-840.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/dec/tulip/tulip_core.c +7 -2
@@ -98,8 +98,7 @@ static int csr0 = 0x01A00000 | 0x4800;#elif defined(__mips__)static int csr0 =0x00200000 |0x4000 ;#else -#warning Processor architecture undefined! -static int csr0 =0x00A00000 |0x4800 ; +static int csr0;#endif /* Operational parameters that usually are not changed. */
@@ -1982,6 +1981,12 @@ static int __init tulip_init (void)pr_info ("%s" , version);#endif +if (!csr0) { +pr_warn ("tulip: unknown CPU architecture, using default csr0\n" ); +/* default to 8 longword cache line alignment */ + csr0 =0x00A00000 |0x4800 ; + } +/* copy module parms into globals */ tulip_rx_copybreak = rx_copybreak; tulip_max_interrupt_work = max_interrupt_work;
drivers/net/ethernet/dec/tulip/winbond-840.c +1 -1
@@ -907,7 +907,7 @@ static void init_registers(struct net_device *dev)#elif defined(CONFIG_SPARC ) || defined (CONFIG_PARISC ) || defined(CONFIG_ARM ) i |=0x4800 ;#else -#warning Processor architecture undefined +dev_warn (&dev->dev,"unknown CPU architecture, using default csr0 setting\n" ); i |=0x4800 ;#endif iowrite32 (i, ioaddr + PCIBusCfg);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ARM: ux500: fix prcmu_is_cpu_in_wfi() calculation
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit f0e8faa7a5e894b0fc99d24be1b18685a92ea466 ]
This function clearly never worked and always returns true, as pointed out by gcc-7:
arch/arm/mach-ux500/pm.c: In function 'prcmu_is_cpu_in_wfi':arch/arm/mach-ux500/pm.c:137:212: error: ?:
using integer constants in boolean context, the expression will always evaluate to 'true' [-Werror=int-in-bool-context]
With the added braces, the condition actually makes sense.
--- arch/arm/mach-ux500/pm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-ux500/pm.c +2 -2
@@ -132,8 +132,8 @@ bool prcmu_pending_irq(void)*/ bool prcmu_is_cpu_in_wfi (int cpu) { -return readl (PRCM_ARM_WFI_STANDBY ) & cpu ?PRCM_ARM_WFI_STANDBY_WFI1 : -PRCM_ARM_WFI_STANDBY_WFI0 ; +return readl (PRCM_ARM_WFI_STANDBY ) & + (cpu ?PRCM_ARM_WFI_STANDBY_WFI1 :PRCM_ARM_WFI_STANDBY_WFI0 ); }/*
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] scsi: bfa: integer overflow in debugfs
In reply to Sasha LevinFrom: Dan Carpenter <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 3e351275655d3c84dc28abf170def9786db5176d ]
We could allocate less memory than intended because we do:
bfad->regdata = kzalloc(len << 2, GFP_KERNEL);
The shift can overflow leading to a crash. This is debugfs code so the impact is very small. I fixed the network version of this in March with commit 13e2d5187f6b ("bna: integer overflow bug in debugfs").
--- drivers/scsi/bfa/bfad_debugfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/bfa/bfad_debugfs.c +3 -2
@@ -254,7 +254,8 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,struct bfad_s *bfad = port->bfad;struct bfa_s *bfa = &bfad->bfa;struct bfa_ioc_s *ioc = &bfa->ioc; -int addr, len, rc, i; +int addr, rc, i; +u32 len;u32 *regbuf;void __iomem *rb, *reg_addr;unsigned long flags;
@@ -265,7 +266,7 @@ bfad_debugfs_write_regrd(struct file *file, const char __user *buf,return PTR_ERR (kern_buf); rc =sscanf (kern_buf,"%x:%x" , &addr, &len); -if (rc <2 ) { +if (rc <2 || len > (UINT_MAX >>2 )) {printk (KERN_INFO "bfad[%d]: %s failed to read user buf\n" , bfad->inst_no, __func__);
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] gcov: support GCC 7.1
In reply to Sasha LevinFrom: Martin Liska <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 05384213436ab690c46d9dfec706b80ef8d671ab ]
Starting from GCC 7.1, __gcov_exit is a new symbol expected to be implemented in a profiling runtime.
--- kernel/gcov/base.c | 6 ++++++ kernel/gcov/gcc_4_7.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
kernel/gcov/base.c +6 -0
@@ -98,6 +98,12 @@ void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters) }EXPORT_SYMBOL (__gcov_merge_icall_topn); +void __gcov_exit (void ) +{ +/* Unused. */ +} +EXPORT_SYMBOL (__gcov_exit); +/** * gcov_enable_events - enable event reporting through gcov_event() *
kernel/gcov/gcc_4_7.c +3 -1
@@ -18,7 +18,9 @@#include <linux/vmalloc.h> #include "gcov.h" -#if (__GNUC__ >5 ) || (__GNUC__ ==5 && __GNUC_MINOR__ >=1 ) +#if (__GNUC__ >=7 ) +#define GCOV_COUNTERS 9 +#elif (__GNUC__ >5 ) || (__GNUC__ ==5 && __GNUC_MINOR__ >=1 )#define GCOV_COUNTERS 10#elif __GNUC__ ==4 && __GNUC_MINOR__ >=9 #define GCOV_COUNTERS 9
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] gpio: 74xx: Fix build warning about void to integer cast
In reply to Sasha LevinFrom: Nicholas Krause <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 54442658d8e83b0589731620bd958cc8b2857167 ]
This fixes the build warning , warning: cast from pointer to integer of different size when building this file on a x86 allmodconfig configuration. In order for me to fix this build warning I changed the cast in the function mmio_74xx_gpio_probe from casting the variable data of the stucture pointer of_id to uintptr_t rather then unsigned when assigning to the variable flag of the structure pointer priv of the structure type mmio_74xx_gpio_priv.
--- drivers/gpio/gpio-74xx-mmio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-74xx-mmio.c +1 -1
@@ -129,7 +129,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)if (IS_ERR (dat))return PTR_ERR (dat); - priv->flags = (unsigned )of_id->data; + priv->flags = (uintptr_t ) of_id->data; err = bgpio_init(&priv->bgc, &pdev->dev, DIV_ROUND_UP(MMIO_74XX_BIT_CNT(priv->flags), 8),
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] bitops.h: add sign_extend64()
In reply to Sasha LevinFrom: Martin Kepplinger <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit 48e203e21b29cd4b2c58403fe8bca68e2e854895 ]
Months back, this was discussed, see https://lkml.org/lkml/2015/1/18/289
The result was the 64-bit version being "likely fine", "valuable" and "correct". The discussion fell asleep but since there are possible users, let's add it.
--- include/linux/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
include/linux/bitops.h +11 -0
@@ -171,6 +171,17 @@ static inline __s32 sign_extend32(__u32 value, int index)return (__s32)(value << shift) >> shift; } +/** +* sign_extend64 - sign extend a 64-bit value using specified bit as sign-bit +* @value: value to sign extend +* @index: 0 based bit index (0<=index<64) to sign bit +*/ +static inline __s64 sign_extend64 (__u64 value,int index) +{ +__u8 shift =63 - index; +return (__s64)(value << shift) >> shift; +} +static inline unsigned fls_long (unsigned long l) {if (sizeof (l) ==4 )
Signature · 1 line
2.11.0
[added to the 4.1 stable tree] ARM: 8584/1: floppy: avoid gcc-6 warning
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
This patch has been added to the stable tree. If you have any objections, please let us know.
===============
[ Upstream commit dd665be0e243873343a28e18f9f345927b658daf ]
gcc-6.0 warns about comparisons between two identical expressions, which is what we get in the floppy driver when writing to the FD_DOR register:
drivers/block/floppy.c: In function 'set_dor':drivers/block/floppy.c:810:44: error: self-comparison always evaluates to true [-Werror=tautological-compare]
fd_outb(newdor, FD_DOR);
It would be nice to use a static inline function instead of the macro, to avoid the warning, but we cannot do that because the FD_DOR definition is incomplete at this point.
Adding a cast to (u32) is a harmless way to shut up the warning, just not very nice.
--- arch/arm/include/asm/floppy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/floppy.h +1 -1
@@ -17,7 +17,7 @@#define fd_outb (val,port) \ do { \ - if ((port) == FD_DOR) \ + if ((port) == (u32)FD_DOR) \ fd_setdor((val)); \ else \ outb((val),(port)); \
Signature · 1 line
2.11.0