Skip to content
  1. Sep 15, 2022
    • Michael Guralnik's avatar
      RDMA/cma: Fix arguments order in net device validation · d3eb252d
      Michael Guralnik authored
      [ Upstream commit 27cfde79 ]
      
      Fix the order of source and destination addresses when resolving the
      route between server and client to validate use of correct net device.
      
      The reverse order we had so far didn't actually validate the net device
      as the server would try to resolve the route to itself, thus always
      getting the server's net device.
      
      The issue was discovered when running cm applications on a single host
      between 2 interfaces with same subnet and source based routing rules.
      When resolving the reverse route the source based route rules were
      ignored.
      
      Fixes: f887f2ac
      
       ("IB/cma: Validate routing of incoming requests")
      Link: https://lore.kernel.org/r/1c1ec2277a131d277ebcceec987fd338d35b775f.1661251872.git.leonro@nvidia.com
      Signed-off-by: default avatarMichael Guralnik <michaelgur@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d3eb252d
    • Jens Wiklander's avatar
      tee: fix compiler warning in tee_shm_register() · e2ec1064
      Jens Wiklander authored
      [ Upstream commit eccd7439 ]
      
      Include <linux/uaccess.h> to avoid the warning:
         drivers/tee/tee_shm.c: In function 'tee_shm_register':
      >> drivers/tee/tee_shm.c:242:14: error: implicit declaration of function 'access_ok' [-Werror=implicit-function-declaration]
           242 |         if (!access_ok((void __user *)addr, length))
               |              ^~~~~~~~~
         cc1: some warnings being treated as errors
      
      Fixes: 573ae4f1
      
       ("tee: add overflow check in register_shm_helper()")
      Reviewed-by: default avatarSumit Garg <sumit.garg@linaro.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e2ec1064
    • Andrew Halaney's avatar
      regulator: core: Clean up on enable failure · eb53e84d
      Andrew Halaney authored
      [ Upstream commit c32f1ebf ]
      
      If regulator_enable() fails, enable_count is incremented still.
      A consumer, assuming no matching regulator_disable() is necessary on
      failure, will then get this error message upon regulator_put()
      since enable_count is non-zero:
      
          [    1.277418] WARNING: CPU: 3 PID: 1 at drivers/regulator/core.c:2304 _regulator_put.part.0+0x168/0x170
      
      The consumer could try to fix this in their driver by cleaning up on
      error from regulator_enable() (i.e. call regulator_disable()), but that
      results in the following since regulator_enable() failed and didn't
      increment user_count:
      
          [    1.258112] unbalanced disables for vreg_l17c
          [    1.262606] WARNING: CPU: 4 PID: 1 at drivers/regulator/core.c:2899 _regulator_disable+0xd4/0x190
      
      Fix this by decrementing enable_count upon failure to enable.
      
      With this in place, just the reason for failure to enable is printed
      as expected and developers can focus on the root cause of their issue
      instead of thinking their usage of the regulator consumer api is
      incorrect. For example, in my case:
      
          [    1.240426] vreg_l17c: invalid input voltage found
      
      Fixes: 5451781d
      
       ("regulator: core: Only count load for enabled consumers")
      Signed-off-by: default avatarAndrew Halaney <ahalaney@redhat.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarBrian Masney <bmasney@redhat.com>
      Link: https://lore.kernel.org/r/20220819194336.382740-1-ahalaney@redhat.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb53e84d
    • Marek Vasut's avatar
      soc: imx: gpcv2: Assert reset before ungating clock · a53b3071
      Marek Vasut authored
      [ Upstream commit df88005b ]
      
      In case the power domain clock are ungated before the reset is asserted,
      the system might freeze completely. This is likely due to a device is an
      undefined state being attached to bus, which sporadically leads to a bus
      hang. Assert the reset before the clock are enabled to assure the device
      is in defined state before being attached to bus.
      
      Fixes: fe58c887
      
       ("soc: imx: gpcv2: add support for optional resets")
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Reviewed-by: default avatarFabio Estevam <festevam@denx.de>
      Reviewed-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a53b3071
    • Marco Felsch's avatar
      ARM: dts: imx6qdl-kontron-samx6i: remove duplicated node · 83a7e5d2
      Marco Felsch authored
      [ Upstream commit 204f67d8 ]
      
      The regulator node 'regulator-3p3v-s0' was dupplicated. Remove it to
      clean the DTS.
      
      Fixes: 2a51f9da
      
       ("ARM: dts: imx6qdl-kontron-samx6i: Add iMX6-based Kontron SMARC-sAMX6i module")
      Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      83a7e5d2
    • Jack Wang's avatar
      RDMA/rtrs-srv: Pass the correct number of entries for dma mapped SGL · ae8e70e3
      Jack Wang authored
      [ Upstream commit 56c310de ]
      
      ib_dma_map_sg() augments the SGL into a 'dma mapped SGL'. This process
      may change the number of entries and the lengths of each entry.
      
      Code that touches dma_address is iterating over the 'dma mapped SGL'
      and must use dma_nents which returned from ib_dma_map_sg().
      
      We should use the return count from ib_dma_map_sg for futher usage.
      
      Fixes: 9cb83748
      
       ("RDMA/rtrs: server: main functionality")
      Link: https://lore.kernel.org/r/20220818105355.110344-4-haris.iqbal@ionos.com
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Reviewed-by: default avatarAleksei Marov <aleksei.marov@ionos.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ae8e70e3
    • Jack Wang's avatar
      RDMA/rtrs-clt: Use the right sg_cnt after ib_dma_map_sg · ad69caa4
      Jack Wang authored
      [ Upstream commit b66905e0 ]
      
      When iommu is enabled, we hit warnings like this:
      WARNING: at rtrs/rtrs.c:178 rtrs_iu_post_rdma_write_imm+0x9b/0x110
      
      rtrs warn on one sge entry length is 0, which is unexpected.
      
      The problem is ib_dma_map_sg augments the SGL into a 'dma mapped SGL'.
      This process may change the number of entries and the lengths of each
      entry.
      
      Code that touches dma_address is iterating over the 'dma mapped SGL'
      and must use dma_nents which returned from ib_dma_map_sg().
      So pass the count return from ib_dma_map_sg.
      
      Fixes: 6a98d71d
      
       ("RDMA/rtrs: client: main functionality")
      Link: https://lore.kernel.org/r/20220818105355.110344-3-haris.iqbal@ionos.com
      Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Reviewed-by: default avatarAleksei Marov <aleksei.marov@ionos.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad69caa4
    • Srinivas Kandagatla's avatar
      ASoC: qcom: sm8250: add missing module owner · 237f1639
      Srinivas Kandagatla authored
      [ Upstream commit c6e14bb9 ]
      
      Add missing module owner to able to build and load this driver as module.
      
      Fixes: aa2e2785
      
       ("ASoC: qcom: sm8250: add sound card qrb5165-rb5 support")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220816165229.7971-1-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      237f1639
    • Tejun Heo's avatar
      cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock · 3bf4bf54
      Tejun Heo authored
      [ Upstream commit 4f7e7236
      
       ]
      
      Bringing up a CPU may involve creating and destroying tasks which requires
      read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside
      cpus_read_lock(). However, cpuset's ->attach(), which may be called with
      thredagroup_rwsem write-locked, also wants to disable CPU hotplug and
      acquires cpus_read_lock(), leading to a deadlock.
      
      Fix it by guaranteeing that ->attach() is always called with CPU hotplug
      disabled and removing cpus_read_lock() call from cpuset_attach().
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-and-tested-by: default avatarImran Khan <imran.f.khan@oracle.com>
      Reported-and-tested-by: default avatarXuewen Yan <xuewen.yan@unisoc.com>
      Fixes: 05c7b7a9
      
       ("cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug")
      Cc: stable@vger.kernel.org # v5.17+
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3bf4bf54
    • Tejun Heo's avatar
      cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree · 509e3456
      Tejun Heo authored
      [ Upstream commit 671c11f0
      
       ]
      
      cgroup_update_dfl_csses() write-lock the threadgroup_rwsem as updating the
      csses can trigger process migrations. However, if the subtree doesn't
      contain any tasks, there aren't gonna be any cgroup migrations. This
      condition can be trivially detected by testing whether
      mgctx.preloaded_src_csets is empty. Elide write-locking threadgroup_rwsem if
      the subtree is empty.
      
      After this optimization, the usage pattern of creating a cgroup, enabling
      the necessary controllers, and then seeding it with CLONE_INTO_CGROUP and
      then removing the cgroup after it becomes empty doesn't need to write-lock
      threadgroup_rwsem at all.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      509e3456
    • Trond Myklebust's avatar
      NFS: Fix another fsync() issue after a server reboot · 3b97deb4
      Trond Myklebust authored
      [ Upstream commit 67f4b5dc ]
      
      Currently, when the writeback code detects a server reboot, it redirties
      any pages that were not committed to disk, and it sets the flag
      NFS_CONTEXT_RESEND_WRITES in the nfs_open_context of the file descriptor
      that dirtied the file. While this allows the file descriptor in question
      to redrive its own writes, it violates the fsync() requirement that we
      should be synchronising all writes to disk.
      While the problem is infrequent, we do see corner cases where an
      untimely server reboot causes the fsync() call to abandon its attempt to
      sync data to disk and causing data corruption issues due to missed error
      conditions or similar.
      
      In order to tighted up the client's ability to deal with this situation
      without introducing livelocks, add a counter that records the number of
      times pages are redirtied due to a server reboot-like condition, and use
      that in fsync() to redrive the sync to disk.
      
      Fixes: 2197e9b0
      
       ("NFS: Fix up fsync() when the server rebooted")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3b97deb4
    • Trond Myklebust's avatar
      NFS: Save some space in the inode · 31b992b3
      Trond Myklebust authored
      [ Upstream commit e591b298
      
       ]
      
      Save some space in the nfs_inode by setting up an anonymous union with
      the fields that are peculiar to a specific type of filesystem object.
      
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      31b992b3
    • Trond Myklebust's avatar
      NFS: Further optimisations for 'ls -l' · 88d24e83
      Trond Myklebust authored
      [ Upstream commit ff81dfb5
      
       ]
      
      If a user is doing 'ls -l', we have a heuristic in GETATTR that tells
      the readdir code to try to use READDIRPLUS in order to refresh the inode
      attributes. In certain cirumstances, we also try to invalidate the
      remaining directory entries in order to ensure this refresh.
      
      If there are multiple readers of the directory, we probably should avoid
      invalidating the page cache, since the heuristic breaks down in that
      situation anyway.
      
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Tested-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      88d24e83
    • Yang Yingliang's avatar
      scsi: lpfc: Add missing destroy_workqueue() in error path · 1dcc3088
      Yang Yingliang authored
      commit da6d507f upstream.
      
      Add the missing destroy_workqueue() before return from
      lpfc_sli4_driver_resource_setup() in the error path.
      
      Link: https://lore.kernel.org/r/20220823044237.285643-1-yangyingliang@huawei.com
      Fixes: 3cee98db
      
       ("scsi: lpfc: Fix crash on driver unload in wq free")
      Reviewed-by: default avatarJames Smart <jsmart2021@gmail.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1dcc3088
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Fix use-after-free warning · 6229fa49
      Sreekanth Reddy authored
      commit 991df3dd
      
       upstream.
      
      Fix the following use-after-free warning which is observed during
      controller reset:
      
      refcount_t: underflow; use-after-free.
      WARNING: CPU: 23 PID: 5399 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
      
      Link: https://lore.kernel.org/r/20220906134908.1039-2-sreekanth.reddy@broadcom.com
      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>
      6229fa49
    • Ville Syrjälä's avatar
      drm/i915: Implement WaEdpLinkRateDataReload · d2ca79dd
      Ville Syrjälä authored
      commit 672d6ca7
      
       upstream.
      
      A lot of modern laptops use the Parade PS8461E MUX for eDP
      switching. The MUX can operate in jitter cleaning mode or
      redriver mode, the first one resulting in higher link
      quality. The jitter cleaning mode needs to know the link
      rate used and the MUX achieves this by snooping the
      LINK_BW_SET, LINK_RATE_SELECT and SUPPORTED_LINK_RATES
      DPCD accesses.
      
      When the MUX is powered down (seems this can happen whenever
      the display is turned off) it loses track of the snooped
      link rates so when we do the LINK_RATE_SELECT write it no
      longer knowns which link rate we're selecting, and thus it
      falls back to the lower quality redriver mode. This results
      in unstable high link rates (eg. usually 8.1Gbps link rate
      no longer works correctly).
      
      In order to avoid all that let's re-snoop SUPPORTED_LINK_RATES
      from the sink at the start of every link training.
      
      Unfortunately we don't have a way to detect the presence of
      the MUX. It looks like the set of laptops equipped with this
      MUX is fairly large and contains devices from multiple
      manufacturers. It may also still be growing with new models.
      So a quirk doesn't seem like a very easily maintainable
      option, thus we shall attempt to do this unconditionally on
      all machines that use LINK_RATE_SELECT. Hopefully this extra
      DPCD read doesn't cause issues for any unaffected machine.
      If that turns out to be the case we'll need to convert this
      into a quirk in the future.
      
      Cc: stable@vger.kernel.org
      Cc: Jason A. Donenfeld <Jason@zx2c4.com>
      Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6205
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220902070319.15395-1-ville.syrjala@linux.intel.com
      Tested-by: default avatarAaron Ma <aaron.ma@canonical.com>
      Tested-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit 25899c59
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2ca79dd
    • Bart Van Assche's avatar
      nvmet: fix a use-after-free · ebf46da5
      Bart Van Assche authored
      commit 6a02a61e upstream.
      
      Fix the following use-after-free complaint triggered by blktests nvme/004:
      
      BUG: KASAN: user-memory-access in blk_mq_complete_request_remote+0xac/0x350
      Read of size 4 at addr 0000607bd1835943 by task kworker/13:1/460
      Workqueue: nvmet-wq nvme_loop_execute_work [nvme_loop]
      Call Trace:
       show_stack+0x52/0x58
       dump_stack_lvl+0x49/0x5e
       print_report.cold+0x36/0x1e2
       kasan_report+0xb9/0xf0
       __asan_load4+0x6b/0x80
       blk_mq_complete_request_remote+0xac/0x350
       nvme_loop_queue_response+0x1df/0x275 [nvme_loop]
       __nvmet_req_complete+0x132/0x4f0 [nvmet]
       nvmet_req_complete+0x15/0x40 [nvmet]
       nvmet_execute_io_connect+0x18a/0x1f0 [nvmet]
       nvme_loop_execute_work+0x20/0x30 [nvme_loop]
       process_one_work+0x56e/0xa70
       worker_thread+0x2d1/0x640
       kthread+0x183/0x1c0
       ret_from_fork+0x1f/0x30
      
      Cc: stable@vger.kernel.org
      Fixes: a07b4970
      
       ("nvmet: add a generic NVMe target")
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebf46da5
    • Greg Kroah-Hartman's avatar
      drm/amd/display: fix memory leak when using debugfs_lookup() · 58acd2eb
      Greg Kroah-Hartman authored
      commit cbfac7fa
      
       upstream.
      
      When calling debugfs_lookup() the result must have dput() called on it,
      otherwise the memory will leak over time.  Fix this up by properly
      calling dput().
      
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Leo Li <sunpeng.li@amd.com>
      Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Wayne Lin <Wayne.Lin@amd.com>
      Cc: hersen wu <hersenxs.wu@amd.com>
      Cc: Wenjing Liu <wenjing.liu@amd.com>
      Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
      Cc: Thelford Williams <tdwilliamsiv@gmail.com>
      Cc: Fangzhi Zuo <Jerry.Zuo@amd.com>
      Cc: Yongzhi Liu <lyz_cs@pku.edu.cn>
      Cc: Mikita Lipski <mikita.lipski@amd.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: amd-gfx@lists.freedesktop.org
      Cc: dri-devel@lists.freedesktop.org
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58acd2eb
    • Greg Kroah-Hartman's avatar
      sched/debug: fix dentry leak in update_sched_domain_debugfs · 26e9a1de
      Greg Kroah-Hartman authored
      commit c2e40659
      
       upstream.
      
      Kuyo reports that the pattern of using debugfs_remove(debugfs_lookup())
      leaks a dentry and with a hotplug stress test, the machine eventually
      runs out of memory.
      
      Fix this up by using the newly created debugfs_lookup_and_remove() call
      instead which properly handles the dentry reference counting logic.
      
      Cc: Major Chen <major.chen@samsung.com>
      Cc: stable <stable@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Ben Segall <bsegall@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Valentin Schneider <vschneid@redhat.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Reported-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220902123107.109274-2-gregkh@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26e9a1de
    • Greg Kroah-Hartman's avatar
      debugfs: add debugfs_lookup_and_remove() · 94c84128
      Greg Kroah-Hartman authored
      commit dec9b2f1
      
       upstream.
      
      There is a very common pattern of using
      debugfs_remove(debufs_lookup(..)) which results in a dentry leak of the
      dentry that was looked up.  Instead of having to open-code the correct
      pattern of calling dput() on the dentry, create
      debugfs_lookup_and_remove() to handle this pattern automatically and
      properly without any memory leaks.
      
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Link: https://lore.kernel.org/r/YxIaQ8cSinDR881k@kroah.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94c84128
    • Christian A. Ehrhardt's avatar
      kprobes: Prohibit probes in gate area · 8875d606
      Christian A. Ehrhardt authored
      commit 1efda38d upstream.
      
      The system call gate area counts as kernel text but trying
      to install a kprobe in this area fails with an Oops later on.
      To fix this explicitly disallow the gate area for kprobes.
      
      Found by syzkaller with the following reproducer:
      perf_event_open$cgroup(&(0x7f00000001c0)={0x6, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80ffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext={0x0, 0xffffffffff600000}}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0)
      
      Sample report:
      BUG: unable to handle page fault for address: fffffbfff3ac6000
      PGD 6dfcb067 P4D 6dfcb067 PUD 6df8f067 PMD 6de4d067 PTE 0
      Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI
      CPU: 0 PID: 21978 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b-dirty #6
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      Call Trace:
       <TASK>
       insn_get_prefixes arch/x86/lib/insn.c:131 [inline]
       insn_get_opcode arch/x86/lib/insn.c:272 [inline]
       insn_get_modrm+0x64a/0x7b0 arch/x86/lib/insn.c:343
       insn_get_sib+0x29a/0x330 arch/x86/lib/insn.c:421
       insn_get_displacement+0x350/0x6b0 arch/x86/lib/insn.c:464
       insn_get_immediate arch/x86/lib/insn.c:632 [inline]
       insn_get_length arch/x86/lib/insn.c:707 [inline]
       insn_decode+0x43a/0x490 arch/x86/lib/insn.c:747
       can_probe+0xfc/0x1d0 arch/x86/kernel/kprobes/core.c:282
       arch_prepare_kprobe+0x79/0x1c0 arch/x86/kernel/kprobes/core.c:739
       prepare_kprobe kernel/kprobes.c:1160 [inline]
       register_kprobe kernel/kprobes.c:1641 [inline]
       register_kprobe+0xb6e/0x1690 kernel/kprobes.c:1603
       __register_trace_kprobe kernel/trace/trace_kprobe.c:509 [inline]
       __register_trace_kprobe+0x26a/0x2d0 kernel/trace/trace_kprobe.c:477
       create_local_trace_kprobe+0x1f7/0x350 kernel/trace/trace_kprobe.c:1833
       perf_kprobe_init+0x18c/0x280 kernel/trace/trace_event_perf.c:271
       perf_kprobe_event_init+0xf8/0x1c0 kernel/events/core.c:9888
       perf_try_init_event+0x12d/0x570 kernel/events/core.c:11261
       perf_init_event kernel/events/core.c:11325 [inline]
       perf_event_alloc.part.0+0xf7f/0x36a0 kernel/events/core.c:11619
       perf_event_alloc kernel/events/core.c:12059 [inline]
       __do_sys_perf_event_open+0x4a8/0x2a00 kernel/events/core.c:12157
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f63ef7efaed
      Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f63eef63028 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
      RAX: ffffffffffffffda RBX: 00007f63ef90ff80 RCX: 00007f63ef7efaed
      RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 00000000200001c0
      RBP: 00007f63ef86019c R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000
      R13: 0000000000000002 R14: 00007f63ef90ff80 R15: 00007f63eef43000
       </TASK>
      Modules linked in:
      CR2: fffffbfff3ac6000
      ---[ end trace 0000000000000000 ]---
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      ==================================================================
      
      Link: https://lkml.kernel.org/r/20220907200917.654103-1-lk@c--e.de
      
      cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      cc: "David S. Miller" <davem@davemloft.net>
      Cc: stable@vger.kernel.org
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8875d606
    • Alex Williamson's avatar
      vfio/type1: Unpin zero pages · 5321908e
      Alex Williamson authored
      commit 873aefb3
      
       upstream.
      
      There's currently a reference count leak on the zero page.  We increment
      the reference via pin_user_pages_remote(), but the page is later handled
      as an invalid/reserved page, therefore it's not accounted against the
      user and not unpinned by our put_pfn().
      
      Introducing special zero page handling in put_pfn() would resolve the
      leak, but without accounting of the zero page, a single user could
      still create enough mappings to generate a reference count overflow.
      
      The zero page is always resident, so for our purposes there's no reason
      to keep it pinned.  Therefore, add a loop to walk pages returned from
      pin_user_pages_remote() and unpin any zero pages.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarLuboslav Pivarc <lpivarc@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Link: https://lore.kernel.org/r/166182871735.3518559.8884121293045337358.stgit@omen
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5321908e
    • Shin'ichiro Kawasaki's avatar
      btrfs: zoned: set pseudo max append zone limit in zone emulation mode · 7da1afa4
      Shin'ichiro Kawasaki authored
      commit cac5c44c upstream.
      
      The commit 7d7672bc ("btrfs: convert count_max_extents() to use
      fs_info->max_extent_size") introduced a division by
      fs_info->max_extent_size. This max_extent_size is initialized with max
      zone append limit size of the device btrfs runs on. However, in zone
      emulation mode, the device is not zoned then its zone append limit is
      zero. This resulted in zero value of fs_info->max_extent_size and caused
      zero division error.
      
      Fix the error by setting non-zero pseudo value to max append zone limit
      in zone emulation mode. Set the pseudo value based on max_segments as
      suggested in the commit c2ae7b77 ("btrfs: zoned: revive
      max_zone_append_bytes").
      
      Fixes: 7d7672bc
      
       ("btrfs: convert count_max_extents() to use fs_info->max_extent_size")
      CC: stable@vger.kernel.org # 5.12+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7da1afa4
    • Masami Hiramatsu (Google)'s avatar
      tracing: Fix to check event_mutex is held while accessing trigger list · 75082ade
      Masami Hiramatsu (Google) authored
      commit cecf8e12 upstream.
      
      Since the check_user_trigger() is called outside of RCU
      read lock, this list_for_each_entry_rcu() caused a suspicious
      RCU usage warning.
      
       # echo hist:keys=pid > events/sched/sched_stat_runtime/trigger
       # cat events/sched/sched_stat_runtime/trigger
      [   43.167032]
      [   43.167418] =============================
      [   43.167992] WARNING: suspicious RCU usage
      [   43.168567] 5.19.0-rc5-00029-g19ebe4651abf #59 Not tainted
      [   43.169283] -----------------------------
      [   43.169863] kernel/trace/trace_events_trigger.c:145 RCU-list traversed in non-reader section!!
      ...
      
      However, this file->triggers list is safe when it is accessed
      under event_mutex is held.
      To fix this warning, adds a lockdep_is_held check to the
      list_for_each_entry_rcu().
      
      Link: https://lkml.kernel.org/r/166226474977.223837.1992182913048377113.stgit@devnote2
      
      Cc: stable@vger.kernel.org
      Fixes: 7491e2c4
      
       ("tracing: Add a probe that attaches to trace events")
      Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75082ade
    • Dongxiang Ke's avatar
      ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() · 98e8e673
      Dongxiang Ke authored
      commit e53f47f6
      
       upstream.
      
      There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and
      the number of it's interfaces less than 4, an out-of-bounds read bug occurs
      when parsing the interface descriptor for this device.
      
      Fix this by checking the number of interfaces.
      
      Signed-off-by: default avatarDongxiang Ke <kdx.glider@gmail.com>
      Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98e8e673
    • Takashi Iwai's avatar
      ALSA: usb-audio: Split endpoint setups for hw_params and prepare · df5ec554
      Takashi Iwai authored
      commit ff878b40 upstream.
      
      One of the former changes for the endpoint management was the more
      consistent setup of endpoints at hw_params.
      snd_usb_endpoint_configure() is a single function that does the full
      setup, and it's called from both PCM hw_params and prepare callbacks.
      Although the EP setup at the prepare phase is usually skipped (by
      checking need_setup flag), it may be still effective in some cases
      like suspend/resume that requires the interface setup again.
      
      As it's a full and single setup, the invocation of
      snd_usb_endpoint_configure() includes not only the USB interface setup
      but also the buffer release and allocation.  OTOH, doing the buffer
      release and re-allocation at PCM prepare phase is rather superfluous,
      and better to be done only in the hw_params phase.
      
      For those optimizations, this patch splits the endpoint setup to two
      phases: snd_usb_endpoint_set_params() and snd_usb_endpoint_prepare(),
      to be called from hw_params and from prepare, respectively.
      
      Note that this patch changes the driver operation slightly,
      effectively moving the USB interface setup again to PCM prepare stage
      instead of hw_params stage, while the buffer allocation and such
      initializations are still done at hw_params stage.
      
      And, the change of the USB interface setup timing (moving to prepare)
      gave an interesting "fix", too: it was reported that the recent
      kernels caused silent output at the beginning on playbacks on some
      devices on Android, and this change casually fixed the regression.
      It seems that those devices are picky about the sample rate change (or
      the interface change?), and don't follow the too immediate rate
      changes.
      
      Meanwhile, Android operates the PCM in the following order:
      - open, then hw_params with the possibly highest sample rate
      - close without prepare
      - re-open, hw_params with the normal sample rate
      - prepare, and start streaming
      This procedure ended up the hw_params twice with different rates, and
      because the recent kernel did set up the sample rate twice one and
      after, it screwed up the device.  OTOH, the earlier kernels didn't set
      up the USB interface at hw_params, hence this problem didn't appear.
      
      Now, with this patch, the USB interface setup is again back to the
      prepare phase, and it works around the problem automagically.
      Although we should address the sample rate problem in a more solid
      way in future, let's keep things working as before for now.
      
      Fixes: bf6313a0
      
       ("ALSA: usb-audio: Refactor endpoint management")
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarchihhao chen <chihhao.chen@mediatek.com>
      Link: https://lore.kernel.org/r/87e6d6ae69d68dc588ac9acc8c0f24d6188375c3.camel@mediatek.com
      Link: https://lore.kernel.org/r/20220901124136.4984-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df5ec554
    • Pattara Teerapong's avatar
      ALSA: aloop: Fix random zeros in capture data when using jiffies timer · d1118465
      Pattara Teerapong authored
      commit 3e48940a
      
       upstream.
      
      In loopback_jiffies_timer_pos_update(), we are getting jiffies twice.
      First time for playback, second time for capture. Jiffies can be updated
      between these two calls and if the capture jiffies is larger, extra zeros
      will be filled in the capture buffer.
      
      Change to get jiffies once and use it for both playback and capture.
      
      Signed-off-by: default avatarPattara Teerapong <pteerapong@chromium.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1118465
    • Tasos Sahanidis's avatar
      ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() · 45814a53
      Tasos Sahanidis authored
      commit d29f5905
      
       upstream.
      
      The voice allocator sometimes begins allocating from near the end of the
      array and then wraps around, however snd_emu10k1_pcm_channel_alloc()
      accesses the newly allocated voices as if it never wrapped around.
      
      This results in out of bounds access if the first voice has a high enough
      index so that first_voice + requested_voice_count > NUM_G (64).
      The more voices are requested, the more likely it is for this to occur.
      
      This was initially discovered using PipeWire, however it can be reproduced
      by calling aplay multiple times with 16 channels:
      aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero
      
      UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40
      index 65 is out of range for type 'snd_emu10k1_voice [64]'
      CPU: 1 PID: 31977 Comm: aplay Tainted: G        W IOE      6.0.0-rc2-emu10k1+ #7
      Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002    07/22/2010
      Call Trace:
      <TASK>
      dump_stack_lvl+0x49/0x63
      dump_stack+0x10/0x16
      ubsan_epilogue+0x9/0x3f
      __ubsan_handle_out_of_bounds.cold+0x44/0x49
      snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1]
      snd_pcm_hw_params+0x29f/0x600 [snd_pcm]
      snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm]
      ? exit_to_user_mode_prepare+0x35/0x170
      ? do_syscall_64+0x69/0x90
      ? syscall_exit_to_user_mode+0x26/0x50
      ? do_syscall_64+0x69/0x90
      ? exit_to_user_mode_prepare+0x35/0x170
      snd_pcm_ioctl+0x27/0x40 [snd_pcm]
      __x64_sys_ioctl+0x95/0xd0
      do_syscall_64+0x5c/0x90
      ? do_syscall_64+0x69/0x90
      ? do_syscall_64+0x69/0x90
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Signed-off-by: default avatarTasos Sahanidis <tasos@tasossah.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45814a53
    • Takashi Iwai's avatar
      ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC · 8015ef9e
      Takashi Iwai authored
      commit 8423f0b6
      
       upstream.
      
      There is a small race window at snd_pcm_oss_sync() that is called from
      OSS PCM SNDCTL_DSP_SYNC ioctl; namely the function calls
      snd_pcm_oss_make_ready() at first, then takes the params_lock mutex
      for the rest.  When the stream is set up again by another thread
      between them, it leads to inconsistency, and may result in unexpected
      results such as NULL dereference of OSS buffer as a fuzzer spotted
      recently.
      
      The fix is simply to cover snd_pcm_oss_make_ready() call into the same
      params_lock mutex with snd_pcm_oss_make_ready_locked() variant.
      
      Reported-and-tested-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com
      Link: https://lore.kernel.org/r/20220905060714.22549-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8015ef9e
    • Qu Huang's avatar
      drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly · ad5ef763
      Qu Huang authored
      [ Upstream commit b8983d42
      
       ]
      
      The mmVM_L2_CNTL3 register is not assigned an initial value
      
      Signed-off-by: default avatarQu Huang <jinsdb@126.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad5ef763
    • Yang Yingliang's avatar
      fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init() · fc5a2a96
      Yang Yingliang authored
      [ Upstream commit 07c55c98
      
       ]
      
      Add missing pci_disable_device() in error path in chipsfb_pci_init().
      
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fc5a2a96
    • Shigeru Yoshida's avatar
      fbdev: fbcon: Destroy mutex on freeing struct fb_info · c3abfd6c
      Shigeru Yoshida authored
      [ Upstream commit 58559dfc
      
       ]
      
      It's needed to destroy bl_curve_mutex on freeing struct fb_info since
      the mutex is embedded in the structure and initialized when it's
      allocated.
      
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3abfd6c
    • David Sloan's avatar
      md: Flush workqueue md_rdev_misc_wq in md_alloc() · a7dff6f4
      David Sloan authored
      [ Upstream commit 5e8daf90
      
       ]
      
      A race condition still exists when removing and re-creating md devices
      in test cases. However, it is only seen on some setups.
      
      The race condition was tracked down to a reference still being held
      to the kobject by the rdev in the md_rdev_misc_wq which will be released
      in rdev_delayed_delete().
      
      md_alloc() waits for previous deletions by waiting on the md_misc_wq,
      but the md_rdev_misc_wq may still be holding a reference to a recently
      removed device.
      
      To fix this, also flush the md_rdev_misc_wq in md_alloc().
      
      Signed-off-by: default avatarDavid Sloan <david.sloan@eideticom.com>
      [logang@deltatee.com: rewrote commit message]
      Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a7dff6f4
    • lily's avatar
      net/core/skbuff: Check the return value of skb_copy_bits() · 0b705806
      lily authored
      [ Upstream commit c624c58e
      
       ]
      
      skb_copy_bits() could fail, which requires a check on the return
      value.
      
      Signed-off-by: default avatarLi Zhong <floridsleeves@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0b705806
    • Lukasz Luba's avatar
      cpufreq: check only freq_table in __resolve_freq() · bd1b7695
      Lukasz Luba authored
      [ Upstream commit 6ca7076f
      
       ]
      
      There is no need to check if the cpufreq driver implements callback
      cpufreq_driver::target_index. The logic in the __resolve_freq uses
      the frequency table available in the policy. It doesn't matter if the
      driver provides 'target_index' or 'target' callback. It just has to
      populate the 'policy->freq_table'.
      
      Thus, check only frequency table during the frequency resolving call.
      
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd1b7695
    • Florian Westphal's avatar
      netfilter: conntrack: work around exceeded receive window · e928cf25
      Florian Westphal authored
      [ Upstream commit cf97769c
      
       ]
      
      When a TCP sends more bytes than allowed by the receive window, all future
      packets can be marked as invalid.
      This can clog up the conntrack table because of 5-day default timeout.
      
      Sequence of packets:
       01 initiator > responder: [S], seq 171, win 5840, options [mss 1330,sackOK,TS val 63 ecr 0,nop,wscale 1]
       02 responder > initiator: [S.], seq 33211, ack 172, win 65535, options [mss 1460,sackOK,TS val 010 ecr 63,nop,wscale 8]
       03 initiator > responder: [.], ack 33212, win 2920, options [nop,nop,TS val 068 ecr 010], length 0
       04 initiator > responder: [P.], seq 172:240, ack 33212, win 2920, options [nop,nop,TS val 279 ecr 010], length 68
      
      Window is 5840 starting from 33212 -> 39052.
      
       05 responder > initiator: [.], ack 240, win 256, options [nop,nop,TS val 872 ecr 279], length 0
       06 responder > initiator: [.], seq 33212:34530, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
      
      This is fine, conntrack will flag the connection as having outstanding
      data (UNACKED), which lowers the conntrack timeout to 300s.
      
       07 responder > initiator: [.], seq 34530:35848, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       08 responder > initiator: [.], seq 35848:37166, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       09 responder > initiator: [.], seq 37166:38484, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       10 responder > initiator: [.], seq 38484:39802, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
      
      Packet 10 is already sending more than permitted, but conntrack doesn't
      validate this (only seq is tested vs. maxend, not 'seq+len').
      
      38484 is acceptable, but only up to 39052, so this packet should
      not have been sent (or only 568 bytes, not 1318).
      
      At this point, connection is still in '300s' mode.
      
      Next packet however will get flagged:
       11 responder > initiator: [P.], seq 39802:40128, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 326
      
      nf_ct_proto_6: SEQ is over the upper bound (over the window of the receiver) .. LEN=378 .. SEQ=39802 ACK=240 ACK PSH ..
      
      Now, a couple of replies/acks comes in:
      
       12 initiator > responder: [.], ack 34530, win 4368,
      [.. irrelevant acks removed ]
       16 initiator > responder: [.], ack 39802, win 8712, options [nop,nop,TS val 296201291 ecr 2982371892], length 0
      
      This ack is significant -- this acks the last packet send by the
      responder that conntrack considered valid.
      
      This means that ack == td_end.  This will withdraw the
      'unacked data' flag, the connection moves back to the 5-day timeout
      of established conntracks.
      
       17 initiator > responder: ack 40128, win 10030, ...
      
      This packet is also flagged as invalid.
      
      Because conntrack only updates state based on packets that are
      considered valid, packet 11 'did not exist' and that gets us:
      
      nf_ct_proto_6: ACK is over upper bound 39803 (ACKed data not seen yet) .. SEQ=240 ACK=40128 WINDOW=10030 RES=0x00 ACK URG
      
      Because this received and processed by the endpoints, the conntrack entry
      remains in a bad state, no packets will ever be considered valid again:
      
       30 responder > initiator: [F.], seq 40432, ack 2045, win 391, ..
       31 initiator > responder: [.], ack 40433, win 11348, ..
       32 initiator > responder: [F.], seq 2045, ack 40433, win 11348 ..
      
      ... all trigger 'ACK is over bound' test and we end up with
      non-early-evictable 5-day default timeout.
      
      NB: This patch triggers a bunch of checkpatch warnings because of silly
      indent.  I will resend the cleanup series linked below to reduce the
      indent level once this change has propagated to net-next.
      
      I could route the cleanup via nf but that causes extra backport work for
      stable maintainers.
      
      Link: https://lore.kernel.org/netfilter-devel/20220720175228.17880-1-fw@strlen.de/T/#mb1d7147d36294573cc4f81d00f9f8dadfdd06cd8
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e928cf25
    • Sudeep Holla's avatar
      arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level · 29906311
      Sudeep Holla authored
      [ Upstream commit e75d18ce ]
      
      Though acpi_find_last_cache_level() always returned signed value and the
      document states it will return any errors caused by lack of a PPTT table,
      it never returned negative values before.
      
      Commit 0c80f9e1
      
       ("ACPI: PPTT: Leave the table mapped for the runtime usage")
      however changed it by returning -ENOENT if no PPTT was found. The value
      returned from acpi_find_last_cache_level() is then assigned to unsigned
      fw_level.
      
      It will result in the number of cache leaves calculated incorrectly as
      a huge value which will then cause the following warning from __alloc_pages
      as the order would be great than MAX_ORDER because of incorrect and huge
      cache leaves value.
      
        |  WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5407 __alloc_pages+0x74/0x314
        |  Modules linked in:
        |  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-10393-g7c2a8d3ac4c0 #73
        |  pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        |  pc : __alloc_pages+0x74/0x314
        |  lr : alloc_pages+0xe8/0x318
        |  Call trace:
        |   __alloc_pages+0x74/0x314
        |   alloc_pages+0xe8/0x318
        |   kmalloc_order_trace+0x68/0x1dc
        |   __kmalloc+0x240/0x338
        |   detect_cache_attributes+0xe0/0x56c
        |   update_siblings_masks+0x38/0x284
        |   store_cpu_topology+0x78/0x84
        |   smp_prepare_cpus+0x48/0x134
        |   kernel_init_freeable+0xc4/0x14c
        |   kernel_init+0x2c/0x1b4
        |   ret_from_fork+0x10/0x20
      
      Fix the same by changing fw_level to be signed integer and return the
      error from init_cache_level() early in case of error.
      
      Reported-and-Tested-by: default avatarBruno Goncalves <bgoncalv@redhat.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Link: https://lore.kernel.org/r/20220808084640.3165368-1-sudeep.holla@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29906311
    • Helge Deller's avatar
      parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines · 27092358
      Helge Deller authored
      [ Upstream commit 591d2108
      
       ]
      
      If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run
      on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x
      machine is detected.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27092358
    • Li Qiong's avatar
      parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() · deb2c9c0
      Li Qiong authored
      [ Upstream commit d46c742f
      
       ]
      
      As the possible failure of the kmalloc(), it should be better
      to fix this error path, check and return '-ENOMEM' error code.
      
      Signed-off-by: default avatarLi Qiong <liqiong@nfschina.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      deb2c9c0
    • Helge Deller's avatar
      Revert "parisc: Show error if wrong 32/64-bit compiler is being used" · c63ff388
      Helge Deller authored
      [ Upstream commit b4b18f47 ]
      
      This reverts commit b160628e
      
      .
      
      There is no need any longer to have this sanity check, because the
      previous commit ("parisc: Make CONFIG_64BIT available for ARCH=parisc64
      only") prevents that CONFIG_64BIT is set if ARCH==parisc.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c63ff388