Skip to content
  1. Sep 08, 2022
    • Colin Ian King's avatar
      drm/i915/reg: Fix spelling mistake "Unsupport" -> "Unsupported" · 079ea01f
      Colin Ian King authored
      [ Upstream commit 233f5674 ]
      
      There is a spelling mistake in a gvt_vgpu_err error message. Fix it.
      
      Fixes: 695fbc08
      
       ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Signed-off-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20220315202449.2952845-1-colin.i.king@gmail.com
      Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      079ea01f
    • Tony Lindgren's avatar
      clk: ti: Fix missing of_node_get() ti_find_clock_provider() · d6c8cc2d
      Tony Lindgren authored
      [ Upstream commit 26f2da0d ]
      
      For ti_find_clock_provider() we want to return the np with refcount
      incremented. However we are missing of_node_get() for the
      clock-output-names case that causes refcount warnings.
      
      Fixes: 51f661ef
      
       ("clk: ti: Add ti_find_clock_provider() to use clock-output-names")
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Link: https://lore.kernel.org/r/20220621091118.33930-1-tony@atomide.com
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d6c8cc2d
    • Conor Dooley's avatar
      riscv: kvm: move extern sbi_ext declarations to a header · 26b03f80
      Conor Dooley authored
      [ Upstream commit 3e5e56c6 ]
      
      Sparse complains about missing statics in the declarations of several
      variables:
      arch/riscv/kvm/vcpu_sbi_replace.c:38:37: warning: symbol 'vcpu_sbi_ext_time' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:73:37: warning: symbol 'vcpu_sbi_ext_ipi' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:126:37: warning: symbol 'vcpu_sbi_ext_rfence' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_replace.c:170:37: warning: symbol 'vcpu_sbi_ext_srst' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:69:37: warning: symbol 'vcpu_sbi_ext_base' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:90:37: warning: symbol 'vcpu_sbi_ext_experimental' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_base.c:96:37: warning: symbol 'vcpu_sbi_ext_vendor' was not declared. Should it be static?
      arch/riscv/kvm/vcpu_sbi_hsm.c:115:37: warning: symbol 'vcpu_sbi_ext_hsm' was not declared. Should it be static?
      
      These variables are however used in vcpu_sbi.c where they are declared
      as extern. Move them to kvm_vcpu_sbi.h which is handily already
      included by the three other files.
      
      Fixes: a046c2d8 ("RISC-V: KVM: Reorganize SBI code by moving SBI v0.1 to its own file")
      Fixes: 5f862df5 ("RISC-V: KVM: Add v0.1 replacement SBI extensions defined in v0.2")
      Fixes: 3e1d8656
      
       ("RISC-V: KVM: Add SBI HSM extension in KVM")
      Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26b03f80
    • Jim Mattson's avatar
      KVM: VMX: Heed the 'msr' argument in msr_write_intercepted() · 5424fd04
      Jim Mattson authored
      [ Upstream commit 020dac41 ]
      
      Regardless of the 'msr' argument passed to the VMX version of
      msr_write_intercepted(), the function always checks to see if a
      specific MSR (IA32_SPEC_CTRL) is intercepted for write.  This behavior
      seems unintentional and unexpected.
      
      Modify the function so that it checks to see if the provided 'msr'
      index is intercepted for write.
      
      Fixes: 67f4b996
      
       ("KVM: nVMX: Handle dynamic MSR intercept toggling")
      Cc: Sean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarJim Mattson <jmattson@google.com>
      Reviewed-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20220810213050.2655000-1-jmattson@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5424fd04
    • Enzo Matsumiya's avatar
      cifs: fix small mempool leak in SMB2_negotiate() · 38a6b469
      Enzo Matsumiya authored
      commit 27893dfc
      
       upstream.
      
      In some cases of failure (dialect mismatches) in SMB2_negotiate(), after
      the request is sent, the checks would return -EIO when they should be
      rather setting rc = -EIO and jumping to neg_exit to free the response
      buffer from mempool.
      
      Signed-off-by: default avatarEnzo Matsumiya <ematsumiya@suse.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      38a6b469
    • Carlos Llamas's avatar
      binder: fix alloc->vma_vm_mm null-ptr dereference · b2a97bab
      Carlos Llamas authored
      commit 1da52815 upstream.
      
      Syzbot reported a couple issues introduced by commit 44e602b4
      ("binder_alloc: add missing mmap_lock calls when using the VMA"), in
      which we attempt to acquire the mmap_lock when alloc->vma_vm_mm has not
      been initialized yet.
      
      This can happen if a binder_proc receives a transaction without having
      previously called mmap() to setup the binder_proc->alloc space in [1].
      Also, a similar issue occurs via binder_alloc_print_pages() when we try
      to dump the debugfs binder stats file in [2].
      
      Sample of syzbot's crash report:
        ==================================================================
        KASAN: null-ptr-deref in range [0x0000000000000128-0x000000000000012f]
        CPU: 0 PID: 3755 Comm: syz-executor229 Not tainted 6.0.0-rc1-next-20220819-syzkaller #0
        syz-executor229[3755] cmdline: ./syz-executor2294415195
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
        RIP: 0010:__lock_acquire+0xd83/0x56d0 kernel/locking/lockdep.c:4923
        [...]
        Call Trace:
         <TASK>
         lock_acquire kernel/locking/lockdep.c:5666 [inline]
         lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
         down_read+0x98/0x450 kernel/locking/rwsem.c:1499
         mmap_read_lock include/linux/mmap_lock.h:117 [inline]
         binder_alloc_new_buf_locked drivers/android/binder_alloc.c:405 [inline]
         binder_alloc_new_buf+0xa5/0x19e0 drivers/android/binder_alloc.c:593
         binder_transaction+0x242e/0x9a80 drivers/android/binder.c:3199
         binder_thread_write+0x664/0x3220 drivers/android/binder.c:3986
         binder_ioctl_write_read drivers/android/binder.c:5036 [inline]
         binder_ioctl+0x3470/0x6d00 drivers/android/binder.c:5323
         vfs_ioctl fs/ioctl.c:51 [inline]
         __do_sys_ioctl fs/ioctl.c:870 [inline]
         __se_sys_ioctl fs/ioctl.c:856 [inline]
         __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
         do_syscall_x64 arch/x86/entry/common.c:50 [inline]
         do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
         [...]
        ==================================================================
      
      Fix these issues by setting up alloc->vma_vm_mm pointer during open()
      and caching directly from current->mm. This guarantees we have a valid
      reference to take the mmap_lock during scenarios described above.
      
      [1] https://syzkaller.appspot.com/bug?extid=f7dc54e5be28950ac459
      [2] https://syzkaller.appspot.com/bug?extid=a75ebe0452711c9e56d9
      
      Fixes: 44e602b4
      
       ("binder_alloc: add missing mmap_lock calls when using the VMA")
      Cc: <stable@vger.kernel.org> # v5.15+
      Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
      Reported-by: default avatar <syzbot+f7dc54e5be28950ac459@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+a75ebe0452711c9e56d9@syzkaller.appspotmail.com>
      Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
      Acked-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Link: https://lore.kernel.org/r/20220829201254.1814484-2-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2a97bab
    • Carlos Llamas's avatar
      binder: fix UAF of ref->proc caused by race condition · 603a47f2
      Carlos Llamas authored
      commit a0e44c64
      
       upstream.
      
      A transaction of type BINDER_TYPE_WEAK_HANDLE can fail to increment the
      reference for a node. In this case, the target proc normally releases
      the failed reference upon close as expected. However, if the target is
      dying in parallel the call will race with binder_deferred_release(), so
      the target could have released all of its references by now leaving the
      cleanup of the new failed reference unhandled.
      
      The transaction then ends and the target proc gets released making the
      ref->proc now a dangling pointer. Later on, ref->node is closed and we
      attempt to take spin_lock(&ref->proc->inner_lock), which leads to the
      use-after-free bug reported below. Let's fix this by cleaning up the
      failed reference on the spot instead of relying on the target to do so.
      
        ==================================================================
        BUG: KASAN: use-after-free in _raw_spin_lock+0xa8/0x150
        Write of size 4 at addr ffff5ca207094238 by task kworker/1:0/590
      
        CPU: 1 PID: 590 Comm: kworker/1:0 Not tainted 5.19.0-rc8 #10
        Hardware name: linux,dummy-virt (DT)
        Workqueue: events binder_deferred_func
        Call trace:
         dump_backtrace.part.0+0x1d0/0x1e0
         show_stack+0x18/0x70
         dump_stack_lvl+0x68/0x84
         print_report+0x2e4/0x61c
         kasan_report+0xa4/0x110
         kasan_check_range+0xfc/0x1a4
         __kasan_check_write+0x3c/0x50
         _raw_spin_lock+0xa8/0x150
         binder_deferred_func+0x5e0/0x9b0
         process_one_work+0x38c/0x5f0
         worker_thread+0x9c/0x694
         kthread+0x188/0x190
         ret_from_fork+0x10/0x20
      
      Acked-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Signed-off-by: default avatarCarlos Llamas <cmllamas@google.com>
      Cc: stable <stable@kernel.org> # 4.14+
      Link: https://lore.kernel.org/r/20220801182511.3371447-1-cmllamas@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      603a47f2
    • Adrian Hunter's avatar
      mmc: core: Fix inconsistent sd3_bus_mode at UHS-I SD voltage switch failure · 71f7644b
      Adrian Hunter authored
      commit 63f15609
      
       upstream.
      
      If re-initialization results is a different signal voltage, because the
      voltage switch failed previously, but not this time (or vice versa), then
      sd3_bus_mode will be inconsistent with the card because the SD_SWITCH
      command is done only upon first initialization.
      
      Fix by always reading SD_SWITCH information during re-initialization, which
      also means it does not need to be re-read later for the 1.8V fixup
      workaround.
      
      Note, brief testing showed SD_SWITCH took about 1.8ms to 2ms which added
      about 1% to 1.5% to the re-initialization time, so it's not particularly
      significant.
      
      Reported-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Tested-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-3-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71f7644b
    • Adrian Hunter's avatar
      mmc: core: Fix UHS-I SD 1.8V workaround branch · bb4be611
      Adrian Hunter authored
      commit 15c56208 upstream.
      
      When introduced, upon success, the 1.8V fixup workaround in
      mmc_sd_init_card() would branch to practically the end of the function, to
      a label named "done". Unfortunately, perhaps due to the label name, over
      time new code has been added that really should have come after "done" not
      before it. Let's fix the problem by moving the label to the correct place
      and rename it "cont".
      
      Fixes: 045d705d
      
       ("mmc: core: Enable the MMC host software queue for the SD card")
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: default avatarSeunghui Lee <sh043.lee@samsung.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20220815073321.63382-2-adrian.hunter@intel.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb4be611
    • Mickaël Salaün's avatar
      landlock: Fix file reparenting without explicit LANDLOCK_ACCESS_FS_REFER · 9f78dda3
      Mickaël Salaün authored
      commit 55e55920 upstream.
      
      This change fixes a mis-handling of the LANDLOCK_ACCESS_FS_REFER right
      when multiple rulesets/domains are stacked. The expected behaviour was
      that an additional ruleset can only restrict the set of permitted
      operations, but in this particular case, it was potentially possible to
      re-gain the LANDLOCK_ACCESS_FS_REFER right.
      
      With the introduction of LANDLOCK_ACCESS_FS_REFER, we added the first
      globally denied-by-default access right.  Indeed, this lifted an initial
      Landlock limitation to rename and link files, which was initially always
      denied when the source or the destination were different directories.
      
      This led to an inconsistent backward compatibility behavior which was
      only taken into account if no domain layer were using the new
      LANDLOCK_ACCESS_FS_REFER right. However, when restricting a thread with
      a new ruleset handling LANDLOCK_ACCESS_FS_REFER, all inherited parent
      rulesets/layers not explicitly handling LANDLOCK_ACCESS_FS_REFER would
      behave as if they were handling this access right and with all their
      rules allowing it. This means that renaming and linking files could
      became allowed by these parent layers, but all the other required
      accesses must also be granted: all layers must allow file removal or
      creation, and renaming and linking operations cannot lead to privilege
      escalation according to the Landlock policy.  See detailed explanation
      in commit b91c3e4e ("landlock: Add support for file reparenting with
      LANDLOCK_ACCESS_FS_REFER").
      
      To say it another way, this bug may lift the renaming and linking
      limitations of the initial Landlock version, and a same ruleset can
      enforce different restrictions depending on previous or next enforced
      ruleset (i.e. inconsistent behavior). The LANDLOCK_ACCESS_FS_REFER right
      cannot give access to data not already allowed, but this doesn't follow
      the contract of the first Landlock ABI. This fix puts back the
      limitation for sandboxes that didn't opt-in for this additional right.
      
      For instance, if a first ruleset allows LANDLOCK_ACCESS_FS_MAKE_REG on
      /dst and LANDLOCK_ACCESS_FS_REMOVE_FILE on /src, renaming /src/file to
      /dst/file is denied. However, without this fix, stacking a new ruleset
      which allows LANDLOCK_ACCESS_FS_REFER on / would now permit the
      sandboxed thread to rename /src/file to /dst/file .
      
      This change fixes the (absolute) rule access rights, which now always
      forbid LANDLOCK_ACCESS_FS_REFER except when it is explicitly allowed
      when creating a rule.
      
      Making all domain handle LANDLOCK_ACCESS_FS_REFER was an initial
      approach but there is two downsides:
      * it makes the code more complex because we still want to check that a
        rule allowing LANDLOCK_ACCESS_FS_REFER is legitimate according to the
        ruleset's handled access rights (i.e. ABI v1 != ABI v2);
      * it would not allow to identify if the user created a ruleset
        explicitly handling LANDLOCK_ACCESS_FS_REFER or not, which will be an
        issue to audit Landlock.
      
      Instead, this change adds an ACCESS_INITIALLY_DENIED list of
      denied-by-default rights, which (only) contains
      LANDLOCK_ACCESS_FS_REFER.  All domains are treated as if they are also
      handling this list, but without modifying their fs_access_masks field.
      
      A side effect is that the errno code returned by rename(2) or link(2)
      *may* be changed from EXDEV to EACCES according to the enforced
      restrictions.  Indeed, we now have the mechanic to identify if an access
      is denied because of a required right (e.g. LANDLOCK_ACCESS_FS_MAKE_REG,
      LANDLOCK_ACCESS_FS_REMOVE_FILE) or if it is denied because of missing
      LANDLOCK_ACCESS_FS_REFER rights.  This may result in different errno
      codes than for the initial Landlock version, but this approach is more
      consistent and better for rename/link compatibility reasons, and it
      wasn't possible before (hence no backport to ABI v1).  The
      layout1.rename_file test reflects this change.
      
      Add 4 layout1.refer_denied_by_default* test suites to check that the
      behavior of a ruleset not handling LANDLOCK_ACCESS_FS_REFER (ABI v1) is
      unchanged even if another layer handles LANDLOCK_ACCESS_FS_REFER (i.e.
      ABI v1 precedence).  Make sure rule's absolute access rights are correct
      by testing with and without a matching path.  Add test_rename() and
      test_exchange() helpers.
      
      Extend layout1.inval tests to check that a denied-by-default access
      right is not necessarily part of a domain's handled access rights.
      
      Test coverage for security/landlock is 95.3% of 599 lines according to
      gcc/gcov-11.
      
      Fixes: b91c3e4e
      
       ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")
      Reviewed-by: default avatarPaul Moore <paul@paul-moore.com>
      Reviewed-by: default avatarGünther Noack <gnoack3000@gmail.com>
      Link: https://lore.kernel.org/r/20220831203840.1370732-1-mic@digikod.net
      Cc: stable@vger.kernel.org
      [mic: Constify and slightly simplify test helpers]
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f78dda3
    • Niek Nooijens's avatar
      USB: serial: ftdi_sio: add Omron CS1W-CIF31 device id · 23475d8e
      Niek Nooijens authored
      commit 001047ea
      
       upstream.
      
      works perfectly with:
      modprobe ftdi_sio
      echo "0590 00b2" | tee
      /sys/module/ftdi_sio/drivers/usb-serial\:ftdi_sio/new_id > /dev/null
      
      but doing this every reboot is a pain in the ass.
      
      Signed-off-by: default avatarNiek Nooijens <niek.nooijens@omron.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23475d8e
    • Russ Weight's avatar
      firmware_loader: Fix memory leak in firmware upload · baf92485
      Russ Weight authored
      commit 789bba82 upstream.
      
      In the case of firmware-upload, an instance of struct fw_upload is
      allocated in firmware_upload_register(). This data needs to be freed
      in fw_dev_release(). Create a new fw_upload_free() function in
      sysfs_upload.c to handle the firmware-upload specific memory frees
      and incorporate the missing kfree call for the fw_upload structure.
      
      Fixes: 97730bbb
      
       ("firmware_loader: Add firmware-upload support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarRuss Weight <russell.h.weight@intel.com>
      Link: https://lore.kernel.org/r/20220831002518.465274-1-russell.h.weight@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      baf92485
    • Russ Weight's avatar
      firmware_loader: Fix use-after-free during unregister · d380d409
      Russ Weight authored
      commit 8b40c38e upstream.
      
      In the following code within firmware_upload_unregister(), the call to
      device_unregister() could result in the dev_release function freeing the
      fw_upload_priv structure before it is dereferenced for the call to
      module_put(). This bug was found by the kernel test robot using
      CONFIG_KASAN while running the firmware selftests.
      
        device_unregister(&fw_sysfs->dev);
        module_put(fw_upload_priv->module);
      
      The problem is fixed by copying fw_upload_priv->module to a local variable
      for use when calling device_unregister().
      
      Fixes: 97730bbb
      
       ("firmware_loader: Add firmware-upload support")
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Reviewed-by: default avatarMatthew Gerlach <matthew.gerlach@linux.intel.com>
      Signed-off-by: default avatarRuss Weight <russell.h.weight@intel.com>
      Link: https://lore.kernel.org/r/20220829174557.437047-1-russell.h.weight@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d380d409
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on open · e0578e60
      Johan Hovold authored
      commit d245f43a upstream.
      
      The probe session-duplication overflow check incremented the session
      count also when there were no more available sessions so that memory
      beyond the fixed-size slab-allocated session array could be corrupted in
      fastrpc_session_alloc() on open().
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-3-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0578e60
    • Johan Hovold's avatar
      misc: fastrpc: fix memory corruption on probe · c0425c2f
      Johan Hovold authored
      commit 9baa1415 upstream.
      
      Add the missing sanity check on the probed-session count to avoid
      corrupting memory beyond the fixed-size slab-allocated session array
      when there are more than FASTRPC_MAX_SESSIONS sessions defined in the
      devicetree.
      
      Fixes: f6f9279f
      
       ("misc: fastrpc: Add Qualcomm fastrpc basic driver model")
      Cc: stable@vger.kernel.org      # 5.1
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220829080531.29681-2-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0425c2f
    • Marcus Folkesson's avatar
      iio: adc: mcp3911: use correct formula for AD conversion · 5461b547
      Marcus Folkesson authored
      commit 9e2238e3 upstream.
      
      The ADC conversion is actually not rail-to-rail but with a factor 1.5.
      Make use of this factor when calculating actual voltage.
      
      Fixes: 3a89b289
      
       ("iio: adc: add support for mcp3911")
      Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/20220722130726.7627-4-marcus.folkesson@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5461b547
    • Marcus Folkesson's avatar
      iio: adc: mcp3911: correct "microchip,device-addr" property · 2838fdab
      Marcus Folkesson authored
      commit cfbd76d5 upstream.
      
      Go for the right property name that is documented in the bindings.
      
      Fixes: 3a89b289
      
       ("iio: adc: add support for mcp3911")
      Signed-off-by: default avatarMarcus Folkesson <marcus.folkesson@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Link: https://lore.kernel.org/r/20220722130726.7627-3-marcus.folkesson@gmail.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2838fdab
    • Matti Vaittinen's avatar
      iio: ad7292: Prevent regulator double disable · 76608a25
      Matti Vaittinen authored
      commit 22b42776 upstream.
      
      The ad7292 tries to add an devm_action for disabling a regulator at
      device detach using devm_add_action_or_reset(). The
      devm_add_action_or_reset() does call the release function should adding
      action fail. The driver inspects the value returned by
      devm_add_action_or_reset() and manually calls regulator_disable() if
      adding the action has failed. This leads to double disable and messes
      the enable count for regulator.
      
      Do not manually call disable if devm_add_action_or_reset() fails.
      
      Fixes: 506d2e31
      
       ("iio: adc: Add driver support for AD7292")
      Signed-off-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
      Tested-by: default avatarMarcelo Schmitt <marcelo.schmitt1@gmail.com>
      Link: https://lore.kernel.org/r/Yv9O+9sxU7gAv3vM@fedora
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76608a25
    • Christophe JAILLET's avatar
      iio: light: cm3605: Fix an error handling path in cm3605_probe() · 3f7f49d8
      Christophe JAILLET authored
      commit 16090554 upstream.
      
      The commit in Fixes also introduced a new error handling path which should
      goto the existing error handling path.
      Otherwise some resources leak.
      
      Fixes: 0d31d91e
      
       ("iio: light: cm3605: Make use of the helper function dev_err_probe()")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Link: https://lore.kernel.org/r/0e186de2c125b3e17476ebf9c54eae4a5d66f994.1659854238.git.christophe.jaillet@wanadoo.fr
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f7f49d8
    • Tetsuo Handa's avatar
      Input: iforce - wake up after clearing IFORCE_XMIT_RUNNING flag · b533b9d3
      Tetsuo Handa authored
      commit 98e01215 upstream.
      
      syzbot is reporting hung task at __input_unregister_device() [1], for
      iforce_close() waiting at wait_event_interruptible() with dev->mutex held
      is blocking input_disconnect_device() from __input_unregister_device().
      
      It seems that the cause is simply that commit c2b27ef6
      
       ("Input:
      iforce - wait for command completion when closing the device") forgot to
      call wake_up() after clear_bit().
      
      Fix this problem by introducing a helper that calls clear_bit() followed
      by wake_up_all().
      
      Reported-by: default avatarsyzbot <syzbot+deb6abc36aad4008f407@syzkaller.appspotmail.com>
      Fixes: c2b27ef6
      
       ("Input: iforce - wait for command completion when closing the device")
      Tested-by: default avatarsyzbot <syzbot+deb6abc36aad4008f407@syzkaller.appspotmail.com>
      Suggested-by: default avatarFabio M. De Francesco <fmdefrancesco@gmail.com>
      Co-developed-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Link: https://lore.kernel.org/r/887021c3-4f13-40ce-c8b9-aa6e09faa3a7@I-love.SAKURA.ne.jp
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b533b9d3
    • Sherry Sun's avatar
      tty: serial: lpuart: disable flow control while waiting for the transmit engine to complete · 3e05af2f
      Sherry Sun authored
      commit d5a2e083 upstream.
      
      When the user initializes the uart port, and waits for the transmit
      engine to complete in lpuart32_set_termios(), if the UART TX fifo has
      dirty data and the UARTMODIR enable the flow control, the TX fifo may
      never be empty. So here we should disable the flow control first to make
      sure the transmit engin can complete.
      
      Fixes: 380c966c
      
       ("tty: serial: fsl_lpuart: add 32-bit register interface support")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarSherry Sun <sherry.sun@nxp.com>
      Link: https://lore.kernel.org/r/20220821101527.10066-1-sherry.sun@nxp.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e05af2f
    • Arnd Bergmann's avatar
      musb: fix USB_MUSB_TUSB6010 dependency · 6f130dff
      Arnd Bergmann authored
      commit a3f2fd22 upstream.
      
      Turning on NOP_USB_XCEIV as builtin broke the TUSB6010 driver because
      of an older issue with the depencency.
      
      It is not necessary to forbid NOP_USB_XCEIV=y in combination with
      USB_MUSB_HDRC=m, but only the reverse, which causes the link failure
      from the original Kconfig change.
      
      Use the correct dependency to still allow NOP_USB_XCEIV=n or
      NOP_USB_XCEIV=y but forbid NOP_USB_XCEIV=m when USB_MUSB_HDRC=m
      to fix the multi_v7_defconfig for tusb.
      
      Fixes: ab37a7a8 ("ARM: multi_v7_defconfig: Make NOP_USB_XCEIV driver built-in")
      Fixes: c0442479
      
       ("usb: musb: Fix randconfig build issues for Kconfig options")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20220818135737.3143895-10-arnd@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f130dff
    • Helge Deller's avatar
      vt: Clear selection before changing the font · c904fe03
      Helge Deller authored
      commit 566f9c9f
      
       upstream.
      
      When changing the console font with ioctl(KDFONTOP) the new font size
      can be bigger than the previous font. A previous selection may thus now
      be outside of the new screen size and thus trigger out-of-bounds
      accesses to graphics memory if the selection is removed in
      vc_do_resize().
      
      Prevent such out-of-memory accesses by dropping the selection before the
      various con_font_set() console handlers are called.
      
      Reported-by: default avatar <syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com>
      Cc: stable <stable@kernel.org>
      Tested-by: default avatarKhalid Masum <khalid.masum.92@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Link: https://lore.kernel.org/r/YuV9apZGNmGfjcor@p100
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c904fe03
    • Michael Ellerman's avatar
      powerpc/rtas: Fix RTAS MSR[HV] handling for Cell · 8b08d4f9
      Michael Ellerman authored
      commit 91926d8b upstream.
      
      The semi-recent changes to MSR handling when entering RTAS (firmware)
      cause crashes on IBM Cell machines. An example trace:
      
        kernel tried to execute user page (2fff01a8) - exploit attempt? (uid: 0)
        BUG: Unable to handle kernel instruction fetch
        Faulting instruction address: 0x2fff01a8
        Oops: Kernel access of bad area, sig: 11 [#1]
        BE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=4 NUMA Cell
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W          6.0.0-rc2-00433-gede0a8d3307a #207
        NIP:  000000002fff01a8 LR: 0000000000032608 CTR: 0000000000000000
        REGS: c0000000015236b0 TRAP: 0400   Tainted: G        W           (6.0.0-rc2-00433-gede0a8d3307a)
        MSR:  0000000008001002 <ME,RI>  CR: 00000000  XER: 20000000
        ...
        NIP 0x2fff01a8
        LR  0x32608
        Call Trace:
          0xc00000000143c5f8 (unreliable)
          .rtas_call+0x224/0x320
          .rtas_get_boot_time+0x70/0x150
          .read_persistent_clock64+0x114/0x140
          .read_persistent_wall_and_boot_offset+0x24/0x80
          .timekeeping_init+0x40/0x29c
          .start_kernel+0x674/0x8f0
          start_here_common+0x1c/0x50
      
      Unlike PAPR platforms where RTAS is only used in guests, on the IBM Cell
      machines Linux runs with MSR[HV] set but also uses RTAS, provided by
      SLOF.
      
      Fix it by copying the MSR[HV] bit from the MSR value we've just read
      using mfmsr into the value used for RTAS.
      
      It seems like we could also fix it using an #ifdef CELL to set MSR[HV],
      but that doesn't work because it's possible to build a single kernel
      image that runs on both Cell native and pseries.
      
      Fixes: b6b1c3ce
      
       ("powerpc/rtas: Keep MSR[RI] set when calling RTAS")
      Cc: stable@vger.kernel.org # v5.19+
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: default avatarJordan Niethe <jniethe5@gmail.com>
      Link: https://lore.kernel.org/r/20220823115952.1203106-2-mpe@ellerman.id.au
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b08d4f9
    • Masahiro Yamada's avatar
      powerpc: align syscall table for ppc32 · b29ee155
      Masahiro Yamada authored
      commit c7acee3d upstream.
      
      Christophe Leroy reported that commit 7b453719 ("kbuild: link
      symbol CRCs at final link,  removing CONFIG_MODULE_REL_CRCS") broke
      mpc85xx_defconfig + CONFIG_RELOCATABLE=y.
      
          LD      vmlinux
          SYSMAP  System.map
          SORTTAB vmlinux
          CHKREL  vmlinux
        WARNING: 451 bad relocations
        c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
        c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
        c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
        c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
        c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
            ...
      
      The compiler emits a bunch of R_PPC_UADDR32, which is not supported by
      arch/powerpc/kernel/reloc_32.S.
      
      The reason is there exists an unaligned symbol.
      
        $ powerpc-linux-gnu-nm -n vmlinux
          ...
        c0b31258 d spe_aligninfo
        c0b31298 d __func__.0
        c0b312a9 D sys_call_table
        c0b319b8 d __func__.0
      
      Commit 7b453719
      
       is not the root cause. Even before that, I can
      reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
      + CONFIG_MODVERSIONS=n.
      
      It is just that nobody noticed because when CONFIG_MODVERSIONS is
      enabled, a __crc_* symbol inserted before sys_call_table was hiding the
      unalignment issue.
      
      Adding alignment to the syscall table for ppc32 fixes the issue.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      [mpe: Trim change log discussion, add Cc stable]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/lkml/38605f6a-a568-f884-f06f-ea4da5b214f0@csgroup.eu/
      Link: https://lore.kernel.org/r/20220820165129.1147589-1-masahiroy@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b29ee155
    • Michael Ellerman's avatar
      Revert "powerpc: Remove unused FW_FEATURE_NATIVE references" · 8b539b5f
      Michael Ellerman authored
      commit 310d1344 upstream.
      
      This reverts commit 79b74a68.
      
      It broke booting on IBM Cell machines when the kernel is also built with
      CONFIG_PPC_PS3=y.
      
      That's because FW_FEATURE_NATIVE_ALWAYS = 0 does have an important
      effect, which is to clear the PS3 ALWAYS features from
      FW_FEATURE_ALWAYS.
      
      Note that CONFIG_PPC_NATIVE has since been renamed
      CONFIG_PPC_HASH_MMU_NATIVE.
      
      Fixes: 79b74a68
      
       ("powerpc: Remove unused FW_FEATURE_NATIVE references")
      Cc: stable@vger.kernel.org # v5.17+
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20220823115952.1203106-1-mpe@ellerman.id.au
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b539b5f
    • Grzegorz Szymaszek's avatar
      staging: r8188eu: add firmware dependency · eaffa77b
      Grzegorz Szymaszek authored
      commit b2fa9e13 upstream.
      
      The old rtl8188eu module, removed in commit 55dfa29b
      
       ("staging:
      rtl8188eu: remove rtl8188eu driver from staging dir") (Linux kernel
      v5.15-rc1), required (through a MODULE_FIRMWARE call()) the
      rtlwifi/rtl8188eufw.bin firmware file, which the new r8188eu driver no
      longer requires.
      
      I have tested a few RTL8188EUS-based Wi-Fi cards and, while supported by
      both drivers, they do not work when using the new one and the firmware
      wasn't manually loaded. According to Larry Finger, the module
      maintainer, all such cards need the firmware and the driver should
      depend on it (see the linked mails).
      
      Add a proper MODULE_FIRMWARE() call, like it was done in the old driver.
      
      Thanks to Greg Kroah-Hartman and Larry Finger for quick responses to my
      questions.
      
      Cc: stable <stable@kernel.org>
      Link: https://answers.launchpad.net/ubuntu/+source/linux-meta-hwe-5.15/+question/702611
      Link: https://lore.kernel.org/lkml/YukkBu3TNODO3or9@nx64de-df6d00/
      Signed-off-by: default avatarGrzegorz Szymaszek <gszymaszek@short.pl>
      Link: https://lore.kernel.org/r/YulcdKfhA8dPQ78s@nx64de-df6d00
      Acked-by: default avatarPhillip Potter <phil@philpotter.co.uk>
      Acked-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eaffa77b
    • Larry Finger's avatar
      staging: r8188eu: Add Rosewill USB-N150 Nano to device tables · 02c09dbb
      Larry Finger authored
      commit e01f5c8d
      
       upstream.
      
      This device is reported as using the RTL8188EUS chip.
      
      It has the improbable USB ID of 0bda:ffef, which normally would belong
      to Realtek, but this ID works for the reporter.
      
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Cc: stable <stable@kernel.org>
      Link: https://lore.kernel.org/r/20220814175027.2689-1-Larry.Finger@lwfinger.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02c09dbb
    • Dan Carpenter's avatar
      staging: rtl8712: fix use after free bugs · b1727def
      Dan Carpenter authored
      commit e230a445 upstream.
      
      _Read/Write_MACREG callbacks are NULL so the read/write_macreg_hdl()
      functions don't do anything except free the "pcmd" pointer.  It
      results in a use after free.  Delete them.
      
      Fixes: 2865d42c
      
       ("staging: r8712u: Add the new driver to the mainline kernel")
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarZheng Wang <hackerzheng666@gmail.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/Yw4ASqkYcUhUfoY2@kili
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1727def
    • Sergiu Moga's avatar
      tty: serial: atmel: Preserve previous USART mode if RS485 disabled · 418a52be
      Sergiu Moga authored
      commit 692a8ebc upstream.
      
      Whenever the atmel_rs485_config() driver method would be called,
      the USART mode is reset to normal mode before even checking if
      RS485 flag is set, thus resulting in losing the previous USART
      mode in the case where the checking fails.
      
      Some tools, such as `linux-serial-test`, lead to the driver calling
      this method when doing the setup of the serial port: after setting the
      port mode (Hardware Flow Control, Normal Mode, RS485 Mode, etc.),
      `linux-serial-test` tries to enable/disable RS485 depending on
      the commandline arguments that were passed.
      
      Example of how this issue could reveal itself:
      When doing a serial communication with Hardware Flow Control through
      `linux-serial-test`, the tool would lead to the driver roughly doing
      the following:
      - set the corresponding bit to 1 (ATMEL_US_USMODE_HWHS bit in the
      ATMEL_US_MR register) through the atmel_set_termios() to enable
      Hardware Flow Control
      - disable RS485 through the atmel_config_rs485() method
      Thus, when the latter is called, the mode will be reset and the
      previously set bit is unset, leaving USART in normal mode instead of
      the expected Hardware Flow Control mode.
      
      This fix ensures that this reset is only done if the checking for
      RS485 succeeds and that the previous mode is preserved otherwise.
      
      Fixes: e8faff73
      
       ("ARM: 6092/1: atmel_serial: support for RS485 communications")
      Cc: stable <stable@kernel.org>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Signed-off-by: default avatarSergiu Moga <sergiu.moga@microchip.com>
      Link: https://lore.kernel.org/r/20220824142902.502596-1-sergiu.moga@microchip.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      418a52be
    • Shenwei Wang's avatar
      serial: fsl_lpuart: RS485 RTS polariy is inverse · a17353e3
      Shenwei Wang authored
      commit 846651ec upstream.
      
      The setting of RS485 RTS polarity is inverse in the current driver.
      
      When the property of 'rs485-rts-active-low' is enabled in the dts node,
      the RTS signal should be LOW during sending. Otherwise, if there is no
      such a property, the RTS should be HIGH during sending.
      
      Fixes: 03895cf4
      
       ("tty: serial: fsl_lpuart: Add support for RS-485")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarNicolas Diaz <nicolas.diaz@nxp.com>
      Signed-off-by: default avatarShenwei Wang <shenwei.wang@nxp.com>
      Link: https://lore.kernel.org/r/20220805144529.604856-1-shenwei.wang@nxp.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a17353e3
    • Vadim Pasternak's avatar
      platform/mellanox: mlxreg-lc: Fix locking issue · ad936d6d
      Vadim Pasternak authored
      [ Upstream commit 1e092b7f ]
      
      Fix locking issues:
      - mlxreg_lc_state_update() takes a lock when set or clear
        "MLXREG_LC_POWERED".
      - All the devices can be deleted before MLXREG_LC_POWERED flag is cleared.
      
      To fix it:
      - Add lock() / unlock() at the beginning / end of
        mlxreg_lc_event_handler() and remove locking from
        mlxreg_lc_power_on_off() and mlxreg_lc_enable_disable()
      - Add locked version of mlxreg_lc_state_update() -
        mlxreg_lc_state_update_locked() for using outside
        mlxreg_lc_event_handler().
      
      (2) Remove redundant NULL check for of if 'data->notifier'.
      
      Fixes: 62f9529b
      
       ("platform/mellanox: mlxreg-lc: Add initial support for Nvidia line card devices")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
      Link: https://lore.kernel.org/r/20220823201937.46855-3-vadimp@nvidia.com
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad936d6d
    • Vadim Pasternak's avatar
      platform/mellanox: mlxreg-lc: Fix coverity warning · daa0d028
      Vadim Pasternak authored
      [ Upstream commit 17c2bd6b ]
      
      Fix smatch warning:
      drivers/platform/mellanox/mlxreg-lc.c:866 mlxreg_lc_probe() warn: passing zero to 'PTR_ERR'
      by removing 'err = PTR_ERR(regmap)'.
      
      Fixes: b4b830a3
      
       ("platform/mellanox: mlxreg-lc: Fix error flow and extend verbosity")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarVadim Pasternak <vadimp@nvidia.com>
      Link: https://lore.kernel.org/r/20220823201937.46855-2-vadimp@nvidia.com
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      daa0d028
    • Waiman Long's avatar
      mm/slab_common: Deleting kobject in kmem_cache_destroy() without holding... · 35732155
      Waiman Long authored
      mm/slab_common: Deleting kobject in kmem_cache_destroy() without holding slab_mutex/cpu_hotplug_lock
      
      [ Upstream commit 0495e337 ]
      
      A circular locking problem is reported by lockdep due to the following
      circular locking dependency.
      
        +--> cpu_hotplug_lock --> slab_mutex --> kn->active --+
        |                                                     |
        +-----------------------------------------------------+
      
      The forward cpu_hotplug_lock ==> slab_mutex ==> kn->active dependency
      happens in
      
        kmem_cache_destroy():	cpus_read_lock(); mutex_lock(&slab_mutex);
        ==> sysfs_slab_unlink()
            ==> kobject_del()
                ==> kernfs_remove()
      	      ==> __kernfs_remove()
      	          ==> kernfs_drain(): rwsem_acquire(&kn->dep_map, ...);
      
      The backward kn->active ==> cpu_hotplug_lock dependency happens in
      
        kernfs_fop_write_iter(): kernfs_get_active();
        ==> slab_attr_store()
            ==> cpu_partial_store()
                ==> flush_all(): cpus_read_lock()
      
      One way to break this circular locking chain is to avoid holding
      cpu_hotplug_lock and slab_mutex while deleting the kobject in
      sysfs_slab_unlink() which should be equivalent to doing a write_lock
      and write_unlock pair of the kn->active virtual lock.
      
      Since the kobject structures are not protected by slab_mutex or the
      cpu_hotplug_lock, we can certainly release those locks before doing
      the delete operation.
      
      Move sysfs_slab_unlink() and sysfs_slab_release() to the newly
      created kmem_cache_release() and call it outside the slab_mutex &
      cpu_hotplug_lock critical sections. There will be a slight delay
      in the deletion of sysfs files if kmem_cache_release() is called
      indirectly from a work function.
      
      Fixes: 5a836bf6
      
       ("mm: slub: move flush_cpu_slab() invocations __free_slab() invocations out of IRQ context")
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Reviewed-by: default avatarHyeonggon Yoo <42.hyeyoo@gmail.com>
      Reviewed-by: default avatarRoman Gushchin <roman.gushchin@linux.dev>
      Acked-by: default avatarDavid Rientjes <rientjes@google.com>
      Link: https://lore.kernel.org/all/YwOImVd+nRUsSAga@hyeyoo/
      Signed-off-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      35732155
    • Srinivas Kandagatla's avatar
      soundwire: qcom: fix device status array range · b823c225
      Srinivas Kandagatla authored
      [ Upstream commit 4ef3f2af ]
      
      This patch updates device status array range from 11 to 12 as we will
      be reading status from device number 0 to device number 11 inclusive.
      
      Without this patch we can potentially access status array out of range
      during auto-enumeration.
      
      Fixes: aa1262ca
      
       ("soundwire: qcom: Check device status before reading devid")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20220708104747.8722-1-srinivas.kandagatla@linaro.org
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b823c225
    • Yacan Liu's avatar
      net/smc: Remove redundant refcount increase · 74d2d7a9
      Yacan Liu authored
      [ Upstream commit a8424a9b ]
      
      For passive connections, the refcount increment has been done in
      smc_clcsock_accept()-->smc_sock_alloc().
      
      Fixes: 3b2dec26
      
       ("net/smc: restructure client and server code in af_smc")
      Signed-off-by: default avatarYacan Liu <liuyacan@corp.netease.com>
      Reviewed-by: default avatarTony Lu <tonylu@linux.alibaba.com>
      Link: https://lore.kernel.org/r/20220830152314.838736-1-liuyacan@corp.netease.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74d2d7a9
    • Jakub Kicinski's avatar
      Revert "sch_cake: Return __NET_XMIT_STOLEN when consuming enqueued skb" · 1e789ee9
      Jakub Kicinski authored
      [ Upstream commit 0b4f688d ]
      
      This reverts commit 90fabae8.
      
      Patch was applied hastily, revert and let the v2 be reviewed.
      
      Fixes: 90fabae8
      
       ("sch_cake: Return __NET_XMIT_STOLEN when consuming enqueued skb")
      Link: https://lore.kernel.org/all/87wnao2ha3.fsf@toke.dk/
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e789ee9
    • Eric Dumazet's avatar
      tcp: annotate data-race around challenge_timestamp · 6c4ef059
      Eric Dumazet authored
      [ Upstream commit 8c705212 ]
      
      challenge_timestamp can be read an written by concurrent threads.
      
      This was expected, but we need to annotate the race to avoid potential issues.
      
      Following patch moves challenge_timestamp and challenge_count
      to per-netns storage to provide better isolation.
      
      Fixes: 354e4aa3
      
       ("tcp: RFC 5961 5.2 Blind Data Injection Attack Mitigation")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarNeal Cardwell <ncardwell@google.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6c4ef059
    • Toke Høiland-Jørgensen's avatar
      sch_cake: Return __NET_XMIT_STOLEN when consuming enqueued skb · ca94a506
      Toke Høiland-Jørgensen authored
      [ Upstream commit 90fabae8 ]
      
      When the GSO splitting feature of sch_cake is enabled, GSO superpackets
      will be broken up and the resulting segments enqueued in place of the
      original skb. In this case, CAKE calls consume_skb() on the original skb,
      but still returns NET_XMIT_SUCCESS. This can confuse parent qdiscs into
      assuming the original skb still exists, when it really has been freed. Fix
      this by adding the __NET_XMIT_STOLEN flag to the return value in this case.
      
      Fixes: 0c850344
      
       ("sch_cake: Conditionally split GSO segments")
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-18231
      Link: https://lore.kernel.org/r/20220831092103.442868-1-toke@toke.dk
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca94a506
    • Cong Wang's avatar
      kcm: fix strp_init() order and cleanup · f865976b
      Cong Wang authored
      [ Upstream commit 8fc29ff3
      
       ]
      
      strp_init() is called just a few lines above this csk->sk_user_data
      check, it also initializes strp->work etc., therefore, it is
      unnecessary to call strp_done() to cancel the freshly initialized
      work.
      
      And if sk_user_data is already used by KCM, psock->strp should not be
      touched, particularly strp->work state, so we need to move strp_init()
      after the csk->sk_user_data check.
      
      This also makes a lockdep warning reported by syzbot go away.
      
      Reported-and-tested-by: default avatar <syzbot+9fc084a4348493ef65d2@syzkaller.appspotmail.com>
      Reported-by: default avatar <syzbot+e696806ef96cdd2d87cd@syzkaller.appspotmail.com>
      Fixes: e5571240 ("kcm: Check if sk_user_data already set in kcm_attach")
      Fixes: dff8baa2
      
       ("kcm: Call strp_stop before strp_done in kcm_attach")
      Cc: Tom Herbert <tom@herbertland.com>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Link: https://lore.kernel.org/r/20220827181314.193710-1-xiyou.wangcong@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f865976b