Skip to content
  1. Mar 17, 2023
    • Rafał Miłecki's avatar
      bgmac: fix *initial* chip reset to support BCM5358 · 3ee0c9fb
      Rafał Miłecki authored
      [ Upstream commit f99e6d7c ]
      
      While bringing hardware up we should perform a full reset including the
      switch bit (BGMAC_BCMA_IOCTL_SW_RESET aka SICF_SWRST). It's what
      specification says and what reference driver does.
      
      This seems to be critical for the BCM5358. Without this hardware doesn't
      get initialized properly and doesn't seem to transmit or receive any
      packets.
      
      Originally bgmac was calling bgmac_chip_reset() before setting
      "has_robosw" property which resulted in expected behaviour. That has
      changed as a side effect of adding platform device support which
      regressed BCM5358 support.
      
      Fixes: f6a95a24
      
       ("net: ethernet: bgmac: Add platform device support")
      Cc: Jon Mason <jdmason@kudzu.us>
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20230227091156.19509-1-zajec5@gmail.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3ee0c9fb
    • Dmitry Baryshkov's avatar
      drm/msm/a5xx: fix context faults during ring switch · 56d67b97
      Dmitry Baryshkov authored
      [ Upstream commit 32e70834 ]
      
      The rptr_addr is set in the preempt_init_ring(), which is called from
      a5xx_gpu_init(). It uses shadowptr() to set the address, however the
      shadow_iova is not yet initialized at that time. Move the rptr_addr
      setting to the a5xx_preempt_hw_init() which is called after setting the
      shadow_iova, getting the correct value for the address.
      
      Fixes: 8907afb4
      
       ("drm/msm: Allow a5xx to mark the RPTR shadow as privileged")
      Suggested-by: default avatarRob Clark <robdclark@gmail.com>
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/522640/
      Link: https://lore.kernel.org/r/20230214020956.164473-5-dmitry.baryshkov@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      56d67b97
    • Dmitry Baryshkov's avatar
      drm/msm/a5xx: fix the emptyness check in the preempt code · ac3af300
      Dmitry Baryshkov authored
      [ Upstream commit b4fb748f
      
       ]
      
      Quoting Yassine: ring->memptrs->rptr is never updated and stays 0, so
      the comparison always evaluates to false and get_next_ring always
      returns ring 0 thinking it isn't empty.
      
      Fix this by calling get_rptr() instead of reading rptr directly.
      
      Reported-by: default avatarYassine Oudjana <y.oudjana@protonmail.com>
      Fixes: b1fc2839
      
       ("drm/msm: Implement preemption for A5XX targets")
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/522642/
      Link: https://lore.kernel.org/r/20230214020956.164473-4-dmitry.baryshkov@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac3af300
    • Dmitry Baryshkov's avatar
      drm/msm/a5xx: fix highest bank bit for a530 · 84053e7d
      Dmitry Baryshkov authored
      [ Upstream commit 141f66eb ]
      
      A530 has highest bank bit equal to 15 (like A540). Fix values written to
      REG_A5XX_RB_MODE_CNTL and REG_A5XX_TPL1_MODE_CNTL registers.
      
      Fixes: 1d832ab3
      
       ("drm/msm/a5xx: Add support for Adreno 508, 509, 512 GPUs")
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/522639/
      Link: https://lore.kernel.org/r/20230214020956.164473-3-dmitry.baryshkov@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      84053e7d
    • Dmitry Baryshkov's avatar
      drm/msm/a5xx: fix setting of the CP_PREEMPT_ENABLE_LOCAL register · d334248d
      Dmitry Baryshkov authored
      [ Upstream commit a7a4c19c ]
      
      Rather than writing CP_PREEMPT_ENABLE_GLOBAL twice, follow the vendor
      kernel and set CP_PREEMPT_ENABLE_LOCAL register instead. a5xx_submit()
      will override it during submission, but let's get the sequence correct.
      
      Fixes: b1fc2839
      
       ("drm/msm: Implement preemption for A5XX targets")
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Patchwork: https://patchwork.freedesktop.org/patch/522638/
      Link: https://lore.kernel.org/r/20230214020956.164473-2-dmitry.baryshkov@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d334248d
    • Rob Clark's avatar
      drm/msm: Fix potential invalid ptr free · fa73f67a
      Rob Clark authored
      [ Upstream commit 8a86f213 ]
      
      The error path cleanup expects that chain and syncobj are either NULL or
      valid pointers.  But post_deps was not allocated with __GFP_ZERO.
      
      Fixes: ab723b7a
      
       ("drm/msm: Add syncobj support.")
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
      Patchwork: https://patchwork.freedesktop.org/patch/523051/
      Link: https://lore.kernel.org/r/20230215235048.1166484-1-robdclark@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fa73f67a
    • Jiri Slaby (SUSE)'s avatar
      drm/nouveau/kms/nv50: fix nv50_wndw_new_ prototype · 5dca6961
      Jiri Slaby (SUSE) authored
      [ Upstream commit 3638a820 ]
      
      gcc-13 warns about mismatching types for enums. That revealed switched
      arguments of nv50_wndw_new_():
        drivers/gpu/drm/nouveau/dispnv50/wndw.c:696:1: error: conflicting types for 'nv50_wndw_new_' due to enum/integer mismatch; have 'int(const struct nv50_wndw_func *, struct drm_device *, enum drm_plane_type,  const char *, int,  const u32 *, u32,  enum nv50_disp_interlock_type,  u32,  struct nv50_wndw **)'
        drivers/gpu/drm/nouveau/dispnv50/wndw.h:36:5: note: previous declaration of 'nv50_wndw_new_' with type 'int(const struct nv50_wndw_func *, struct drm_device *, enum drm_plane_type,  const char *, int,  const u32 *, enum nv50_disp_interlock_type,  u32,  u32,  struct nv50_wndw **)'
      
      It can be barely visible, but the declaration says about the parameters
      in the middle:
        enum nv50_disp_interlock_type,
        u32 interlock_data,
        u32 heads,
      
      While the definition states differently:
        u32 heads,
        enum nv50_disp_interlock_type interlock_type,
        u32 interlock_data,
      
      Unify/fix the declaration to match the definition.
      
      Fixes: 53e0a3e7
      
       ("drm/nouveau/kms/nv50-: simplify tracking of channel interlocks")
      Cc: Martin Liska <mliska@suse.cz>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Karol Herbst <kherbst@redhat.com>
      Cc: Lyude Paul <lyude@redhat.com>
      Cc: David Airlie <airlied@gmail.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: dri-devel@lists.freedesktop.org
      Cc: nouveau@lists.freedesktop.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarJiri Slaby (SUSE) <jirislaby@kernel.org>
      Signed-off-by: default avatarKarol Herbst <kherbst@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221031114229.10289-1-jirislaby@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5dca6961
    • Paulo Alcantara's avatar
      cifs: improve checking of DFS links over STATUS_OBJECT_NAME_INVALID · 512aa2fd
      Paulo Alcantara authored
      [ Upstream commit b9ee2e30 ]
      
      Do not map STATUS_OBJECT_NAME_INVALID to -EREMOTE under non-DFS
      shares, or 'nodfs' mounts or CONFIG_CIFS_DFS_UPCALL=n builds.
      Otherwise, in the slow path, get a referral to figure out whether it
      is an actual DFS link.
      
      This could be simply reproduced under a non-DFS share by running the
      following
      
        $ mount.cifs //srv/share /mnt -o ...
        $ cat /mnt/$(printf '\U110000')
        cat: '/mnt/'$'\364\220\200\200': Object is remote
      
      Fixes: c877ce47
      
       ("cifs: reduce roundtrips on create/qinfo requests")
      CC: stable@vger.kernel.org # 6.2
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      512aa2fd
    • Jan Kara's avatar
      ext4: Fix possible corruption when moving a directory · b0bb1361
      Jan Kara authored
      [ Upstream commit 0813299c ]
      
      When we are renaming a directory to a different directory, we need to
      update '..' entry in the moved directory. However nothing prevents moved
      directory from being modified and even converted from the inline format
      to the normal format. When such race happens the rename code gets
      confused and we crash. Fix the problem by locking the moved directory.
      
      CC: stable@vger.kernel.org
      Fixes: 32f7f22c
      
       ("ext4: let ext4_rename handle inline dir")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230126112221.11866-1-jack@suse.cz
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0bb1361
    • Bart Van Assche's avatar
      scsi: core: Remove the /proc/scsi/${proc_name} directory earlier · 17e98a5e
      Bart Van Assche authored
      [ Upstream commit fc663711 ]
      
      Remove the /proc/scsi/${proc_name} directory earlier to fix a race
      condition between unloading and reloading kernel modules. This fixes a bug
      introduced in 2009 by commit 77c01976 ("[SCSI] fix /proc memory leak in
      the SCSI core").
      
      Fix the following kernel warning:
      
      proc_dir_entry 'scsi/scsi_debug' already registered
      WARNING: CPU: 19 PID: 27986 at fs/proc/generic.c:376 proc_register+0x27d/0x2e0
      Call Trace:
       proc_mkdir+0xb5/0xe0
       scsi_proc_hostdir_add+0xb5/0x170
       scsi_host_alloc+0x683/0x6c0
       sdebug_driver_probe+0x6b/0x2d0 [scsi_debug]
       really_probe+0x159/0x540
       __driver_probe_device+0xdc/0x230
       driver_probe_device+0x4f/0x120
       __device_attach_driver+0xef/0x180
       bus_for_each_drv+0xe5/0x130
       __device_attach+0x127/0x290
       device_initial_probe+0x17/0x20
       bus_probe_device+0x110/0x130
       device_add+0x673/0xc80
       device_register+0x1e/0x30
       sdebug_add_host_helper+0x1a7/0x3b0 [scsi_debug]
       scsi_debug_init+0x64f/0x1000 [scsi_debug]
       do_one_initcall+0xd7/0x470
       do_init_module+0xe7/0x330
       load_module+0x122a/0x12c0
       __do_sys_finit_module+0x124/0x1a0
       __x64_sys_finit_module+0x46/0x50
       do_syscall_64+0x38/0x80
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Link: https://lore.kernel.org/r/20230210205200.36973-3-bvanassche@acm.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Yi Zhang <yi.zhang@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 77c01976
      
       ("[SCSI] fix /proc memory leak in the SCSI core")
      Reported-by: default avatarYi Zhang <yi.zhang@redhat.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      17e98a5e
    • Liao Chang's avatar
      riscv: Add header include guards to insn.h · 0d14555f
      Liao Chang authored
      [ Upstream commit 8ac6e619 ]
      
      Add header include guards to insn.h to prevent repeating declaration of
      any identifiers in insn.h.
      
      Fixes: edde5584
      
       ("riscv: Add SW single-step support for KDB")
      Signed-off-by: default avatarLiao Chang <liaochang1@huawei.com>
      Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Fixes: c9c1af3f
      
       ("RISC-V: rename parse_asm.h to insn.h")
      Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20230129094242.282620-1-liaochang1@huawei.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d14555f
    • Yu Kuai's avatar
      block: fix scan partition for exclusively open device again · 82f713e8
      Yu Kuai authored
      [ Upstream commit e5cfefa9 ]
      
      As explained in commit 36369f46 ("block: Do not reread partition table
      on exclusively open device"), reread partition on the device that is
      exclusively opened by someone else is problematic.
      
      This patch will make sure partition scan will only be proceed if current
      thread open the device exclusively, or the device is not opened
      exclusively, and in the later case, other scanners and exclusive openers
      will be blocked temporarily until partition scan is done.
      
      Fixes: 10c70d95
      
       ("block: remove the bd_openers checks in blk_drop_partitions")
      Cc: <stable@vger.kernel.org>
      Suggested-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20230217022200.3092987-3-yukuai1@huaweicloud.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      82f713e8
    • Yu Kuai's avatar
      block: Revert "block: Do not reread partition table on exclusively open device" · 573e58f5
      Yu Kuai authored
      [ Upstream commit 0f77b29a ]
      
      This reverts commit 36369f46
      
      .
      
      This patch can't fix the problem in a corner case that device can be
      opened exclusively after the checking and before blkdev_get_by_dev().
      We'll use a new solution to fix the problem in the next patch, and
      the new solution doesn't need to change apis.
      
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Acked-by: default avatarJan Kara <jack@suse.cz>
      Link: https://lore.kernel.org/r/20230217022200.3092987-2-yukuai1@huaweicloud.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Stable-dep-of: e5cfefa9
      
       ("block: fix scan partition for exclusively open device again")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      573e58f5
    • Ville Syrjälä's avatar
      drm/i915: Populate encoder->devdata for DSI on icl+ · 783c225e
      Ville Syrjälä authored
      [ Upstream commit 14e591a1
      
       ]
      
      We now have some eDP+DSI dual panel systems floating around
      where the DSI panel is the secondary LFP and thus needs to
      consult "panel type 2" in VBT in order to locate all the
      other panel type dependant stuff correctly.
      
      To that end we need to pass in the devdata to
      intel_bios_init_panel_late(), otherwise it'll just assume
      we want the primary panel type. So let's try to just populate
      the vbt.ports[] stuff and encoder->devdata for icl+ DSI
      panels as well.
      
      We can't do this on older platforms as there we risk a DSI
      port aliasing with a HDMI/DP port, which is a totally legal
      thing as the DSI ports live in their own little parallel
      universe.
      
      Cc: stable@vger.kernel.org
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/8016
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230207064337.18697-3-ville.syrjala@linux.intel.com
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit ba00eb6a
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      783c225e
    • Ville Syrjälä's avatar
      drm/i915: Do panel VBT init early if the VBT declares an explicit panel type · bd61a84b
      Ville Syrjälä authored
      [ Upstream commit 3f9ffce5
      
       ]
      
      Lots of ADL machines out there with bogus VBTs that declare
      two eDP child devices. In order for those to work we need to
      figure out which power sequencer to use before we try the EDID
      read. So let's do the panel VBT init early if we can, falling
      back to the post-EDID init otherwise.
      
      The post-EDID init panel_type=0xff approach of assuming the
      power sequencer should already be enabled doesn't really work
      with multiple eDP panels, and currently we just end up using
      the same power sequencer for both eDP ports, which at least
      confuses the wakeref tracking, and potentially also causes us
      to toggle the VDD for the panel when we should not.
      
      Cc: Animesh Manna <animesh.manna@intel.com>
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221125173156.31689-3-ville.syrjala@linux.intel.com
      Stable-dep-of: 14e591a1
      
       ("drm/i915: Populate encoder->devdata for DSI on icl+")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd61a84b
    • Ville Syrjälä's avatar
      drm/i915: Introduce intel_panel_init_alloc() · e340197a
      Ville Syrjälä authored
      [ Upstream commit f70f8153
      
       ]
      
      Introduce a place where we can initialize connector->panel
      after it's been allocated. We already have a intel_panel_init()
      so had to get creative with the name and came up with
      intel_panel_init_alloc().
      
      Cc: Animesh Manna <animesh.manna@intel.com>
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221125173156.31689-2-ville.syrjala@linux.intel.com
      Stable-dep-of: 14e591a1
      
       ("drm/i915: Populate encoder->devdata for DSI on icl+")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e340197a
    • Mika Westerberg's avatar
      spi: intel: Check number of chip selects after reading the descriptor · 87228e1c
      Mika Westerberg authored
      [ Upstream commit 574fbb95
      
       ]
      
      The flash decriptor contains the number of flash components that we use
      to figure out how many flash chips there are connected. Therefore we
      need to read it first before deciding how many chip selects the
      controller has.
      
      Reported-by: default avatarMarcin Witkowski <marcin.witkowski@intel.com>
      Fixes: 3f03c618
      
       ("spi: intel: Add support for second flash chip")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Link: https://lore.kernel.org/r/20230215110040.42186-1-mika.westerberg@linux.intel.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      87228e1c
    • Corey Minyard's avatar
      ipmi:ssif: Add a timer between request retries · 9858e0fb
      Corey Minyard authored
      [ Upstream commit 00bb7e76
      
       ]
      
      The IPMI spec has a time (T6) specified between request retries.  Add
      the handling for that.
      
      Reported by: Tony Camuso <tcamuso@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9858e0fb
    • Corey Minyard's avatar
      ipmi:ssif: Increase the message retry time · 8a676b6e
      Corey Minyard authored
      [ Upstream commit 39721d62
      
       ]
      
      The spec states that the minimum message retry time is 60ms, but it was
      set to 20ms.  Correct it.
      
      Reported by: Tony Camuso <tcamuso@redhat.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Stable-dep-of: 00bb7e76
      
       ("ipmi:ssif: Add a timer between request retries")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8a676b6e
    • Corey Minyard's avatar
      ipmi:ssif: Remove rtc_us_timer · f12869ff
      Corey Minyard authored
      [ Upstream commit 9e8b8992
      
       ]
      
      It was cruft left over from older handling of run to completion.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f12869ff
    • Dmitry Torokhov's avatar
      Input: exc3000 - properly stop timer on shutdown · 526a177a
      Dmitry Torokhov authored
      [ Upstream commit 79c81d13 ]
      
      We need to stop the timer on driver unbind or probe failures, otherwise
      we get UAF/Oops.
      
      Fixes: 7e577a17
      
       ("Input: add I2C attached EETI EXC3000 multi touch driver")
      Reported-by: default avatar"Stahl, Michael" <mstahl@moba.de>
      Link: https://lore.kernel.org/r/Y9dK57BFqtlf8NmN@google.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      526a177a
    • Manivannan Sadhasivam's avatar
      bus: mhi: ep: Change state_lock to mutex · 86e9eb69
      Manivannan Sadhasivam authored
      [ Upstream commit 1ddc7618 ]
      
      state_lock, the spinlock type is meant to protect race against concurrent
      MHI state transitions. In mhi_ep_set_m0_state(), while the state_lock is
      being held, the channels are resumed in mhi_ep_resume_channels() if the
      previous state was M3. This causes sleeping in atomic bug, since
      mhi_ep_resume_channels() use mutex internally.
      
      Since the state_lock is supposed to be held throughout the state change,
      it is not ideal to drop the lock before calling mhi_ep_resume_channels().
      So to fix this issue, let's change the type of state_lock to mutex. This
      would also allow holding the lock throughout all state transitions thereby
      avoiding any potential race.
      
      Cc: <stable@vger.kernel.org> # 5.19
      Fixes: e4b7b5f0
      
       ("bus: mhi: ep: Add support for suspending and resuming channels")
      Reported-by: default avatarDan Carpenter <error27@gmail.com>
      Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      86e9eb69
    • Manivannan Sadhasivam's avatar
      bus: mhi: ep: Power up/down MHI stack during MHI RESET · b6dc68ac
      Manivannan Sadhasivam authored
      [ Upstream commit 47a1dcae
      
       ]
      
      During graceful shutdown scenario, host will issue MHI RESET to the
      endpoint device before initiating shutdown. In that case, it makes sense
      to completely power down the MHI stack as sooner or later the access to
      MMIO registers will be prohibited. Also, the stack needs to be powered
      up in the case of SYS_ERR to recover the device.
      
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
      Link: https://lore.kernel.org/r/20221228161704.255268-2-manivannan.sadhasivam@linaro.org
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Stable-dep-of: 1ddc7618
      
       ("bus: mhi: ep: Change state_lock to mutex")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b6dc68ac
    • Jan Kara's avatar
      udf: Fix off-by-one error when discarding preallocation · 9ee18ff0
      Jan Kara authored
      [ Upstream commit f54aa97f ]
      
      The condition determining whether the preallocation can be used had
      an off-by-one error so we didn't discard preallocation when new
      allocation was just following it. This can then confuse code in
      inode_getblk().
      
      CC: stable@vger.kernel.org
      Fixes: 16d05565
      
       ("udf: Discard preallocation before extending file with a hole")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ee18ff0
    • Alexander Aring's avatar
      fs: dlm: fix race setting stop tx flag · a926daa8
      Alexander Aring authored
      [ Upstream commit 16427211 ]
      
      This patch sets the stop tx flag before we commit the dlm message.
      This flag will report about unexpected transmissions after we
      send the DLM_FIN message out, which should be the last message sent.
      When we commit the dlm fin message, it could be that we already
      got an ack back and the CLOSED state change already happened.
      We should not set this flag when we are in CLOSED state. To avoid this
      race we simply set the tx flag before the state change can be in
      progress by moving it before dlm_midcomms_commit_mhandle().
      
      Cc: stable@vger.kernel.org
      Fixes: 489d8e55
      
       ("fs: dlm: add reliable connection if reconnect")
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a926daa8
    • Alexander Aring's avatar
      fs: dlm: be sure to call dlm_send_queue_flush() · 3c1bc8de
      Alexander Aring authored
      [ Upstream commit 7354fa4e ]
      
      If we release a midcomms node structure, there should be nothing left
      inside the dlm midcomms send queue. However, sometimes this is not true
      because I believe some DLM_FIN message was not acked... if we run
      into a shutdown timeout, then we should be sure there is no pending send
      dlm message inside this queue when releasing midcomms node structure.
      
      Cc: stable@vger.kernel.org
      Fixes: 489d8e55
      
       ("fs: dlm: add reliable connection if reconnect")
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c1bc8de
    • Alexander Aring's avatar
      fs: dlm: use WARN_ON_ONCE() instead of WARN_ON() · 29682b8a
      Alexander Aring authored
      [ Upstream commit 775af207
      
       ]
      
      To not get the console spammed about WARN_ON() of invalid states in the
      dlm midcomms hot path handling we switch to WARN_ON_ONCE() to get it
      only once that there might be an issue with the midcomms state handling.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: 7354fa4e
      
       ("fs: dlm: be sure to call dlm_send_queue_flush()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29682b8a
    • Alexander Aring's avatar
      fs: dlm: fix use after free in midcomms commit · a3b0e9ac
      Alexander Aring authored
      [ Upstream commit 724b6bab ]
      
      While working on processing dlm message in softirq context I experienced
      the following KASAN use-after-free warning:
      
      [  151.760477] ==================================================================
      [  151.761803] BUG: KASAN: use-after-free in dlm_midcomms_commit_mhandle+0x19d/0x4b0
      [  151.763414] Read of size 4 at addr ffff88811a980c60 by task lock_torture/1347
      
      [  151.765284] CPU: 7 PID: 1347 Comm: lock_torture Not tainted 6.1.0-rc4+ #2828
      [  151.766778] Hardware name: Red Hat KVM/RHEL-AV, BIOS 1.16.0-3.module+el8.7.0+16134+e5908aa2 04/01/2014
      [  151.768726] Call Trace:
      [  151.769277]  <TASK>
      [  151.769748]  dump_stack_lvl+0x5b/0x86
      [  151.770556]  print_report+0x180/0x4c8
      [  151.771378]  ? kasan_complete_mode_report_info+0x7c/0x1e0
      [  151.772241]  ? dlm_midcomms_commit_mhandle+0x19d/0x4b0
      [  151.773069]  kasan_report+0x93/0x1a0
      [  151.773668]  ? dlm_midcomms_commit_mhandle+0x19d/0x4b0
      [  151.774514]  __asan_load4+0x7e/0xa0
      [  151.775089]  dlm_midcomms_commit_mhandle+0x19d/0x4b0
      [  151.775890]  ? create_message.isra.29.constprop.64+0x57/0xc0
      [  151.776770]  send_common+0x19f/0x1b0
      [  151.777342]  ? remove_from_waiters+0x60/0x60
      [  151.778017]  ? lock_downgrade+0x410/0x410
      [  151.778648]  ? __this_cpu_preempt_check+0x13/0x20
      [  151.779421]  ? rcu_lockdep_current_cpu_online+0x88/0xc0
      [  151.780292]  _convert_lock+0x46/0x150
      [  151.780893]  convert_lock+0x7b/0xc0
      [  151.781459]  dlm_lock+0x3ac/0x580
      [  151.781993]  ? 0xffffffffc0540000
      [  151.782522]  ? torture_stop+0x120/0x120 [dlm_locktorture]
      [  151.783379]  ? dlm_scan_rsbs+0xa70/0xa70
      [  151.784003]  ? preempt_count_sub+0xd6/0x130
      [  151.784661]  ? is_module_address+0x47/0x70
      [  151.785309]  ? torture_stop+0x120/0x120 [dlm_locktorture]
      [  151.786166]  ? 0xffffffffc0540000
      [  151.786693]  ? lockdep_init_map_type+0xc3/0x360
      [  151.787414]  ? 0xffffffffc0540000
      [  151.787947]  torture_dlm_lock_sync.isra.3+0xe9/0x150 [dlm_locktorture]
      [  151.789004]  ? torture_stop+0x120/0x120 [dlm_locktorture]
      [  151.789858]  ? 0xffffffffc0540000
      [  151.790392]  ? lock_torture_cleanup+0x20/0x20 [dlm_locktorture]
      [  151.791347]  ? delay_tsc+0x94/0xc0
      [  151.791898]  torture_ex_iter+0xc3/0xea [dlm_locktorture]
      [  151.792735]  ? torture_start+0x30/0x30 [dlm_locktorture]
      [  151.793606]  lock_torture+0x177/0x270 [dlm_locktorture]
      [  151.794448]  ? torture_dlm_lock_sync.isra.3+0x150/0x150 [dlm_locktorture]
      [  151.795539]  ? lock_torture_stats+0x80/0x80 [dlm_locktorture]
      [  151.796476]  ? do_raw_spin_lock+0x11e/0x1e0
      [  151.797152]  ? mark_held_locks+0x34/0xb0
      [  151.797784]  ? _raw_spin_unlock_irqrestore+0x30/0x70
      [  151.798581]  ? __kthread_parkme+0x79/0x110
      [  151.799246]  ? trace_preempt_on+0x2a/0xf0
      [  151.799902]  ? __kthread_parkme+0x79/0x110
      [  151.800579]  ? preempt_count_sub+0xd6/0x130
      [  151.801271]  ? __kasan_check_read+0x11/0x20
      [  151.801963]  ? __kthread_parkme+0xec/0x110
      [  151.802630]  ? lock_torture_stats+0x80/0x80 [dlm_locktorture]
      [  151.803569]  kthread+0x192/0x1d0
      [  151.804104]  ? kthread_complete_and_exit+0x30/0x30
      [  151.804881]  ret_from_fork+0x1f/0x30
      [  151.805480]  </TASK>
      
      [  151.806111] Allocated by task 1347:
      [  151.806681]  kasan_save_stack+0x26/0x50
      [  151.807308]  kasan_set_track+0x25/0x30
      [  151.807920]  kasan_save_alloc_info+0x1e/0x30
      [  151.808609]  __kasan_slab_alloc+0x63/0x80
      [  151.809263]  kmem_cache_alloc+0x1ad/0x830
      [  151.809916]  dlm_allocate_mhandle+0x17/0x20
      [  151.810590]  dlm_midcomms_get_mhandle+0x96/0x260
      [  151.811344]  _create_message+0x95/0x180
      [  151.811994]  create_message.isra.29.constprop.64+0x57/0xc0
      [  151.812880]  send_common+0x129/0x1b0
      [  151.813467]  _convert_lock+0x46/0x150
      [  151.814074]  convert_lock+0x7b/0xc0
      [  151.814648]  dlm_lock+0x3ac/0x580
      [  151.815199]  torture_dlm_lock_sync.isra.3+0xe9/0x150 [dlm_locktorture]
      [  151.816258]  torture_ex_iter+0xc3/0xea [dlm_locktorture]
      [  151.817129]  lock_torture+0x177/0x270 [dlm_locktorture]
      [  151.817986]  kthread+0x192/0x1d0
      [  151.818518]  ret_from_fork+0x1f/0x30
      
      [  151.819369] Freed by task 1336:
      [  151.819890]  kasan_save_stack+0x26/0x50
      [  151.820514]  kasan_set_track+0x25/0x30
      [  151.821128]  kasan_save_free_info+0x2e/0x50
      [  151.821812]  __kasan_slab_free+0x107/0x1a0
      [  151.822483]  kmem_cache_free+0x204/0x5e0
      [  151.823152]  dlm_free_mhandle+0x18/0x20
      [  151.823781]  dlm_mhandle_release+0x2e/0x40
      [  151.824454]  rcu_core+0x583/0x1330
      [  151.825047]  rcu_core_si+0xe/0x20
      [  151.825594]  __do_softirq+0xf4/0x5c2
      
      [  151.826450] Last potentially related work creation:
      [  151.827238]  kasan_save_stack+0x26/0x50
      [  151.827870]  __kasan_record_aux_stack+0xa2/0xc0
      [  151.828609]  kasan_record_aux_stack_noalloc+0xb/0x20
      [  151.829415]  call_rcu+0x4c/0x760
      [  151.829954]  dlm_mhandle_delete+0x97/0xb0
      [  151.830718]  dlm_process_incoming_buffer+0x2fc/0xb30
      [  151.831524]  process_dlm_messages+0x16e/0x470
      [  151.832245]  process_one_work+0x505/0xa10
      [  151.832905]  worker_thread+0x67/0x650
      [  151.833507]  kthread+0x192/0x1d0
      [  151.834046]  ret_from_fork+0x1f/0x30
      
      [  151.834900] The buggy address belongs to the object at ffff88811a980c30
                      which belongs to the cache dlm_mhandle of size 88
      [  151.836894] The buggy address is located 48 bytes inside of
                      88-byte region [ffff88811a980c30, ffff88811a980c88)
      
      [  151.839007] The buggy address belongs to the physical page:
      [  151.839904] page:0000000076cf5d62 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11a980
      [  151.841378] flags: 0x8000000000000200(slab|zone=2)
      [  151.842141] raw: 8000000000000200 0000000000000000 dead000000000122 ffff8881089b43c0
      [  151.843401] raw: 0000000000000000 0000000000220022 00000001ffffffff 0000000000000000
      [  151.844640] page dumped because: kasan: bad access detected
      
      [  151.845822] Memory state around the buggy address:
      [  151.846602]  ffff88811a980b00: fb fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb
      [  151.847761]  ffff88811a980b80: fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb fb
      [  151.848921] >ffff88811a980c00: fb fb fc fc fc fc fa fb fb fb fb fb fb fb fb fb
      [  151.850076]                                                        ^
      [  151.851085]  ffff88811a980c80: fb fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
      [  151.852269]  ffff88811a980d00: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fc
      [  151.853428] ==================================================================
      [  151.855618] Disabling lock debugging due to kernel taint
      
      It is accessing a mhandle in dlm_midcomms_commit_mhandle() and the mhandle
      was freed by a call_rcu() call in dlm_process_incoming_buffer(),
      dlm_mhandle_delete(). It looks like it was freed because an ack of
      this message was received. There is a short race between committing the
      dlm message to be transmitted and getting an ack back. If the ack is
      faster than returning from dlm_midcomms_commit_msg_3_2(), then we run
      into a use-after free because we still need to reference the mhandle when
      calling srcu_read_unlock().
      
      To avoid that, we don't allow that mhandle to be freed between
      dlm_midcomms_commit_msg_3_2() and srcu_read_unlock() by using rcu read
      lock. We can do that because mhandle is protected by rcu handling.
      
      Cc: stable@vger.kernel.org
      Fixes: 489d8e55
      
       ("fs: dlm: add reliable connection if reconnect")
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a3b0e9ac
    • Alexander Aring's avatar
      fd: dlm: trace send/recv of dlm message and rcom · 387c3038
      Alexander Aring authored
      [ Upstream commit e01c4b7b
      
       ]
      
      This patch adds tracepoints for send and recv cases of dlm messages and
      dlm rcom messages. In case of send and dlm message we add the dlm rsb
      resource name this dlm messages belongs to. This has the advantage to
      follow dlm messages on a per lock basis. In case of recv message the
      resource name can be extracted by follow the send message sequence
      number.
      
      The dlm message DLM_MSG_PURGE doesn't belong to a lock request and will
      not set the resource name in a dlm_message trace. The same for all rcom
      messages.
      
      There is additional handling required for this debugging functionality
      which is tried to be small as possible. Also the midcomms layer gets
      aware of lock resource names, for now this is required to make a
      connection between sequence number and lock resource names. It is for
      debugging purpose only.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: 724b6bab
      
       ("fs: dlm: fix use after free in midcomms commit")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      387c3038
    • Alexander Aring's avatar
      fs: dlm: use packet in dlm_mhandle · 8885e12a
      Alexander Aring authored
      [ Upstream commit 5b787667
      
       ]
      
      To allow more than just dereferencing the inner header we directly point
      to the inner dlm packet which allows us to dereference the header, rcom
      or message structure.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: 724b6bab
      
       ("fs: dlm: fix use after free in midcomms commit")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8885e12a
    • Alexander Aring's avatar
      fs: dlm: remove send repeat remove handling · cb2849ca
      Alexander Aring authored
      [ Upstream commit 57a5724e
      
       ]
      
      This patch removes the send repeat remove handling. This handling is
      there to repeatingly DLM_MSG_REMOVE messages in cases the dlm stack
      thinks it was not received at the first time. In cases of message drops
      this functionality is necessary, but since the DLM midcomms layer
      guarantees there are no messages drops between cluster nodes this
      feature became not strict necessary anymore. Due message
      delays/processing it could be that two send_repeat_remove() are sent out
      while the other should be still on it's way. We remove the repeat remove
      handling because we are sure that the message cannot be dropped due
      communication errors.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: 724b6bab
      
       ("fs: dlm: fix use after free in midcomms commit")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb2849ca
    • Alexander Aring's avatar
      fs: dlm: start midcomms before scand · 14c5a584
      Alexander Aring authored
      [ Upstream commit aad633dc ]
      
      The scand kthread can send dlm messages out, especially dlm remove
      messages to free memory for unused rsb on other nodes. To send out dlm
      messages, midcomms must be initialized. This patch moves the midcomms
      start before scand is started.
      
      Cc: stable@vger.kernel.org
      Fixes: e7fd4179
      
       ("[DLM] The core of the DLM for GFS2/CLVM")
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      14c5a584
    • Alexander Aring's avatar
      fs: dlm: add midcomms init/start functions · f7889206
      Alexander Aring authored
      [ Upstream commit 8b0188b0
      
       ]
      
      This patch introduces leftovers of init, start, stop and exit
      functionality. The dlm application layer should always call the midcomms
      layer which getting aware of such event and redirect it to the lowcomms
      layer. Some functionality which is currently handled inside the start
      functionality of midcomms and lowcomms should be handled in the init
      functionality as it only need to be initialized once when dlm is loaded.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: aad633dc
      
       ("fs: dlm: start midcomms before scand")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7889206
    • Alexander Aring's avatar
      fs: dlm: fix log of lowcomms vs midcomms · e7935f5a
      Alexander Aring authored
      [ Upstream commit 3e54c9e8
      
       ]
      
      This patch will fix a small issue when printing out that
      dlm_midcomms_start() failed to start and it was printing out that the
      dlm subcomponent lowcomms was failed but lowcomms is behind the midcomms
      layer.
      
      Signed-off-by: default avatarAlexander Aring <aahringo@redhat.com>
      Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
      Stable-dep-of: aad633dc
      
       ("fs: dlm: start midcomms before scand")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e7935f5a
    • Sean Christopherson's avatar
      KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace · e136e969
      Sean Christopherson authored
      [ Upstream commit e32b1200
      
       ]
      
      Call kvm_init() only after _all_ setup is complete, as kvm_init() exposes
      /dev/kvm to userspace and thus allows userspace to create VMs (and call
      other ioctls).  E.g. KVM will encounter a NULL pointer when attempting to
      add a vCPU to the per-CPU loaded_vmcss_on_cpu list if userspace is able to
      create a VM before vmx_init() configures said list.
      
       BUG: kernel NULL pointer dereference, address: 0000000000000008
       #PF: supervisor write access in kernel mode
       #PF: error_code(0x0002) - not-present page
       PGD 0 P4D 0
       Oops: 0002 [#1] SMP
       CPU: 6 PID: 1143 Comm: stable Not tainted 6.0.0-rc7+ #988
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
       RIP: 0010:vmx_vcpu_load_vmcs+0x68/0x230 [kvm_intel]
        <TASK>
        vmx_vcpu_load+0x16/0x60 [kvm_intel]
        kvm_arch_vcpu_load+0x32/0x1f0 [kvm]
        vcpu_load+0x2f/0x40 [kvm]
        kvm_arch_vcpu_create+0x231/0x310 [kvm]
        kvm_vm_ioctl+0x79f/0xe10 [kvm]
        ? handle_mm_fault+0xb1/0x220
        __x64_sys_ioctl+0x80/0xb0
        do_syscall_64+0x2b/0x50
        entry_SYSCALL_64_after_hwframe+0x46/0xb0
       RIP: 0033:0x7f5a6b05743b
        </TASK>
       Modules linked in: vhost_net vhost vhost_iotlb tap kvm_intel(+) kvm irqbypass
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221130230934.1014142-15-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e136e969
    • Sean Christopherson's avatar
      KVM: x86: Move guts of kvm_arch_init() to standalone helper · adc0dd8b
      Sean Christopherson authored
      [ Upstream commit 4f8396b9
      
       ]
      
      Move the guts of kvm_arch_init() to a new helper, kvm_x86_vendor_init(),
      so that VMX can do _all_ arch and vendor initialization before calling
      kvm_init().  Calling kvm_init() must be the _very_ last step during init,
      as kvm_init() exposes /dev/kvm to userspace, i.e. allows creating VMs.
      
      No functional change intended.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221130230934.1014142-14-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Stable-dep-of: e32b1200
      
       ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      adc0dd8b
    • Sean Christopherson's avatar
      KVM: VMX: Don't bother disabling eVMCS static key on module exit · 5daa32be
      Sean Christopherson authored
      [ Upstream commit da66de44
      
       ]
      
      Don't disable the eVMCS static key on module exit, kvm_intel.ko owns the
      key so there can't possibly be users after the kvm_intel.ko is unloaded,
      at least not without much bigger issues.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20221130230934.1014142-12-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Stable-dep-of: e32b1200
      
       ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5daa32be
    • Sean Christopherson's avatar
      KVM: VMX: Reset eVMCS controls in VP assist page during hardware disabling · afb26bfc
      Sean Christopherson authored
      [ Upstream commit 2916b70f
      
       ]
      
      Reset the eVMCS controls in the per-CPU VP assist page during hardware
      disabling instead of waiting until kvm-intel's module exit.  The controls
      are activated if and only if KVM creates a VM, i.e. don't need to be
      reset if hardware is never enabled.
      
      Doing the reset during hardware disabling will naturally fix a potential
      NULL pointer deref bug once KVM disables CPU hotplug while enabling and
      disabling hardware (which is necessary to fix a variety of bugs).  If the
      kernel is running as the root partition, the VP assist page is unmapped
      during CPU hot unplug, and so KVM's clearing of the eVMCS controls needs
      to occur with CPU hot(un)plug disabled, otherwise KVM could attempt to
      write to a CPU's VP assist page after it's unmapped.
      
      Reported-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Message-Id: <20221130230934.1014142-11-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Stable-dep-of: e32b1200
      
       ("KVM: VMX: Do _all_ initialization before exposing /dev/kvm to userspace")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      afb26bfc
    • Fedor Pchelkin's avatar
      nfc: change order inside nfc_se_io error path · 4d72cdd6
      Fedor Pchelkin authored
      commit 7d834b4d upstream.
      
      cb_context should be freed on the error path in nfc_se_io as stated by
      commit 25ff6f8a
      
       ("nfc: fix memory leak of se_io context in
      nfc_genl_se_io").
      
      Make the error path in nfc_se_io unwind everything in reverse order, i.e.
      free the cb_context after unlocking the device.
      
      Suggested-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Link: https://lore.kernel.org/r/20230306212650.230322-1-pchelkin@ispras.ru
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d72cdd6
    • Lee Jones's avatar
      HID: uhid: Over-ride the default maximum data buffer value with our own · 4cd8ffa4
      Lee Jones authored
      commit 1c5d4221
      
       upstream.
      
      The default maximum data buffer size for this interface is UHID_DATA_MAX
      (4k).  When data buffers are being processed, ensure this value is used
      when ensuring the sanity, rather than a value between the user provided
      value and HID_MAX_BUFFER_SIZE (16k).
      
      Signed-off-by: default avatarLee Jones <lee@kernel.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4cd8ffa4