Skip to content
  1. Sep 30, 2021
    • Kaige Fu's avatar
      irqchip/gic-v3-its: Fix potential VPE leak on error · e0c1c2e5
      Kaige Fu authored
      [ Upstream commit 280bef51 ]
      
      In its_vpe_irq_domain_alloc, when its_vpe_init() returns an error,
      there is an off-by-one in the number of VPEs to be freed.
      
      Fix it by simply passing the number of VPEs allocated, which is the
      index of the loop iterating over the VPEs.
      
      Fixes: 7d75bbb4
      
       ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown")
      Signed-off-by: default avatarKaige Fu <kaige.fu@linux.alibaba.com>
      [maz: fixed commit message]
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/d9e36dee512e63670287ed9eff884a5d8d6d27f2.1631672311.git.kaige.fu@linux.alibaba.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e0c1c2e5
    • Randy Dunlap's avatar
      irqchip/goldfish-pic: Select GENERIC_IRQ_CHIP to fix build · 54688670
      Randy Dunlap authored
      [ Upstream commit 969ac78d ]
      
      irq-goldfish-pic uses GENERIC_IRQ_CHIP interfaces so select that symbol
      to fix build errors.
      
      Fixes these build errors:
      
      mips-linux-ld: drivers/irqchip/irq-goldfish-pic.o: in function `goldfish_pic_of_init':
      irq-goldfish-pic.c:(.init.text+0xc0): undefined reference to `irq_alloc_generic_chip'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0xf4): undefined reference to `irq_gc_unmask_enable_reg'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0xf8): undefined reference to `irq_gc_unmask_enable_reg'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0x100): undefined reference to `irq_gc_mask_disable_reg'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0x104): undefined reference to `irq_gc_mask_disable_reg'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0x11c): undefined reference to `irq_setup_generic_chip'
      mips-linux-ld: irq-goldfish-pic.c:(.init.text+0x168): undefined reference to `irq_remove_generic_chip'
      
      Fixes: 4235ff50
      
       ("irqchip/irq-goldfish-pic: Add Goldfish PIC driver")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Miodrag Dinic <miodrag.dinic@mips.com>
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Goran Ferenc <goran.ferenc@mips.com>
      Cc: Aleksandar Markovic <aleksandar.markovic@mips.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20210905162519.21507-1-rdunlap@infradead.org
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      54688670
    • Dan Carpenter's avatar
      scsi: lpfc: Use correct scnprintf() limit · 329cb72b
      Dan Carpenter authored
      [ Upstream commit 6dacc371 ]
      
      The limit should be "PAGE_SIZE - len" instead of "PAGE_SIZE".  We're not
      going to hit the limit so this fix will not affect runtime.
      
      Link: https://lore.kernel.org/r/20210916132331.GE25094@kili
      Fixes: 5b9e70b2
      
       ("scsi: lpfc: raise sg count for nvme to use available sg resources")
      Reviewed-by: default avatarJames Smart <jsmart2021@gmail.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      329cb72b
    • Dmitry Bogdanov's avatar
      scsi: qla2xxx: Restore initiator in dual mode · f56250ae
      Dmitry Bogdanov authored
      [ Upstream commit 5f857903 ]
      
      In dual mode in case of disabling the target, the whole port goes offline
      and initiator is turned off too.
      
      Fix restoring initiator mode after disabling target in dual mode.
      
      Link: https://lore.kernel.org/r/20210915153239.8035-1-d.bogdanov@yadro.com
      Fixes: 0645cb83
      
       ("scsi: qla2xxx: Add mode control for each physical port")
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarDmitry Bogdanov <d.bogdanov@yadro.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f56250ae
    • Bart Van Assche's avatar
      scsi: ufs: core: Unbreak the reset handler · e607120e
      Bart Van Assche authored
      [ Upstream commit d04a968c ]
      
      A command tag is passed as the second argument of the
      __ufshcd_transfer_req_compl() call in ufshcd_eh_device_reset_handler()
      instead of a bitmask. Fix this by passing a bitmask as argument instead of
      a command tag.
      
      Link: https://lore.kernel.org/r/20210916175408.2260084-1-bvanassche@acm.org
      Fixes: a45f9371
      
       ("scsi: ufs: Optimize host lock on transfer requests send/compl paths")
      Cc: Can Guo <cang@codeaurora.org>
      Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e607120e
    • Bart Van Assche's avatar
      scsi: ufs: Retry aborted SCSI commands instead of completing these successfully · 1d65bff0
      Bart Van Assche authored
      [ Upstream commit 73dc3c4a ]
      
      Neither SAM nor the UFS standard require that the UFS controller fills in
      the completion status of commands that have been aborted (LUN RESET aborts
      pending commands). Hence do not rely on the completion status provided by
      the UFS controller for aborted commands but instead ask the SCSI core to
      retry SCSI commands that have been aborted.
      
      Link: https://lore.kernel.org/r/20210722033439.26550-18-bvanassche@acm.org
      
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Stanley Chu <stanley.chu@mediatek.com>
      Cc: Can Guo <cang@codeaurora.org>
      Cc: Asutosh Das <asutoshd@codeaurora.org>
      Cc: Avri Altman <avri.altman@wdc.com>
      Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1d65bff0
    • Bart Van Assche's avatar
      scsi: ufs: Revert "Utilize Transfer Request List Completion Notification Register" · 4368d7a1
      Bart Van Assche authored
      [ Upstream commit 1f522c50 ]
      
      Using the UTRLCNR register involves two MMIO accesses in the hot path while
      using the doorbell register only involves a single MMIO access. Since MMIO
      accesses take time, do not use the UTRLCNR register. The spinlock
      contention on the SCSI host lock that is reintroduced by this commit will
      be addressed later.
      
      This reverts commit 6f715172.
      
      Link: https://lore.kernel.org/r/20210722033439.26550-12-bvanassche@acm.org
      
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Stanley Chu <stanley.chu@mediatek.com>
      Cc: Can Guo <cang@codeaurora.org>
      Cc: Asutosh Das <asutoshd@codeaurora.org>
      Cc: Avri Altman <avri.altman@wdc.com>
      Tested-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4368d7a1
    • Bart Van Assche's avatar
      scsi: sd_zbc: Support disks with more than 2**32 logical blocks · 1fc9119e
      Bart Van Assche authored
      [ Upstream commit 1d479e6c ]
      
      This patch addresses the following Coverity report about the zno *
      sdkp->zone_blocks expression:
      
      CID 1475514 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
      overflow_before_widen: Potentially overflowing expression zno *
      sdkp->zone_blocks with type unsigned int (32 bits, unsigned) is evaluated
      using 32-bit arithmetic, and then used in a context that expects an
      expression of type sector_t (64 bits, unsigned).
      
      Link: https://lore.kernel.org/r/20210917212314.2362324-1-bvanassche@acm.org
      Fixes: 5795eb44
      
       ("scsi: sd_zbc: emulate ZONE_APPEND commands")
      Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
      Cc: Damien Le Moal <Damien.LeMoal@wdc.com>
      Cc: Hannes Reinecke <hare@suse.de>
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1fc9119e
    • Dan Carpenter's avatar
      cifs: fix a sign extension bug · 309c4b00
      Dan Carpenter authored
      [ Upstream commit e946d3c8 ]
      
      The problem is the mismatched types between "ctx->total_len" which is
      an unsigned int, "rc" which is an int, and "ctx->rc" which is a
      ssize_t.  The code does:
      
      	ctx->rc = (rc == 0) ? ctx->total_len : rc;
      
      We want "ctx->rc" to store the negative "rc" error code.  But what
      happens is that "rc" is type promoted to a high unsigned int and
      'ctx->rc" will store the high positive value instead of a negative
      value.
      
      The fix is to change "rc" from an int to a ssize_t.
      
      Fixes: c610c4b6
      
       ("CIFS: Add asynchronous write support through kernel AIO")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      309c4b00
    • Dan Carpenter's avatar
      thermal/core: Potential buffer overflow in thermal_build_list_of_policies() · a5024c71
      Dan Carpenter authored
      [ Upstream commit 1bb30b20 ]
      
      After printing the list of thermal governors, then this function prints
      a newline character.  The problem is that "size" has not been updated
      after printing the last governor.  This means that it can write one
      character (the NUL terminator) beyond the end of the buffer.
      
      Get rid of the "size" variable and just use "PAGE_SIZE - count" directly.
      
      Fixes: 1b4f4849
      
       ("thermal: core: group functions related to governor handling")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      Link: https://lore.kernel.org/r/20210916131342.GB25094@kili
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a5024c71
    • Christoph Hellwig's avatar
      nvme: keep ctrl->namespaces ordered · ed1e0252
      Christoph Hellwig authored
      [ Upstream commit 298ba0e3 ]
      
      Various places in the nvme code that rely on ctrl->namespace to be
      ordered.  Ensure that the namespae is inserted into the list at the
      right position from the start instead of sorting it after the fact.
      
      Fixes: 540c801c
      
       ("NVMe: Implement namespace list scanning")
      Reported-by: default avatarAnton Eidelman <anton.eidelman@gmail.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
      Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
      Reviewed-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ed1e0252
    • Sagi Grimberg's avatar
      nvme-tcp: fix incorrect h2cdata pdu offset accounting · 08a14a65
      Sagi Grimberg authored
      [ Upstream commit e371af03 ]
      
      When the controller sends us multiple r2t PDUs in a single
      request we need to account for it correctly as our send/recv
      context run concurrently (i.e. we get a new r2t with r2t_offset
      before we updated our iterator and req->data_sent marker). This
      can cause wrong offsets to be sent to the controller.
      
      To fix that, we will first know that this may happen only in
      the send sequence of the last page, hence we will take
      the r2t_offset to the h2c PDU data_offset, and in
      nvme_tcp_try_send_data loop, we make sure to increment
      the request markers also when we completed a PDU but
      we are expecting more r2t PDUs as we still did not send
      the entire data of the request.
      
      Fixes: 825619b0
      
       ("nvme-tcp: fix possible use-after-completion")
      Reported-by: default avatarNowak, Lukasz <Lukasz.Nowak@Dell.com>
      Tested-by: default avatarNowak, Lukasz <Lukasz.Nowak@Dell.com>
      Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
      Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      08a14a65
    • Jiashuo Liang's avatar
      x86/fault: Fix wrong signal when vsyscall fails with pkey · 8cd1ae34
      Jiashuo Liang authored
      [ Upstream commit d4ffd5df ]
      
      The function __bad_area_nosemaphore() calls kernelmode_fixup_or_oops()
      with the parameter @signal being actually @pkey, which will send a
      signal numbered with the argument in @pkey.
      
      This bug can be triggered when the kernel fails to access user-given
      memory pages that are protected by a pkey, so it can go down the
      do_user_addr_fault() path and pass the !user_mode() check in
      __bad_area_nosemaphore().
      
      Most cases will simply run the kernel fixup code to make an -EFAULT. But
      when another condition current->thread.sig_on_uaccess_err is met, which
      is only used to emulate vsyscall, the kernel will generate the wrong
      signal.
      
      Add a new parameter @pkey to kernelmode_fixup_or_oops() to fix this.
      
       [ bp: Massage commit message, fix build error as reported by the 0day
         bot: https://lkml.kernel.org/r/202109202245.APvuT8BX-lkp@intel.com ]
      
      Fixes: 5042d40a
      
       ("x86/fault: Bypass no_context() for implicit kernel faults from usermode")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJiashuo Liang <liangjs@pku.edu.cn>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
      Link: https://lkml.kernel.org/r/20210730030152.249106-1-liangjs@pku.edu.cn
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cd1ae34
    • Jiapeng Chong's avatar
      fpga: machxo2-spi: Fix missing error code in machxo2_write_complete() · bfacc1de
      Jiapeng Chong authored
      [ Upstream commit a1e44708 ]
      
      The error code is missing in this code scenario, add the error code
      '-EINVAL' to the return value 'ret'.
      
      Eliminate the follow smatch warning:
      
      drivers/fpga/machxo2-spi.c:341 machxo2_write_complete()
        warn: missing error code 'ret'.
      
      [mdf@kernel.org: Reworded commit message]
      Fixes: 88fb3a00
      
       ("fpga: lattice machxo2: Add Lattice MachXO2 support")
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bfacc1de
    • Tom Rix's avatar
      fpga: machxo2-spi: Return an error on failure · 674fd6ad
      Tom Rix authored
      [ Upstream commit 34331739 ]
      
      Earlier successes leave 'ret' in a non error state, so these errors are
      not reported. Set ret to -EINVAL before going to the error handler.
      
      This addresses two issues reported by smatch:
      drivers/fpga/machxo2-spi.c:229 machxo2_write_init()
        warn: missing error code 'ret'
      
      drivers/fpga/machxo2-spi.c:316 machxo2_write_complete()
        warn: missing error code 'ret'
      
      [mdf@kernel.org: Reworded commit message]
      Fixes: 88fb3a00
      
       ("fpga: lattice machxo2: Add Lattice MachXO2 support")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      674fd6ad
    • Randy Dunlap's avatar
      tty: synclink_gt: rename a conflicting function name · 0ee0fbc2
      Randy Dunlap authored
      [ Upstream commit 06e49073 ]
      
      'set_signals()' in synclink_gt.c conflicts with an exported symbol
      in arch/um/, so change set_signals() to set_gtsignals(). Keep
      the function names similar by also changing get_signals() to
      get_gtsignals().
      
      ../drivers/tty/synclink_gt.c:442:13: error: conflicting types for ‘set_signals’
       static void set_signals(struct slgt_info *info);
                   ^~~~~~~~~~~
      In file included from ../include/linux/irqflags.h:16:0,
                       from ../include/linux/spinlock.h:58,
                       from ../include/linux/mm_types.h:9,
                       from ../include/linux/buildid.h:5,
                       from ../include/linux/module.h:14,
                       from ../drivers/tty/synclink_gt.c:46:
      ../arch/um/include/asm/irqflags.h:6:5: note: previous declaration of ‘set_signals’ was here
       int set_signals(int enable);
           ^~~~~~~~~~~
      
      Fixes: 705b6c7b
      
       ("[PATCH] new driver synclink_gt")
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Paul Fulghum <paulkf@microgate.com>
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Link: https://lore.kernel.org/r/20210902003806.17054-1-rdunlap@infradead.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ee0fbc2
    • Maurizio Lombardi's avatar
      scsi: target: Fix the pgr/alua_support_store functions · 8cbf9ac9
      Maurizio Lombardi authored
      [ Upstream commit ef7ae7f7 ]
      
      Commit 356ba2a8 ("scsi: target: tcmu: Make pgr_support and alua_support
      attributes writable") introduced support for changeable alua_support and
      pgr_support target attributes. These can only be changed if the backstore
      is user-backed, otherwise the kernel returns -EINVAL.
      
      This triggers a warning in the targetcli/rtslib code when performing a
      target restore that includes non-userbacked backstores:
      
        # targetctl restore
        Storage Object block/storage1: Cannot set attribute alua_support:
        [Errno 22] Invalid argument, skipped
        Storage Object block/storage1: Cannot set attribute pgr_support:
        [Errno 22] Invalid argument, skipped
      
      Fix this warning by returning an error code only if we are really going to
      flip the PGR/ALUA bit in the transport_flags field, otherwise we will do
      nothing and return success.
      
      Return ENOSYS instead of EINVAL if the pgr/alua attributes can not be
      changed, this way it will be possible for userspace to understand if the
      operation failed because an invalid value has been passed to strtobool() or
      because the attributes are fixed.
      
      Fixes: 356ba2a8 ("scsi: target: tcmu: Make pgr_support and alua_support attributes writable")
      Link: https://lore.kernel.org/r/20210906151809.52811-1-mlombard@redhat.com
      
      
      Reviewed-by: default avatarBodo Stroesser <bostroesser@gmail.com>
      Signed-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cbf9ac9
    • Baokun Li's avatar
      scsi: iscsi: Adjust iface sysfs attr detection · 0c1b2c0d
      Baokun Li authored
      [ Upstream commit 4e285508 ]
      
      ISCSI_NET_PARAM_IFACE_ENABLE belongs to enum iscsi_net_param instead of
      iscsi_iface_param so move it to ISCSI_NET_PARAM. Otherwise, when we call
      into the driver, we might not match and return that we don't want attr
      visible in sysfs. Found in code review.
      
      Link: https://lore.kernel.org/r/20210901085336.2264295-1-libaokun1@huawei.com
      Fixes: e746f345
      
       ("scsi: iscsi: Fix iface sysfs attr detection")
      Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
      Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0c1b2c0d
    • Philip Yang's avatar
      drm/amdkfd: fix dma mapping leaking warning · c7da1781
      Philip Yang authored
      [ Upstream commit f6325118 ]
      
      For xnack off, restore work dma unmap previous system memory page, and
      dma map the updated system memory page to update GPU mapping, this is
      not dma mapping leaking, remove the WARN_ONCE for dma mapping leaking.
      
      prange->dma_addr store the VRAM page pfn after the range migrated to
      VRAM, should not dma unmap VRAM page when updating GPU mapping or
      remove prange. Add helper svm_is_valid_dma_mapping_addr to check VRAM
      page and error cases.
      
      Mask out SVM_RANGE_VRAM_DOMAIN flag in dma_addr before calling amdgpu vm
      update to avoid BUG_ON(*addr & 0xFFFF00000000003FULL), and set it again
      immediately after. This flag is used to know the type of page later to
      dma unmapping system memory page.
      
      Fixes: 1d5dbfe6
      
       ("drm/amdkfd: classify and map mixed svm range pages in GPU")
      Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c7da1781
    • Philip Yang's avatar
      drm/amdkfd: map SVM range with correct access permission · bb8078d3
      Philip Yang authored
      [ Upstream commit 2f617f4d
      
       ]
      
      Restore retry fault or prefetch range, or restore svm range after
      eviction to map range to GPU with correct read or write access
      permission.
      
      Range may includes multiple VMAs, update GPU page table with offset of
      prange, number of pages for each VMA according VMA access permission.
      
      Signed-off-by: default avatarPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb8078d3
    • Sudarsana Reddy Kalluru's avatar
      atlantic: Fix issue in the pm resume flow. · 80ec71bd
      Sudarsana Reddy Kalluru authored
      [ Upstream commit 4d88c339 ]
      
      After fixing hibernation resume flow, another usecase was found which
      should be explicitly handled - resume when device is in "down" state.
      Invoke aq_nic_init jointly with aq_nic_start only if ndev was already
      up during suspend/hibernate. We still need to perform nic_deinit() if
      caller requests for it, to handle the freeze/resume scenarios.
      
      Fixes: 57f780f1
      
       ("atlantic: Fix driver resume flow.")
      Signed-off-by: default avatarSudarsana Reddy Kalluru <skalluru@marvell.com>
      Signed-off-by: default avatarIgor Russkikh <irusskikh@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      80ec71bd
    • Aya Levin's avatar
      net/mlx4_en: Don't allow aRFS for encapsulated packets · d0a3a062
      Aya Levin authored
      [ Upstream commit fdbccea4 ]
      
      Driver doesn't support aRFS for encapsulated packets, return early error
      in such a case.
      
      Fixes: 1eb8c695
      
       ("net/mlx4_en: Add accelerated RFS support")
      Signed-off-by: default avatarAya Levin <ayal@nvidia.com>
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0a3a062
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix forwarding from BLOCKING ports remaining enabled · 6909a55c
      Vladimir Oltean authored
      [ Upstream commit acc64f52 ]
      
      The blamed commit made the fatally incorrect assumption that ports which
      aren't in the FORWARDING STP state should not have packets forwarded
      towards them, and that is all that needs to be done.
      
      However, that logic alone permits BLOCKING ports to forward to
      FORWARDING ports, which of course allows packet storms to occur when
      there is an L2 loop.
      
      The ocelot_get_bridge_fwd_mask should not only ask "what can the bridge
      do for you", but "what can you do for the bridge". This way, only
      FORWARDING ports forward to the other FORWARDING ports from the same
      bridging domain, and we are still compatible with the idea of multiple
      bridges.
      
      Fixes: df291e54
      
       ("net: ocelot: support multiple bridges")
      Suggested-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Reported-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6909a55c
    • Felix Fietkau's avatar
      net: ethernet: mtk_eth_soc: avoid creating duplicate offload entries · 6081c82c
      Felix Fietkau authored
      [ Upstream commit e68daf61 ]
      
      Sometimes multiple CLS_REPLACE calls are issued for the same connection.
      rhashtable_insert_fast does not check for these duplicates, so multiple
      hardware flow entries can be created.
      Fix this by checking for an existing entry early
      
      Fixes: 502e84e2
      
       ("net: ethernet: mtk_eth_soc: add flow offloading support")
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6081c82c
    • Mark Brown's avatar
      nfc: st-nci: Add SPI ID matching DT compatible · 339440b1
      Mark Brown authored
      [ Upstream commit 31339440 ]
      
      Currently autoloading for SPI devices does not use the DT ID table, it uses
      SPI modalises. Supporting OF modalises is going to be difficult if not
      impractical, an attempt was made but has been reverted, so ensure that
      module autoloading works for this driver by adding the part name used in
      the compatible to the list of SPI IDs.
      
      Fixes: 96c8395e
      
       ("spi: Revert modalias changes")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      339440b1
    • Ido Schimmel's avatar
      nexthop: Fix memory leaks in nexthop notification chain listeners · 741760fa
      Ido Schimmel authored
      [ Upstream commit 3106a084 ]
      
      syzkaller discovered memory leaks [1] that can be reduced to the
      following commands:
      
       # ip nexthop add id 1 blackhole
       # devlink dev reload pci/0000:06:00.0
      
      As part of the reload flow, mlxsw will unregister its netdevs and then
      unregister from the nexthop notification chain. Before unregistering
      from the notification chain, mlxsw will receive delete notifications for
      nexthop objects using netdevs registered by mlxsw or their uppers. mlxsw
      will not receive notifications for nexthops using netdevs that are not
      dismantled as part of the reload flow. For example, the blackhole
      nexthop above that internally uses the loopback netdev as its nexthop
      device.
      
      One way to fix this problem is to have listeners flush their nexthop
      tables after unregistering from the notification chain. This is
      error-prone as evident by this patch and also not symmetric with the
      registration path where a listener receives a dump of all the existing
      nexthops.
      
      Therefore, fix this problem by replaying delete notifications for the
      listener being unregistered. This is symmetric to the registration path
      and also consistent with the netdev notification chain.
      
      The above means that unregister_nexthop_notifier(), like
      register_nexthop_notifier(), will have to take RTNL in order to iterate
      over the existing nexthops and that any callers of the function cannot
      hold RTNL. This is true for mlxsw and netdevsim, but not for the VXLAN
      driver. To avoid a deadlock, change the latter to unregister its nexthop
      listener without holding RTNL, making it symmetric to the registration
      path.
      
      [1]
      unreferenced object 0xffff88806173d600 (size 512):
        comm "syz-executor.0", pid 1290, jiffies 4295583142 (age 143.507s)
        hex dump (first 32 bytes):
          41 9d 1e 60 80 88 ff ff 08 d6 73 61 80 88 ff ff  A..`......sa....
          08 d6 73 61 80 88 ff ff 01 00 00 00 00 00 00 00  ..sa............
        backtrace:
          [<ffffffff81a6b576>] kmemleak_alloc_recursive include/linux/kmemleak.h:43 [inline]
          [<ffffffff81a6b576>] slab_post_alloc_hook+0x96/0x490 mm/slab.h:522
          [<ffffffff81a716d3>] slab_alloc_node mm/slub.c:3206 [inline]
          [<ffffffff81a716d3>] slab_alloc mm/slub.c:3214 [inline]
          [<ffffffff81a716d3>] kmem_cache_alloc_trace+0x163/0x370 mm/slub.c:3231
          [<ffffffff82e8681a>] kmalloc include/linux/slab.h:591 [inline]
          [<ffffffff82e8681a>] kzalloc include/linux/slab.h:721 [inline]
          [<ffffffff82e8681a>] mlxsw_sp_nexthop_obj_group_create drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:4918 [inline]
          [<ffffffff82e8681a>] mlxsw_sp_nexthop_obj_new drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5054 [inline]
          [<ffffffff82e8681a>] mlxsw_sp_nexthop_obj_event+0x59a/0x2910 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:5239
          [<ffffffff813ef67d>] notifier_call_chain+0xbd/0x210 kernel/notifier.c:83
          [<ffffffff813f0662>] blocking_notifier_call_chain kernel/notifier.c:318 [inline]
          [<ffffffff813f0662>] blocking_notifier_call_chain+0x72/0xa0 kernel/notifier.c:306
          [<ffffffff8384b9c6>] call_nexthop_notifiers+0x156/0x310 net/ipv4/nexthop.c:244
          [<ffffffff83852bd8>] insert_nexthop net/ipv4/nexthop.c:2336 [inline]
          [<ffffffff83852bd8>] nexthop_add net/ipv4/nexthop.c:2644 [inline]
          [<ffffffff83852bd8>] rtm_new_nexthop+0x14e8/0x4d10 net/ipv4/nexthop.c:2913
          [<ffffffff833e9a78>] rtnetlink_rcv_msg+0x448/0xbf0 net/core/rtnetlink.c:5572
          [<ffffffff83608703>] netlink_rcv_skb+0x173/0x480 net/netlink/af_netlink.c:2504
          [<ffffffff833de032>] rtnetlink_rcv+0x22/0x30 net/core/rtnetlink.c:5590
          [<ffffffff836069de>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
          [<ffffffff836069de>] netlink_unicast+0x5ae/0x7f0 net/netlink/af_netlink.c:1340
          [<ffffffff83607501>] netlink_sendmsg+0x8e1/0xe30 net/netlink/af_netlink.c:1929
          [<ffffffff832fde84>] sock_sendmsg_nosec net/socket.c:704 [inline]
          [<ffffffff832fde84>] sock_sendmsg net/socket.c:724 [inline]
          [<ffffffff832fde84>] ____sys_sendmsg+0x874/0x9f0 net/socket.c:2409
          [<ffffffff83304a44>] ___sys_sendmsg+0x104/0x170 net/socket.c:2463
          [<ffffffff83304c01>] __sys_sendmsg+0x111/0x1f0 net/socket.c:2492
          [<ffffffff83304d5d>] __do_sys_sendmsg net/socket.c:2501 [inline]
          [<ffffffff83304d5d>] __se_sys_sendmsg net/socket.c:2499 [inline]
          [<ffffffff83304d5d>] __x64_sys_sendmsg+0x7d/0xc0 net/socket.c:2499
      
      Fixes: 2a014b20
      
       ("mlxsw: spectrum_router: Add support for nexthop objects")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      741760fa
    • Paolo Abeni's avatar
      mptcp: ensure tx skbs always have the MPTCP ext · f8ff625a
      Paolo Abeni authored
      [ Upstream commit 977d293e
      
       ]
      
      Due to signed/unsigned comparison, the expression:
      
      	info->size_goal - skb->len > 0
      
      evaluates to true when the size goal is smaller than the
      skb size. That results in lack of tx cache refill, so that
      the skb allocated by the core TCP code lacks the required
      MPTCP skb extensions.
      
      Due to the above, syzbot is able to trigger the following WARN_ON():
      
      WARNING: CPU: 1 PID: 810 at net/mptcp/protocol.c:1366 mptcp_sendmsg_frag+0x1362/0x1bc0 net/mptcp/protocol.c:1366
      Modules linked in:
      CPU: 1 PID: 810 Comm: syz-executor.4 Not tainted 5.14.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:mptcp_sendmsg_frag+0x1362/0x1bc0 net/mptcp/protocol.c:1366
      Code: ff 4c 8b 74 24 50 48 8b 5c 24 58 e9 0f fb ff ff e8 13 44 8b f8 4c 89 e7 45 31 ed e8 98 57 2e fe e9 81 f4 ff ff e8 fe 43 8b f8 <0f> 0b 41 bd ea ff ff ff e9 6f f4 ff ff 4c 89 e7 e8 b9 8e d2 f8 e9
      RSP: 0018:ffffc9000531f6a0 EFLAGS: 00010216
      RAX: 000000000000697f RBX: 0000000000000000 RCX: ffffc90012107000
      RDX: 0000000000040000 RSI: ffffffff88eac9e2 RDI: 0000000000000003
      RBP: ffff888078b15780 R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffff88eac017 R11: 0000000000000000 R12: ffff88801de0a280
      R13: 0000000000006b58 R14: ffff888066278280 R15: ffff88803c2fe9c0
      FS:  00007fd9f866e700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007faebcb2f718 CR3: 00000000267cb000 CR4: 00000000001506e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       __mptcp_push_pending+0x1fb/0x6b0 net/mptcp/protocol.c:1547
       mptcp_release_cb+0xfe/0x210 net/mptcp/protocol.c:3003
       release_sock+0xb4/0x1b0 net/core/sock.c:3206
       sk_stream_wait_memory+0x604/0xed0 net/core/stream.c:145
       mptcp_sendmsg+0xc39/0x1bc0 net/mptcp/protocol.c:1749
       inet6_sendmsg+0x99/0xe0 net/ipv6/af_inet6.c:643
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:724
       sock_write_iter+0x2a0/0x3e0 net/socket.c:1057
       call_write_iter include/linux/fs.h:2163 [inline]
       new_sync_write+0x40b/0x640 fs/read_write.c:507
       vfs_write+0x7cf/0xae0 fs/read_write.c:594
       ksys_write+0x1ee/0x250 fs/read_write.c:647
       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+0x44/0xae
      RIP: 0033:0x4665f9
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 bc ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007fd9f866e188 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 000000000056c038 RCX: 00000000004665f9
      RDX: 00000000000e7b78 RSI: 0000000020000000 RDI: 0000000000000003
      RBP: 00000000004bfcc4 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 000000000056c038
      R13: 0000000000a9fb1f R14: 00007fd9f866e300 R15: 0000000000022000
      
      Fix the issue rewriting the relevant expression to avoid
      sign-related problems - note: size_goal is always >= 0.
      
      Additionally, ensure that the skb in the tx cache always carries
      the relevant extension.
      
      Reported-and-tested-by: default avatar <syzbot+263a248eec3e875baa7b@syzkaller.appspotmail.com>
      Fixes: 1094c6fe
      
       ("mptcp: fix possible divide by zero")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f8ff625a
    • Shai Malin's avatar
      qed: rdma - don't wait for resources under hw error recovery flow · 3d6374d5
      Shai Malin authored
      [ Upstream commit 1ea78123 ]
      
      If the HW device is during recovery, the HW resources will never return,
      hence we shouldn't wait for the CID (HW context ID) bitmaps to clear.
      This fix speeds up the error recovery flow.
      
      Fixes: 64515dc8
      
       ("qed: Add infrastructure for error detection and recovery")
      Signed-off-by: default avatarMichal Kalderon <mkalderon@marvell.com>
      Signed-off-by: default avatarAriel Elior <aelior@marvell.com>
      Signed-off-by: default avatarShai Malin <smalin@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d6374d5
    • Kunihiko Hayashi's avatar
      gpio: uniphier: Fix void functions to remove return value · 18eab899
      Kunihiko Hayashi authored
      [ Upstream commit 2dd824cc ]
      
      The return type of irq_chip.irq_mask() and irq_chip.irq_unmask() should
      be void.
      
      Fixes: dbe776c2
      
       ("gpio: uniphier: add UniPhier GPIO controller driver")
      Signed-off-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18eab899
    • Hans de Goede's avatar
      gpiolib: acpi: Make set-debounce-timeout failures non fatal · 26c204fb
      Hans de Goede authored
      [ Upstream commit cef0d022 ]
      
      Commit 8dcb7a15 ("gpiolib: acpi: Take into account debounce settings")
      made the gpiolib-acpi code call gpio_set_debounce_timeout() when requesting
      GPIOs.
      
      This in itself is fine, but it also made gpio_set_debounce_timeout()
      errors fatal, causing the requesting of the GPIO to fail. This is causing
      regressions. E.g. on a HP ElitePad 1000 G2 various _AEI specified GPIO
      ACPI event sources specify a debouncy timeout of 20 ms, but the
      pinctrl-baytrail.c only supports certain fixed values, the closest
      ones being 12 or 24 ms and pinctrl-baytrail.c responds with -EINVAL
      when specified a value which is not one of the fixed values.
      
      This is causing the acpi_request_own_gpiod() call to fail for 3
      ACPI event sources on the HP ElitePad 1000 G2, which in turn is causing
      e.g. the battery charging vs discharging status to never get updated,
      even though a charger has been plugged-in or unplugged.
      
      Make gpio_set_debounce_timeout() errors non fatal, warning about the
      failure instead, to fix this regression.
      
      Note we should probably also fix various pinctrl drivers to just
      pick the first bigger discrete value rather then returning -EINVAL but
      this will need to be done on a per driver basis, where as this fix
      at least gets us back to where things were before and thus restores
      functionality on devices where this was lost due to
      gpio_set_debounce_timeout() errors.
      
      Fixes: 8dcb7a15 ("gpiolib: acpi: Take into account debounce settings")
      Depends-on: 2e2b496c
      
       ("gpiolib: acpi: Extract acpi_request_own_gpiod() helper")
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26c204fb
    • Julian Wiedmann's avatar
      s390/qeth: fix NULL deref in qeth_clear_working_pool_list() · 9b00fb12
      Julian Wiedmann authored
      [ Upstream commit 248f064a ]
      
      When qeth_set_online() calls qeth_clear_working_pool_list() to roll
      back after an error exit from qeth_hardsetup_card(), we are at risk of
      accessing card->qdio.in_q before it was allocated by
      qeth_alloc_qdio_queues() via qeth_mpc_initialize().
      
      qeth_clear_working_pool_list() then dereferences NULL, and by writing to
      queue->bufs[i].pool_entry scribbles all over the CPU's lowcore.
      Resulting in a crash when those lowcore areas are used next (eg. on
      the next machine-check interrupt).
      
      Such a scenario would typically happen when the device is first set
      online and its queues aren't allocated yet. An early IO error or certain
      misconfigs (eg. mismatched transport mode, bad portno) then cause us to
      error out from qeth_hardsetup_card() with card->qdio.in_q still being
      NULL.
      
      Fix it by checking the pointer for NULL before accessing it.
      
      Note that we also have (rare) paths inside qeth_mpc_initialize() where
      a configuration change can cause us to free the existing queues,
      expecting that subsequent code will allocate them again. If we then
      error out before that re-allocation happens, the same bug occurs.
      
      Fixes: eff73e16
      
       ("s390/qeth: tolerate pre-filled RX buffer")
      Reported-by: default avatarStefan Raspl <raspl@linux.ibm.com>
      Root-caused-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Reviewed-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9b00fb12
    • Mark Brown's avatar
      spi: Revert modalias changes · b9fc4ed7
      Mark Brown authored
      [ Upstream commit 96c8395e ]
      
      During the v5.13 cycle we updated the SPI subsystem to generate OF style
      modaliases for SPI devices, replacing the old Linux style modalises we
      used to generate based on spi_device_id which are the DT style name with
      the vendor removed.  Unfortunately this means that we start only
      reporting OF style modalises and not the old ones and there is nothing
      that ensures that drivers list every possible OF compatible string in
      their OF ID table.  The result is that there are systems which have been
      relying on loading modules based on the old style that are now broken,
      as found by Russell King with spi-nor on Macchiatobin.
      
      spi-nor is a particularly problematic case for this, it only lists a
      single generic DT compatible jedec,spi-nor in the driver but supports a
      huge raft of device specific compatibles, with a large set of part
      numbers many of which are offered by multiple vendors.  Russell's
      searches of upstream device trees has turned up examples with vendor
      names written in non-standard ways too.  To make matters worse up until
      8ff16cf7 ("Documentation: devicetree: m25p80: add "nor-jedec"
      binding") the generic compatible was not part of the binding so there
      are device trees out there written to that binding version which don't
      list it all.  The sheer number of parts supported together with our
      previous approach of ignoring the vendor ID makes robustly fixing this
      by adding compatibles to the spi-nor driver seem problematic, the
      current DT binding document does not list all the parts supported by the
      driver at the minute (further patches will fix this).
      
      I've also investigated supporting both formats of modalias
      simultaneously but that doesn't seem possible, especially without
      breaking our userspace ABI which is obviously not viable.
      
      Instead revert the relevant changes for now:
      
      e09f2ab8 ("spi: update modalias_show after of_device_uevent_modalias support")
      3ce6c9e2 ("spi: add of_device_uevent_modalias support")
      
      This will unfortunately mean that any system which had started having
      modules autoload based on the OF compatibles for drivers that list
      things there but not in the spi_device_ids will now not have those
      modules load which is itself a regression.  Since it affects a narrower
      time window and the particularly problematic spi-nor driver may be
      critical to system boot on smaller systems this seems the best of a
      series of bad options.  I will start an audit of SPI drivers to identify
      and fix cases where things won't autoload using spi_device_id, this is
      not great but seems to be the best way forward that anyone has been able
      to identify.
      
      Thanks to Russell for both his report and the additional diagnostic and
      analysis work he has done here, the detailed research above was his
      work.
      
      Fixes: e09f2ab8 ("spi: update modalias_show after of_device_uevent_modalias support")
      Fixes: 3ce6c9e2
      
       ("spi: add of_device_uevent_modalias support")
      Reported-by: default avatarRussell King (Oracle) <linux@armlinux.org.uk>
      Suggested-by: default avatarRussell King (Oracle) <linux@armlinux.org.uk>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Tested-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Cc: Andreas Schwab <schwab@suse.de>
      Cc: Marco Felsch <m.felsch@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b9fc4ed7
    • Cristian Marussi's avatar
      kselftest/arm64: signal: Skip tests if required features are missing · 9839bb2b
      Cristian Marussi authored
      [ Upstream commit 0e3dbf76 ]
      
      During initialization of a signal testcase, features declared as required
      are properly checked against the running system but no action is then taken
      to effectively skip such a testcase.
      
      Fix core signals test logic to abort initialization and report such a
      testcase as skipped to the KSelfTest framework.
      
      Fixes: f96bf434
      
       ("kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils")
      Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210920121228.35368-1-cristian.marussi@arm.com
      
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9839bb2b
    • Mark Brown's avatar
      kselftest/arm64: signal: Add SVE to the set of features we can check for · 6407eb66
      Mark Brown authored
      [ Upstream commit d4e4dc4f
      
       ]
      
      Allow testcases for SVE signal handling to flag the dependency and be
      skipped on systems without SVE support.
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210819134245.13935-2-broonie@kernel.org
      
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6407eb66
    • Randy Dunlap's avatar
      platform/x86: dell: fix DELL_WMI_PRIVACY dependencies & build error · d12feda3
      Randy Dunlap authored
      [ Upstream commit 5b72dafa ]
      
      When DELL_WMI=y, DELL_WMI_PRIVACY=y, and LEDS_TRIGGER_AUDIO=m, there
      is a linker error since the LEDS trigger code is built as a loadable
      module. This happens because DELL_WMI_PRIVACY is a bool that depends
      on a tristate (LEDS_TRIGGER_AUDIO=m), which can be dangerous.
      
      ld: drivers/platform/x86/dell/dell-wmi-privacy.o: in function `dell_privacy_wmi_probe':
      dell-wmi-privacy.c:(.text+0x3df): undefined reference to `ledtrig_audio_get'
      
      Fixes: 8af9fa37
      
       ("platform/x86: dell-privacy: Add support for Dell hardware privacy")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Perry Yuan <Perry.Yuan@dell.com>
      Cc: Dell.Client.Kernel@dell.com
      Cc: platform-driver-x86@vger.kernel.org
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mark Gross <mgross@linux.intel.com>
      Link: https://lore.kernel.org/r/20210918044829.19222-1-rdunlap@infradead.org
      
      
      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>
      d12feda3
    • Vladimir Oltean's avatar
      net: dsa: realtek: register the MDIO bus under devres · 5e95328a
      Vladimir Oltean authored
      [ Upstream commit 74b6d7d1 ]
      
      The Linux device model permits both the ->shutdown and ->remove driver
      methods to get called during a shutdown procedure. Example: a DSA switch
      which sits on an SPI bus, and the SPI bus driver calls this on its
      ->shutdown method:
      
      spi_unregister_controller
      -> device_for_each_child(&ctlr->dev, NULL, __unregister);
         -> spi_unregister_device(to_spi_device(dev));
            -> device_del(&spi->dev);
      
      So this is a simple pattern which can theoretically appear on any bus,
      although the only other buses on which I've been able to find it are
      I2C:
      
      i2c_del_adapter
      -> device_for_each_child(&adap->dev, NULL, __unregister_client);
         -> i2c_unregister_device(client);
            -> device_unregister(&client->dev);
      
      The implication of this pattern is that devices on these buses can be
      unregistered after having been shut down. The drivers for these devices
      might choose to return early either from ->remove or ->shutdown if the
      other callback has already run once, and they might choose that the
      ->shutdown method should only perform a subset of the teardown done by
      ->remove (to avoid unnecessary delays when rebooting).
      
      So in other words, the device driver may choose on ->remove to not
      do anything (therefore to not unregister an MDIO bus it has registered
      on ->probe), because this ->remove is actually triggered by the
      device_shutdown path, and its ->shutdown method has already run and done
      the minimally required cleanup.
      
      This used to be fine until the blamed commit, but now, the following
      BUG_ON triggers:
      
      void mdiobus_free(struct mii_bus *bus)
      {
      	/* For compatibility with error handling in drivers. */
      	if (bus->state == MDIOBUS_ALLOCATED) {
      		kfree(bus);
      		return;
      	}
      
      	BUG_ON(bus->state != MDIOBUS_UNREGISTERED);
      	bus->state = MDIOBUS_RELEASED;
      
      	put_device(&bus->dev);
      }
      
      In other words, there is an attempt to free an MDIO bus which was not
      unregistered. The attempt to free it comes from the devres release
      callbacks of the SPI device, which are executed after the device is
      unregistered.
      
      I'm not saying that the fact that MDIO buses allocated using devres
      would automatically get unregistered wasn't strange. I'm just saying
      that the commit didn't care about auditing existing call paths in the
      kernel, and now, the following code sequences are potentially buggy:
      
      (a) devm_mdiobus_alloc followed by plain mdiobus_register, for a device
          located on a bus that unregisters its children on shutdown. After
          the blamed patch, either both the alloc and the register should use
          devres, or none should.
      
      (b) devm_mdiobus_alloc followed by plain mdiobus_register, and then no
          mdiobus_unregister at all in the remove path. After the blamed
          patch, nobody unregisters the MDIO bus anymore, so this is even more
          buggy than the previous case which needs a specific bus
          configuration to be seen, this one is an unconditional bug.
      
      In this case, the Realtek drivers fall under category (b). To solve it,
      we can register the MDIO bus under devres too, which restores the
      previous behavior.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Reported-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
      Reported-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e95328a
    • Vladimir Oltean's avatar
      net: dsa: don't allocate the slave_mii_bus using devres · 880ee7cf
      Vladimir Oltean authored
      [ Upstream commit 5135e96a ]
      
      The Linux device model permits both the ->shutdown and ->remove driver
      methods to get called during a shutdown procedure. Example: a DSA switch
      which sits on an SPI bus, and the SPI bus driver calls this on its
      ->shutdown method:
      
      spi_unregister_controller
      -> device_for_each_child(&ctlr->dev, NULL, __unregister);
         -> spi_unregister_device(to_spi_device(dev));
            -> device_del(&spi->dev);
      
      So this is a simple pattern which can theoretically appear on any bus,
      although the only other buses on which I've been able to find it are
      I2C:
      
      i2c_del_adapter
      -> device_for_each_child(&adap->dev, NULL, __unregister_client);
         -> i2c_unregister_device(client);
            -> device_unregister(&client->dev);
      
      The implication of this pattern is that devices on these buses can be
      unregistered after having been shut down. The drivers for these devices
      might choose to return early either from ->remove or ->shutdown if the
      other callback has already run once, and they might choose that the
      ->shutdown method should only perform a subset of the teardown done by
      ->remove (to avoid unnecessary delays when rebooting).
      
      So in other words, the device driver may choose on ->remove to not
      do anything (therefore to not unregister an MDIO bus it has registered
      on ->probe), because this ->remove is actually triggered by the
      device_shutdown path, and its ->shutdown method has already run and done
      the minimally required cleanup.
      
      This used to be fine until the blamed commit, but now, the following
      BUG_ON triggers:
      
      void mdiobus_free(struct mii_bus *bus)
      {
      	/* For compatibility with error handling in drivers. */
      	if (bus->state == MDIOBUS_ALLOCATED) {
      		kfree(bus);
      		return;
      	}
      
      	BUG_ON(bus->state != MDIOBUS_UNREGISTERED);
      	bus->state = MDIOBUS_RELEASED;
      
      	put_device(&bus->dev);
      }
      
      In other words, there is an attempt to free an MDIO bus which was not
      unregistered. The attempt to free it comes from the devres release
      callbacks of the SPI device, which are executed after the device is
      unregistered.
      
      I'm not saying that the fact that MDIO buses allocated using devres
      would automatically get unregistered wasn't strange. I'm just saying
      that the commit didn't care about auditing existing call paths in the
      kernel, and now, the following code sequences are potentially buggy:
      
      (a) devm_mdiobus_alloc followed by plain mdiobus_register, for a device
          located on a bus that unregisters its children on shutdown. After
          the blamed patch, either both the alloc and the register should use
          devres, or none should.
      
      (b) devm_mdiobus_alloc followed by plain mdiobus_register, and then no
          mdiobus_unregister at all in the remove path. After the blamed
          patch, nobody unregisters the MDIO bus anymore, so this is even more
          buggy than the previous case which needs a specific bus
          configuration to be seen, this one is an unconditional bug.
      
      In this case, DSA falls into category (a), it tries to be helpful and
      registers an MDIO bus on behalf of the switch, which might be on such a
      bus. I've no idea why it does it under devres.
      
      It does this on probe:
      
      	if (!ds->slave_mii_bus && ds->ops->phy_read)
      		alloc and register mdio bus
      
      and this on remove:
      
      	if (ds->slave_mii_bus && ds->ops->phy_read)
      		unregister mdio bus
      
      I _could_ imagine using devres because the condition used on remove is
      different than the condition used on probe. So strictly speaking, DSA
      cannot determine whether the ds->slave_mii_bus it sees on remove is the
      ds->slave_mii_bus that _it_ has allocated on probe. Using devres would
      have solved that problem. But nonetheless, the existing code already
      proceeds to unregister the MDIO bus, even though it might be
      unregistering an MDIO bus it has never registered. So I can only guess
      that no driver that implements ds->ops->phy_read also allocates and
      registers ds->slave_mii_bus itself.
      
      So in that case, if unregistering is fine, freeing must be fine too.
      
      Stop using devres and free the MDIO bus manually. This will make devres
      stop attempting to free a still registered MDIO bus on ->shutdown.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Reported-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      880ee7cf
    • Vladimir Oltean's avatar
      net: dsa: fix dsa_tree_setup error path · e15b7001
      Vladimir Oltean authored
      [ Upstream commit e5845aa0 ]
      
      Since the blamed commit, dsa_tree_teardown_switches() was split into two
      smaller functions, dsa_tree_teardown_switches and dsa_tree_teardown_ports.
      
      However, the error path of dsa_tree_setup stopped calling dsa_tree_teardown_ports.
      
      Fixes: a57d8c21
      
       ("net: dsa: flush switchdev workqueue before tearing down CPU/DSA ports")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e15b7001
    • Karsten Graul's avatar
      net/smc: fix 'workqueue leaked lock' in smc_conn_abort_work · 79816b22
      Karsten Graul authored
      [ Upstream commit a18cee47 ]
      
      The abort_work is scheduled when a connection was detected to be
      out-of-sync after a link failure. The work calls smc_conn_kill(),
      which calls smc_close_active_abort() and that might end up calling
      smc_close_cancel_work().
      smc_close_cancel_work() cancels any pending close_work and tx_work but
      needs to release the sock_lock before and acquires the sock_lock again
      afterwards. So when the sock_lock was NOT acquired before then it may
      be held after the abort_work completes. Thats why the sock_lock is
      acquired before the call to smc_conn_kill() in __smc_lgr_terminate(),
      but this is missing in smc_conn_abort_work().
      
      Fix that by acquiring the sock_lock first and release it after the
      call to smc_conn_kill().
      
      Fixes: b286a065
      
       ("net/smc: handle incoming CDC validation message")
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      79816b22
    • Karsten Graul's avatar
      net/smc: add missing error check in smc_clc_prfx_set() · edb96e60
      Karsten Graul authored
      [ Upstream commit 6c907319 ]
      
      Coverity stumbled over a missing error check in smc_clc_prfx_set():
      
      *** CID 1475954:  Error handling issues  (CHECKED_RETURN)
      /net/smc/smc_clc.c: 233 in smc_clc_prfx_set()
      >>>     CID 1475954:  Error handling issues  (CHECKED_RETURN)
      >>>     Calling "kernel_getsockname" without checking return value (as is done elsewhere 8 out of 10 times).
      233     	kernel_getsockname(clcsock, (struct sockaddr *)&addrs);
      
      Add the return code check in smc_clc_prfx_set().
      
      Fixes: c246d942
      
       ("net/smc: restructure netinfo for CLC proposal msgs")
      Reported-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      edb96e60