1. 24 Feb, 2020 40 commits
    • Wei Liu's avatar
      PCI: iproc: Apply quirk_paxc_bridge() for module as well as built-in · 8422f39c
      Wei Liu authored
      [ Upstream commit 574f2903 ]
      
      Previously quirk_paxc_bridge() was applied when the iproc driver was
      built-in, but not when it was compiled as a module.
      
      This happened because it was under #ifdef CONFIG_PCIE_IPROC_PLATFORM:
      PCIE_IPROC_PLATFORM=y causes CONFIG_PCIE_IPROC_PLATFORM to be defined, but
      PCIE_IPROC_PLATFORM=m causes CONFIG_PCIE_IPROC_PLATFORM_MODULE to be
      defined.
      
      Move quirk_paxc_bridge() to pcie-iproc.c and drop the #ifdef so the quirk
      is always applied, whether iproc is built-in or a module.
      
      [bhelgaas: commit log, move to pcie-iproc.c, not pcie-iproc-platform.c]
      Link: https://lore.kernel.org/r/20191211174511.89713-1-wei.liu@kernel.orgSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8422f39c
    • Andrey Smirnov's avatar
      ARM: dts: imx6: rdu2: Limit USBH1 to Full Speed · 86c8e8a6
      Andrey Smirnov authored
      [ Upstream commit 6bb1e09c ]
      
      Cabling used to connect devices to USBH1 on RDU2 does not meet USB
      spec cable quality and cable length requirements to operate at High
      Speed, so limit the port to Full Speed only.
      Reported-by: default avatarChris Healy <cphealy@gmail.com>
      Reviewed-by: default avatarChris Healy <cphealy@gmail.com>
      Reviewed-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Lucas Stach <l.stach@pengutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      86c8e8a6
    • Andrey Smirnov's avatar
      ARM: dts: imx6: rdu2: Disable WP for USDHC2 and USDHC3 · 3aeb6bc9
      Andrey Smirnov authored
      [ Upstream commit cd58a174 ]
      
      RDU2 production units come with resistor connecting WP pin to
      correpsonding GPIO DNPed for both SD card slots. Drop any WP related
      configuration and mark both slots with "disable-wp".
      Reported-by: default avatarChris Healy <cphealy@gmail.com>
      Reviewed-by: default avatarChris Healy <cphealy@gmail.com>
      Reviewed-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Lucas Stach <l.stach@pengutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3aeb6bc9
    • Manu Gautam's avatar
      arm64: dts: qcom: msm8996: Disable USB2 PHY suspend by core · 1dca9e93
      Manu Gautam authored
      [ Upstream commit d026c96b ]
      
      QUSB2 PHY on msm8996 doesn't work well when autosuspend by
      dwc3 core using USB2PHYCFG register is enabled. One of the
      issue seen is that PHY driver reports PLL lock failure and
      fails phy_init() if dwc3 core has USB2 PHY suspend enabled.
      Fix this by using quirks to disable USB2 PHY LPM/suspend and
      dwc3 core already takes care of explicitly suspending PHY
      during suspend if quirks are specified.
      Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
      Signed-off-by: default avatarPaolo Pisati <p.pisati@gmail.com>
      Link: https://lore.kernel.org/r/20191209151501.26993-1-p.pisati@gmail.comSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1dca9e93
    • Paul Moore's avatar
      selinux: ensure we cleanup the internal AVC counters on error in avc_insert() · c0d7b3fa
      Paul Moore authored
      [ Upstream commit d8db60cb ]
      
      Fix avc_insert() to call avc_node_kill() if we've already allocated
      an AVC node and the code fails to insert the node in the cache.
      
      Fixes: fa1aa143 ("selinux: extended permissions for ioctls")
      Reported-by: rsiddoji@codeaurora.org
      Suggested-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Acked-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c0d7b3fa
    • Andre Przywara's avatar
      arm: dts: allwinner: H3: Add PMU node · b9df95dd
      Andre Przywara authored
      [ Upstream commit 0388a110 ]
      
      Add the Performance Monitoring Unit (PMU) device tree node to the H3
      .dtsi, which tells DT users which interrupts are triggered by PMU
      overflow events on each core. The numbers come from the manual and have
      been checked in U-Boot and with perf in Linux.
      
      Tested with perf record and taskset on an OrangePi Zero.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b9df95dd
    • Andre Przywara's avatar
      arm64: dts: allwinner: H6: Add PMU mode · 8f1046b3
      Andre Przywara authored
      [ Upstream commit 7aa9b9eb ]
      
      Add the Performance Monitoring Unit (PMU) device tree node to the H6
      .dtsi, which tells DT users which interrupts are triggered by PMU
      overflow events on each core. The numbers come from the manual and have
      been checked in U-Boot and with perf in Linux.
      
      Tested with perf record and taskset on a Pine H64.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8f1046b3
    • Stephen Smalley's avatar
      selinux: fall back to ref-walk if audit is required · efd5ce8b
      Stephen Smalley authored
      [ Upstream commit 0188d5c0 ]
      
      commit bda0be7a ("security: make inode_follow_link RCU-walk aware")
      passed down the rcu flag to the SELinux AVC, but failed to adjust the
      test in slow_avc_audit() to also return -ECHILD on LSM_AUDIT_DATA_DENTRY.
      Previously, we only returned -ECHILD if generating an audit record with
      LSM_AUDIT_DATA_INODE since this was only relevant from inode_permission.
      Move the handling of MAY_NOT_BLOCK to avc_audit() and its inlined
      equivalent in selinux_inode_permission() immediately after we determine
      that audit is required, and always fall back to ref-walk in this case.
      
      Fixes: bda0be7a ("security: make inode_follow_link RCU-walk aware")
      Reported-by: default avatarWill Deacon <will@kernel.org>
      Suggested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      efd5ce8b
    • Mao Wenan's avatar
      NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu(). · ec0237cb
      Mao Wenan authored
      [ Upstream commit 718eae27 ]
      
      Convert cpu_to_le16(le16_to_cpu(frame->datalen) + len) to
      use le16_add_cpu(), which is more concise and does the same thing.
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarMao Wenan <maowenan@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec0237cb
    • Rasmus Villemoes's avatar
      net/wan/fsl_ucc_hdlc: reject muram offsets above 64K · 354704ed
      Rasmus Villemoes authored
      [ Upstream commit 148587a5 ]
      
      Qiang Zhao points out that these offsets get written to 16-bit
      registers, and there are some QE platforms with more than 64K
      muram. So it is possible that qe_muram_alloc() gives us an allocation
      that can't actually be used by the hardware, so detect and reject
      that.
      Reported-by: default avatarQiang Zhao <qiang.zhao@nxp.com>
      Reviewed-by: default avatarTimur Tabi <timur@kernel.org>
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      354704ed
    • Miquel Raynal's avatar
      regulator: rk808: Lower log level on optional GPIOs being not available · ad763354
      Miquel Raynal authored
      [ Upstream commit b8a039d3 ]
      
      RK808 can leverage a couple of GPIOs to tweak the ramp rate during DVS
      (Dynamic Voltage Scaling). These GPIOs are entirely optional but a
      dev_warn() appeared when cleaning this driver to use a more up-to-date
      gpiod API. At least reduce the log level to 'info' as it is totally
      fine to not populate these GPIO on a hardware design.
      
      This change is trivial but it is worth not polluting the logs during
      bringup phase by having real warnings and errors sorted out
      correctly.
      
      Fixes: a13eaf02 ("regulator: rk808: make better use of the gpiod API")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/r/20191203164709.11127-1-miquel.raynal@bootlin.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad763354
    • Nathan Chancellor's avatar
      drm/amdgpu: Ensure ret is always initialized when using SOC15_WAIT_ON_RREG · a882dcd9
      Nathan Chancellor authored
      [ Upstream commit a63141e3 ]
      
      Commit b0f3cd31 ("drm/amdgpu: remove unnecessary JPEG2.0 code from
      VCN2.0") introduced a new clang warning in the vcn_v2_0_stop function:
      
      ../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1082:2: warning: variable 'r'
      is used uninitialized whenever 'while' loop exits because its condition
      is false [-Wsometimes-uninitialized]
              SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, 0x7, r);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../drivers/gpu/drm/amd/amdgpu/../amdgpu/soc15_common.h:55:10: note:
      expanded from macro 'SOC15_WAIT_ON_RREG'
                      while ((tmp_ & (mask)) != (expected_value)) {   \
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1083:6: note: uninitialized use
      occurs here
              if (r)
                  ^
      ../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1082:2: note: remove the
      condition if it is always true
              SOC15_WAIT_ON_RREG(VCN, 0, mmUVD_STATUS, UVD_STATUS__IDLE, 0x7, r);
              ^
      ../drivers/gpu/drm/amd/amdgpu/../amdgpu/soc15_common.h:55:10: note:
      expanded from macro 'SOC15_WAIT_ON_RREG'
                      while ((tmp_ & (mask)) != (expected_value)) {   \
                             ^
      ../drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c:1072:7: note: initialize the
      variable 'r' to silence this warning
              int r;
                   ^
                    = 0
      1 warning generated.
      
      To prevent warnings like this from happening in the future, make the
      SOC15_WAIT_ON_RREG macro initialize its ret variable before the while
      loop that can time out. This macro's return value is always checked so
      it should set ret in both the success and fail path.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/776Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a882dcd9
    • yu kuai's avatar
      drm/amdgpu: remove 4 set but not used variable in... · b367528f
      yu kuai authored
      drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table
      
      [ Upstream commit bae028e3 ]
      
      Fixes gcc '-Wunused-but-set-variable' warning:
      
      drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c: In function
      'amdgpu_atombios_get_connector_info_from_object_table':
      drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:376:26: warning: variable
      'grph_obj_num' set but not used [-Wunused-but-set-variable]
      drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:376:13: warning: variable
      'grph_obj_id' set but not used [-Wunused-but-set-variable]
      drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:341:37: warning: variable
      'con_obj_type' set but not used [-Wunused-but-set-variable]
      drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:341:24: warning: variable
      'con_obj_num' set but not used [-Wunused-but-set-variable]
      
      They are never used, so can be removed.
      
      Fixes: d38ceaf9 ("drm/amdgpu: add core driver (v4)")
      Signed-off-by: default avataryu kuai <yukuai3@huawei.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b367528f
    • Douglas Anderson's avatar
      clk: qcom: rcg2: Don't crash if our parent can't be found; return an error · 087f8bf4
      Douglas Anderson authored
      [ Upstream commit 908b0501 ]
      
      When I got my clock parenting slightly wrong I ended up with a crash
      that looked like this:
      
        Unable to handle kernel NULL pointer dereference at virtual
        address 0000000000000000
        ...
        pc : clk_hw_get_rate+0x14/0x44
        ...
        Call trace:
         clk_hw_get_rate+0x14/0x44
         _freq_tbl_determine_rate+0x94/0xfc
         clk_rcg2_determine_rate+0x2c/0x38
         clk_core_determine_round_nolock+0x4c/0x88
         clk_core_round_rate_nolock+0x6c/0xa8
         clk_core_round_rate_nolock+0x9c/0xa8
         clk_core_set_rate_nolock+0x70/0x180
         clk_set_rate+0x3c/0x6c
         of_clk_set_defaults+0x254/0x360
         platform_drv_probe+0x28/0xb0
         really_probe+0x120/0x2dc
         driver_probe_device+0x64/0xfc
         device_driver_attach+0x4c/0x6c
         __driver_attach+0xac/0xc0
         bus_for_each_dev+0x84/0xcc
         driver_attach+0x2c/0x38
         bus_add_driver+0xfc/0x1d0
         driver_register+0x64/0xf8
         __platform_driver_register+0x4c/0x58
         msm_drm_register+0x5c/0x60
         ...
      
      It turned out that clk_hw_get_parent_by_index() was returning NULL and
      we weren't checking.  Let's check it so that we don't crash.
      
      Fixes: ac269395 ("clk: qcom: Convert to clk_hw based provider APIs")
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Link: https://lkml.kernel.org/r/20200203103049.v4.1.I7487325fe8e701a68a07d3be8a6a4b571eca9cfa@changeidSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      087f8bf4
    • Masahiro Yamada's avatar
      kconfig: fix broken dependency in randconfig-generated .config · 296372fb
      Masahiro Yamada authored
      [ Upstream commit c8fb7d7e ]
      
      Running randconfig on arm64 using KCONFIG_SEED=0x40C5E904 (e.g. on v5.5)
      produces the .config with CONFIG_EFI=y and CONFIG_CPU_BIG_ENDIAN=y,
      which does not meet the !CONFIG_CPU_BIG_ENDIAN dependency.
      
      This is because the user choice for CONFIG_CPU_LITTLE_ENDIAN vs
      CONFIG_CPU_BIG_ENDIAN is set by randomize_choice_values() after the
      value of CONFIG_EFI is calculated.
      
      When this happens, the has_changed flag should be set.
      
      Currently, it takes the result from the last iteration. It should
      accumulate all the results of the loop.
      
      Fixes: 3b9a19e0 ("kconfig: loop as long as we changed some symbols in randconfig")
      Reported-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      296372fb
    • Christian Borntraeger's avatar
      KVM: s390: ENOTSUPP -> EOPNOTSUPP fixups · 5fe69d2b
      Christian Borntraeger authored
      [ Upstream commit c6119908 ]
      
      There is no ENOTSUPP for userspace.
      Reported-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Fixes: 51978393 ("KVM: s390: introduce ais mode modify function")
      Fixes: 2c1a48f2 ("KVM: S390: add new group for flic")
      Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5fe69d2b
    • Sun Ke's avatar
      nbd: add a flush_workqueue in nbd_start_device · 7ce9e00a
      Sun Ke authored
      [ Upstream commit 5c0dd228 ]
      
      When kzalloc fail, may cause trying to destroy the
      workqueue from inside the workqueue.
      
      If num_connections is m (2 < m), and NO.1 ~ NO.n
      (1 < n < m) kzalloc are successful. The NO.(n + 1)
      failed. Then, nbd_start_device will return ENOMEM
      to nbd_start_device_ioctl, and nbd_start_device_ioctl
      will return immediately without running flush_workqueue.
      However, we still have n recv threads. If nbd_release
      run first, recv threads may have to drop the last
      config_refs and try to destroy the workqueue from
      inside the workqueue.
      
      To fix it, add a flush_workqueue in nbd_start_device.
      
      Fixes: e9e006f5 ("nbd: fix max number of supported devs")
      Signed-off-by: default avatarSun Ke <sunke32@huawei.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ce9e00a
    • Harry Wentland's avatar
      drm/amd/display: Retrain dongles when SINK_COUNT becomes non-zero · ff19c8c6
      Harry Wentland authored
      [ Upstream commit 3eb6d7ac ]
      
      [WHY]
      Two years ago the patch referenced by the Fixes tag stopped running
      dp_verify_link_cap_with_retries during DP detection when the reason
      for the detection was a short-pulse interrupt. This effectively meant
      that we were no longer doing the verify_link_cap training on active
      dongles when their SINK_COUNT changed from 0 to 1.
      
      A year ago this was partly remedied with:
      commit 80adaebd ("drm/amd/display: Don't skip link training for empty dongle")
      
      This made sure that we trained the dongle on initial hotplug (without
      connected downstream devices).
      
      This is all fine and dandy if it weren't for the fact that there are
      some dongles on the market that don't like link training when SINK_COUNT
      is 0 These dongles will in fact indicate a SINK_COUNT of 0 immediately
      after hotplug, even when a downstream device is connected, and then
      trigger a shortpulse interrupt indicating a SINK_COUNT change to 1.
      
      In order to play nicely we will need our policy to not link train an
      active DP dongle when SINK_COUNT is 0 but ensure we train it when the
      SINK_COUNT changes to 1.
      
      [HOW]
      Call dp_verify_link_cap_with_retries on detection even when the detection
      is triggered from a short pulse interrupt.
      
      With this change we can also revert this commit which we'll do in a separate
      follow-up change:
      commit 80adaebd ("drm/amd/display: Don't skip link training for empty dongle")
      
      Fixes: 0301ccba ("drm/amd/display: DP Compliance 400.1.1 failure")
      Suggested-by: default avatarLouis Li <Ching-shih.Li@amd.com>
      Tested-by: default avatarLouis Li <Ching-shih.Li@amd.com>
      Cc: Wenjing Liu <Wenjing.Liu@amd.com>
      Cc: Hersen Wu <hersenxs.wu@amd.com>
      Cc: Eric Yang <Eric.Yang2@amd.com>
      Reviewed-by: default avatarWenjing Liu <Wenjing.Liu@amd.com>
      Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff19c8c6
    • Rakesh Pillai's avatar
      ath10k: Correct the DMA direction for management tx buffers · 2a044ba3
      Rakesh Pillai authored
      [ Upstream commit 6ba8b3b6 ]
      
      The management packets, send to firmware via WMI, are
      mapped using the direction DMA_TO_DEVICE. Currently in
      case of wmi cleanup, these buffers are being unmapped
      using an incorrect DMA direction. This can cause unwanted
      behavior when the host driver is handling a restart
      of the wlan firmware.
      
      We might see a trace like below
      
      [<ffffff8008098b18>] __dma_inv_area+0x28/0x58
      [<ffffff8001176734>] ath10k_wmi_mgmt_tx_clean_up_pending+0x60/0xb0 [ath10k_core]
      [<ffffff80088c7c50>] idr_for_each+0x78/0xe4
      [<ffffff80011766a4>] ath10k_wmi_detach+0x4c/0x7c [ath10k_core]
      [<ffffff8001163d7c>] ath10k_core_stop+0x58/0x68 [ath10k_core]
      [<ffffff800114fb74>] ath10k_halt+0xec/0x13c [ath10k_core]
      [<ffffff8001165110>] ath10k_core_restart+0x11c/0x1a8 [ath10k_core]
      [<ffffff80080c36bc>] process_one_work+0x16c/0x31c
      
      Fix the incorrect DMA direction during the wmi
      management tx buffer cleanup.
      
      Tested HW: WCN3990
      Tested FW: WLAN.HL.3.1-00784-QCAHLSWMTPLZ-1
      
      Fixes: dc405152 ("ath10k: handle mgmt tx completion event")
      Signed-off-by: default avatarRakesh Pillai <pillair@codeaurora.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2a044ba3
    • zhangyi (F)'s avatar
      ext4, jbd2: ensure panic when aborting with zero errno · d5e7ba4e
      zhangyi (F) authored
      [ Upstream commit 51f57b01 ]
      
      JBD2_REC_ERR flag used to indicate the errno has been updated when jbd2
      aborted, and then __ext4_abort() and ext4_handle_error() can invoke
      panic if ERRORS_PANIC is specified. But if the journal has been aborted
      with zero errno, jbd2_journal_abort() didn't set this flag so we can
      no longer panic. Fix this by always record the proper errno in the
      journal superblock.
      
      Fixes: 4327ba52 ("ext4, jbd2: ensure entering into panic after recording an error in superblock")
      Signed-off-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20191204124614.45424-3-yi.zhang@huawei.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d5e7ba4e
    • Vincenzo Frascino's avatar
      ARM: 8952/1: Disable kmemleak on XIP kernels · c0deae0a
      Vincenzo Frascino authored
      [ Upstream commit bc420c6c ]
      
      Kmemleak relies on specific symbols to register the read only data
      during init (e.g. __start_ro_after_init).
      Trying to build an XIP kernel on arm results in the linking error
      reported below because when this option is selected read only data
      after init are not allowed since .data is read only (.rodata).
      
        arm-linux-gnueabihf-ld: mm/kmemleak.o: in function `kmemleak_init':
        kmemleak.c:(.init.text+0x148): undefined reference to `__end_ro_after_init'
        arm-linux-gnueabihf-ld: kmemleak.c:(.init.text+0x14c):
           undefined reference to `__end_ro_after_init'
        arm-linux-gnueabihf-ld: kmemleak.c:(.init.text+0x150):
           undefined reference to `__start_ro_after_init'
        arm-linux-gnueabihf-ld: kmemleak.c:(.init.text+0x156):
           undefined reference to `__start_ro_after_init'
        arm-linux-gnueabihf-ld: kmemleak.c:(.init.text+0x162):
           undefined reference to `__start_ro_after_init'
        arm-linux-gnueabihf-ld: kmemleak.c:(.init.text+0x16a):
           undefined reference to `__start_ro_after_init'
        linux/Makefile:1078: recipe for target 'vmlinux' failed
      
      Fix the issue enabling kmemleak only on non XIP kernels.
      Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c0deae0a
    • Steven Rostedt (VMware)'s avatar
      tracing: Fix very unlikely race of registering two stat tracers · 56d37932
      Steven Rostedt (VMware) authored
      [ Upstream commit dfb6cd1e ]
      
      Looking through old emails in my INBOX, I came across a patch from Luis
      Henriques that attempted to fix a race of two stat tracers registering the
      same stat trace (extremely unlikely, as this is done in the kernel, and
      probably doesn't even exist). The submitted patch wasn't quite right as it
      needed to deal with clean up a bit better (if two stat tracers were the
      same, it would have the same files).
      
      But to make the code cleaner, all we needed to do is to keep the
      all_stat_sessions_mutex held for most of the registering function.
      
      Link: http://lkml.kernel.org/r/1410299375-20068-1-git-send-email-luis.henriques@canonical.com
      
      Fixes: 002bb86d ("tracing/ftrace: separate events tracing and stats tracing engine")
      Reported-by: default avatarLuis Henriques <luis.henriques@canonical.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      56d37932
    • Luis Henriques's avatar
      tracing: Fix tracing_stat return values in error handling paths · fb008507
      Luis Henriques authored
      [ Upstream commit afccc00f ]
      
      tracing_stat_init() was always returning '0', even on the error paths.  It
      now returns -ENODEV if tracing_init_dentry() fails or -ENOMEM if it fails
      to created the 'trace_stat' debugfs directory.
      
      Link: http://lkml.kernel.org/r/1410299381-20108-1-git-send-email-luis.henriques@canonical.com
      
      Fixes: ed6f1c99 ("tracing: Check return value of tracing_init_dentry()")
      Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
      [ Pulled from the archeological digging of my INBOX ]
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb008507
    • Oliver O'Halloran's avatar
      powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov() · 9c401178
      Oliver O'Halloran authored
      [ Upstream commit 965c94f3 ]
      
      An ioda_pe for each VF is allocated in pnv_pci_sriov_enable() before
      the pci_dev for the VF is created. We need to set the pe->pdev pointer
      at some point after the pci_dev is created. Currently we do that in:
      
      pcibios_bus_add_device()
      	pnv_pci_dma_dev_setup() (via phb->ops.dma_dev_setup)
      		/* fixup is done here */
      		pnv_pci_ioda_dma_dev_setup() (via pnv_phb->dma_dev_setup)
      
      The fixup needs to be done before setting up DMA for for the VF's PE,
      but there's no real reason to delay it until this point. Move the
      fixup into pnv_pci_ioda_fixup_iov() so the ordering is:
      
      	pcibios_add_device()
      		pnv_pci_ioda_fixup_iov() (via ppc_md.pcibios_fixup_sriov)
      
      	pcibios_bus_add_device()
      		...
      
      This isn't strictly required, but it's a slightly more logical place
      to do the fixup and it simplifies pnv_pci_dma_dev_setup().
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Reviewed-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200110070207.439-4-oohall@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      9c401178
    • Niklas Schnelle's avatar
      s390/pci: Fix possible deadlock in recover_store() · 034a6635
      Niklas Schnelle authored
      [ Upstream commit 576c75e3 ]
      
      With zpci_disable() working, lockdep detected a potential deadlock
      (lockdep output at the end).
      
      The deadlock is between recovering a PCI function via the
      
      /sys/bus/pci/devices/<dev>/recover
      
      attribute vs powering it off via
      
      /sys/bus/pci/slots/<slot>/power.
      
      The fix is analogous to the changes in commit 0ee223b2 ("scsi: core:
      Avoid that SCSI device removal through sysfs triggers a deadlock")
      that fixed a potential deadlock on removing a SCSI device via sysfs.
      
      [  204.830107] ======================================================
      [  204.830109] WARNING: possible circular locking dependency detected
      [  204.830111] 5.5.0-rc2-06072-gbc03ecc9a672 #6 Tainted: G        W
      [  204.830112] ------------------------------------------------------
      [  204.830113] bash/1034 is trying to acquire lock:
      [  204.830115] 0000000192a1a610 (kn->count#200){++++}, at: kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830122]
                     but task is already holding lock:
      [  204.830123] 00000000c16134a8 (pci_rescan_remove_lock){+.+.}, at: pci_stop_and_remove_bus_device_locked+0x26/0x48
      [  204.830128]
                     which lock already depends on the new lock.
      
      [  204.830129]
                     the existing dependency chain (in reverse order) is:
      [  204.830130]
                     -> #1 (pci_rescan_remove_lock){+.+.}:
      [  204.830134]        validate_chain+0x93a/0xd08
      [  204.830136]        __lock_acquire+0x4ae/0x9d0
      [  204.830137]        lock_acquire+0x114/0x280
      [  204.830140]        __mutex_lock+0xa2/0x960
      [  204.830142]        mutex_lock_nested+0x32/0x40
      [  204.830145]        recover_store+0x4c/0xa8
      [  204.830147]        kernfs_fop_write+0xe6/0x218
      [  204.830151]        vfs_write+0xb0/0x1b8
      [  204.830152]        ksys_write+0x6c/0xf8
      [  204.830154]        system_call+0xd8/0x2d8
      [  204.830155]
                     -> #0 (kn->count#200){++++}:
      [  204.830187]        check_noncircular+0x1e6/0x240
      [  204.830189]        check_prev_add+0xfc/0xdb0
      [  204.830190]        validate_chain+0x93a/0xd08
      [  204.830192]        __lock_acquire+0x4ae/0x9d0
      [  204.830193]        lock_acquire+0x114/0x280
      [  204.830194]        __kernfs_remove.part.0+0x2e4/0x360
      [  204.830196]        kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830198]        remove_files.isra.0+0x4c/0x98
      [  204.830199]        sysfs_remove_group+0x66/0xc8
      [  204.830201]        sysfs_remove_groups+0x46/0x68
      [  204.830204]        device_remove_attrs+0x52/0x90
      [  204.830207]        device_del+0x182/0x418
      [  204.830208]        pci_remove_bus_device+0x8a/0x130
      [  204.830210]        pci_stop_and_remove_bus_device_locked+0x3a/0x48
      [  204.830212]        disable_slot+0x68/0x100
      [  204.830213]        power_write_file+0x7c/0x130
      [  204.830215]        kernfs_fop_write+0xe6/0x218
      [  204.830217]        vfs_write+0xb0/0x1b8
      [  204.830218]        ksys_write+0x6c/0xf8
      [  204.830220]        system_call+0xd8/0x2d8
      [  204.830221]
                     other info that might help us debug this:
      
      [  204.830223]  Possible unsafe locking scenario:
      
      [  204.830224]        CPU0                    CPU1
      [  204.830225]        ----                    ----
      [  204.830226]   lock(pci_rescan_remove_lock);
      [  204.830227]                                lock(kn->count#200);
      [  204.830229]                                lock(pci_rescan_remove_lock);
      [  204.830231]   lock(kn->count#200);
      [  204.830233]
                      *** DEADLOCK ***
      
      [  204.830234] 4 locks held by bash/1034:
      [  204.830235]  #0: 00000001b6fbc498 (sb_writers#4){.+.+}, at: vfs_write+0x158/0x1b8
      [  204.830239]  #1: 000000018c9f5090 (&of->mutex){+.+.}, at: kernfs_fop_write+0xaa/0x218
      [  204.830242]  #2: 00000001f7da0810 (kn->count#235){.+.+}, at: kernfs_fop_write+0xb6/0x218
      [  204.830245]  #3: 00000000c16134a8 (pci_rescan_remove_lock){+.+.}, at: pci_stop_and_remove_bus_device_locked+0x26/0x48
      [  204.830248]
                     stack backtrace:
      [  204.830250] CPU: 2 PID: 1034 Comm: bash Tainted: G        W         5.5.0-rc2-06072-gbc03ecc9a672 #6
      [  204.830252] Hardware name: IBM 8561 T01 703 (LPAR)
      [  204.830253] Call Trace:
      [  204.830257]  [<00000000c05e10c0>] show_stack+0x88/0xf0
      [  204.830260]  [<00000000c112dca4>] dump_stack+0xa4/0xe0
      [  204.830261]  [<00000000c0694c06>] check_noncircular+0x1e6/0x240
      [  204.830263]  [<00000000c0695bec>] check_prev_add+0xfc/0xdb0
      [  204.830264]  [<00000000c06971da>] validate_chain+0x93a/0xd08
      [  204.830266]  [<00000000c06994c6>] __lock_acquire+0x4ae/0x9d0
      [  204.830267]  [<00000000c069867c>] lock_acquire+0x114/0x280
      [  204.830269]  [<00000000c09ca15c>] __kernfs_remove.part.0+0x2e4/0x360
      [  204.830270]  [<00000000c09cb5c4>] kernfs_remove_by_name_ns+0x5c/0xa8
      [  204.830272]  [<00000000c09cee14>] remove_files.isra.0+0x4c/0x98
      [  204.830274]  [<00000000c09cf2ae>] sysfs_remove_group+0x66/0xc8
      [  204.830276]  [<00000000c09cf356>] sysfs_remove_groups+0x46/0x68
      [  204.830278]  [<00000000c0e3dfe2>] device_remove_attrs+0x52/0x90
      [  204.830280]  [<00000000c0e40382>] device_del+0x182/0x418
      [  204.830281]  [<00000000c0dcfd7a>] pci_remove_bus_device+0x8a/0x130
      [  204.830283]  [<00000000c0dcfe92>] pci_stop_and_remove_bus_device_locked+0x3a/0x48
      [  204.830285]  [<00000000c0de7190>] disable_slot+0x68/0x100
      [  204.830286]  [<00000000c0de6514>] power_write_file+0x7c/0x130
      [  204.830288]  [<00000000c09cc846>] kernfs_fop_write+0xe6/0x218
      [  204.830290]  [<00000000c08f3480>] vfs_write+0xb0/0x1b8
      [  204.830291]  [<00000000c08f378c>] ksys_write+0x6c/0xf8
      [  204.830293]  [<00000000c1154374>] system_call+0xd8/0x2d8
      [  204.830294] INFO: lockdep is turned off.
      Signed-off-by: default avatarNiklas Schnelle <schnelle@linux.ibm.com>
      Reviewed-by: default avatarPeter Oberparleiter <oberpar@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      034a6635
    • Uwe Kleine-König's avatar
      pwm: omap-dmtimer: Simplify error handling · be9cc6c5
      Uwe Kleine-König authored
      [ Upstream commit c4cf7aa5 ]
      
      Instead of doing error handling in the middle of ->probe(), move error
      handling and freeing the reference to timer to the end.
      
      This fixes a resource leak as dm_timer wasn't freed when allocating
      *omap failed.
      
      Implementation note: The put: label was never reached without a goto and
      ret being unequal to 0, so the removed return statement is fine.
      
      Fixes: 6604c655 ("pwm: Add PWM driver for OMAP using dual-mode timers")
      Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be9cc6c5
    • Arvind Sankar's avatar
      x86/sysfb: Fix check for bad VRAM size · 0ef2661d
      Arvind Sankar authored
      [ Upstream commit dacc9092 ]
      
      When checking whether the reported lfb_size makes sense, the height
      * stride result is page-aligned before seeing whether it exceeds the
      reported size.
      
      This doesn't work if height * stride is not an exact number of pages.
      For example, as reported in the kernel bugzilla below, an 800x600x32 EFI
      framebuffer gets skipped because of this.
      
      Move the PAGE_ALIGN to after the check vs size.
      Reported-by: default avatarChristopher Head <chead@chead.ca>
      Tested-by: default avatarChristopher Head <chead@chead.ca>
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=206051
      Link: https://lkml.kernel.org/r/20200107230410.2291947-1-nivedita@alum.mit.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ef2661d
    • Kai Li's avatar
      jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal · 8d8a4711
      Kai Li authored
      [ Upstream commit a09decff ]
      
      If the journal is dirty when the filesystem is mounted, jbd2 will replay
      the journal but the journal superblock will not be updated by
      journal_reset() because JBD2_ABORT flag is still set (it was set in
      journal_init_common()). This is problematic because when a new transaction
      is then committed, it will be recorded in block 1 (journal->j_tail was set
      to 1 in journal_reset()). If unclean shutdown happens again before the
      journal superblock is updated, the new recorded transaction will not be
      replayed during the next mount (because of stale sb->s_start and
      sb->s_sequence values) which can lead to filesystem corruption.
      
      Fixes: 85e0c4e8 ("jbd2: if the journal is aborted then don't allow update of the log tail")
      Signed-off-by: default avatarKai Li <li.kai4@h3c.com>
      Link: https://lore.kernel.org/r/20200111022542.5008-1-li.kai4@h3c.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d8a4711
    • Siddhesh Poyarekar's avatar
      kselftest: Minimise dependency of get_size on C library interfaces · 0ee2c886
      Siddhesh Poyarekar authored
      [ Upstream commit 6b64a650 ]
      
      It was observed[1] on arm64 that __builtin_strlen led to an infinite
      loop in the get_size selftest.  This is because __builtin_strlen (and
      other builtins) may sometimes result in a call to the C library
      function.  The C library implementation of strlen uses an IFUNC
      resolver to load the most efficient strlen implementation for the
      underlying machine and hence has a PLT indirection even for static
      binaries.  Because this binary avoids the C library startup routines,
      the PLT initialization never happens and hence the program gets stuck
      in an infinite loop.
      
      On x86_64 the __builtin_strlen just happens to expand inline and avoid
      the call but that is not always guaranteed.
      
      Further, while testing on x86_64 (Fedora 31), it was observed that the
      test also failed with a segfault inside write() because the generated
      code for the write function in glibc seems to access TLS before the
      syscall (probably due to the cancellation point check) and fails
      because TLS is not initialised.
      
      To mitigate these problems, this patch reduces the interface with the
      C library to just the syscall function.  The syscall function still
      sets errno on failure, which is undesirable but for now it only
      affects cases where syscalls fail.
      
      [1] https://bugs.linaro.org/show_bug.cgi?id=5479Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@gotplt.org>
      Reported-by: default avatarMasami Hiramatsu <masami.hiramatsu@linaro.org>
      Tested-by: default avatarMasami Hiramatsu <masami.hiramatsu@linaro.org>
      Reviewed-by: default avatarTim Bird <tim.bird@sony.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ee2c886
    • Colin Ian King's avatar
      clocksource/drivers/bcm2835_timer: Fix memory leak of timer · be1777ba
      Colin Ian King authored
      [ Upstream commit 2052d032 ]
      
      Currently when setup_irq fails the error exit path will leak the
      recently allocated timer structure.  Originally the code would
      throw a panic but a later commit changed the behaviour to return
      via the err_iounmap path and hence we now have a memory leak. Fix
      this by adding a err_timer_free error path that kfree's timer.
      
      Addresses-Coverity: ("Resource Leak")
      Fixes: 524a7f08 ("clocksource/drivers/bcm2835_timer: Convert init function to return error")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/r/20191219213246.34437-1-colin.king@canonical.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      be1777ba
    • John Keeping's avatar
      usb: dwc2: Fix IN FIFO allocation · 39a80bbf
      John Keeping authored
      [ Upstream commit 644139f8 ]
      
      On chips with fewer FIFOs than endpoints (for example RK3288 which has 9
      endpoints, but only 6 which are cabable of input), the DPTXFSIZN
      registers above the FIFO count may return invalid values.
      
      With logging added on startup, I see:
      
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=1 sz=256
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=2 sz=128
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=3 sz=128
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=4 sz=64
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=5 sz=64
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=6 sz=32
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=7 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=8 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=9 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=10 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=11 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=12 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=13 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=14 sz=0
      	dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=15 sz=0
      
      but:
      
      	# cat /sys/kernel/debug/ff580000.usb/fifo
      	Non-periodic FIFOs:
      	RXFIFO: Size 275
      	NPTXFIFO: Size 16, Start 0x00000113
      
      	Periodic TXFIFOs:
      		DPTXFIFO 1: Size 256, Start 0x00000123
      		DPTXFIFO 2: Size 128, Start 0x00000223
      		DPTXFIFO 3: Size 128, Start 0x000002a3
      		DPTXFIFO 4: Size 64, Start 0x00000323
      		DPTXFIFO 5: Size 64, Start 0x00000363
      		DPTXFIFO 6: Size 32, Start 0x000003a3
      		DPTXFIFO 7: Size 0, Start 0x000003e3
      		DPTXFIFO 8: Size 0, Start 0x000003a3
      		DPTXFIFO 9: Size 256, Start 0x00000123
      
      so it seems that FIFO 9 is mirroring FIFO 1.
      
      Fix the allocation by using the FIFO count instead of the endpoint count
      when selecting a FIFO for an endpoint.
      Acked-by: default avatarMinas Harutyunyan <hminas@synopsys.com>
      Signed-off-by: default avatarJohn Keeping <john@metanate.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39a80bbf
    • Jia-Ju Bai's avatar
      usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe() · 6c053825
      Jia-Ju Bai authored
      [ Upstream commit 9c1ed62a ]
      
      The driver may sleep while holding a spinlock.
      The function call path (from bottom to top) in Linux 4.19 is:
      
      drivers/usb/gadget/udc/core.c, 1175:
      	kzalloc(GFP_KERNEL) in usb_add_gadget_udc_release
      drivers/usb/gadget/udc/core.c, 1272:
      	usb_add_gadget_udc_release in usb_add_gadget_udc
      drivers/usb/gadget/udc/gr_udc.c, 2186:
      	usb_add_gadget_udc in gr_probe
      drivers/usb/gadget/udc/gr_udc.c, 2183:
      	spin_lock in gr_probe
      
      drivers/usb/gadget/udc/core.c, 1195:
      	mutex_lock in usb_add_gadget_udc_release
      drivers/usb/gadget/udc/core.c, 1272:
      	usb_add_gadget_udc_release in usb_add_gadget_udc
      drivers/usb/gadget/udc/gr_udc.c, 2186:
      	usb_add_gadget_udc in gr_probe
      drivers/usb/gadget/udc/gr_udc.c, 2183:
      	spin_lock in gr_probe
      
      drivers/usb/gadget/udc/gr_udc.c, 212:
      	debugfs_create_file in gr_probe
      drivers/usb/gadget/udc/gr_udc.c, 2197:
      	gr_dfs_create in gr_probe
      drivers/usb/gadget/udc/gr_udc.c, 2183:
          spin_lock in gr_probe
      
      drivers/usb/gadget/udc/gr_udc.c, 2114:
      	devm_request_threaded_irq in gr_request_irq
      drivers/usb/gadget/udc/gr_udc.c, 2202:
      	gr_request_irq in gr_probe
      drivers/usb/gadget/udc/gr_udc.c, 2183:
          spin_lock in gr_probe
      
      kzalloc(GFP_KERNEL), mutex_lock(), debugfs_create_file() and
      devm_request_threaded_irq() can sleep at runtime.
      
      To fix these possible bugs, usb_add_gadget_udc(), gr_dfs_create() and
      gr_request_irq() are called without handling the spinlock.
      
      These bugs are found by a static analysis tool STCheck written by myself.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6c053825
    • Jia-Ju Bai's avatar
      uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol() · ea6b7b1d
      Jia-Ju Bai authored
      [ Upstream commit b7435128 ]
      
      The driver may sleep while holding a spinlock.
      The function call path (from bottom to top) in Linux 4.19 is:
      
      kernel/irq/manage.c, 523:
      	synchronize_irq in disable_irq
      drivers/uio/uio_dmem_genirq.c, 140:
      	disable_irq in uio_dmem_genirq_irqcontrol
      drivers/uio/uio_dmem_genirq.c, 134:
      	_raw_spin_lock_irqsave in uio_dmem_genirq_irqcontrol
      
      synchronize_irq() can sleep at runtime.
      
      To fix this bug, disable_irq() is called without holding the spinlock.
      
      This bug is found by a static analysis tool STCheck written by myself.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Link: https://lore.kernel.org/r/20191218094405.6009-1-baijiaju1990@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea6b7b1d
    • David S. Miller's avatar
      sparc: Add .exit.data section. · 73a1803c
      David S. Miller authored
      [ Upstream commit 548f0b9a ]
      
      This fixes build errors of all sorts.
      
      Also, emit .exit.text unconditionally.
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      73a1803c
    • Tiezhu Yang's avatar
      MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init() · 2ebbbc9b
      Tiezhu Yang authored
      [ Upstream commit 72d052e2 ]
      
      If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL
      pointer dereference.
      
      Fixes: 3adeb256 ("MIPS: Loongson: Improve LEFI firmware interface")
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarPaul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Jiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: linux-mips@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ebbbc9b
    • Ard Biesheuvel's avatar
      efi/x86: Map the entire EFI vendor string before copying it · cf8938b1
      Ard Biesheuvel authored
      [ Upstream commit ffc2760b ]
      
      Fix a couple of issues with the way we map and copy the vendor string:
      - we map only 2 bytes, which usually works since you get at least a
        page, but if the vendor string happens to cross a page boundary,
        a crash will result
      - only call early_memunmap() if early_memremap() succeeded, or we will
        call it with a NULL address which it doesn't like,
      - while at it, switch to early_memremap_ro(), and array indexing rather
        than pointer dereferencing to read the CHAR16 characters.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Fixes: 5b83683f ("x86: EFI runtime service support")
      Link: https://lkml.kernel.org/r/20200103113953.9571-5-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cf8938b1
    • Hans de Goede's avatar
      pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins · 0a8a859f
      Hans de Goede authored
      [ Upstream commit a2368059 ]
      
      Suspending Goodix touchscreens requires changing the interrupt pin to
      output before sending them a power-down command. Followed by wiggling
      the interrupt pin to wake the device up, after which it is put back
      in input mode.
      
      On Bay Trail devices with a Goodix touchscreen direct-irq mode is used
      in combination with listing the pin as a normal GpioIo resource.
      
      This works fine, until the goodix driver gets rmmod-ed and then insmod-ed
      again. In this case byt_gpio_disable_free() calls
      byt_gpio_clear_triggering() which clears the IRQ flags and after that the
      (direct) IRQ no longer triggers.
      
      This commit fixes this by adding a check for the BYT_DIRECT_IRQ_EN flag
      to byt_gpio_clear_triggering().
      
      Note that byt_gpio_clear_triggering() only gets called from
      byt_gpio_disable_free() for direct-irq enabled pins, as these are excluded
      from the irq_valid mask by byt_init_irq_valid_mask().
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0a8a859f
    • Jia-Ju Bai's avatar
      media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run() · 47505a7d
      Jia-Ju Bai authored
      [ Upstream commit bb6d4206 ]
      
      The driver may sleep while holding a spinlock.
      The function call path (from bottom to top) in Linux 4.19 is:
      
      drivers/media/platform/sti/bdisp/bdisp-hw.c, 385:
          msleep in bdisp_hw_reset
      drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 341:
          bdisp_hw_reset in bdisp_device_run
      drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 317:
          _raw_spin_lock_irqsave in bdisp_device_run
      
      To fix this bug, msleep() is replaced with udelay().
      
      This bug is found by a static analysis tool STCheck written by myself.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Reviewed-by: default avatarFabien Dessenne <fabien.dessenne@st.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      47505a7d
    • Sergey Senozhatsky's avatar
      char/random: silence a lockdep splat with printk() · 15341b1d
      Sergey Senozhatsky authored
      [ Upstream commit 1b710b1b ]
      
      Sergey didn't like the locking order,
      
      uart_port->lock  ->  tty_port->lock
      
      uart_write (uart_port->lock)
        __uart_start
          pl011_start_tx
            pl011_tx_chars
              uart_write_wakeup
                tty_port_tty_wakeup
                  tty_port_default
                    tty_port_tty_get (tty_port->lock)
      
      but those code is so old, and I have no clue how to de-couple it after
      checking other locks in the splat. There is an onging effort to make all
      printk() as deferred, so until that happens, workaround it for now as a
      short-term fix.
      
      LTP: starting iogen01 (export LTPROOT; rwtest -N iogen01 -i 120s -s
      read,write -Da -Dv -n 2 500b:$TMPDIR/doio.f1.$$
      1000b:$TMPDIR/doio.f2.$$)
      WARNING: possible circular locking dependency detected
      ------------------------------------------------------
      doio/49441 is trying to acquire lock:
      ffff008b7cff7290 (&(&zone->lock)->rlock){..-.}, at: rmqueue+0x138/0x2050
      
      but task is already holding lock:
      60ff000822352818 (&pool->lock/1){-.-.}, at: start_flush_work+0xd8/0x3f0
      
        which lock already depends on the new lock.
      
        the existing dependency chain (in reverse order) is:
      
        -> #4 (&pool->lock/1){-.-.}:
             lock_acquire+0x320/0x360
             _raw_spin_lock+0x64/0x80
             __queue_work+0x4b4/0xa10
             queue_work_on+0xac/0x11c
             tty_schedule_flip+0x84/0xbc
             tty_flip_buffer_push+0x1c/0x28
             pty_write+0x98/0xd0
             n_tty_write+0x450/0x60c
             tty_write+0x338/0x474
             __vfs_write+0x88/0x214
             vfs_write+0x12c/0x1a4
             redirected_tty_write+0x90/0xdc
             do_loop_readv_writev+0x140/0x180
             do_iter_write+0xe0/0x10c
             vfs_writev+0x134/0x1cc
             do_writev+0xbc/0x130
             __arm64_sys_writev+0x58/0x8c
             el0_svc_handler+0x170/0x240
             el0_sync_handler+0x150/0x250
             el0_sync+0x164/0x180
      
        -> #3 (&(&port->lock)->rlock){-.-.}:
             lock_acquire+0x320/0x360
             _raw_spin_lock_irqsave+0x7c/0x9c
             tty_port_tty_get+0x24/0x60
             tty_port_default_wakeup+0x1c/0x3c
             tty_port_tty_wakeup+0x34/0x40
             uart_write_wakeup+0x28/0x44
             pl011_tx_chars+0x1b8/0x270
             pl011_start_tx+0x24/0x70
             __uart_start+0x5c/0x68
             uart_write+0x164/0x1c8
             do_output_char+0x33c/0x348
             n_tty_write+0x4bc/0x60c
             tty_write+0x338/0x474
             redirected_tty_write+0xc0/0xdc
             do_loop_readv_writev+0x140/0x180
             do_iter_write+0xe0/0x10c
             vfs_writev+0x134/0x1cc
             do_writev+0xbc/0x130
             __arm64_sys_writev+0x58/0x8c
             el0_svc_handler+0x170/0x240
             el0_sync_handler+0x150/0x250
             el0_sync+0x164/0x180
      
        -> #2 (&port_lock_key){-.-.}:
             lock_acquire+0x320/0x360
             _raw_spin_lock+0x64/0x80
             pl011_console_write+0xec/0x2cc
             console_unlock+0x794/0x96c
             vprintk_emit+0x260/0x31c
             vprintk_default+0x54/0x7c
             vprintk_func+0x218/0x254
             printk+0x7c/0xa4
             register_console+0x734/0x7b0
             uart_add_one_port+0x734/0x834
             pl011_register_port+0x6c/0xac
             sbsa_uart_probe+0x234/0x2ec
             platform_drv_probe+0xd4/0x124
             really_probe+0x250/0x71c
             driver_probe_device+0xb4/0x200
             __device_attach_driver+0xd8/0x188
             bus_for_each_drv+0xbc/0x110
             __device_attach+0x120/0x220
             device_initial_probe+0x20/0x2c
             bus_probe_device+0x54/0x100
             device_add+0xae8/0xc2c
             platform_device_add+0x278/0x3b8
             platform_device_register_full+0x238/0x2ac
             acpi_create_platform_device+0x2dc/0x3a8
             acpi_bus_attach+0x390/0x3cc
             acpi_bus_attach+0x108/0x3cc
             acpi_bus_attach+0x108/0x3cc
             acpi_bus_attach+0x108/0x3cc
             acpi_bus_scan+0x7c/0xb0
             acpi_scan_init+0xe4/0x304
             acpi_init+0x100/0x114
             do_one_initcall+0x348/0x6a0
             do_initcall_level+0x190/0x1fc
             do_basic_setup+0x34/0x4c
             kernel_init_freeable+0x19c/0x260
             kernel_init+0x18/0x338
             ret_from_fork+0x10/0x18
      
        -> #1 (console_owner){-...}:
             lock_acquire+0x320/0x360
             console_lock_spinning_enable+0x6c/0x7c
             console_unlock+0x4f8/0x96c
             vprintk_emit+0x260/0x31c
             vprintk_default+0x54/0x7c
             vprintk_func+0x218/0x254
             printk+0x7c/0xa4
             get_random_u64+0x1c4/0x1dc
             shuffle_pick_tail+0x40/0xac
             __free_one_page+0x424/0x710
             free_one_page+0x70/0x120
             __free_pages_ok+0x61c/0xa94
             __free_pages_core+0x1bc/0x294
             memblock_free_pages+0x38/0x48
             __free_pages_memory+0xcc/0xfc
             __free_memory_core+0x70/0x78
             free_low_memory_core_early+0x148/0x18c
             memblock_free_all+0x18/0x54
             mem_init+0xb4/0x17c
             mm_init+0x14/0x38
             start_kernel+0x19c/0x530
      
        -> #0 (&(&zone->lock)->rlock){..-.}:
             validate_chain+0xf6c/0x2e2c
             __lock_acquire+0x868/0xc2c
             lock_acquire+0x320/0x360
             _raw_spin_lock+0x64/0x80
             rmqueue+0x138/0x2050
             get_page_from_freelist+0x474/0x688
             __alloc_pages_nodemask+0x3b4/0x18dc
             alloc_pages_current+0xd0/0xe0
             alloc_slab_page+0x2b4/0x5e0
             new_slab+0xc8/0x6bc
             ___slab_alloc+0x3b8/0x640
             kmem_cache_alloc+0x4b4/0x588
             __debug_object_init+0x778/0x8b4
             debug_object_init_on_stack+0x40/0x50
             start_flush_work+0x16c/0x3f0
             __flush_work+0xb8/0x124
             flush_work+0x20/0x30
             xlog_cil_force_lsn+0x88/0x204 [xfs]
             xfs_log_force_lsn+0x128/0x1b8 [xfs]
             xfs_file_fsync+0x3c4/0x488 [xfs]
             vfs_fsync_range+0xb0/0xd0
             generic_write_sync+0x80/0xa0 [xfs]
             xfs_file_buffered_aio_write+0x66c/0x6e4 [xfs]
             xfs_file_write_iter+0x1a0/0x218 [xfs]
             __vfs_write+0x1cc/0x214
             vfs_write+0x12c/0x1a4
             ksys_write+0xb0/0x120
             __arm64_sys_write+0x54/0x88
             el0_svc_handler+0x170/0x240
             el0_sync_handler+0x150/0x250
             el0_sync+0x164/0x180
      
             other info that might help us debug this:
      
       Chain exists of:
         &(&zone->lock)->rlock --> &(&port->lock)->rlock --> &pool->lock/1
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(&pool->lock/1);
                                     lock(&(&port->lock)->rlock);
                                     lock(&pool->lock/1);
        lock(&(&zone->lock)->rlock);
      
                      *** DEADLOCK ***
      
      4 locks held by doio/49441:
       #0: a0ff00886fc27408 (sb_writers#8){.+.+}, at: vfs_write+0x118/0x1a4
       #1: 8fff00080810dfe0 (&xfs_nondir_ilock_class){++++}, at:
      xfs_ilock+0x2a8/0x300 [xfs]
       #2: ffff9000129f2390 (rcu_read_lock){....}, at:
      rcu_lock_acquire+0x8/0x38
       #3: 60ff000822352818 (&pool->lock/1){-.-.}, at:
      start_flush_work+0xd8/0x3f0
      
                     stack backtrace:
      CPU: 48 PID: 49441 Comm: doio Tainted: G        W
      Hardware name: HPE Apollo 70             /C01_APACHE_MB         , BIOS
      L50_5.13_1.11 06/18/2019
      Call trace:
       dump_backtrace+0x0/0x248
       show_stack+0x20/0x2c
       dump_stack+0xe8/0x150
       print_circular_bug+0x368/0x380
       check_noncircular+0x28c/0x294
       validate_chain+0xf6c/0x2e2c
       __lock_acquire+0x868/0xc2c
       lock_acquire+0x320/0x360
       _raw_spin_lock+0x64/0x80
       rmqueue+0x138/0x2050
       get_page_from_freelist+0x474/0x688
       __alloc_pages_nodemask+0x3b4/0x18dc
       alloc_pages_current+0xd0/0xe0
       alloc_slab_page+0x2b4/0x5e0
       new_slab+0xc8/0x6bc
       ___slab_alloc+0x3b8/0x640
       kmem_cache_alloc+0x4b4/0x588
       __debug_object_init+0x778/0x8b4
       debug_object_init_on_stack+0x40/0x50
       start_flush_work+0x16c/0x3f0
       __flush_work+0xb8/0x124
       flush_work+0x20/0x30
       xlog_cil_force_lsn+0x88/0x204 [xfs]
       xfs_log_force_lsn+0x128/0x1b8 [xfs]
       xfs_file_fsync+0x3c4/0x488 [xfs]
       vfs_fsync_range+0xb0/0xd0
       generic_write_sync+0x80/0xa0 [xfs]
       xfs_file_buffered_aio_write+0x66c/0x6e4 [xfs]
       xfs_file_write_iter+0x1a0/0x218 [xfs]
       __vfs_write+0x1cc/0x214
       vfs_write+0x12c/0x1a4
       ksys_write+0xb0/0x120
       __arm64_sys_write+0x54/0x88
       el0_svc_handler+0x170/0x240
       el0_sync_handler+0x150/0x250
       el0_sync+0x164/0x180
      Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Link: https://lore.kernel.org/r/1573679785-21068-1-git-send-email-cai@lca.pwSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      15341b1d
    • Jacob Pan's avatar
      iommu/vt-d: Fix off-by-one in PASID allocation · 4802b257
      Jacob Pan authored
      [ Upstream commit 39d630e3 ]
      
      PASID allocator uses IDR which is exclusive for the end of the
      allocation range. There is no need to decrement pasid_max.
      
      Fixes: af395073 ("iommu/vt-d: Apply global PASID in SVA")
      Reported-by: default avatarEric Auger <eric.auger@redhat.com>
      Signed-off-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
      Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4802b257