1. 21 Apr, 2020 7 commits
  2. 17 Apr, 2020 33 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.19.116 · 8488c3f3
      Greg Kroah-Hartman authored
      8488c3f3
    • Gary Lin's avatar
      efi/x86: Fix the deletion of variables in mixed mode · 94fe9e44
      Gary Lin authored
      [ Upstream commit a4b81ccf ]
      
      efi_thunk_set_variable() treated the NULL "data" pointer as an invalid
      parameter, and this broke the deletion of variables in mixed mode.
      This commit fixes the check of data so that the userspace program can
      delete a variable in mixed mode.
      
      Fixes: 8319e9d5 ("efi/x86: Handle by-ref arguments covering multiple pages in mixed mode")
      Signed-off-by: default avatarGary Lin <glin@suse.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200408081606.1504-1-glin@suse.com
      Link: https://lore.kernel.org/r/20200409130434.6736-9-ardb@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      94fe9e44
    • Andy Shevchenko's avatar
      mfd: dln2: Fix sanity checking for endpoints · 502d8e56
      Andy Shevchenko authored
      [ Upstream commit fb945c95 ]
      
      While the commit 2b8bd606 ("mfd: dln2: More sanity checking for endpoints")
      tries to harden the sanity checks it made at the same time a regression,
      i.e.  mixed in and out endpoints. Obviously it should have been not tested on
      real hardware at that time, but unluckily it didn't happen.
      
      So, fix above mentioned typo and make device being enumerated again.
      
      While here, introduce an enumerator for magic values to prevent similar issue
      to happen in the future.
      
      Fixes: 2b8bd606 ("mfd: dln2: More sanity checking for endpoints")
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      502d8e56
    • Christian Gmeiner's avatar
      etnaviv: perfmon: fix total and idle HI cyleces readout · 04fe2fbd
      Christian Gmeiner authored
      [ Upstream commit 15ff4a7b ]
      
      As seen at CodeAurora's linux-imx git repo in imx_4.19.35_1.0.0 branch.
      Signed-off-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04fe2fbd
    • Nathan Chancellor's avatar
      misc: echo: Remove unnecessary parentheses and simplify check for zero · bbff44d6
      Nathan Chancellor authored
      [ Upstream commit 85dc2c65 ]
      
      Clang warns when multiple pairs of parentheses are used for a single
      conditional statement.
      
      drivers/misc/echo/echo.c:384:27: warning: equality comparison with
      extraneous parentheses [-Wparentheses-equality]
              if ((ec->nonupdate_dwell == 0)) {
                   ~~~~~~~~~~~~~~~~~~~~^~~~
      drivers/misc/echo/echo.c:384:27: note: remove extraneous parentheses
      around the comparison to silence this warning
              if ((ec->nonupdate_dwell == 0)) {
                  ~                    ^   ~
      drivers/misc/echo/echo.c:384:27: note: use '=' to turn this equality
      comparison into an assignment
              if ((ec->nonupdate_dwell == 0)) {
                                       ^~
                                       =
      1 warning generated.
      
      Remove them and while we're at it, simplify the zero check as '!var' is
      used more than 'var == 0'.
      Reported-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bbff44d6
    • Laurentiu Tudor's avatar
      powerpc/fsl_booke: Avoid creating duplicate tlb1 entry · 87279a35
      Laurentiu Tudor authored
      [ Upstream commit aa411334 ]
      
      In the current implementation, the call to loadcam_multi() is wrapped
      between switch_to_as1() and restore_to_as0() calls so, when it tries
      to create its own temporary AS=1 TLB1 entry, it ends up duplicating
      the existing one created by switch_to_as1(). Add a check to skip
      creating the temporary entry if already running in AS=1.
      
      Fixes: d9e1831a ("powerpc/85xx: Load all early TLB entries at once")
      Cc: stable@vger.kernel.org # v4.4+
      Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
      Acked-by: default avatarScott Wood <oss@buserror.net>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200123111914.2565-1-laurentiu.tudor@nxp.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      87279a35
    • Masami Hiramatsu's avatar
      ftrace/kprobe: Show the maxactive number on kprobe_events · 52f1c425
      Masami Hiramatsu authored
      [ Upstream commit 6a13a0d7 ]
      
      Show maxactive parameter on kprobe_events.
      This allows user to save the current configuration and
      restore it without losing maxactive parameter.
      
      Link: http://lkml.kernel.org/r/4762764a-6df7-bc93-ed60-e336146dce1f@gmail.com
      Link: http://lkml.kernel.org/r/158503528846.22706.5549974121212526020.stgit@devnote2
      
      Cc: stable@vger.kernel.org
      Fixes: 696ced4f ("tracing/kprobes: expose maxactive for kretprobe in kprobe_events")
      Reported-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      52f1c425
    • Chris Wilson's avatar
      drm: Remove PageReserved manipulation from drm_pci_alloc · 49d7fa0e
      Chris Wilson authored
      [ Upstream commit ea36ec86 ]
      
      drm_pci_alloc/drm_pci_free are very thin wrappers around the core dma
      facilities, and we have no special reason within the drm layer to behave
      differently. In particular, since
      
      commit de09d31d
      Author: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Date:   Fri Jan 15 16:51:42 2016 -0800
      
          page-flags: define PG_reserved behavior on compound pages
      
          As far as I can see there's no users of PG_reserved on compound pages.
          Let's use PF_NO_COMPOUND here.
      
      it has been illegal to combine GFP_COMP with SetPageReserved, so lets
      stop doing both and leave the dma layer to its own devices.
      
      Reported-by: Taketo Kabe
      Bug: https://gitlab.freedesktop.org/drm/intel/issues/1027
      Fixes: de09d31d ("page-flags: define PG_reserved behavior on compound pages")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: <stable@vger.kernel.org> # v4.5+
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200202171635.4039044-1-chris@chris-wilson.co.ukSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      49d7fa0e
    • Lyude Paul's avatar
      drm/dp_mst: Fix clearing payload state on topology disable · a0522bbd
      Lyude Paul authored
      [ Upstream commit 8732fe46 ]
      
      The issues caused by:
      
      commit 64e62bdf ("drm/dp_mst: Remove VCPI while disabling topology
      mgr")
      
      Prompted me to take a closer look at how we clear the payload state in
      general when disabling the topology, and it turns out there's actually
      two subtle issues here.
      
      The first is that we're not grabbing &mgr.payload_lock when clearing the
      payloads in drm_dp_mst_topology_mgr_set_mst(). Seeing as the canonical
      lock order is &mgr.payload_lock -> &mgr.lock (because we always want
      &mgr.lock to be the inner-most lock so topology validation always
      works), this makes perfect sense. It also means that -technically- there
      could be racing between someone calling
      drm_dp_mst_topology_mgr_set_mst() to disable the topology, along with a
      modeset occurring that's modifying the payload state at the same time.
      
      The second is the more obvious issue that Wayne Lin discovered, that
      we're not clearing proposed_payloads when disabling the topology.
      
      I actually can't see any obvious places where the racing caused by the
      first issue would break something, and it could be that some of our
      higher-level locks already prevent this by happenstance, but better safe
      then sorry. So, let's make it so that drm_dp_mst_topology_mgr_set_mst()
      first grabs &mgr.payload_lock followed by &mgr.lock so that we never
      race when modifying the payload state. Then, we also clear
      proposed_payloads to fix the original issue of enabling a new topology
      with a dirty payload state. This doesn't clear any of the drm_dp_vcpi
      structures, but those are getting destroyed along with the ports anyway.
      
      Changes since v1:
      * Use sizeof(mgr->payloads[0])/sizeof(mgr->proposed_vcpis[0]) instead -
        vsyrjala
      
      Cc: Sean Paul <sean@poorly.run>
      Cc: Wayne Lin <Wayne.Lin@amd.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: stable@vger.kernel.org # v4.4+
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200122194321.14953-1-lyude@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      a0522bbd
    • Sasha Levin's avatar
      Revert "drm/dp_mst: Remove VCPI while disabling topology mgr" · 9a61fe23
      Sasha Levin authored
      [ Upstream commit a8667596 ]
      
      This reverts commit 64e62bdf.
      
      This commit ends up causing some lockdep splats due to trying to grab the
      payload lock while holding the mgr's lock:
      
      [   54.010099]
      [   54.011765] ======================================================
      [   54.018670] WARNING: possible circular locking dependency detected
      [   54.025577] 5.5.0-rc6-02274-g77381c23ee63 #47 Not tainted
      [   54.031610] ------------------------------------------------------
      [   54.038516] kworker/1:6/1040 is trying to acquire lock:
      [   54.044354] ffff888272af3228 (&mgr->payload_lock){+.+.}, at:
      drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.054957]
      [   54.054957] but task is already holding lock:
      [   54.061473] ffff888272af3060 (&mgr->lock){+.+.}, at:
      drm_dp_mst_topology_mgr_set_mst+0x3c/0x2e4
      [   54.071193]
      [   54.071193] which lock already depends on the new lock.
      [   54.071193]
      [   54.080334]
      [   54.080334] the existing dependency chain (in reverse order) is:
      [   54.088697]
      [   54.088697] -> #1 (&mgr->lock){+.+.}:
      [   54.094440]        __mutex_lock+0xc3/0x498
      [   54.099015]        drm_dp_mst_topology_get_port_validated+0x25/0x80
      [   54.106018]        drm_dp_update_payload_part1+0xa2/0x2e2
      [   54.112051]        intel_mst_pre_enable_dp+0x144/0x18f
      [   54.117791]        intel_encoders_pre_enable+0x63/0x70
      [   54.123532]        hsw_crtc_enable+0xa1/0x722
      [   54.128396]        intel_update_crtc+0x50/0x194
      [   54.133455]        skl_commit_modeset_enables+0x40c/0x540
      [   54.139485]        intel_atomic_commit_tail+0x5f7/0x130d
      [   54.145418]        intel_atomic_commit+0x2c8/0x2d8
      [   54.150770]        drm_atomic_helper_set_config+0x5a/0x70
      [   54.156801]        drm_mode_setcrtc+0x2ab/0x833
      [   54.161862]        drm_ioctl+0x2e5/0x424
      [   54.166242]        vfs_ioctl+0x21/0x2f
      [   54.170426]        do_vfs_ioctl+0x5fb/0x61e
      [   54.175096]        ksys_ioctl+0x55/0x75
      [   54.179377]        __x64_sys_ioctl+0x1a/0x1e
      [   54.184146]        do_syscall_64+0x5c/0x6d
      [   54.188721]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      [   54.194946]
      [   54.194946] -> #0 (&mgr->payload_lock){+.+.}:
      [   54.201463]
      [   54.201463] other info that might help us debug this:
      [   54.201463]
      [   54.210410]  Possible unsafe locking scenario:
      [   54.210410]
      [   54.217025]        CPU0                    CPU1
      [   54.222082]        ----                    ----
      [   54.227138]   lock(&mgr->lock);
      [   54.230643]                                lock(&mgr->payload_lock);
      [   54.237742]                                lock(&mgr->lock);
      [   54.244062]   lock(&mgr->payload_lock);
      [   54.248346]
      [   54.248346]  *** DEADLOCK ***
      [   54.248346]
      [   54.254959] 7 locks held by kworker/1:6/1040:
      [   54.259822]  #0: ffff888275c4f528 ((wq_completion)events){+.+.},
      at: worker_thread+0x455/0x6e2
      [   54.269451]  #1: ffffc9000119beb0
      ((work_completion)(&(&dev_priv->hotplug.hotplug_work)->work)){+.+.},
      at: worker_thread+0x455/0x6e2
      [   54.282768]  #2: ffff888272a403f0 (&dev->mode_config.mutex){+.+.},
      at: i915_hotplug_work_func+0x4b/0x2be
      [   54.293368]  #3: ffffffff824fc6c0 (drm_connector_list_iter){.+.+},
      at: i915_hotplug_work_func+0x17e/0x2be
      [   54.304061]  #4: ffffc9000119bc58 (crtc_ww_class_acquire){+.+.},
      at: drm_helper_probe_detect_ctx+0x40/0xfd
      [   54.314855]  #5: ffff888272a40470 (crtc_ww_class_mutex){+.+.}, at:
      drm_modeset_lock+0x74/0xe2
      [   54.324385]  #6: ffff888272af3060 (&mgr->lock){+.+.}, at:
      drm_dp_mst_topology_mgr_set_mst+0x3c/0x2e4
      [   54.334597]
      [   54.334597] stack backtrace:
      [   54.339464] CPU: 1 PID: 1040 Comm: kworker/1:6 Not tainted
      5.5.0-rc6-02274-g77381c23ee63 #47
      [   54.348893] Hardware name: Google Fizz/Fizz, BIOS
      Google_Fizz.10139.39.0 01/04/2018
      [   54.357451] Workqueue: events i915_hotplug_work_func
      [   54.362995] Call Trace:
      [   54.365724]  dump_stack+0x71/0x9c
      [   54.369427]  check_noncircular+0x91/0xbc
      [   54.373809]  ? __lock_acquire+0xc9e/0xf66
      [   54.378286]  ? __lock_acquire+0xc9e/0xf66
      [   54.382763]  ? lock_acquire+0x175/0x1ac
      [   54.387048]  ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.393177]  ? __mutex_lock+0xc3/0x498
      [   54.397362]  ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.403492]  ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.409620]  ? drm_dp_dpcd_access+0xd9/0x101
      [   54.414390]  ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.420517]  ? drm_dp_mst_topology_mgr_set_mst+0x218/0x2e4
      [   54.426645]  ? intel_digital_port_connected+0x34d/0x35c
      [   54.432482]  ? intel_dp_detect+0x227/0x44e
      [   54.437056]  ? ww_mutex_lock+0x49/0x9a
      [   54.441242]  ? drm_helper_probe_detect_ctx+0x75/0xfd
      [   54.446789]  ? intel_encoder_hotplug+0x4b/0x97
      [   54.451752]  ? intel_ddi_hotplug+0x61/0x2e0
      [   54.456423]  ? mark_held_locks+0x53/0x68
      [   54.460803]  ? _raw_spin_unlock_irqrestore+0x3a/0x51
      [   54.466347]  ? lockdep_hardirqs_on+0x187/0x1a4
      [   54.471310]  ? drm_connector_list_iter_next+0x89/0x9a
      [   54.476953]  ? i915_hotplug_work_func+0x206/0x2be
      [   54.482208]  ? worker_thread+0x4d5/0x6e2
      [   54.486587]  ? worker_thread+0x455/0x6e2
      [   54.490966]  ? queue_work_on+0x64/0x64
      [   54.495151]  ? kthread+0x1e9/0x1f1
      [   54.498946]  ? queue_work_on+0x64/0x64
      [   54.503130]  ? kthread_unpark+0x5e/0x5e
      [   54.507413]  ? ret_from_fork+0x3a/0x50
      
      The proper fix for this is probably cleanup the VCPI allocations when we're
      enabling the topology, or on the first payload allocation. For now though,
      let's just revert.
      Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
      Fixes: 64e62bdf ("drm/dp_mst: Remove VCPI while disabling topology mgr")
      Cc: Sean Paul <sean@poorly.run>
      Cc: Wayne Lin <Wayne.Lin@amd.com>
      Reviewed-by: default avatarSean Paul <sean@poorly.run>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200117205149.97262-1-lyude@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      9a61fe23
    • Gilad Ben-Yossef's avatar
      crypto: ccree - only try to map auth tag if needed · 1e0c3805
      Gilad Ben-Yossef authored
      [ Upstream commit 504e84ab ]
      
      Make sure to only add the size of the auth tag to the source mapping
      for encryption if it is an in-place operation. Failing to do this
      previously caused us to try and map auth size len bytes from a NULL
      mapping and crashing if both the cryptlen and assoclen are zero.
      Reported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e0c3805
    • Gilad Ben-Yossef's avatar
      crypto: ccree - dec auth tag size from cryptlen map · dd5f4a04
      Gilad Ben-Yossef authored
      [ Upstream commit 8962c6d2 ]
      
      Remove the auth tag size from cryptlen before mapping the destination
      in out-of-place AEAD decryption thus resolving a crash with
      extended testmgr tests.
      Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
      Reported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: stable@vger.kernel.org # v4.19+
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd5f4a04
    • Gilad Ben-Yossef's avatar
      crypto: ccree - don't mangle the request assoclen · a44ed698
      Gilad Ben-Yossef authored
      [ Upstream commit da3cf67f ]
      
      We were mangling the request struct assoclen field.
      Fix it by keeping an internal version and working on it.
      Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a44ed698
    • Gilad Ben-Yossef's avatar
      crypto: ccree - zero out internal struct before use · c8cff87d
      Gilad Ben-Yossef authored
      [ Upstream commit 9f31eb6e ]
      
      We did not zero out the internal struct before use causing problem
      in some rare error code paths.
      Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c8cff87d
    • Hadar Gat's avatar
      crypto: ccree - improve error handling · c08805aa
      Hadar Gat authored
      [ Upstream commit ccba2f11 ]
      
      pass the returned error code to the higher level functions
      Signed-off-by: default avatarHadar Gat <hadar.gat@arm.com>
      Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c08805aa
    • Andrei Botila's avatar
      crypto: caam - update xts sector size for large input length · 9b463a24
      Andrei Botila authored
      [ Upstream commit 3f142b6a ]
      
      Since in the software implementation of XTS-AES there is
      no notion of sector every input length is processed the same way.
      CAAM implementation has the notion of sector which causes different
      results between the software implementation and the one in CAAM
      for input lengths bigger than 512 bytes.
      Increase sector size to maximum value on 16 bits.
      
      Fixes: c6415a60 ("crypto: caam - add support for acipher xts(aes)")
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: default avatarAndrei Botila <andrei.botila@nxp.com>
      Reviewed-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9b463a24
    • Bob Liu's avatar
      dm zoned: remove duplicate nr_rnd_zones increase in dmz_init_zone() · 738d853b
      Bob Liu authored
      [ Upstream commit b8fdd090 ]
      
      zmd->nr_rnd_zones was increased twice by mistake. The other place it
      is increased in dmz_init_zone() is the only one needed:
      
      1131                 zmd->nr_useable_zones++;
      1132                 if (dmz_is_rnd(zone)) {
      1133                         zmd->nr_rnd_zones++;
      					^^^
      Fixes: 3b1a94c8 ("dm zoned: drive-managed zoned block device target")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBob Liu <bob.liu@oracle.com>
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      738d853b
    • Josef Bacik's avatar
      btrfs: use nofs allocations for running delayed items · 45b9d993
      Josef Bacik authored
      [ Upstream commit 351cbf6e ]
      
      Zygo reported the following lockdep splat while testing the balance
      patches
      
      ======================================================
      WARNING: possible circular locking dependency detected
      5.6.0-c6f0579d496a+ #53 Not tainted
      ------------------------------------------------------
      kswapd0/1133 is trying to acquire lock:
      ffff888092f622c0 (&delayed_node->mutex){+.+.}, at: __btrfs_release_delayed_node+0x7c/0x5b0
      
      but task is already holding lock:
      ffffffff8fc5f860 (fs_reclaim){+.+.}, at: __fs_reclaim_acquire+0x5/0x30
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #1 (fs_reclaim){+.+.}:
             fs_reclaim_acquire.part.91+0x29/0x30
             fs_reclaim_acquire+0x19/0x20
             kmem_cache_alloc_trace+0x32/0x740
             add_block_entry+0x45/0x260
             btrfs_ref_tree_mod+0x6e2/0x8b0
             btrfs_alloc_tree_block+0x789/0x880
             alloc_tree_block_no_bg_flush+0xc6/0xf0
             __btrfs_cow_block+0x270/0x940
             btrfs_cow_block+0x1ba/0x3a0
             btrfs_search_slot+0x999/0x1030
             btrfs_insert_empty_items+0x81/0xe0
             btrfs_insert_delayed_items+0x128/0x7d0
             __btrfs_run_delayed_items+0xf4/0x2a0
             btrfs_run_delayed_items+0x13/0x20
             btrfs_commit_transaction+0x5cc/0x1390
             insert_balance_item.isra.39+0x6b2/0x6e0
             btrfs_balance+0x72d/0x18d0
             btrfs_ioctl_balance+0x3de/0x4c0
             btrfs_ioctl+0x30ab/0x44a0
             ksys_ioctl+0xa1/0xe0
             __x64_sys_ioctl+0x43/0x50
             do_syscall_64+0x77/0x2c0
             entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      -> #0 (&delayed_node->mutex){+.+.}:
             __lock_acquire+0x197e/0x2550
             lock_acquire+0x103/0x220
             __mutex_lock+0x13d/0xce0
             mutex_lock_nested+0x1b/0x20
             __btrfs_release_delayed_node+0x7c/0x5b0
             btrfs_remove_delayed_node+0x49/0x50
             btrfs_evict_inode+0x6fc/0x900
             evict+0x19a/0x2c0
             dispose_list+0xa0/0xe0
             prune_icache_sb+0xbd/0xf0
             super_cache_scan+0x1b5/0x250
             do_shrink_slab+0x1f6/0x530
             shrink_slab+0x32e/0x410
             shrink_node+0x2a5/0xba0
             balance_pgdat+0x4bd/0x8a0
             kswapd+0x35a/0x800
             kthread+0x1e9/0x210
             ret_from_fork+0x3a/0x50
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(fs_reclaim);
                                     lock(&delayed_node->mutex);
                                     lock(fs_reclaim);
        lock(&delayed_node->mutex);
      
       *** DEADLOCK ***
      
      3 locks held by kswapd0/1133:
       #0: ffffffff8fc5f860 (fs_reclaim){+.+.}, at: __fs_reclaim_acquire+0x5/0x30
       #1: ffffffff8fc380d8 (shrinker_rwsem){++++}, at: shrink_slab+0x1e8/0x410
       #2: ffff8881e0e6c0e8 (&type->s_umount_key#42){++++}, at: trylock_super+0x1b/0x70
      
      stack backtrace:
      CPU: 2 PID: 1133 Comm: kswapd0 Not tainted 5.6.0-c6f0579d496a+ #53
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Call Trace:
       dump_stack+0xc1/0x11a
       print_circular_bug.isra.38.cold.57+0x145/0x14a
       check_noncircular+0x2a9/0x2f0
       ? print_circular_bug.isra.38+0x130/0x130
       ? stack_trace_consume_entry+0x90/0x90
       ? save_trace+0x3cc/0x420
       __lock_acquire+0x197e/0x2550
       ? btrfs_inode_clear_file_extent_range+0x9b/0xb0
       ? register_lock_class+0x960/0x960
       lock_acquire+0x103/0x220
       ? __btrfs_release_delayed_node+0x7c/0x5b0
       __mutex_lock+0x13d/0xce0
       ? __btrfs_release_delayed_node+0x7c/0x5b0
       ? __asan_loadN+0xf/0x20
       ? pvclock_clocksource_read+0xeb/0x190
       ? __btrfs_release_delayed_node+0x7c/0x5b0
       ? mutex_lock_io_nested+0xc20/0xc20
       ? __kasan_check_read+0x11/0x20
       ? check_chain_key+0x1e6/0x2e0
       mutex_lock_nested+0x1b/0x20
       ? mutex_lock_nested+0x1b/0x20
       __btrfs_release_delayed_node+0x7c/0x5b0
       btrfs_remove_delayed_node+0x49/0x50
       btrfs_evict_inode+0x6fc/0x900
       ? btrfs_setattr+0x840/0x840
       ? do_raw_spin_unlock+0xa8/0x140
       evict+0x19a/0x2c0
       dispose_list+0xa0/0xe0
       prune_icache_sb+0xbd/0xf0
       ? invalidate_inodes+0x310/0x310
       super_cache_scan+0x1b5/0x250
       do_shrink_slab+0x1f6/0x530
       shrink_slab+0x32e/0x410
       ? do_shrink_slab+0x530/0x530
       ? do_shrink_slab+0x530/0x530
       ? __kasan_check_read+0x11/0x20
       ? mem_cgroup_protected+0x13d/0x260
       shrink_node+0x2a5/0xba0
       balance_pgdat+0x4bd/0x8a0
       ? mem_cgroup_shrink_node+0x490/0x490
       ? _raw_spin_unlock_irq+0x27/0x40
       ? finish_task_switch+0xce/0x390
       ? rcu_read_lock_bh_held+0xb0/0xb0
       kswapd+0x35a/0x800
       ? _raw_spin_unlock_irqrestore+0x4c/0x60
       ? balance_pgdat+0x8a0/0x8a0
       ? finish_wait+0x110/0x110
       ? __kasan_check_read+0x11/0x20
       ? __kthread_parkme+0xc6/0xe0
       ? balance_pgdat+0x8a0/0x8a0
       kthread+0x1e9/0x210
       ? kthread_create_worker_on_cpu+0xc0/0xc0
       ret_from_fork+0x3a/0x50
      
      This is because we hold that delayed node's mutex while doing tree
      operations.  Fix this by just wrapping the searches in nofs.
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45b9d993
    • Clement Courbet's avatar
      powerpc: Make setjmp/longjmp signature standard · 473575d5
      Clement Courbet authored
      commit c17eb4dc upstream.
      
      Declaring setjmp()/longjmp() as taking longs makes the signature
      non-standard, and makes clang complain. In the past, this has been
      worked around by adding -ffreestanding to the compile flags.
      
      The implementation looks like it only ever propagates the value
      (in longjmp) or sets it to 1 (in setjmp), and we only call longjmp
      with integer parameters.
      
      This allows removing -ffreestanding from the compilation flags.
      
      Fixes: c9029ef9 ("powerpc: Avoid clang warnings around setjmp and longjmp")
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: default avatarClement Courbet <courbet@google.com>
      Reviewed-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Tested-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200330080400.124803-1-courbet@google.comSigned-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      473575d5
    • Segher Boessenkool's avatar
      powerpc: Add attributes for setjmp/longjmp · 303b647b
      Segher Boessenkool authored
      commit aa497d43 upstream.
      
      The setjmp function should be declared as "returns_twice", or bad
      things can happen[1]. This does not actually change generated code in
      my testing.
      
      The longjmp function should be declared as "noreturn", so that the
      compiler can optimise calls to it better. This makes the generated
      code a little shorter.
      
      1: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-returns_005ftwice-function-attributeSigned-off-by: default avatarSegher Boessenkool <segher@kernel.crashing.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/c02ce4a573f3bac907e2c70957a2d1275f910013.1567605586.git.segher@kernel.crashing.orgSigned-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      303b647b
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Fix kernel panic observed on soft HBA unplug · 3851b89b
      Sreekanth Reddy authored
      commit cc41f11a upstream.
      
      Generic protection fault type kernel panic is observed when user performs
      soft (ordered) HBA unplug operation while IOs are running on drives
      connected to HBA.
      
      When user performs ordered HBA removal operation, the kernel calls PCI
      device's .remove() call back function where driver is flushing out all the
      outstanding SCSI IO commands with DID_NO_CONNECT host byte and also unmaps
      sg buffers allocated for these IO commands.
      
      However, in the ordered HBA removal case (unlike of real HBA hot removal),
      HBA device is still alive and hence HBA hardware is performing the DMA
      operations to those buffers on the system memory which are already unmapped
      while flushing out the outstanding SCSI IO commands and this leads to
      kernel panic.
      
      Don't flush out the outstanding IOs from .remove() path in case of ordered
      removal since HBA will be still alive in this case and it can complete the
      outstanding IOs. Flush out the outstanding IOs only in case of 'physical
      HBA hot unplug' where there won't be any communication with the HBA.
      
      During shutdown also it is possible that HBA hardware can perform DMA
      operations on those outstanding IO buffers which are completed with
      DID_NO_CONNECT by the driver from .shutdown(). So same above fix is applied
      in shutdown path as well.
      
      It is safe to drop the outstanding commands when HBA is inaccessible such
      as when permanent PCI failure happens, when HBA is in non-operational
      state, or when someone does a real HBA hot unplug operation. Since driver
      knows that HBA is inaccessible during these cases, it is safe to drop the
      outstanding commands instead of waiting for SCSI error recovery to kick in
      and clear these outstanding commands.
      
      Link: https://lore.kernel.org/r/1585302763-23007-1-git-send-email-sreekanth.reddy@broadcom.com
      Fixes: c666d3be ("scsi: mpt3sas: wait for and flush running commands on shutdown/unload")
      Cc: stable@vger.kernel.org #v4.14.174+
      Signed-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      3851b89b
    • Christophe Leroy's avatar
      powerpc/kprobes: Ignore traps that happened in real mode · 82efee6a
      Christophe Leroy authored
      commit 21f8b2fa upstream.
      
      When a program check exception happens while MMU translation is
      disabled, following Oops happens in kprobe_handler() in the following
      code:
      
      	} else if (*addr != BREAKPOINT_INSTRUCTION) {
      
        BUG: Unable to handle kernel data access on read at 0x0000e268
        Faulting instruction address: 0xc000ec34
        Oops: Kernel access of bad area, sig: 11 [#1]
        BE PAGE_SIZE=16K PREEMPT CMPC885
        Modules linked in:
        CPU: 0 PID: 429 Comm: cat Not tainted 5.6.0-rc1-s3k-dev-00824-g84195dc6c58a #3267
        NIP:  c000ec34 LR: c000ecd8 CTR: c019cab8
        REGS: ca4d3b58 TRAP: 0300   Not tainted  (5.6.0-rc1-s3k-dev-00824-g84195dc6c58a)
        MSR:  00001032 <ME,IR,DR,RI>  CR: 2a4d3c52  XER: 00000000
        DAR: 0000e268 DSISR: c0000000
        GPR00: c000b09c ca4d3c10 c66d0620 00000000 ca4d3c60 00000000 00009032 00000000
        GPR08: 00020000 00000000 c087de44 c000afe0 c66d0ad0 100d3dd6 fffffff3 00000000
        GPR16: 00000000 00000041 00000000 ca4d3d70 00000000 00000000 0000416d 00000000
        GPR24: 00000004 c53b6128 00000000 0000e268 00000000 c07c0000 c07bb6fc ca4d3c60
        NIP [c000ec34] kprobe_handler+0x128/0x290
        LR [c000ecd8] kprobe_handler+0x1cc/0x290
        Call Trace:
        [ca4d3c30] [c000b09c] program_check_exception+0xbc/0x6fc
        [ca4d3c50] [c000e43c] ret_from_except_full+0x0/0x4
        --- interrupt: 700 at 0xe268
        Instruction dump:
        913e0008 81220000 38600001 3929ffff 91220000 80010024 bb410008 7c0803a6
        38210020 4e800020 38600000 4e800020 <813b0000> 6d2a7fe0 2f8a0008 419e0154
        ---[ end trace 5b9152d4cdadd06d ]---
      
      kprobe is not prepared to handle events in real mode and functions
      running in real mode should have been blacklisted, so kprobe_handler()
      can safely bail out telling 'this trap is not mine' for any trap that
      happened while in real-mode.
      
      If the trap happened with MSR_IR or MSR_DR cleared, return 0
      immediately.
      Reported-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Fixes: 6cc89bad ("powerpc/kprobes: Invoke handlers directly")
      Cc: stable@vger.kernel.org # v4.10+
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@c-s.fr>
      Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Reviewed-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/424331e2006e7291a1bfe40e7f3fa58825f565e1.1582054578.git.christophe.leroy@c-s.frSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82efee6a
    • Cédric Le Goater's avatar
      powerpc/xive: Use XIVE_BAD_IRQ instead of zero to catch non configured IPIs · d1de05f2
      Cédric Le Goater authored
      commit b1a504a6 upstream.
      
      When a CPU is brought up, an IPI number is allocated and recorded
      under the XIVE CPU structure. Invalid IPI numbers are tracked with
      interrupt number 0x0.
      
      On the PowerNV platform, the interrupt number space starts at 0x10 and
      this works fine. However, on the sPAPR platform, it is possible to
      allocate the interrupt number 0x0 and this raises an issue when CPU 0
      is unplugged. The XIVE spapr driver tracks allocated interrupt numbers
      in a bitmask and it is not correctly updated when interrupt number 0x0
      is freed. It stays allocated and it is then impossible to reallocate.
      
      Fix by using the XIVE_BAD_IRQ value instead of zero on both platforms.
      Reported-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Fixes: eac1e731 ("powerpc/xive: guest exploitation of the XIVE interrupt controller")
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      Reviewed-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Tested-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200306150143.5551-2-clg@kaod.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1de05f2
    • Aneesh Kumar K.V's avatar
      powerpc/hash64/devmap: Use H_PAGE_THP_HUGE when setting up huge devmap PTE entries · 7ab2eb7c
      Aneesh Kumar K.V authored
      commit 36b78402 upstream.
      
      H_PAGE_THP_HUGE is used to differentiate between a THP hugepage and
      hugetlb hugepage entries. The difference is WRT how we handle hash
      fault on these address. THP address enables MPSS in segments. We want
      to manage devmap hugepage entries similar to THP pt entries. Hence use
      H_PAGE_THP_HUGE for devmap huge PTE entries.
      
      With current code while handling hash PTE fault, we do set is_thp =
      true when finding devmap PTE huge PTE entries.
      
      Current code also does the below sequence we setting up huge devmap
      entries.
      
      	entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
      	if (pfn_t_devmap(pfn))
      		entry = pmd_mkdevmap(entry);
      
      In that case we would find both H_PAGE_THP_HUGE and PAGE_DEVMAP set
      for huge devmap PTE entries. This results in false positive error like
      below.
      
        kernel BUG at /home/kvaneesh/src/linux/mm/memory.c:4321!
        Oops: Exception in kernel mode, sig: 5 [#1]
        LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in:
        CPU: 56 PID: 67996 Comm: t_mmap_dio Not tainted 5.6.0-rc4-59640-g371c804dedbc #128
        ....
        NIP [c00000000044c9e4] __follow_pte_pmd+0x264/0x900
        LR [c0000000005d45f8] dax_writeback_one+0x1a8/0x740
        Call Trace:
          str_spec.74809+0x22ffb4/0x2d116c (unreliable)
          dax_writeback_one+0x1a8/0x740
          dax_writeback_mapping_range+0x26c/0x700
          ext4_dax_writepages+0x150/0x5a0
          do_writepages+0x68/0x180
          __filemap_fdatawrite_range+0x138/0x180
          file_write_and_wait_range+0xa4/0x110
          ext4_sync_file+0x370/0x6e0
          vfs_fsync_range+0x70/0xf0
          sys_msync+0x220/0x2e0
          system_call+0x5c/0x68
      
      This is because our pmd_trans_huge check doesn't exclude _PAGE_DEVMAP.
      
      To make this all consistent, update pmd_mkdevmap to set
      H_PAGE_THP_HUGE and pmd_trans_huge check now excludes _PAGE_DEVMAP
      correctly.
      
      Fixes: ebd31197 ("powerpc/mm: Add devmap support for ppc64")
      Cc: stable@vger.kernel.org # v4.13+
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200313094842.351830-1-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ab2eb7c
    • Michael Ellerman's avatar
      powerpc/64/tm: Don't let userspace set regs->trap via sigreturn · c14e3ade
      Michael Ellerman authored
      commit c7def7fb upstream.
      
      In restore_tm_sigcontexts() we take the trap value directly from the
      user sigcontext with no checking:
      
      	err |= __get_user(regs->trap, &sc->gp_regs[PT_TRAP]);
      
      This means we can be in the kernel with an arbitrary regs->trap value.
      
      Although that's not immediately problematic, there is a risk we could
      trigger one of the uses of CHECK_FULL_REGS():
      
      	#define CHECK_FULL_REGS(regs)	BUG_ON(regs->trap & 1)
      
      It can also cause us to unnecessarily save non-volatile GPRs again in
      save_nvgprs(), which shouldn't be problematic but is still wrong.
      
      It's also possible it could trick the syscall restart machinery, which
      relies on regs->trap not being == 0xc00 (see 9a81c16b ("powerpc:
      fix double syscall restarts")), though I haven't been able to make
      that happen.
      
      Finally it doesn't match the behaviour of the non-TM case, in
      restore_sigcontext() which zeroes regs->trap.
      
      So change restore_tm_sigcontexts() to zero regs->trap.
      
      This was discovered while testing Nick's upcoming rewrite of the
      syscall entry path. In that series the call to save_nvgprs() prior to
      signal handling (do_notify_resume()) is removed, which leaves the
      low-bit of regs->trap uncleared which can then trigger the FULL_REGS()
      WARNs in setup_tm_sigcontexts().
      
      Fixes: 2b0a576d ("powerpc: Add new transactional memory state to the signal context")
      Cc: stable@vger.kernel.org # v3.9+
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200401023836.3286664-1-mpe@ellerman.id.auSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c14e3ade
    • Michael Ellerman's avatar
      powerpc/powernv/idle: Restore AMR/UAMOR/AMOR after idle · 1855c543
      Michael Ellerman authored
      commit 53a712ba upstream.
      
      In order to implement KUAP (Kernel Userspace Access Protection) on
      Power9 we will be using the AMR, and therefore indirectly the
      UAMOR/AMOR.
      
      So save/restore these regs in the idle code.
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      [ajd: Backport to 4.19 tree, CVE-2020-11669]
      Signed-off-by: default avatarAndrew Donnellan <ajd@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1855c543
    • Juergen Gross's avatar
      xen/blkfront: fix memory allocation flags in blkfront_setup_indirect() · 5f547e7c
      Juergen Gross authored
      commit 3a169c0b upstream.
      
      Commit 1d5c76e6 ("xen-blkfront: switch kcalloc to kvcalloc for
      large array allocation") didn't fix the issue it was meant to, as the
      flags for allocating the memory are GFP_NOIO, which will lead the
      memory allocation falling back to kmalloc().
      
      So instead of GFP_NOIO use GFP_KERNEL and do all the memory allocation
      in blkfront_setup_indirect() in a memalloc_noio_{save,restore} section.
      
      Fixes: 1d5c76e6 ("xen-blkfront: switch kcalloc to kvcalloc for large array allocation")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Acked-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Link: https://lore.kernel.org/r/20200403090034.8753-1-jgross@suse.comSigned-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5f547e7c
    • Wen Yang's avatar
      ipmi: fix hung processes in __get_guid() · 0721b549
      Wen Yang authored
      commit 32830a05 upstream.
      
      The wait_event() function is used to detect command completion.
      When send_guid_cmd() returns an error, smi_send() has not been
      called to send data. Therefore, wait_event() should not be used
      on the error path, otherwise it will cause the following warning:
      
      [ 1361.588808] systemd-udevd   D    0  1501   1436 0x00000004
      [ 1361.588813]  ffff883f4b1298c0 0000000000000000 ffff883f4b188000 ffff887f7e3d9f40
      [ 1361.677952]  ffff887f64bd4280 ffffc90037297a68 ffffffff8173ca3b ffffc90000000010
      [ 1361.767077]  00ffc90037297ad0 ffff887f7e3d9f40 0000000000000286 ffff883f4b188000
      [ 1361.856199] Call Trace:
      [ 1361.885578]  [<ffffffff8173ca3b>] ? __schedule+0x23b/0x780
      [ 1361.951406]  [<ffffffff8173cfb6>] schedule+0x36/0x80
      [ 1362.010979]  [<ffffffffa071f178>] get_guid+0x118/0x150 [ipmi_msghandler]
      [ 1362.091281]  [<ffffffff810d5350>] ? prepare_to_wait_event+0x100/0x100
      [ 1362.168533]  [<ffffffffa071f755>] ipmi_register_smi+0x405/0x940 [ipmi_msghandler]
      [ 1362.258337]  [<ffffffffa0230ae9>] try_smi_init+0x529/0x950 [ipmi_si]
      [ 1362.334521]  [<ffffffffa022f350>] ? std_irq_setup+0xd0/0xd0 [ipmi_si]
      [ 1362.411701]  [<ffffffffa0232bd2>] init_ipmi_si+0x492/0x9e0 [ipmi_si]
      [ 1362.487917]  [<ffffffffa0232740>] ? ipmi_pci_probe+0x280/0x280 [ipmi_si]
      [ 1362.568219]  [<ffffffff810021a0>] do_one_initcall+0x50/0x180
      [ 1362.636109]  [<ffffffff812231b2>] ? kmem_cache_alloc_trace+0x142/0x190
      [ 1362.714330]  [<ffffffff811b2ae1>] do_init_module+0x5f/0x200
      [ 1362.781208]  [<ffffffff81123ca8>] load_module+0x1898/0x1de0
      [ 1362.848069]  [<ffffffff811202e0>] ? __symbol_put+0x60/0x60
      [ 1362.913886]  [<ffffffff8130696b>] ? security_kernel_post_read_file+0x6b/0x80
      [ 1362.998514]  [<ffffffff81124465>] SYSC_finit_module+0xe5/0x120
      [ 1363.068463]  [<ffffffff81124465>] ? SYSC_finit_module+0xe5/0x120
      [ 1363.140513]  [<ffffffff811244be>] SyS_finit_module+0xe/0x10
      [ 1363.207364]  [<ffffffff81003c04>] do_syscall_64+0x74/0x180
      
      Fixes: 50c812b2 ("[PATCH] ipmi: add full sysfs support")
      Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
      Cc: Corey Minyard <minyard@acm.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: openipmi-developer@lists.sourceforge.net
      Cc: linux-kernel@vger.kernel.org
      Cc: stable@vger.kernel.org # 2.6.17-
      Message-Id: <20200403090408.58745-1-wenyang@linux.alibaba.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0721b549
    • Kai-Heng Feng's avatar
      libata: Return correct status in sata_pmp_eh_recover_pm() when ATA_DFLAG_DETACH is set · 7676f94f
      Kai-Heng Feng authored
      commit 8305f72f upstream.
      
      During system resume from suspend, this can be observed on ASM1062 PMP
      controller:
      
      ata10.01: SATA link down (SStatus 0 SControl 330)
      ata10.02: hard resetting link
      ata10.02: SATA link down (SStatus 0 SControl 330)
      ata10.00: configured for UDMA/133
      Kernel panic - not syncing: stack-protector: Kernel
       in: sata_pmp_eh_recover+0xa2b/0xa40
      
      CPU: 2 PID: 230 Comm: scsi_eh_9 Tainted: P OE
      #49-Ubuntu
      Hardware name: System manufacturer System Product
       1001 12/10/2017
      Call Trace:
      dump_stack+0x63/0x8b
      panic+0xe4/0x244
      ? sata_pmp_eh_recover+0xa2b/0xa40
      __stack_chk_fail+0x19/0x20
      sata_pmp_eh_recover+0xa2b/0xa40
      ? ahci_do_softreset+0x260/0x260 [libahci]
      ? ahci_do_hardreset+0x140/0x140 [libahci]
      ? ata_phys_link_offline+0x60/0x60
      ? ahci_stop_engine+0xc0/0xc0 [libahci]
      sata_pmp_error_handler+0x22/0x30
      ahci_error_handler+0x45/0x80 [libahci]
      ata_scsi_port_error_handler+0x29b/0x770
      ? ata_scsi_cmd_error_handler+0x101/0x140
      ata_scsi_error+0x95/0xd0
      ? scsi_try_target_reset+0x90/0x90
      scsi_error_handler+0xd0/0x5b0
      kthread+0x121/0x140
      ? scsi_eh_get_sense+0x200/0x200
      ? kthread_create_worker_on_cpu+0x70/0x70
      ret_from_fork+0x22/0x40
      Kernel Offset: 0xcc00000 from 0xffffffff81000000
      (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
      
      Since sata_pmp_eh_recover_pmp() doens't set rc when ATA_DFLAG_DETACH is
      set, sata_pmp_eh_recover() continues to run. During retry it triggers
      the stack protector.
      
      Set correct rc in sata_pmp_eh_recover_pmp() to let sata_pmp_eh_recover()
      jump to pmp_fail directly.
      
      BugLink: https://bugs.launchpad.net/bugs/1821434
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7676f94f
    • Simon Gander's avatar
      hfsplus: fix crash and filesystem corruption when deleting files · 3151839f
      Simon Gander authored
      commit 25efb2ff upstream.
      
      When removing files containing extended attributes, the hfsplus driver may
      remove the wrong entries from the attributes b-tree, causing major
      filesystem damage and in some cases even kernel crashes.
      
      To remove a file, all its extended attributes have to be removed as well.
      The driver does this by looking up all keys in the attributes b-tree with
      the cnid of the file.  Each of these entries then gets deleted using the
      key used for searching, which doesn't contain the attribute's name when it
      should.  Since the key doesn't contain the name, the deletion routine will
      not find the correct entry and instead remove the one in front of it.  If
      parent nodes have to be modified, these become corrupt as well.  This
      causes invalid links and unsorted entries that not even macOS's fsck_hfs
      is able to fix.
      
      To fix this, modify the search key before an entry is deleted from the
      attributes b-tree by copying the found entry's key into the search key,
      therefore ensuring that the correct entry gets removed from the tree.
      Signed-off-by: default avatarSimon Gander <simon@tuxera.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarAnton Altaparmakov <anton@tuxera.com>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200327155541.1521-1-simon@tuxera.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3151839f
    • Oliver O'Halloran's avatar
      cpufreq: powernv: Fix use-after-free · 35e68aef
      Oliver O'Halloran authored
      commit d0a72efa upstream.
      
      The cpufreq driver has a use-after-free that we can hit if:
      
      a) There's an OCC message pending when the notifier is registered, and
      b) The cpufreq driver fails to register with the core.
      
      When a) occurs the notifier schedules a workqueue item to handle the
      message. The backing work_struct is located on chips[].throttle and
      when b) happens we clean up by freeing the array. Once we get to
      the (now free) queued item and the kernel crashes.
      
      Fixes: c5e29ea7 ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}")
      Cc: stable@vger.kernel.org # v4.6+
      Signed-off-by: default avatarOliver O'Halloran <oohall@gmail.com>
      Reviewed-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200206062622.28235-1-oohall@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35e68aef
    • Eric Biggers's avatar
      kmod: make request_module() return an error when autoloading is disabled · 2a87b491
      Eric Biggers authored
      commit d7d27cfc upstream.
      
      Patch series "module autoloading fixes and cleanups", v5.
      
      This series fixes a bug where request_module() was reporting success to
      kernel code when module autoloading had been completely disabled via
      'echo > /proc/sys/kernel/modprobe'.
      
      It also addresses the issues raised on the original thread
      (https://lkml.kernel.org/lkml/20200310223731.126894-1-ebiggers@kernel.org/T/#u)
      bydocumenting the modprobe sysctl, adding a self-test for the empty path
      case, and downgrading a user-reachable WARN_ONCE().
      
      This patch (of 4):
      
      It's long been possible to disable kernel module autoloading completely
      (while still allowing manual module insertion) by setting
      /proc/sys/kernel/modprobe to the empty string.
      
      This can be preferable to setting it to a nonexistent file since it
      avoids the overhead of an attempted execve(), avoids potential
      deadlocks, and avoids the call to security_kernel_module_request() and
      thus on SELinux-based systems eliminates the need to write SELinux rules
      to dontaudit module_request.
      
      However, when module autoloading is disabled in this way,
      request_module() returns 0.  This is broken because callers expect 0 to
      mean that the module was successfully loaded.
      
      Apparently this was never noticed because this method of disabling
      module autoloading isn't used much, and also most callers don't use the
      return value of request_module() since it's always necessary to check
      whether the module registered its functionality or not anyway.
      
      But improperly returning 0 can indeed confuse a few callers, for example
      get_fs_type() in fs/filesystems.c where it causes a WARNING to be hit:
      
      	if (!fs && (request_module("fs-%.*s", len, name) == 0)) {
      		fs = __get_fs_type(name, len);
      		WARN_ONCE(!fs, "request_module fs-%.*s succeeded, but still no fs?\n", len, name);
      	}
      
      This is easily reproduced with:
      
      	echo > /proc/sys/kernel/modprobe
      	mount -t NONEXISTENT none /
      
      It causes:
      
      	request_module fs-NONEXISTENT succeeded, but still no fs?
      	WARNING: CPU: 1 PID: 1106 at fs/filesystems.c:275 get_fs_type+0xd6/0xf0
      	[...]
      
      This should actually use pr_warn_once() rather than WARN_ONCE(), since
      it's also user-reachable if userspace immediately unloads the module.
      Regardless, request_module() should correctly return an error when it
      fails.  So let's make it return -ENOENT, which matches the error when
      the modprobe binary doesn't exist.
      
      I've also sent patches to document and test this case.
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarJessica Yu <jeyu@kernel.org>
      Acked-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jeff Vander Stoep <jeffv@google.com>
      Cc: Ben Hutchings <benh@debian.org>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: <stable@vger.kernel.org>
      Link: http://lkml.kernel.org/r/20200310223731.126894-1-ebiggers@kernel.org
      Link: http://lkml.kernel.org/r/20200312202552.241885-1-ebiggers@kernel.orgSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a87b491
    • Paul Cercueil's avatar
      clk: ingenic/jz4770: Exit with error if CGU init failed · ae6baa8c
      Paul Cercueil authored
      commit c067b46d upstream.
      
      Exit jz4770_cgu_init() if the 'cgu' pointer we get is NULL, since the
      pointer is passed as argument to functions later on.
      
      Fixes: 7a01c190 ("clk: Add Ingenic jz4770 CGU driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lkml.kernel.org/r/20200213161952.37460-1-paul@crapouillou.netSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae6baa8c