1. 20 May, 2020 40 commits
    • John Stultz's avatar
      dwc3: Remove check for HWO flag in dwc3_gadget_ep_reclaim_trb_sg() · 5ac0e17e
      John Stultz authored
      commit 00e21763 upstream.
      
      The check for the HWO flag in dwc3_gadget_ep_reclaim_trb_sg()
      causes us to break out of the loop before we call
      dwc3_gadget_ep_reclaim_completed_trb(), which is what likely
      should be clearing the HWO flag.
      
      This can cause odd behavior where we never reclaim all the trbs
      in the sg list, so we never call giveback on a usb req, and that
      will causes transfer stalls.
      
      This effectively resovles the adb stalls seen on HiKey960
      after userland changes started only using AIO in adbd.
      
      Cc: YongQin Liu <yongqin.liu@linaro.org>
      Cc: Anurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>
      Cc: Yang Fei <fei.yang@intel.com>
      Cc: Thinh Nguyen <thinhn@synopsys.com>
      Cc: Tejas Joglekar <tejas.joglekar@synopsys.com>
      Cc: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
      Cc: Jack Pham <jackp@codeaurora.org>
      Cc: Josh Gao <jmgao@google.com>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: linux-usb@vger.kernel.org
      Cc: stable@vger.kernel.org #4.20+
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5ac0e17e
    • Justin Swartz's avatar
      clk: rockchip: fix incorrect configuration of rk3228 aclk_gpu* clocks · 4ebb32ef
      Justin Swartz authored
      commit cec9d101 upstream.
      
      The following changes prevent the unrecoverable freezes and rcu_sched
      stall warnings experienced in each of my attempts to take advantage of
      lima.
      
      Replace the COMPOSITE_NOGATE definition of aclk_gpu_pre with a
      COMPOSITE that retains the selection of HDMIPHY as the PLL source, but
      instead makes uses of the aclk_gpu PLL source gate and parent names
      defined by mux_pll_src_4plls_p rather than mux_aclk_gpu_pre_p.
      
      Remove the now unused mux_aclk_gpu_pre_p and the four named but also
      unused definitions (cpll_gpu, gpll_gpu, hdmiphy_gpu and usb480m_gpu)
      of the aclk_gpu PLL source gate.
      
      Use the correct gate offset for aclk_gpu and aclk_gpu_noc.
      
      Fixes: 307a2e9a ("clk: rockchip: add clock controller for rk3228")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJustin Swartz <justin.swartz@risingedge.co.za>
      [double-checked against SoC manual and added fixes tag]
      Link: https://lore.kernel.org/r/20200114162503.7548-1-justin.swartz@risingedge.co.zaSigned-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4ebb32ef
    • Eric W. Biederman's avatar
      exec: Move would_dump into flush_old_exec · bfdb1828
      Eric W. Biederman authored
      commit f87d1c95 upstream.
      
      I goofed when I added mm->user_ns support to would_dump.  I missed the
      fact that in the case of binfmt_loader, binfmt_em86, binfmt_misc, and
      binfmt_script bprm->file is reassigned.  Which made the move of
      would_dump from setup_new_exec to __do_execve_file before exec_binprm
      incorrect as it can result in would_dump running on the script instead
      of the interpreter of the script.
      
      The net result is that the code stopped making unreadable interpreters
      undumpable.  Which allows them to be ptraced and written to disk
      without special permissions.  Oops.
      
      The move was necessary because the call in set_new_exec was after
      bprm->mm was no longer valid.
      
      To correct this mistake move the misplaced would_dump from
      __do_execve_file into flos_old_exec, before exec_mmap is called.
      
      I tested and confirmed that without this fix I can attach with gdb to
      a script with an unreadable interpreter, and with this fix I can not.
      
      Cc: stable@vger.kernel.org
      Fixes: f84df2a6 ("exec: Ensure mm->user_ns contains the execed files")
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bfdb1828
    • Josh Poimboeuf's avatar
      x86/unwind/orc: Fix error handling in __unwind_start() · 7f95c110
      Josh Poimboeuf authored
      commit 71c95825 upstream.
      
      The unwind_state 'error' field is used to inform the reliable unwinding
      code that the stack trace can't be trusted.  Set this field for all
      errors in __unwind_start().
      
      Also, move the zeroing out of the unwind_state struct to before the ORC
      table initialization check, to prevent the caller from reading
      uninitialized data if the ORC table is corrupted.
      
      Fixes: af085d90 ("stacktrace/x86: add function for detecting reliable stack traces")
      Fixes: d3a09104 ("x86/unwinder/orc: Dont bail on stack overflow")
      Fixes: 98d0c8eb ("x86/unwind/orc: Prevent unwinding before ORC initialization")
      Reported-by: default avatarPavel Machek <pavel@denx.de>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/d6ac7215a84ca92b895fdd2e1aa546729417e6e6.1589487277.git.jpoimboe@redhat.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f95c110
    • Borislav Petkov's avatar
      x86: Fix early boot crash on gcc-10, third try · 15b4f26b
      Borislav Petkov authored
      commit a9a3ed1e upstream.
      
      ... or the odyssey of trying to disable the stack protector for the
      function which generates the stack canary value.
      
      The whole story started with Sergei reporting a boot crash with a kernel
      built with gcc-10:
      
        Kernel panic — not syncing: stack-protector: Kernel stack is corrupted in: start_secondary
        CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.6.0-rc5—00235—gfffb08b3 #139
        Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./H77M—D3H, BIOS F12 11/14/2013
        Call Trace:
          dump_stack
          panic
          ? start_secondary
          __stack_chk_fail
          start_secondary
          secondary_startup_64
        -—-[ end Kernel panic — not syncing: stack—protector: Kernel stack is corrupted in: start_secondary
      
      This happens because gcc-10 tail-call optimizes the last function call
      in start_secondary() - cpu_startup_entry() - and thus emits a stack
      canary check which fails because the canary value changes after the
      boot_init_stack_canary() call.
      
      To fix that, the initial attempt was to mark the one function which
      generates the stack canary with:
      
        __attribute__((optimize("-fno-stack-protector"))) ... start_secondary(void *unused)
      
      however, using the optimize attribute doesn't work cumulatively
      as the attribute does not add to but rather replaces previously
      supplied optimization options - roughly all -fxxx options.
      
      The key one among them being -fno-omit-frame-pointer and thus leading to
      not present frame pointer - frame pointer which the kernel needs.
      
      The next attempt to prevent compilers from tail-call optimizing
      the last function call cpu_startup_entry(), shy of carving out
      start_secondary() into a separate compilation unit and building it with
      -fno-stack-protector, was to add an empty asm("").
      
      This current solution was short and sweet, and reportedly, is supported
      by both compilers but we didn't get very far this time: future (LTO?)
      optimization passes could potentially eliminate this, which leads us
      to the third attempt: having an actual memory barrier there which the
      compiler cannot ignore or move around etc.
      
      That should hold for a long time, but hey we said that about the other
      two solutions too so...
      Reported-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Tested-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lkml.kernel.org/r/20200314164451.346497-1-slyfox@gentoo.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15b4f26b
    • Adam McCoy's avatar
      cifs: fix leaked reference on requeued write · ad149b6e
      Adam McCoy authored
      commit a4813799 upstream.
      
      Failed async writes that are requeued may not clean up a refcount
      on the file, which can result in a leaked open. This scenario arises
      very reliably when using persistent handles and a reconnect occurs
      while writing.
      
      cifs_writev_requeue only releases the reference if the write fails
      (rc != 0). The server->ops->async_writev operation will take its own
      reference, so the initial reference can always be released.
      Signed-off-by: default avatarAdam McCoy <adam@forsedomani.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad149b6e
    • Fabio Estevam's avatar
      ARM: dts: imx27-phytec-phycard-s-rdk: Fix the I2C1 pinctrl entries · 643ca709
      Fabio Estevam authored
      commit 0caf3435 upstream.
      
      The I2C2 pins are already used and the following errors are seen:
      
      imx27-pinctrl 10015000.iomuxc: pin MX27_PAD_I2C2_SDA already requested by 10012000.i2c; cannot claim for 1001d000.i2c
      imx27-pinctrl 10015000.iomuxc: pin-69 (1001d000.i2c) status -22
      imx27-pinctrl 10015000.iomuxc: could not request pin 69 (MX27_PAD_I2C2_SDA) from group i2c2grp  on device 10015000.iomuxc
      imx-i2c 1001d000.i2c: Error applying setting, reverse things back
      imx-i2c: probe of 1001d000.i2c failed with error -22
      
      Fix it by adding the correct I2C1 IOMUX entries for the pinctrl_i2c1 group.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 61664d0b ("ARM: dts: imx27 phyCARD-S pinctrl")
      Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
      Reviewed-by: default avatarStefan Riedmueller <s.riedmueller@phytec.de>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      643ca709
    • Kishon Vijay Abraham I's avatar
      ARM: dts: dra7: Fix bus_dma_limit for PCIe · 7abecb94
      Kishon Vijay Abraham I authored
      commit 90d4d3f4 upstream.
      
      Even though commit cfb5d65f ("ARM: dts: dra7: Add bus_dma_limit
      for L3 bus") added bus_dma_limit for L3 bus, the PCIe controller
      gets incorrect value of bus_dma_limit.
      
      Fix it by adding empty dma-ranges property to axi@0 and axi@1
      (parent device tree node of PCIe controller).
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7abecb94
    • Sriharsha Allenki's avatar
      usb: xhci: Fix NULL pointer dereference when enqueuing trbs from urb sg list · 563cdec8
      Sriharsha Allenki authored
      commit 3c6f8cb9 upstream.
      
      On platforms with IOMMU enabled, multiple SGs can be coalesced into one
      by the IOMMU driver. In that case the SG list processing as part of the
      completion of a urb on a bulk endpoint can result into a NULL pointer
      dereference with the below stack dump.
      
      <6> Unable to handle kernel NULL pointer dereference at virtual address 0000000c
      <6> pgd = c0004000
      <6> [0000000c] *pgd=00000000
      <6> Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      <2> PC is at xhci_queue_bulk_tx+0x454/0x80c
      <2> LR is at xhci_queue_bulk_tx+0x44c/0x80c
      <2> pc : [<c08907c4>]    lr : [<c08907bc>]    psr: 000000d3
      <2> sp : ca337c80  ip : 00000000  fp : ffffffff
      <2> r10: 00000000  r9 : 50037000  r8 : 00004000
      <2> r7 : 00000000  r6 : 00004000  r5 : 00000000  r4 : 00000000
      <2> r3 : 00000000  r2 : 00000082  r1 : c2c1a200  r0 : 00000000
      <2> Flags: nzcv  IRQs off  FIQs off  Mode SVC_32  ISA ARM  Segment none
      <2> Control: 10c0383d  Table: b412c06a  DAC: 00000051
      <6> Process usb-storage (pid: 5961, stack limit = 0xca336210)
      <snip>
      <2> [<c08907c4>] (xhci_queue_bulk_tx)
      <2> [<c0881b3c>] (xhci_urb_enqueue)
      <2> [<c0831068>] (usb_hcd_submit_urb)
      <2> [<c08350b4>] (usb_sg_wait)
      <2> [<c089f384>] (usb_stor_bulk_transfer_sglist)
      <2> [<c089f2c0>] (usb_stor_bulk_srb)
      <2> [<c089fe38>] (usb_stor_Bulk_transport)
      <2> [<c089f468>] (usb_stor_invoke_transport)
      <2> [<c08a11b4>] (usb_stor_control_thread)
      <2> [<c014a534>] (kthread)
      
      The above NULL pointer dereference is the result of block_len and the
      sent_len set to zero after the first SG of the list when IOMMU driver
      is enabled. Because of this the loop of processing the SGs has run
      more than num_sgs which resulted in a sg_next on the last SG of the
      list which has SG_END set.
      
      Fix this by check for the sg before any attributes of the sg are
      accessed.
      
      [modified reason for null pointer dereference in commit message subject -Mathias]
      Fixes: f9c589e1 ("xhci: TD-fragment, align the unsplittable case with a bounce buffer")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20200514110432.25564-2-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      563cdec8
    • Kyungtae Kim's avatar
      USB: gadget: fix illegal array access in binding with UDC · a105bb54
      Kyungtae Kim authored
      commit 15753588 upstream.
      
      FuzzUSB (a variant of syzkaller) found an illegal array access
      using an incorrect index while binding a gadget with UDC.
      
      Reference: https://www.spinics.net/lists/linux-usb/msg194331.html
      
      This bug occurs when a size variable used for a buffer
      is misused to access its strcpy-ed buffer.
      Given a buffer along with its size variable (taken from user input),
      from which, a new buffer is created using kstrdup().
      Due to the original buffer containing 0 value in the middle,
      the size of the kstrdup-ed buffer becomes smaller than that of the original.
      So accessing the kstrdup-ed buffer with the same size variable
      triggers memory access violation.
      
      The fix makes sure no zero value in the buffer,
      by comparing the strlen() of the orignal buffer with the size variable,
      so that the access to the kstrdup-ed buffer is safe.
      
      BUG: KASAN: slab-out-of-bounds in gadget_dev_desc_UDC_store+0x1ba/0x200
      drivers/usb/gadget/configfs.c:266
      Read of size 1 at addr ffff88806a55dd7e by task syz-executor.0/17208
      
      CPU: 2 PID: 17208 Comm: syz-executor.0 Not tainted 5.6.8 #1
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0xce/0x128 lib/dump_stack.c:118
       print_address_description.constprop.4+0x21/0x3c0 mm/kasan/report.c:374
       __kasan_report+0x131/0x1b0 mm/kasan/report.c:506
       kasan_report+0x12/0x20 mm/kasan/common.c:641
       __asan_report_load1_noabort+0x14/0x20 mm/kasan/generic_report.c:132
       gadget_dev_desc_UDC_store+0x1ba/0x200 drivers/usb/gadget/configfs.c:266
       flush_write_buffer fs/configfs/file.c:251 [inline]
       configfs_write_file+0x2f1/0x4c0 fs/configfs/file.c:283
       __vfs_write+0x85/0x110 fs/read_write.c:494
       vfs_write+0x1cd/0x510 fs/read_write.c:558
       ksys_write+0x18a/0x220 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __x64_sys_write+0x73/0xb0 fs/read_write.c:620
       do_syscall_64+0x9e/0x510 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      Signed-off-by: default avatarKyungtae Kim <kt0755@gmail.com>
      Reported-and-tested-by: default avatarKyungtae Kim <kt0755@gmail.com>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200510054326.GA19198@pizza01Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a105bb54
    • Li Jun's avatar
      usb: host: xhci-plat: keep runtime active when removing host · 8fd38d31
      Li Jun authored
      commit 1449cb2c upstream.
      
      While removing the host (e.g. for USB role switch from host to device),
      if runtime pm is enabled by user, below oops occurs on dwc3 and cdns3
      platforms.
      Keeping the xhci-plat device active during host removal, and disabling
      runtime pm before calling pm_runtime_set_suspended() fixes them.
      
      oops1:
      Unable to handle kernel NULL pointer dereference at virtual address
      0000000000000240
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 5 Comm: kworker/0:0 Not tainted 5.4.3-00107-g64d454a-dirty
      Hardware name: FSL i.MX8MP EVK (DT)
      Workqueue: pm pm_runtime_work
      pstate: 60000005 (nZCv daif -PAN -UAO)
      pc : xhci_suspend+0x34/0x698
      lr : xhci_plat_runtime_suspend+0x2c/0x38
      sp : ffff800011ddbbc0
      Call trace:
       xhci_suspend+0x34/0x698
       xhci_plat_runtime_suspend+0x2c/0x38
       pm_generic_runtime_suspend+0x28/0x40
       __rpm_callback+0xd8/0x138
       rpm_callback+0x24/0x98
       rpm_suspend+0xe0/0x448
       rpm_idle+0x124/0x140
       pm_runtime_work+0xa0/0xf8
       process_one_work+0x1dc/0x370
       worker_thread+0x48/0x468
       kthread+0xf0/0x120
       ret_from_fork+0x10/0x1c
      
      oops2:
      usb 2-1: USB disconnect, device number 2
      xhci-hcd xhci-hcd.1.auto: remove, state 4
      usb usb2: USB disconnect, device number 1
      xhci-hcd xhci-hcd.1.auto: USB bus 2 deregistered
      xhci-hcd xhci-hcd.1.auto: remove, state 4
      usb usb1: USB disconnect, device number 1
      Unable to handle kernel NULL pointer dereference at virtual address
      0000000000000138
      Internal error: Oops: 96000004 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 2 PID: 7 Comm: kworker/u8:0 Not tainted 5.6.0-rc4-next-20200304-03578
      Hardware name: Freescale i.MX8QXP MEK (DT)
      Workqueue: 1-0050 tcpm_state_machine_work
      pstate: 20000005 (nzCv daif -PAN -UAO)
      pc : xhci_free_dev+0x214/0x270
      lr : xhci_plat_runtime_resume+0x78/0x88
      sp : ffff80001006b5b0
      Call trace:
       xhci_free_dev+0x214/0x270
       xhci_plat_runtime_resume+0x78/0x88
       pm_generic_runtime_resume+0x30/0x48
       __rpm_callback+0x90/0x148
       rpm_callback+0x28/0x88
       rpm_resume+0x568/0x758
       rpm_resume+0x260/0x758
       rpm_resume+0x260/0x758
       __pm_runtime_resume+0x40/0x88
       device_release_driver_internal+0xa0/0x1c8
       device_release_driver+0x1c/0x28
       bus_remove_device+0xd4/0x158
       device_del+0x15c/0x3a0
       usb_disable_device+0xb0/0x268
       usb_disconnect+0xcc/0x300
       usb_remove_hcd+0xf4/0x1dc
       xhci_plat_remove+0x78/0xe0
       platform_drv_remove+0x30/0x50
       device_release_driver_internal+0xfc/0x1c8
       device_release_driver+0x1c/0x28
       bus_remove_device+0xd4/0x158
       device_del+0x15c/0x3a0
       platform_device_del.part.0+0x20/0x90
       platform_device_unregister+0x28/0x40
       cdns3_host_exit+0x20/0x40
       cdns3_role_stop+0x60/0x90
       cdns3_role_set+0x64/0xd8
       usb_role_switch_set_role.part.0+0x3c/0x68
       usb_role_switch_set_role+0x20/0x30
       tcpm_mux_set+0x60/0xf8
       tcpm_reset_port+0xa4/0xf0
       tcpm_detach.part.0+0x28/0x50
       tcpm_state_machine_work+0x12ac/0x2360
       process_one_work+0x1c8/0x470
       worker_thread+0x50/0x428
       kthread+0xfc/0x128
       ret_from_fork+0x10/0x18
      Code: c8037c02 35ffffa3 17ffe7c3 f9800011 (c85f7c01)
      ---[ end trace 45b1a173d2679e44 ]---
      
      [minor commit message cleanup  -Mathias]
      Cc: Baolin Wang <baolin.wang@linaro.org>
      Cc: <stable@vger.kernel.org>
      Fixes: b0c69b4b ("usb: host: plat: Enable xHCI plat runtime PM")
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Tested-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20200514110432.25564-3-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8fd38d31
    • Eugeniu Rosca's avatar
      usb: core: hub: limit HUB_QUIRK_DISABLE_AUTOSUSPEND to USB5534B · 073a30cb
      Eugeniu Rosca authored
      commit 76e1ef1d upstream.
      
      On Tue, May 12, 2020 at 09:36:07PM +0800, Kai-Heng Feng wrote [1]:
      > This patch prevents my Raven Ridge xHCI from getting runtime suspend.
      
      The problem described in v5.6 commit 1208f9e1 ("USB: hub: Fix the
      broken detection of USB3 device in SMSC hub") applies solely to the
      USB5534B hub [2] present on the Kingfisher Infotainment Carrier Board,
      manufactured by Shimafuji Electric Inc [3].
      
      Despite that, the aforementioned commit applied the quirk to _all_ hubs
      carrying vendor ID 0x424 (i.e. SMSC), of which there are more [4] than
      initially expected. Consequently, the quirk is now enabled on platforms
      carrying SMSC/Microchip hub models which potentially don't exhibit the
      original issue.
      
      To avoid reports like [1], further limit the quirk's scope to
      USB5534B [2], by employing both Vendor and Product ID checks.
      
      Tested on H3ULCB + Kingfisher rev. M05.
      
      [1] https://lore.kernel.org/linux-renesas-soc/73933975-6F0E-40F5-9584-D2B8F615C0F3@canonical.com/
      [2] https://www.microchip.com/wwwproducts/en/USB5534B
      [3] http://www.shimafuji.co.jp/wp/wp-content/uploads/2018/08/SBEV-RCAR-KF-M06Board_HWSpecificationEN_Rev130.pdf
      [4] https://devicehunt.com/search/type/usb/vendor/0424/device/any
      
      Fixes: 1208f9e1 ("USB: hub: Fix the broken detection of USB3 device in SMSC hub")
      Cc: stable@vger.kernel.org # v4.14+
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Hardik Gajjar <hgajjar@de.adit-jv.com>
      Cc: linux-renesas-soc@vger.kernel.org
      Cc: linux-usb@vger.kernel.org
      Reported-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Tested-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Link: https://lore.kernel.org/r/20200514220246.13290-1-erosca@de.adit-jv.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      073a30cb
    • Jesus Ramos's avatar
      ALSA: usb-audio: Add control message quirk delay for Kingston HyperX headset · e5c0fbcd
      Jesus Ramos authored
      commit 073919e0 upstream.
      
      Kingston HyperX headset with 0951:16ad also needs the same quirk for
      delaying the frequency controls.
      Signed-off-by: default avatarJesus Ramos <jesus-ramos@live.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/BY5PR19MB3634BA68C7CCA23D8DF428E796AF0@BY5PR19MB3634.namprd19.prod.outlook.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e5c0fbcd
    • Takashi Iwai's avatar
      ALSA: rawmidi: Fix racy buffer resize under concurrent accesses · a507658f
      Takashi Iwai authored
      commit c1f6e3c8 upstream.
      
      The rawmidi core allows user to resize the runtime buffer via ioctl,
      and this may lead to UAF when performed during concurrent reads or
      writes: the read/write functions unlock the runtime lock temporarily
      during copying form/to user-space, and that's the race window.
      
      This patch fixes the hole by introducing a reference counter for the
      runtime buffer read/write access and returns -EBUSY error when the
      resize is performed concurrently against read/write.
      
      Note that the ref count field is a simple integer instead of
      refcount_t here, since the all contexts accessing the buffer is
      basically protected with a spinlock, hence we need no expensive atomic
      ops.  Also, note that this busy check is needed only against read /
      write functions, and not in receive/transmit callbacks; the race can
      happen only at the spinlock hole mentioned in the above, while the
      whole function is protected for receive / transmit callbacks.
      Reported-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAFcO6XMWpUVK_yzzCpp8_XP7+=oUpQvuBeCbMffEDkpe8jWrfg@mail.gmail.com
      Link: https://lore.kernel.org/r/s5heerw3r5z.wl-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a507658f
    • Takashi Iwai's avatar
      ALSA: hda/realtek - Limit int mic boost for Thinkpad T530 · f8685c33
      Takashi Iwai authored
      commit b590b38c upstream.
      
      Lenovo Thinkpad T530 seems to have a sensitive internal mic capture
      that needs to limit the mic boost like a few other Thinkpad models.
      Although we may change the quirk for ALC269_FIXUP_LENOVO_DOCK, this
      hits way too many other laptop models, so let's add a new fixup model
      that limits the internal mic boost on top of the existing quirk and
      apply to only T530.
      
      BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1171293
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200514160533.10337-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8685c33
    • Linus Torvalds's avatar
      gcc-10: avoid shadowing standard library 'free()' in crypto · f81c4cc9
      Linus Torvalds authored
      commit 1a263ae6 upstream.
      
      gcc-10 has started warning about conflicting types for a few new
      built-in functions, particularly 'free()'.
      
      This results in warnings like:
      
         crypto/xts.c:325:13: warning: conflicting types for built-in function ‘free’; expected ‘void(void *)’ [-Wbuiltin-declaration-mismatch]
      
      because the crypto layer had its local freeing functions called
      'free()'.
      
      Gcc-10 is in the wrong here, since that function is marked 'static', and
      thus there is no chance of confusion with any standard library function
      namespace.
      
      But the simplest thing to do is to just use a different name here, and
      avoid this gcc mis-feature.
      
      [ Side note: gcc knowing about 'free()' is in itself not the
        mis-feature: the semantics of 'free()' are special enough that a
        compiler can validly do special things when seeing it.
      
        So the mis-feature here is that gcc thinks that 'free()' is some
        restricted name, and you can't shadow it as a local static function.
      
        Making the special 'free()' semantics be a function attribute rather
        than tied to the name would be the much better model ]
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f81c4cc9
    • Linus Torvalds's avatar
      gcc-10: disable 'restrict' warning for now · 28b0bcee
      Linus Torvalds authored
      commit adc71920 upstream.
      
      gcc-10 now warns about passing aliasing pointers to functions that take
      restricted pointers.
      
      That's actually a great warning, and if we ever start using 'restrict'
      in the kernel, it might be quite useful.  But right now we don't, and it
      turns out that the only thing this warns about is an idiom where we have
      declared a few functions to be "printf-like" (which seems to make gcc
      pick up the restricted pointer thing), and then we print to the same
      buffer that we also use as an input.
      
      And people do that as an odd concatenation pattern, with code like this:
      
          #define sysfs_show_gen_prop(buffer, fmt, ...) \
              snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__)
      
      where we have 'buffer' as both the destination of the final result, and
      as the initial argument.
      
      Yes, it's a bit questionable.  And outside of the kernel, people do have
      standard declarations like
      
          int snprintf( char *restrict buffer, size_t bufsz,
                        const char *restrict format, ... );
      
      where that output buffer is marked as a restrict pointer that cannot
      alias with any other arguments.
      
      But in the context of the kernel, that 'use snprintf() to concatenate to
      the end result' does work, and the pattern shows up in multiple places.
      And we have not marked our own version of snprintf() as taking restrict
      pointers, so the warning is incorrect for now, and gcc picks it up on
      its own.
      
      If we do start using 'restrict' in the kernel (and it might be a good
      idea if people find places where it matters), we'll need to figure out
      how to avoid this issue for snprintf and friends.  But in the meantime,
      this warning is not useful.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      28b0bcee
    • Linus Torvalds's avatar
      gcc-10: disable 'stringop-overflow' warning for now · 8a5530c2
      Linus Torvalds authored
      commit 5a76021c upstream.
      
      This is the final array bounds warning removal for gcc-10 for now.
      
      Again, the warning is good, and we should re-enable all these warnings
      when we have converted all the legacy array declaration cases to
      flexible arrays. But in the meantime, it's just noise.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a5530c2
    • Linus Torvalds's avatar
      gcc-10: disable 'array-bounds' warning for now · fa848762
      Linus Torvalds authored
      commit 44720996 upstream.
      
      This is another fine warning, related to the 'zero-length-bounds' one,
      but hitting the same historical code in the kernel.
      
      Because C didn't historically support flexible array members, we have
      code that instead uses a one-sized array, the same way we have cases of
      zero-sized arrays.
      
      The one-sized arrays come from either not wanting to use the gcc
      zero-sized array extension, or from a slight convenience-feature, where
      particularly for strings, the size of the structure now includes the
      allocation for the final NUL character.
      
      So with a "char name[1];" at the end of a structure, you can do things
      like
      
             v = my_malloc(sizeof(struct vendor) + strlen(name));
      
      and avoid the "+1" for the terminator.
      
      Yes, the modern way to do that is with a flexible array, and using
      'offsetof()' instead of 'sizeof()', and adding the "+1" by hand.  That
      also technically gets the size "more correct" in that it avoids any
      alignment (and thus padding) issues, but this is another long-term
      cleanup thing that will not happen for 5.7.
      
      So disable the warning for now, even though it's potentially quite
      useful.  Having a slew of warnings that then hide more urgent new issues
      is not an improvement.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa848762
    • Linus Torvalds's avatar
      gcc-10: disable 'zero-length-bounds' warning for now · 7f43fca7
      Linus Torvalds authored
      commit 5c45de21 upstream.
      
      This is a fine warning, but we still have a number of zero-length arrays
      in the kernel that come from the traditional gcc extension.  Yes, they
      are getting converted to flexible arrays, but in the meantime the gcc-10
      warning about zero-length bounds is very verbose, and is hiding other
      issues.
      
      I missed one actual build failure because it was hidden among hundreds
      of lines of warning.  Thankfully I caught it on the second go before
      pushing things out, but it convinced me that I really need to disable
      the new warnings for now.
      
      We'll hopefully be all done with our conversion to flexible arrays in
      the not too distant future, and we can then re-enable this warning.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f43fca7
    • Linus Torvalds's avatar
      Stop the ad-hoc games with -Wno-maybe-initialized · ec223222
      Linus Torvalds authored
      commit 78a5255f upstream.
      
      We have some rather random rules about when we accept the
      "maybe-initialized" warnings, and when we don't.
      
      For example, we consider it unreliable for gcc versions < 4.9, but also
      if -O3 is enabled, or if optimizing for size.  And then various kernel
      config options disabled it, because they know that they trigger that
      warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES).
      
      And now gcc-10 seems to be introducing a lot of those warnings too, so
      it falls under the same heading as 4.9 did.
      
      At the same time, we have a very straightforward way to _enable_ that
      warning when wanted: use "W=2" to enable more warnings.
      
      So stop playing these ad-hoc games, and just disable that warning by
      default, with the known and straight-forward "if you want to work on the
      extra compiler warnings, use W=123".
      
      Would it be great to have code that is always so obvious that it never
      confuses the compiler whether a variable is used initialized or not?
      Yes, it would.  In a perfect world, the compilers would be smarter, and
      our source code would be simpler.
      
      That's currently not the world we live in, though.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec223222
    • Masahiro Yamada's avatar
      kbuild: compute false-positive -Wmaybe-uninitialized cases in Kconfig · 9088569b
      Masahiro Yamada authored
      commit b303c6df upstream.
      
      Since -Wmaybe-uninitialized was introduced by GCC 4.7, we have patched
      various false positives:
      
       - commit e74fc973 ("Turn off -Wmaybe-uninitialized when building
         with -Os") turned off this option for -Os.
      
       - commit 815eb71e ("Kbuild: disable 'maybe-uninitialized' warning
         for CONFIG_PROFILE_ALL_BRANCHES") turned off this option for
         CONFIG_PROFILE_ALL_BRANCHES
      
       - commit a76bcf55 ("Kbuild: enable -Wmaybe-uninitialized warning
         for "make W=1"") turned off this option for GCC < 4.9
         Arnd provided more explanation in https://lkml.org/lkml/2017/3/14/903
      
      I think this looks better by shifting the logic from Makefile to Kconfig.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/350Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9088569b
    • Linus Torvalds's avatar
      gcc-10 warnings: fix low-hanging fruit · 51cc5495
      Linus Torvalds authored
      commit 9d82973e upstream.
      
      Due to a bug-report that was compiler-dependent, I updated one of my
      machines to gcc-10.  That shows a lot of new warnings.  Happily they
      seem to be mostly the valid kind, but it's going to cause a round of
      churn for getting rid of them..
      
      This is the really low-hanging fruit of removing a couple of zero-sized
      arrays in some core code.  We have had a round of these patches before,
      and we'll have many more coming, and there is nothing special about
      these except that they were particularly trivial, and triggered more
      warnings than most.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51cc5495
    • Jason Gunthorpe's avatar
      pnp: Use list_for_each_entry() instead of open coding · bd2cefcd
      Jason Gunthorpe authored
      commit 01b2bafe upstream.
      
      Aside from good practice, this avoids a warning from gcc 10:
      
      ./include/linux/kernel.h:997:3: warning: array subscript -31 is outside array bounds of ‘struct list_head[1]’ [-Warray-bounds]
        997 |  ((type *)(__mptr - offsetof(type, member))); })
            |  ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/list.h:493:2: note: in expansion of macro ‘container_of’
        493 |  container_of(ptr, type, member)
            |  ^~~~~~~~~~~~
      ./include/linux/pnp.h:275:30: note: in expansion of macro ‘list_entry’
        275 | #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
            |                              ^~~~~~~~~~
      ./include/linux/pnp.h:281:11: note: in expansion of macro ‘global_to_pnp_dev’
        281 |  (dev) != global_to_pnp_dev(&pnp_global); \
            |           ^~~~~~~~~~~~~~~~~
      arch/x86/kernel/rtc.c:189:2: note: in expansion of macro ‘pnp_for_each_dev’
        189 |  pnp_for_each_dev(dev) {
      
      Because the common code doesn't cast the starting list_head to the
      containing struct.
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      [ rjw: Whitespace adjustments ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd2cefcd
    • Samu Nuutamo's avatar
      hwmon: (da9052) Synchronize access with mfd · 89148bf7
      Samu Nuutamo authored
      [ Upstream commit 333e22db ]
      
      When tsi-as-adc is configured it is possible for in7[0123]_input read to
      return an incorrect value if a concurrent read to in[456]_input is
      performed. This is caused by a concurrent manipulation of the mux
      channel without proper locking as hwmon and mfd use different locks for
      synchronization.
      
      Switch hwmon to use the same lock as mfd when accessing the TSI channel.
      
      Fixes: 4f16cab1 ("hwmon: da9052: Add support for TSI channel")
      Signed-off-by: default avatarSamu Nuutamo <samu.nuutamo@vincit.fi>
      [rebase to current master, reword commit message slightly]
      Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      89148bf7
    • Jack Morgenstein's avatar
      IB/mlx4: Test return value of calls to ib_get_cached_pkey · 893e55eb
      Jack Morgenstein authored
      [ Upstream commit 6693ca95 ]
      
      In the mlx4_ib_post_send() flow, some functions call ib_get_cached_pkey()
      without checking its return value. If ib_get_cached_pkey() returns an
      error code, these functions should return failure.
      
      Fixes: 1ffeb2eb ("IB/mlx4: SR-IOV IB context objects and proxy/tunnel SQP support")
      Fixes: 225c7b1f ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
      Fixes: e622f2f4 ("IB: split struct ib_send_wr")
      Link: https://lore.kernel.org/r/20200426075921.130074-1-leon@kernel.orgSigned-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      893e55eb
    • Stefano Brivio's avatar
      netfilter: nft_set_rbtree: Introduce and use nft_rbtree_interval_start() · 35825430
      Stefano Brivio authored
      [ Upstream commit 6f7c9caf ]
      
      Replace negations of nft_rbtree_interval_end() with a new helper,
      nft_rbtree_interval_start(), wherever this helps to visualise the
      problem at hand, that is, for all the occurrences except for the
      comparison against given flags in __nft_rbtree_get().
      
      This gets especially useful in the next patch.
      Signed-off-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      35825430
    • Christoph Hellwig's avatar
      arm64: fix the flush_icache_range arguments in machine_kexec · 63e320a0
      Christoph Hellwig authored
      [ Upstream commit d51c2145 ]
      
      The second argument is the end "pointer", not the length.
      
      Fixes: d28f6df1 ("arm64/kexec: Add core kexec support")
      Cc: <stable@vger.kernel.org> # 4.8.x-
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      63e320a0
    • Arnd Bergmann's avatar
      netfilter: conntrack: avoid gcc-10 zero-length-bounds warning · d2413ec1
      Arnd Bergmann authored
      [ Upstream commit 2c407aca ]
      
      gcc-10 warns around a suspicious access to an empty struct member:
      
      net/netfilter/nf_conntrack_core.c: In function '__nf_conntrack_alloc':
      net/netfilter/nf_conntrack_core.c:1522:9: warning: array subscript 0 is outside the bounds of an interior zero-length array 'u8[0]' {aka 'unsigned char[0]'} [-Wzero-length-bounds]
       1522 |  memset(&ct->__nfct_init_offset[0], 0,
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from net/netfilter/nf_conntrack_core.c:37:
      include/net/netfilter/nf_conntrack.h:90:5: note: while referencing '__nfct_init_offset'
         90 |  u8 __nfct_init_offset[0];
            |     ^~~~~~~~~~~~~~~~~~
      
      The code is correct but a bit unusual. Rework it slightly in a way that
      does not trigger the warning, using an empty struct instead of an empty
      array. There are probably more elegant ways to do this, but this is the
      smallest change.
      
      Fixes: c41884ce ("netfilter: conntrack: avoid zeroing timer")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d2413ec1
    • Dave Wysochanski's avatar
      NFSv4: Fix fscache cookie aux_data to ensure change_attr is included · 0840f672
      Dave Wysochanski authored
      [ Upstream commit 50eaa652 ]
      
      Commit 402cb8dd ("fscache: Attach the index key and aux data to
      the cookie") added the aux_data and aux_data_len to parameters to
      fscache_acquire_cookie(), and updated the callers in the NFS client.
      In the process it modified the aux_data to include the change_attr,
      but missed adding change_attr to a couple places where aux_data was
      used.  Specifically, when opening a file and the change_attr is not
      added, the following attempt to lookup an object will fail inside
      cachefiles_check_object_xattr() = -116 due to
      nfs_fscache_inode_check_aux() failing memcmp on auxdata and returning
      FSCACHE_CHECKAUX_OBSOLETE.
      
      Fix this by adding nfs_fscache_update_auxdata() to set the auxdata
      from all relevant fields in the inode, including the change_attr.
      
      Fixes: 402cb8dd ("fscache: Attach the index key and aux data to the cookie")
      Signed-off-by: default avatarDave Wysochanski <dwysocha@redhat.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0840f672
    • Arnd Bergmann's avatar
      nfs: fscache: use timespec64 in inode auxdata · d8b16f4a
      Arnd Bergmann authored
      [ Upstream commit 6e31ded6 ]
      
      nfs currently behaves differently on 32-bit and 64-bit kernels regarding
      the on-disk format of nfs_fscache_inode_auxdata.
      
      That format should really be the same on any kernel, and we should avoid
      the 'timespec' type in order to remove that from the kernel later on.
      
      Using plain 'timespec64' would not be good here, since that includes
      implied padding and would possibly leak kernel stack data to the on-disk
      format on 32-bit architectures.
      
      struct __kernel_timespec would work as a replacement, but open-coding
      the two struct members in nfs_fscache_inode_auxdata makes it more
      obvious what's going on here, and keeps the current format for 64-bit
      architectures.
      
      Cc: David Howells <dhowells@redhat.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d8b16f4a
    • Dave Wysochanski's avatar
      NFS: Fix fscache super_cookie index_key from changing after umount · f61787f7
      Dave Wysochanski authored
      [ Upstream commit d9bfced1 ]
      
      Commit 402cb8dd ("fscache: Attach the index key and aux data to
      the cookie") added the index_key and index_key_len parameters to
      fscache_acquire_cookie(), and updated the callers in the NFS client.
      One of the callers was inside nfs_fscache_get_super_cookie()
      and was changed to use the full struct nfs_fscache_key as the
      index_key.  However, a couple members of this structure contain
      pointers and thus will change each time the same NFS share is
      remounted.  Since index_key is used for fscache_cookie->key_hash
      and this subsequently is used to compare cookies, the effectiveness
      of fscache with NFS is reduced to the point at which a umount
      occurs.   Any subsequent remount of the same share will cause a
      unique NFS super_block index_key and key_hash to be generated for
      the same data, rendering any prior fscache data unable to be
      found.  A simple reproducer demonstrates the problem.
      
      1. Mount share with 'fsc', create a file, drop page cache
      systemctl start cachefilesd
      mount -o vers=3,fsc 127.0.0.1:/export /mnt
      dd if=/dev/zero of=/mnt/file1.bin bs=4096 count=1
      echo 3 > /proc/sys/vm/drop_caches
      
      2. Read file into page cache and fscache, then unmount
      dd if=/mnt/file1.bin of=/dev/null bs=4096 count=1
      umount /mnt
      
      3. Remount and re-read which should come from fscache
      mount -o vers=3,fsc 127.0.0.1:/export /mnt
      echo 3 > /proc/sys/vm/drop_caches
      dd if=/mnt/file1.bin of=/dev/null bs=4096 count=1
      
      4. Check for READ ops in mountstats - there should be none
      grep READ: /proc/self/mountstats
      
      Looking at the history and the removed function, nfs_super_get_key(),
      we should only use nfs_fscache_key.key plus any uniquifier, for
      the fscache index_key.
      
      Fixes: 402cb8dd ("fscache: Attach the index key and aux data to the cookie")
      Signed-off-by: default avatarDave Wysochanski <dwysocha@redhat.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f61787f7
    • Adrian Hunter's avatar
      mmc: block: Fix request completion in the CQE timeout path · 57a5bd6c
      Adrian Hunter authored
      [ Upstream commit c077dc5e ]
      
      First, it should be noted that the CQE timeout (60 seconds) is substantial
      so a CQE request that times out is really stuck, and the race between
      timeout and completion is extremely unlikely. Nevertheless this patch
      fixes an issue with it.
      
      Commit ad73d6fe ("mmc: complete requests from ->timeout")
      preserved the existing functionality, to complete the request.
      However that had only been necessary because the block layer
      timeout handler had been marking the request to prevent it from being
      completed normally. That restriction was removed at the same time, the
      result being that a request that has gone will have been completed anyway.
      That is, the completion was unnecessary.
      
      At the time, the unnecessary completion was harmless because the block
      layer would ignore it, although that changed in kernel v5.0.
      
      Note for stable, this patch will not apply cleanly without patch "mmc:
      core: Fix recursive locking issue in CQE recovery path"
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Fixes: ad73d6fe ("mmc: complete requests from ->timeout")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200508062227.23144-1-adrian.hunter@intel.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      57a5bd6c
    • Veerabhadrarao Badiganti's avatar
      mmc: core: Check request type before completing the request · d8c167dd
      Veerabhadrarao Badiganti authored
      [ Upstream commit e6bfb1bf ]
      
      In the request completion path with CQE, request type is being checked
      after the request is getting completed. This is resulting in returning
      the wrong request type and leading to the IO hang issue.
      
      ASYNC request type is getting returned for DCMD type requests.
      Because of this mismatch, mq->cqe_busy flag is never getting cleared
      and the driver is not invoking blk_mq_hw_run_queue. So requests are not
      getting dispatched to the LLD from the block layer.
      
      All these eventually leading to IO hang issues.
      So, get the request type before completing the request.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 1e8e55b6 ("mmc: block: Add CQE support")
      Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: https://lore.kernel.org/r/1588775643-18037-2-git-send-email-vbadigan@codeaurora.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d8c167dd
    • Dan Carpenter's avatar
      i40iw: Fix error handling in i40iw_manage_arp_cache() · 3d03be75
      Dan Carpenter authored
      [ Upstream commit 37e31d2d ]
      
      The i40iw_arp_table() function can return -EOVERFLOW if
      i40iw_alloc_resource() fails so we can't just test for "== -1".
      
      Fixes: 4e9042e6 ("i40iw: add hw and utils files")
      Link: https://lore.kernel.org/r/20200422092211.GA195357@mwandaSigned-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d03be75
    • Grace Kao's avatar
      pinctrl: cherryview: Add missing spinlock usage in chv_gpio_irq_handler · 6f5c38c7
      Grace Kao authored
      [ Upstream commit 69388e15 ]
      
      According to Braswell NDA Specification Update (#557593),
      concurrent read accesses may result in returning 0xffffffff and write
      instructions may be dropped. We have an established format for the
      commit references, i.e.
      cdca06e4 ("pinctrl: baytrail: Add missing spinlock usage in
      byt_gpio_irq_handler")
      
      Fixes: 0bd50d71 ("pinctrl: cherryview: prevent concurrent access to GPIO controllers")
      Signed-off-by: default avatarGrace Kao <grace.kao@intel.com>
      Reported-by: default avatarBrian Norris <briannorris@chromium.org>
      Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6f5c38c7
    • Andy Shevchenko's avatar
      pinctrl: baytrail: Enable pin configuration setting for GPIO chip · 823fb483
      Andy Shevchenko authored
      [ Upstream commit ccd025ea ]
      
      It appears that pin configuration for GPIO chip hasn't been enabled yet
      due to absence of ->set_config() callback.
      
      Enable it here for Intel Baytrail.
      
      Fixes: c501d0b1 ("pinctrl: baytrail: Add pin control operations")
      Depends-on: 2956b5d9 ("pinctrl / gpio: Introduce .set_config() callback for GPIO chips")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      823fb483
    • Andreas Gruenbacher's avatar
      gfs2: Another gfs2_walk_metadata fix · ecf4cb65
      Andreas Gruenbacher authored
      [ Upstream commit 566a2ab3 ]
      
      Make sure we don't walk past the end of the metadata in gfs2_walk_metadata: the
      inode holds fewer pointers than indirect blocks.
      
      Slightly clean up gfs2_iomap_get.
      
      Fixes: a27a0c9b ("gfs2: gfs2_walk_metadata fix")
      Cc: stable@vger.kernel.org # v5.3+
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ecf4cb65
    • Kai-Heng Feng's avatar
      ALSA: hda/realtek - Fix S3 pop noise on Dell Wyse · 0a79765b
      Kai-Heng Feng authored
      [ Upstream commit 52e4e368 ]
      
      Commit 317d9313 ("ALSA: hda/realtek - Set default power save node to
      0") makes the ALC225 have pop noise on S3 resume and cold boot.
      
      The previous fix enable power save node universally for ALC225, however
      it makes some ALC225 systems unable to produce any sound.
      
      So let's only enable power save node for the affected Dell Wyse
      platform.
      
      Fixes: 317d9313 ("ALSA: hda/realtek - Set default power save node to 0")
      BugLink: https://bugs.launchpad.net/bugs/1866357Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Link: https://lore.kernel.org/r/20200503152449.22761-2-kai.heng.feng@canonical.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0a79765b
    • Vasily Averin's avatar
      ipc/util.c: sysvipc_find_ipc() incorrectly updates position index · 15e0db6e
      Vasily Averin authored
      [ Upstream commit 5e698222 ]
      
      Commit 89163f93 ("ipc/util.c: sysvipc_find_ipc() should increase
      position index") is causing this bug (seen on 5.6.8):
      
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
      
         # ipcmk -Q
         Message queue id: 0
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
         0x82db8127 0          root       644        0            0
      
         # ipcmk -Q
         Message queue id: 1
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
         0x82db8127 0          root       644        0            0
         0x76d1fb2a 1          root       644        0            0
      
         # ipcrm -q 0
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
         0x76d1fb2a 1          root       644        0            0
         0x76d1fb2a 1          root       644        0            0
      
         # ipcmk -Q
         Message queue id: 2
         # ipcrm -q 2
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
         0x76d1fb2a 1          root       644        0            0
         0x76d1fb2a 1          root       644        0            0
      
         # ipcmk -Q
         Message queue id: 3
         # ipcrm -q 1
         # ipcs -q
      
         ------ Message Queues --------
         key        msqid      owner      perms      used-bytes   messages
         0x7c982867 3          root       644        0            0
         0x7c982867 3          root       644        0            0
         0x7c982867 3          root       644        0            0
         0x7c982867 3          root       644        0            0
      
      Whenever an IPC item with a low id is deleted, the items with higher ids
      are duplicated, as if filling a hole.
      
      new_pos should jump through hole of unused ids, pos can be updated
      inside "for" cycle.
      
      Fixes: 89163f93 ("ipc/util.c: sysvipc_find_ipc() should increase position index")
      Reported-by: default avatarAndreas Schwab <schwab@suse.de>
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarVasily Averin <vvs@virtuozzo.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarWaiman Long <longman@redhat.com>
      Cc: NeilBrown <neilb@suse.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Manfred Spraul <manfred@colorfullife.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/4921fe9b-9385-a2b4-1dc4-1099be6d2e39@virtuozzo.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      15e0db6e