1. 20 Jun, 2020 40 commits
    • Larry Finger's avatar
      b43legacy: Fix case where channel status is corrupted · 7581e7d3
      Larry Finger authored
      commit ec4d3e3a upstream.
      
      This patch fixes commit 75388acd ("add mac80211-based driver for
      legacy BCM43xx devices")
      
      In https://bugzilla.kernel.org/show_bug.cgi?id=207093, a defect in
      b43legacy is reported. Upon testing, thus problem exists on PPC and
      X86 platforms, is present in the oldest kernel tested (3.2), and
      has been present in the driver since it was first added to the kernel.
      
      The problem is a corrupted channel status received from the device.
      Both the internal card in a PowerBook G4 and the PCMCIA version
      (Broadcom BCM4306 with PCI ID 14e4:4320) have the problem. Only Rev, 2
      (revision 4 of the 802.11 core) of the chip has been tested. No other
      devices using b43legacy are available for testing.
      
      Various sources of the problem were considered. Buffer overrun and
      other sources of corruption within the driver were rejected because
      the faulty channel status is always the same, not a random value.
      It was concluded that the faulty data is coming from the device, probably
      due to a firmware bug. As that source is not available, the driver
      must take appropriate action to recover.
      
      At present, the driver reports the error, and them continues to process
      the bad packet. This is believed that to be a mistake, and the correct
      action is to drop the correpted packet.
      
      Fixes: 75388acd ("add mac80211-based driver for legacy BCM43xx devices")
      Cc: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Reported-and-tested by: F. Erhard <erhard_f@mailbox.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200407190043.1686-1-Larry.Finger@lwfinger.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7581e7d3
    • Chuhong Yuan's avatar
      media: go7007: fix a miss of snd_card_free · 3e70f204
      Chuhong Yuan authored
      commit 9453264e upstream.
      
      go7007_snd_init() misses a snd_card_free() in an error path.
      Add the missed call to fix it.
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      [Salvatore Bonaccorso: Adjust context for backport to versions which do
      not contain c0decac1 ("media: use strscpy() instead of strlcpy()")
      and ba78170e ("media: go7007: Fix misuse of strscpy")]
      Signed-off-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e70f204
    • Christian Lamparter's avatar
      carl9170: remove P2P_GO support · bd16f8d4
      Christian Lamparter authored
      commit b14fba7e upstream.
      
      This patch follows up on a bug-report by Frank Schäfer that
      discovered P2P GO wasn't working with wpa_supplicant.
      This patch removes part of the broken P2P GO support but
      keeps the vif switchover code in place.
      
      Cc: <stable@vger.kernel.org>
      Link: <https://lkml.kernel.org/r/3a9d86b6-744f-e670-8792-9167257edef8@googlemail.com>
      Reported-by: default avatarFrank Schäfer <fschaefer.oss@googlemail.com>
      Signed-off-by: default avatarChristian Lamparter <chunkeey@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200425092811.9494-1-chunkeey@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd16f8d4
    • Punit Agrawal's avatar
      e1000e: Relax condition to trigger reset for ME workaround · 831e0636
      Punit Agrawal authored
      commit d601afca upstream.
      
      It's an error if the value of the RX/TX tail descriptor does not match
      what was written. The error condition is true regardless the duration
      of the interference from ME. But the driver only performs the reset if
      E1000_ICH_FWSM_PCIM2PCI_COUNT (2000) iterations of 50us delay have
      transpired. The extra condition can lead to inconsistency between the
      state of hardware as expected by the driver.
      
      Fix this by dropping the check for number of delay iterations.
      
      While at it, also make __ew32_prepare() static as it's not used
      anywhere else.
      
      CC: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarPunit Agrawal <punit1.agrawal@toshiba.co.jp>
      Reviewed-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      831e0636
    • Ashok Raj's avatar
      PCI: Program MPS for RCiEP devices · 08727720
      Ashok Raj authored
      commit aa0ce96d upstream.
      
      Root Complex Integrated Endpoints (RCiEPs) do not have an upstream bridge,
      so pci_configure_mps() previously ignored them, which may result in reduced
      performance.
      
      Instead, program the Max_Payload_Size of RCiEPs to the maximum supported
      value (unless it is limited for the PCIE_BUS_PEER2PEER case).  This also
      affects the subsequent programming of Max_Read_Request_Size because Linux
      programs MRRS based on the MPS value.
      
      Fixes: 9dae3a97 ("PCI: Move MPS configuration check to pci_configure_device()")
      Link: https://lore.kernel.org/r/1585343775-4019-1-git-send-email-ashok.raj@intel.comTested-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarAshok Raj <ashok.raj@intel.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08727720
    • Giuliano Procida's avatar
      blk-mq: move blk_mq_update_nr_hw_queues synchronize_rcu call · 6754baab
      Giuliano Procida authored
      This fixes the
      4.9 backport commit f530afb9
      which was
      upstream commit f5bbbbe4.
      
      The upstream commit added a call to synchronize_rcu to
      _blk_mq_update_nr_hw_queues, just after freezing queues.
      
      In the backport this landed (in blk_mq_update_nr_hw_queues instead),
      just after unfreezeing queues.
      
      This commit moves the call to its intended place.
      
      Fixes: f530afb9 ("blk-mq: sync the update nr_hw_queues with blk_mq_queue_tag_busy_iter")
      Signed-off-by: default avatarGiuliano Procida <gprocida@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6754baab
    • Omar Sandoval's avatar
      btrfs: fix error handling when submitting direct I/O bio · ed80f400
      Omar Sandoval authored
      [ Upstream commit 6d3113a1 ]
      
      In btrfs_submit_direct_hook(), if a direct I/O write doesn't span a RAID
      stripe or chunk, we submit orig_bio without cloning it. In this case, we
      don't increment pending_bios. Then, if btrfs_submit_dio_bio() fails, we
      decrement pending_bios to -1, and we never complete orig_bio. Fix it by
      initializing pending_bios to 1 instead of incrementing later.
      
      Fixing this exposes another bug: we put orig_bio prematurely and then
      put it again from end_io. Fix it by not putting orig_bio.
      
      After this change, pending_bios is really more of a reference count, but
      I'll leave that cleanup separate to keep the fix small.
      
      Fixes: e65e1535 ("btrfs: fix panic caused by direct IO")
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ed80f400
    • Eric Biggers's avatar
      ext4: fix race between ext4_sync_parent() and rename() · 86498641
      Eric Biggers authored
      commit 08adf452 upstream.
      
      'igrab(d_inode(dentry->d_parent))' without holding dentry->d_lock is
      broken because without d_lock, d_parent can be concurrently changed due
      to a rename().  Then if the old directory is immediately deleted, old
      d_parent->inode can be NULL.  That causes a NULL dereference in igrab().
      
      To fix this, use dget_parent() to safely grab a reference to the parent
      dentry, which pins the inode.  This also eliminates the need to use
      d_find_any_alias() other than for the initial inode, as we no longer
      throw away the dentry at each step.
      
      This is an extremely hard race to hit, but it is possible.  Adding a
      udelay() in between the reads of ->d_parent and its ->d_inode makes it
      reproducible on a no-journal filesystem using the following program:
      
          #include <fcntl.h>
          #include <unistd.h>
      
          int main()
          {
              if (fork()) {
                  for (;;) {
                      mkdir("dir1", 0700);
                      int fd = open("dir1/file", O_RDWR|O_CREAT|O_SYNC);
                      write(fd, "X", 1);
                      close(fd);
                  }
              } else {
                  mkdir("dir2", 0700);
                  for (;;) {
                      rename("dir1/file", "dir2/file");
                      rmdir("dir1");
                  }
              }
          }
      
      Fixes: d59729f4 ("ext4: fix races in ext4_sync_parent()")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20200506183140.541194-1-ebiggers@kernel.orgSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86498641
    • Harshad Shirwadkar's avatar
      ext4: fix EXT_MAX_EXTENT/INDEX to check for zeroed eh_max · b61a98f7
      Harshad Shirwadkar authored
      commit c36a71b4 upstream.
      
      If eh->eh_max is 0, EXT_MAX_EXTENT/INDEX would evaluate to unsigned
      (-1) resulting in illegal memory accesses. Although there is no
      consistent repro, we see that generic/019 sometimes crashes because of
      this bug.
      
      Ran gce-xfstests smoke and verified that there were no regressions.
      Signed-off-by: default avatarHarshad Shirwadkar <harshadshirwadkar@gmail.com>
      Link: https://lore.kernel.org/r/20200421023959.20879-2-harshadshirwadkar@gmail.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b61a98f7
    • Roberto Sassu's avatar
      evm: Fix possible memory leak in evm_calc_hmac_or_hash() · 4b9d238c
      Roberto Sassu authored
      commit 0c4395fb upstream.
      
      Don't immediately return if the signature is portable and security.ima is
      not present. Just set error so that memory allocated is freed before
      returning from evm_calc_hmac_or_hash().
      
      Fixes: 50b97748 ("EVM: Add support for portable signature format")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b9d238c
    • Roberto Sassu's avatar
      ima: Directly assign the ima_default_policy pointer to ima_rules · 63125a4a
      Roberto Sassu authored
      commit 067a436b upstream.
      
      This patch prevents the following oops:
      
      [   10.771813] BUG: kernel NULL pointer dereference, address: 0000000000000
      [...]
      [   10.779790] RIP: 0010:ima_match_policy+0xf7/0xb80
      [...]
      [   10.798576] Call Trace:
      [   10.798993]  ? ima_lsm_policy_change+0x2b0/0x2b0
      [   10.799753]  ? inode_init_owner+0x1a0/0x1a0
      [   10.800484]  ? _raw_spin_lock+0x7a/0xd0
      [   10.801592]  ima_must_appraise.part.0+0xb6/0xf0
      [   10.802313]  ? ima_fix_xattr.isra.0+0xd0/0xd0
      [   10.803167]  ima_must_appraise+0x4f/0x70
      [   10.804004]  ima_post_path_mknod+0x2e/0x80
      [   10.804800]  do_mknodat+0x396/0x3c0
      
      It occurs when there is a failure during IMA initialization, and
      ima_init_policy() is not called. IMA hooks still call ima_match_policy()
      but ima_rules is NULL. This patch prevents the crash by directly assigning
      the ima_default_policy pointer to ima_rules when ima_rules is defined. This
      wouldn't alter the existing behavior, as ima_rules is always set at the end
      of ima_init_policy().
      
      Cc: stable@vger.kernel.org # 3.7.x
      Fixes: 07f6a794 ("ima: add appraise action keywords and default rules")
      Reported-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63125a4a
    • Krzysztof Struczynski's avatar
      ima: Fix ima digest hash table key calculation · 446e3919
      Krzysztof Struczynski authored
      commit 1129d31b upstream.
      
      Function hash_long() accepts unsigned long, while currently only one byte
      is passed from ima_hash_key(), which calculates a key for ima_htable.
      
      Given that hashing the digest does not give clear benefits compared to
      using the digest itself, remove hash_long() and return the modulus
      calculated on the first two bytes of the digest with the number of slots.
      Also reduce the depth of the hash table by doubling the number of slots.
      
      Cc: stable@vger.kernel.org
      Fixes: 3323eec9 ("integrity: IMA as an integrity service provider")
      Co-developed-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarKrzysztof Struczynski <krzysztof.struczynski@huawei.com>
      Acked-by: David.Laight@aculab.com (big endian system concerns)
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      446e3919
    • Andrea Arcangeli's avatar
      mm: thp: make the THP mapcount atomic against __split_huge_pmd_locked() · d93d7bd6
      Andrea Arcangeli authored
      commit c444eb56 upstream.
      
      Write protect anon page faults require an accurate mapcount to decide
      if to break the COW or not. This is implemented in the THP path with
      reuse_swap_page() ->
      page_trans_huge_map_swapcount()/page_trans_huge_mapcount().
      
      If the COW triggers while the other processes sharing the page are
      under a huge pmd split, to do an accurate reading, we must ensure the
      mapcount isn't computed while it's being transferred from the head
      page to the tail pages.
      
      reuse_swap_cache() already runs serialized by the page lock, so it's
      enough to add the page lock around __split_huge_pmd_locked too, in
      order to add the missing serialization.
      
      Note: the commit in "Fixes" is just to facilitate the backporting,
      because the code before such commit didn't try to do an accurate THP
      mapcount calculation and it instead used the page_count() to decide if
      to COW or not. Both the page_count and the pin_count are THP-wide
      refcounts, so they're inaccurate if used in
      reuse_swap_page(). Reverting such commit (besides the unrelated fix to
      the local anon_vma assignment) would have also opened the window for
      memory corruption side effects to certain workloads as documented in
      such commit header.
      Signed-off-by: default avatarAndrea Arcangeli <aarcange@redhat.com>
      Suggested-by: default avatarJann Horn <jannh@google.com>
      Reported-by: default avatarJann Horn <jannh@google.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Fixes: 6d0a07ed ("mm: thp: calculate the mapcount correctly for THP pages during WP faults")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d93d7bd6
    • Marcos Paulo de Souza's avatar
      btrfs: send: emit file capabilities after chown · 9e36fae9
      Marcos Paulo de Souza authored
      commit 89efda52 upstream.
      
      Whenever a chown is executed, all capabilities of the file being touched
      are lost.  When doing incremental send with a file with capabilities,
      there is a situation where the capability can be lost on the receiving
      side. The sequence of actions bellow shows the problem:
      
        $ mount /dev/sda fs1
        $ mount /dev/sdb fs2
      
        $ touch fs1/foo.bar
        $ setcap cap_sys_nice+ep fs1/foo.bar
        $ btrfs subvolume snapshot -r fs1 fs1/snap_init
        $ btrfs send fs1/snap_init | btrfs receive fs2
      
        $ chgrp adm fs1/foo.bar
        $ setcap cap_sys_nice+ep fs1/foo.bar
      
        $ btrfs subvolume snapshot -r fs1 fs1/snap_complete
        $ btrfs subvolume snapshot -r fs1 fs1/snap_incremental
      
        $ btrfs send fs1/snap_complete | btrfs receive fs2
        $ btrfs send -p fs1/snap_init fs1/snap_incremental | btrfs receive fs2
      
      At this point, only a chown was emitted by "btrfs send" since only the
      group was changed. This makes the cap_sys_nice capability to be dropped
      from fs2/snap_incremental/foo.bar
      
      To fix that, only emit capabilities after chown is emitted. The current
      code first checks for xattrs that are new/changed, emits them, and later
      emit the chown. Now, __process_new_xattr skips capabilities, letting
      only finish_inode_if_needed to emit them, if they exist, for the inode
      being processed.
      
      This behavior was being worked around in "btrfs receive" side by caching
      the capability and only applying it after chown. Now, xattrs are only
      emmited _after_ chown, making that workaround not needed anymore.
      
      Link: https://github.com/kdave/btrfs-progs/issues/202
      CC: stable@vger.kernel.org # 4.4+
      Suggested-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarMarcos Paulo de Souza <mpdesouza@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e36fae9
    • Qiushi Wu's avatar
      cpuidle: Fix three reference count leaks · 42b548b9
      Qiushi Wu authored
      [ Upstream commit c343bf1b ]
      
      kobject_init_and_add() takes reference even when it fails.
      If this function returns an error, kobject_put() must be called to
      properly clean up the memory associated with the object.
      
      Previous commit "b8eb7183" fixed a similar problem.
      Signed-off-by: default avatarQiushi Wu <wu000273@umn.edu>
      [ rjw: Subject ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      42b548b9
    • Serge Semin's avatar
      spi: dw: Return any value retrieved from the dma_transfer callback · d6043872
      Serge Semin authored
      [ Upstream commit f0410bbf ]
      
      DW APB SSI DMA-part of the driver may need to perform the requested
      SPI-transfer synchronously. In that case the dma_transfer() callback
      will return 0 as a marker of the SPI transfer being finished so the
      SPI core doesn't need to wait and may proceed with the SPI message
      trasnfers pumping procedure. This will be needed to fix the problem
      when DMA transactions are finished, but there is still data left in
      the SPI Tx/Rx FIFOs being sent/received. But for now make dma_transfer
      to return 1 as the normal dw_spi_transfer_one() method.
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Georgy Vlasov <Georgy.Vlasov@baikalelectronics.ru>
      Cc: Ramil Zaripov <Ramil.Zaripov@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Feng Tang <feng.tang@intel.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-mips@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Link: https://lore.kernel.org/r/20200529131205.31838-3-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d6043872
    • Haibo Chen's avatar
      mmc: sdhci-esdhc-imx: fix the mask for tuning start point · 109f1be2
      Haibo Chen authored
      [ Upstream commit 1194be8c ]
      
      According the RM, the bit[6~0] of register ESDHC_TUNING_CTRL is
      TUNING_START_TAP, bit[7] of this register is to disable the command
      CRC check for standard tuning. So fix it here.
      
      Fixes: d87fc966 ("mmc: sdhci-esdhc-imx: support setting tuning start point")
      Signed-off-by: default avatarHaibo Chen <haibo.chen@nxp.com>
      Link: https://lore.kernel.org/r/1590488522-9292-1-git-send-email-haibo.chen@nxp.comSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      109f1be2
    • Xie XiuQi's avatar
      ixgbe: fix signed-integer-overflow warning · 74b775b3
      Xie XiuQi authored
      [ Upstream commit 3b70683f ]
      
      ubsan report this warning, fix it by adding a unsigned suffix.
      
      UBSAN: signed-integer-overflow in
      drivers/net/ethernet/intel/ixgbe/ixgbe_common.c:2246:26
      65535 * 65537 cannot be represented in type 'int'
      CPU: 21 PID: 7 Comm: kworker/u256:0 Not tainted 5.7.0-rc3-debug+ #39
      Hardware name: Huawei TaiShan 2280 V2/BC82AMDC, BIOS 2280-V2 03/27/2020
      Workqueue: ixgbe ixgbe_service_task [ixgbe]
      Call trace:
       dump_backtrace+0x0/0x3f0
       show_stack+0x28/0x38
       dump_stack+0x154/0x1e4
       ubsan_epilogue+0x18/0x60
       handle_overflow+0xf8/0x148
       __ubsan_handle_mul_overflow+0x34/0x48
       ixgbe_fc_enable_generic+0x4d0/0x590 [ixgbe]
       ixgbe_service_task+0xc20/0x1f78 [ixgbe]
       process_one_work+0x8f0/0xf18
       worker_thread+0x430/0x6d0
       kthread+0x218/0x238
       ret_from_fork+0x10/0x18
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74b775b3
    • Ulf Hansson's avatar
      staging: greybus: sdio: Respect the cmd->busy_timeout from the mmc core · bf143873
      Ulf Hansson authored
      [ Upstream commit a389087e ]
      
      Using a fixed 1s timeout for all commands is a bit problematic.
      
      For some commands it means waiting longer than needed for the timeout to
      expire, which may not a big issue, but still. For other commands, like for
      an erase (CMD38) that uses a R1B response, may require longer timeouts than
      1s. In these cases, we may end up treating the command as it failed, while
      it just needed some more time to complete successfully.
      
      Fix the problem by respecting the cmd->busy_timeout, which is provided by
      the mmc core.
      
      Cc: Rui Miguel Silva <rmfrfs@gmail.com>
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Alex Elder <elder@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: greybus-dev@lists.linaro.org
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Link: https://lore.kernel.org/r/20200414161413.3036-20-ulf.hansson@linaro.orgSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bf143873
    • YuanJunQing's avatar
      MIPS: Fix IRQ tracing when call handle_fpe() and handle_msa_fpe() · cf4c788e
      YuanJunQing authored
      [ Upstream commit 31e1b3ef ]
      
      Register "a1" is unsaved in this function,
       when CONFIG_TRACE_IRQFLAGS is enabled,
       the TRACE_IRQS_OFF macro will call trace_hardirqs_off(),
       and this may change register "a1".
       The changed register "a1" as argument will be send
       to do_fpe() and do_msa_fpe().
      Signed-off-by: default avatarYuanJunQing <yuanjunqing66@163.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cf4c788e
    • Jiaxun Yang's avatar
      PCI: Don't disable decoding when mmio_always_on is set · 97aad0ad
      Jiaxun Yang authored
      [ Upstream commit b6caa1d8 ]
      
      Don't disable MEM/IO decoding when a device have both non_compliant_bars
      and mmio_always_on.
      
      That would allow us quirk devices with junk in BARs but can't disable
      their decoding.
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Acked-by: default avatarBjorn Helgaas <helgaas@kernel.org>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97aad0ad
    • Alexander Sverdlin's avatar
      macvlan: Skip loopback packets in RX handler · 9c8ca9ee
      Alexander Sverdlin authored
      [ Upstream commit 81f3dc93 ]
      
      Ignore loopback-originatig packets soon enough and don't try to process L2
      header where it doesn't exist. The very similar br_handle_frame() in bridge
      code performs exactly the same check.
      
      This is an example of such ICMPv6 packet:
      
      skb len=96 headroom=40 headlen=96 tailroom=56
      mac=(40,0) net=(40,40) trans=80
      shinfo(txflags=0 nr_frags=0 gso(size=0 type=0 segs=0))
      csum(0xae2e9a2f ip_summed=1 complete_sw=0 valid=0 level=0)
      hash(0xc97ebd88 sw=1 l4=1) proto=0x86dd pkttype=5 iif=24
      dev name=etha01.212 feat=0x0x0000000040005000
      skb headroom: 00000000: 00 7c 86 52 84 88 ff ff 00 00 00 00 00 00 08 00
      skb headroom: 00000010: 45 00 00 9e 5d 5c 40 00 40 11 33 33 00 00 00 01
      skb headroom: 00000020: 02 40 43 80 00 00 86 dd
      skb linear:   00000000: 60 09 88 bd 00 38 3a ff fe 80 00 00 00 00 00 00
      skb linear:   00000010: 00 40 43 ff fe 80 00 00 ff 02 00 00 00 00 00 00
      skb linear:   00000020: 00 00 00 00 00 00 00 01 86 00 61 00 40 00 00 2d
      skb linear:   00000030: 00 00 00 00 00 00 00 00 03 04 40 e0 00 00 01 2c
      skb linear:   00000040: 00 00 00 78 00 00 00 00 fd 5f 42 68 23 87 a8 81
      skb linear:   00000050: 00 00 00 00 00 00 00 00 01 01 02 40 43 80 00 00
      skb tailroom: 00000000: ...
      skb tailroom: 00000010: ...
      skb tailroom: 00000020: ...
      skb tailroom: 00000030: ...
      
      Call Trace, how it happens exactly:
       ...
       macvlan_handle_frame+0x321/0x425 [macvlan]
       ? macvlan_forward_source+0x110/0x110 [macvlan]
       __netif_receive_skb_core+0x545/0xda0
       ? enqueue_task_fair+0xe5/0x8e0
       ? __netif_receive_skb_one_core+0x36/0x70
       __netif_receive_skb_one_core+0x36/0x70
       process_backlog+0x97/0x140
       net_rx_action+0x1eb/0x350
       ? __hrtimer_run_queues+0x136/0x2e0
       __do_softirq+0xe3/0x383
       do_softirq_own_stack+0x2a/0x40
       </IRQ>
       do_softirq.part.4+0x4e/0x50
       netif_rx_ni+0x60/0xd0
       dev_loopback_xmit+0x83/0xf0
       ip6_finish_output2+0x575/0x590 [ipv6]
       ? ip6_cork_release.isra.1+0x64/0x90 [ipv6]
       ? __ip6_make_skb+0x38d/0x680 [ipv6]
       ? ip6_output+0x6c/0x140 [ipv6]
       ip6_output+0x6c/0x140 [ipv6]
       ip6_send_skb+0x1e/0x60 [ipv6]
       rawv6_sendmsg+0xc4b/0xe10 [ipv6]
       ? proc_put_long+0xd0/0xd0
       ? rw_copy_check_uvector+0x4e/0x110
       ? sock_sendmsg+0x36/0x40
       sock_sendmsg+0x36/0x40
       ___sys_sendmsg+0x2b6/0x2d0
       ? proc_dointvec+0x23/0x30
       ? addrconf_sysctl_forward+0x8d/0x250 [ipv6]
       ? dev_forward_change+0x130/0x130 [ipv6]
       ? _raw_spin_unlock+0x12/0x30
       ? proc_sys_call_handler.isra.14+0x9f/0x110
       ? __call_rcu+0x213/0x510
       ? get_max_files+0x10/0x10
       ? trace_hardirqs_on+0x2c/0xe0
       ? __sys_sendmsg+0x63/0xa0
       __sys_sendmsg+0x63/0xa0
       do_syscall_64+0x6c/0x1e0
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      Signed-off-by: default avatarAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9c8ca9ee
    • Finn Thain's avatar
      m68k: mac: Don't call via_flush_cache() on Mac IIfx · 04c01ac2
      Finn Thain authored
      [ Upstream commit bcc44f6b ]
      
      There is no VIA2 chip on the Mac IIfx, so don't call via_flush_cache().
      This avoids a boot crash which appeared in v5.4.
      
      printk: console [ttyS0] enabled
      printk: bootconsole [debug0] disabled
      printk: bootconsole [debug0] disabled
      Calibrating delay loop... 9.61 BogoMIPS (lpj=48064)
      pid_max: default: 32768 minimum: 301
      Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
      Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
      devtmpfs: initialized
      random: get_random_u32 called from bucket_table_alloc.isra.27+0x68/0x194 with crng_init=0
      clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
      futex hash table entries: 256 (order: -1, 3072 bytes, linear)
      NET: Registered protocol family 16
      Data read fault at 0x00000000 in Super Data (pc=0x8a6a)
      BAD KERNEL BUSERR
      Oops: 00000000
      Modules linked in:
      PC: [<00008a6a>] via_flush_cache+0x12/0x2c
      SR: 2700  SP: 01c1fe3c  a2: 01c24000
      d0: 00001119    d1: 0000000c    d2: 00012000    d3: 0000000f
      d4: 01c06840    d5: 00033b92    a0: 00000000    a1: 00000000
      Process swapper (pid: 1, task=01c24000)
      Frame format=B ssw=0755 isc=0200 isb=fff7 daddr=00000000 dobuf=01c1fed0
      baddr=00008a6e dibuf=0000004e ver=f
      Stack from 01c1fec4:
              01c1fed0 00007d7e 00010080 01c1fedc 0000792e 00000001 01c1fef4 00006b40
              01c80000 00040000 00000006 00000003 01c1ff1c 004a545e 004ff200 00040000
              00000000 00000003 01c06840 00033b92 004a5410 004b6c88 01c1ff84 000021e2
              00000073 00000003 01c06840 00033b92 0038507a 004bb094 004b6ca8 004b6c88
              004b6ca4 004b6c88 000021ae 00020002 00000000 01c0685d 00000000 01c1ffb4
              0049f938 00409c85 01c06840 0045bd40 00000073 00000002 00000002 00000000
      Call Trace: [<00007d7e>] mac_cache_card_flush+0x12/0x1c
       [<00010080>] fix_dnrm+0x2/0x18
       [<0000792e>] cache_push+0x46/0x5a
       [<00006b40>] arch_dma_prep_coherent+0x60/0x6e
       [<00040000>] switched_to_dl+0x76/0xd0
       [<004a545e>] dma_atomic_pool_init+0x4e/0x188
       [<00040000>] switched_to_dl+0x76/0xd0
       [<00033b92>] parse_args+0x0/0x370
       [<004a5410>] dma_atomic_pool_init+0x0/0x188
       [<000021e2>] do_one_initcall+0x34/0x1be
       [<00033b92>] parse_args+0x0/0x370
       [<0038507a>] strcpy+0x0/0x1e
       [<000021ae>] do_one_initcall+0x0/0x1be
       [<00020002>] do_proc_dointvec_conv+0x54/0x74
       [<0049f938>] kernel_init_freeable+0x126/0x190
       [<0049f94c>] kernel_init_freeable+0x13a/0x190
       [<004a5410>] dma_atomic_pool_init+0x0/0x188
       [<00041798>] complete+0x0/0x3c
       [<000b9b0c>] kfree+0x0/0x20a
       [<0038df98>] schedule+0x0/0xd0
       [<0038d604>] kernel_init+0x0/0xda
       [<0038d610>] kernel_init+0xc/0xda
       [<0038d604>] kernel_init+0x0/0xda
       [<00002d38>] ret_from_kernel_thread+0xc/0x14
      Code: 0000 2079 0048 10da 2279 0048 10c8 d3c8 <1011> 0200 fff7 1280 d1f9 0048 10c8 1010 0000 0008 1080 4e5e 4e75 4e56 0000 2039
      Disabling lock debugging due to kernel taint
      Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
      
      Thanks to Stan Johnson for capturing the console log and running git
      bisect.
      
      Git bisect said commit 8e3a68fb ("dma-mapping: make
      dma_atomic_pool_init self-contained") is the first "bad" commit. I don't
      know why. Perhaps mach_l2_flush first became reachable with that commit.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-and-tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Cc: Joshua Thompson <funaho@jurai.org>
      Link: https://lore.kernel.org/r/b8bbeef197d6b3898e82ed0d231ad08f575a4b34.1589949122.git.fthain@telegraphics.com.auSigned-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04c01ac2
    • Arvind Sankar's avatar
      x86/mm: Stop printing BRK addresses · eeb233a0
      Arvind Sankar authored
      [ Upstream commit 67d631b7 ]
      
      This currently leaks kernel physical addresses into userspace.
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarDave Hansen <dave.hansen@intel.com>
      Link: https://lkml.kernel.org/r/20200229231120.1147527-1-nivedita@alum.mit.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      eeb233a0
    • Serge Semin's avatar
      mips: Add udelay lpj numbers adjustment · b935463d
      Serge Semin authored
      [ Upstream commit ed26aacf ]
      
      Loops-per-jiffies is a special number which represents a number of
      noop-loop cycles per CPU-scheduler quantum - jiffies. As you
      understand aside from CPU-specific implementation it depends on
      the CPU frequency. So when a platform has the CPU frequency fixed,
      we have no problem and the current udelay interface will work
      just fine. But as soon as CPU-freq driver is enabled and the cores
      frequency changes, we'll end up with distorted udelay's. In order
      to fix this we have to accordinly adjust the per-CPU udelay_val
      (the same as the global loops_per_jiffy) number. This can be done
      in the CPU-freq transition event handler. We subscribe to that event
      in the MIPS arch time-inititalization method.
      Co-developed-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarAlexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Reviewed-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b935463d
    • Arvind Sankar's avatar
      x86/boot: Correct relocation destination on old linkers · 93b6bebe
      Arvind Sankar authored
      [ Upstream commit 5214028d ]
      
      For the 32-bit kernel, as described in
      
        6d92bc9d ("x86/build: Build compressed x86 kernels as PIE"),
      
      pre-2.26 binutils generates R_386_32 relocations in PIE mode. Since the
      startup code does not perform relocation, any reloc entry with R_386_32
      will remain as 0 in the executing code.
      
      Commit
      
        974f221c ("x86/boot: Move compressed kernel to the end of the
                       decompression buffer")
      
      added a new symbol _end but did not mark it hidden, which doesn't give
      the correct offset on older linkers. This causes the compressed kernel
      to be copied beyond the end of the decompression buffer, rather than
      flush against it. This region of memory may be reserved or already
      allocated for other purposes by the bootloader.
      
      Mark _end as hidden to fix. This changes the relocation from R_386_32 to
      R_386_RELATIVE even on the pre-2.26 binutils.
      
      For 64-bit, this is not strictly necessary, as the 64-bit kernel is only
      built as PIE if the linker supports -z noreloc-overflow, which implies
      binutils-2.27+, but for consistency, mark _end as hidden here too.
      
      The below illustrates the before/after impact of the patch using
      binutils-2.25 and gcc-4.6.4 (locally compiled from source) and QEMU.
      
        Disassembly before patch:
          48:   8b 86 60 02 00 00       mov    0x260(%esi),%eax
          4e:   2d 00 00 00 00          sub    $0x0,%eax
                                4f: R_386_32    _end
        Disassembly after patch:
          48:   8b 86 60 02 00 00       mov    0x260(%esi),%eax
          4e:   2d 00 f0 76 00          sub    $0x76f000,%eax
                                4f: R_386_RELATIVE      *ABS*
      
      Dump from extract_kernel before patch:
      	early console in extract_kernel
      	input_data: 0x0207c098 <--- this is at output + init_size
      	input_len: 0x0074fef1
      	output: 0x01000000
      	output_len: 0x00fa63d0
      	kernel_total_size: 0x0107c000
      	needed_size: 0x0107c000
      
      Dump from extract_kernel after patch:
      	early console in extract_kernel
      	input_data: 0x0190d098 <--- this is at output + init_size - _end
      	input_len: 0x0074fef1
      	output: 0x01000000
      	output_len: 0x00fa63d0
      	kernel_total_size: 0x0107c000
      	needed_size: 0x0107c000
      
      Fixes: 974f221c ("x86/boot: Move compressed kernel to the end of the decompression buffer")
      Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://lkml.kernel.org/r/20200207214926.3564079-1-nivedita@alum.mit.eduSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      93b6bebe
    • Pali Rohár's avatar
      mwifiex: Fix memory corruption in dump_station · 33c2268e
      Pali Rohár authored
      [ Upstream commit 3aa42bae ]
      
      The mwifiex_cfg80211_dump_station() uses static variable for iterating
      over a linked list of all associated stations (when the driver is in UAP
      role). This has a race condition if .dump_station is called in parallel
      for multiple interfaces. This corruption can be triggered by registering
      multiple SSIDs and calling, in parallel for multiple interfaces
          iw dev <iface> station dump
      
      [16750.719775] Unable to handle kernel paging request at virtual address dead000000000110
      ...
      [16750.899173] Call trace:
      [16750.901696]  mwifiex_cfg80211_dump_station+0x94/0x100 [mwifiex]
      [16750.907824]  nl80211_dump_station+0xbc/0x278 [cfg80211]
      [16750.913160]  netlink_dump+0xe8/0x320
      [16750.916827]  netlink_recvmsg+0x1b4/0x338
      [16750.920861]  ____sys_recvmsg+0x7c/0x2b0
      [16750.924801]  ___sys_recvmsg+0x70/0x98
      [16750.928564]  __sys_recvmsg+0x58/0xa0
      [16750.932238]  __arm64_sys_recvmsg+0x28/0x30
      [16750.936453]  el0_svc_common.constprop.3+0x90/0x158
      [16750.941378]  do_el0_svc+0x74/0x90
      [16750.944784]  el0_sync_handler+0x12c/0x1a8
      [16750.948903]  el0_sync+0x114/0x140
      [16750.952312] Code: f9400003 f907f423 eb02007f 54fffd60 (b9401060)
      [16750.958583] ---[ end trace c8ad181c2f4b8576 ]---
      
      This patch drops the use of the static iterator, and instead every time
      the function is called iterates to the idx-th position of the
      linked-list.
      
      It would be better to convert the code not to use linked list for
      associated stations storage (since the chip has a limited number of
      associated stations anyway - it could just be an array). Such a change
      may be proposed in the future. In the meantime this patch can backported
      into stable kernels in this simple form.
      
      Fixes: 8baca1a3 ("mwifiex: dump station support in uap mode")
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Acked-by: default avatarGanapathi Bhat <ganapathi.bhat@nxp.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200515075924.13841-1-pali@kernel.orgSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      33c2268e
    • Dan Carpenter's avatar
      rtlwifi: Fix a double free in _rtl_usb_tx_urb_setup() · 5f78833e
      Dan Carpenter authored
      [ Upstream commit beb12813 ]
      
      Seven years ago we tried to fix a leak but actually introduced a double
      free instead.  It was an understandable mistake because the code was a
      bit confusing and the free was done in the wrong place.  The "skb"
      pointer is freed in both _rtl_usb_tx_urb_setup() and _rtl_usb_transmit().
      The free belongs _rtl_usb_transmit() instead of _rtl_usb_tx_urb_setup()
      and I've cleaned the code up a bit to hopefully make it more clear.
      
      Fixes: 36ef0b47 ("rtlwifi: usb: add missing freeing of skbuff")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/20200513093951.GD347693@mwandaSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f78833e
    • Guoqing Jiang's avatar
      md: don't flush workqueue unconditionally in md_open · 9e9b57c4
      Guoqing Jiang authored
      [ Upstream commit f6766ff6 ]
      
      We need to check mddev->del_work before flush workqueu since the purpose
      of flush is to ensure the previous md is disappeared. Otherwise the similar
      deadlock appeared if LOCKDEP is enabled, it is due to md_open holds the
      bdev->bd_mutex before flush workqueue.
      
      kernel: [  154.522645] ======================================================
      kernel: [  154.522647] WARNING: possible circular locking dependency detected
      kernel: [  154.522650] 5.6.0-rc7-lp151.27-default #25 Tainted: G           O
      kernel: [  154.522651] ------------------------------------------------------
      kernel: [  154.522653] mdadm/2482 is trying to acquire lock:
      kernel: [  154.522655] ffff888078529128 ((wq_completion)md_misc){+.+.}, at: flush_workqueue+0x84/0x4b0
      kernel: [  154.522673]
      kernel: [  154.522673] but task is already holding lock:
      kernel: [  154.522675] ffff88804efa9338 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x79/0x590
      kernel: [  154.522691]
      kernel: [  154.522691] which lock already depends on the new lock.
      kernel: [  154.522691]
      kernel: [  154.522694]
      kernel: [  154.522694] the existing dependency chain (in reverse order) is:
      kernel: [  154.522696]
      kernel: [  154.522696] -> #4 (&bdev->bd_mutex){+.+.}:
      kernel: [  154.522704]        __mutex_lock+0x87/0x950
      kernel: [  154.522706]        __blkdev_get+0x79/0x590
      kernel: [  154.522708]        blkdev_get+0x65/0x140
      kernel: [  154.522709]        blkdev_get_by_dev+0x2f/0x40
      kernel: [  154.522716]        lock_rdev+0x3d/0x90 [md_mod]
      kernel: [  154.522719]        md_import_device+0xd6/0x1b0 [md_mod]
      kernel: [  154.522723]        new_dev_store+0x15e/0x210 [md_mod]
      kernel: [  154.522728]        md_attr_store+0x7a/0xc0 [md_mod]
      kernel: [  154.522732]        kernfs_fop_write+0x117/0x1b0
      kernel: [  154.522735]        vfs_write+0xad/0x1a0
      kernel: [  154.522737]        ksys_write+0xa4/0xe0
      kernel: [  154.522745]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522748]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522749]
      kernel: [  154.522749] -> #3 (&mddev->reconfig_mutex){+.+.}:
      kernel: [  154.522752]        __mutex_lock+0x87/0x950
      kernel: [  154.522756]        new_dev_store+0xc9/0x210 [md_mod]
      kernel: [  154.522759]        md_attr_store+0x7a/0xc0 [md_mod]
      kernel: [  154.522761]        kernfs_fop_write+0x117/0x1b0
      kernel: [  154.522763]        vfs_write+0xad/0x1a0
      kernel: [  154.522765]        ksys_write+0xa4/0xe0
      kernel: [  154.522767]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522769]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522770]
      kernel: [  154.522770] -> #2 (kn->count#253){++++}:
      kernel: [  154.522775]        __kernfs_remove+0x253/0x2c0
      kernel: [  154.522778]        kernfs_remove+0x1f/0x30
      kernel: [  154.522780]        kobject_del+0x28/0x60
      kernel: [  154.522783]        mddev_delayed_delete+0x24/0x30 [md_mod]
      kernel: [  154.522786]        process_one_work+0x2a7/0x5f0
      kernel: [  154.522788]        worker_thread+0x2d/0x3d0
      kernel: [  154.522793]        kthread+0x117/0x130
      kernel: [  154.522795]        ret_from_fork+0x3a/0x50
      kernel: [  154.522796]
      kernel: [  154.522796] -> #1 ((work_completion)(&mddev->del_work)){+.+.}:
      kernel: [  154.522800]        process_one_work+0x27e/0x5f0
      kernel: [  154.522802]        worker_thread+0x2d/0x3d0
      kernel: [  154.522804]        kthread+0x117/0x130
      kernel: [  154.522806]        ret_from_fork+0x3a/0x50
      kernel: [  154.522807]
      kernel: [  154.522807] -> #0 ((wq_completion)md_misc){+.+.}:
      kernel: [  154.522813]        __lock_acquire+0x1392/0x1690
      kernel: [  154.522816]        lock_acquire+0xb4/0x1a0
      kernel: [  154.522818]        flush_workqueue+0xab/0x4b0
      kernel: [  154.522821]        md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522823]        __blkdev_get+0xea/0x590
      kernel: [  154.522825]        blkdev_get+0x65/0x140
      kernel: [  154.522828]        do_dentry_open+0x1d1/0x380
      kernel: [  154.522831]        path_openat+0x567/0xcc0
      kernel: [  154.522834]        do_filp_open+0x9b/0x110
      kernel: [  154.522836]        do_sys_openat2+0x201/0x2a0
      kernel: [  154.522838]        do_sys_open+0x57/0x80
      kernel: [  154.522840]        do_syscall_64+0x64/0x2b0
      kernel: [  154.522842]        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522844]
      kernel: [  154.522844] other info that might help us debug this:
      kernel: [  154.522844]
      kernel: [  154.522846] Chain exists of:
      kernel: [  154.522846]   (wq_completion)md_misc --> &mddev->reconfig_mutex --> &bdev->bd_mutex
      kernel: [  154.522846]
      kernel: [  154.522850]  Possible unsafe locking scenario:
      kernel: [  154.522850]
      kernel: [  154.522852]        CPU0                    CPU1
      kernel: [  154.522853]        ----                    ----
      kernel: [  154.522854]   lock(&bdev->bd_mutex);
      kernel: [  154.522856]                                lock(&mddev->reconfig_mutex);
      kernel: [  154.522858]                                lock(&bdev->bd_mutex);
      kernel: [  154.522860]   lock((wq_completion)md_misc);
      kernel: [  154.522861]
      kernel: [  154.522861]  *** DEADLOCK ***
      kernel: [  154.522861]
      kernel: [  154.522864] 1 lock held by mdadm/2482:
      kernel: [  154.522865]  #0: ffff88804efa9338 (&bdev->bd_mutex){+.+.}, at: __blkdev_get+0x79/0x590
      kernel: [  154.522868]
      kernel: [  154.522868] stack backtrace:
      kernel: [  154.522873] CPU: 1 PID: 2482 Comm: mdadm Tainted: G           O      5.6.0-rc7-lp151.27-default #25
      kernel: [  154.522875] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
      kernel: [  154.522878] Call Trace:
      kernel: [  154.522881]  dump_stack+0x8f/0xcb
      kernel: [  154.522884]  check_noncircular+0x194/0x1b0
      kernel: [  154.522888]  ? __lock_acquire+0x1392/0x1690
      kernel: [  154.522890]  __lock_acquire+0x1392/0x1690
      kernel: [  154.522893]  lock_acquire+0xb4/0x1a0
      kernel: [  154.522895]  ? flush_workqueue+0x84/0x4b0
      kernel: [  154.522898]  flush_workqueue+0xab/0x4b0
      kernel: [  154.522900]  ? flush_workqueue+0x84/0x4b0
      kernel: [  154.522905]  ? md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522908]  md_open+0xb6/0xc0 [md_mod]
      kernel: [  154.522910]  __blkdev_get+0xea/0x590
      kernel: [  154.522912]  ? bd_acquire+0xc0/0xc0
      kernel: [  154.522914]  blkdev_get+0x65/0x140
      kernel: [  154.522916]  ? bd_acquire+0xc0/0xc0
      kernel: [  154.522918]  do_dentry_open+0x1d1/0x380
      kernel: [  154.522921]  path_openat+0x567/0xcc0
      kernel: [  154.522923]  ? __lock_acquire+0x380/0x1690
      kernel: [  154.522926]  do_filp_open+0x9b/0x110
      kernel: [  154.522929]  ? __alloc_fd+0xe5/0x1f0
      kernel: [  154.522935]  ? kmem_cache_alloc+0x28c/0x630
      kernel: [  154.522939]  ? do_sys_openat2+0x201/0x2a0
      kernel: [  154.522941]  do_sys_openat2+0x201/0x2a0
      kernel: [  154.522944]  do_sys_open+0x57/0x80
      kernel: [  154.522946]  do_syscall_64+0x64/0x2b0
      kernel: [  154.522948]  entry_SYSCALL_64_after_hwframe+0x49/0xbe
      kernel: [  154.522951] RIP: 0033:0x7f98d279d9ae
      
      And md_alloc also flushed the same workqueue, but the thing is different
      here. Because all the paths call md_alloc don't hold bdev->bd_mutex, and
      the flush is necessary to avoid race condition, so leave it as it is.
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9e9b57c4
    • Daniel Thompson's avatar
      kgdb: Fix spurious true from in_dbg_master() · fb228bf2
      Daniel Thompson authored
      [ Upstream commit 3fec4aec ]
      
      Currently there is a small window where a badly timed migration could
      cause in_dbg_master() to spuriously return true. Specifically if we
      migrate to a new core after reading the processor id and the previous
      core takes a breakpoint then we will evaluate true if we read
      kgdb_active before we get the IPI to bring us to halt.
      
      Fix this by checking irqs_disabled() first. Interrupts are always
      disabled when we are executing the kgdb trap so this is an acceptable
      prerequisite. This also allows us to replace raw_smp_processor_id()
      with smp_processor_id() since the short circuit logic will prevent
      warnings from PREEMPT_DEBUG.
      
      Fixes: dcc78711 ("kgdb: core changes to support kdb")
      Suggested-by: default avatarWill Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20200506164223.2875760-1-daniel.thompson@linaro.orgReviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb228bf2
    • Serge Semin's avatar
      mips: cm: Fix an invalid error code of INTVN_*_ERR · bb3bcde1
      Serge Semin authored
      [ Upstream commit 8a0efb8b ]
      
      Commit 3885c2b4 ("MIPS: CM: Add support for reporting CM cache
      errors") adds cm2_causes[] array with map of error type ID and
      pointers to the short description string. There is a mistake in
      the table, since according to MIPS32 manual CM2_ERROR_TYPE = {17,18}
      correspond to INTVN_WR_ERR and INTVN_RD_ERR, while the table
      claims they have {0x17,0x18} codes. This is obviously hex-dec
      copy-paste bug. Moreover codes {0x18 - 0x1a} indicate L2 ECC errors.
      
      Fixes: 3885c2b4 ("MIPS: CM: Add support for reporting CM cache errors")
      Signed-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
      Cc: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Paul Burton <paulburton@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: linux-pm@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb3bcde1
    • Jiaxun Yang's avatar
      MIPS: Truncate link address into 32bit for 32bit kernel · 8b01fb17
      Jiaxun Yang authored
      [ Upstream commit ff487d41 ]
      
      LLD failed to link vmlinux with 64bit load address for 32bit ELF
      while bfd will strip 64bit address into 32bit silently.
      To fix LLD build, we should truncate load address provided by platform
      into 32bit for 32bit kernel.
      Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
      Link: https://github.com/ClangBuiltLinux/linux/issues/786
      Link: https://sourceware.org/bugzilla/show_bug.cgi?id=25784Reviewed-by: default avatarFangrui Song <maskray@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Tested-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Cc: Maciej W. Rozycki <macro@linux-mips.org>
      Tested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b01fb17
    • Jeremy Kerr's avatar
      powerpc/spufs: fix copy_to_user while atomic · 123a8d0b
      Jeremy Kerr authored
      [ Upstream commit 88413a6b ]
      
      Currently, we may perform a copy_to_user (through
      simple_read_from_buffer()) while holding a context's register_lock,
      while accessing the context save area.
      
      This change uses a temporary buffer for the context save area data,
      which we then pass to simple_read_from_buffer.
      
      Includes changes from Christoph Hellwig <hch@lst.de>.
      
      Fixes: bf1ab978 ("[POWERPC] coredump: Add SPU elf notes to coredump.")
      Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      [hch: renamed to function to avoid ___-prefixes]
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      123a8d0b
    • Yunjian Wang's avatar
      net: allwinner: Fix use correct return type for ndo_start_xmit() · 720b4f27
      Yunjian Wang authored
      [ Upstream commit 09f6c44a ]
      
      The method ndo_start_xmit() returns a value of type netdev_tx_t. Fix
      the ndo function to use the correct type. And emac_start_xmit() can
      leak one skb if 'channel' == 3.
      Signed-off-by: default avatarYunjian Wang <wangyunjian@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      720b4f27
    • Wei Yongjun's avatar
      net: lpc-enet: fix error return code in lpc_mii_init() · e6eadb14
      Wei Yongjun authored
      [ Upstream commit 88ec7cb2 ]
      
      Fix to return a negative error code from the error handling
      case instead of 0, as done elsewhere in this function.
      
      Fixes: b7370112 ("lpc32xx: Added ethernet driver")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Acked-by: default avatarVladimir Zapolskiy <vz@mleia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6eadb14
    • Jann Horn's avatar
      exit: Move preemption fixup up, move blocking operations down · 1e587ce7
      Jann Horn authored
      [ Upstream commit 586b58ca ]
      
      With CONFIG_DEBUG_ATOMIC_SLEEP=y and CONFIG_CGROUPS=y, kernel oopses in
      non-preemptible context look untidy; after the main oops, the kernel prints
      a "sleeping function called from invalid context" report because
      exit_signals() -> cgroup_threadgroup_change_begin() -> percpu_down_read()
      can sleep, and that happens before the preempt_count_set(PREEMPT_ENABLED)
      fixup.
      
      It looks like the same thing applies to profile_task_exit() and
      kcov_task_exit().
      
      Fix it by moving the preemption fixup up and the calls to
      profile_task_exit() and kcov_task_exit() down.
      
      Fixes: 1dc0fffc ("sched/core: Robustify preemption leak checks")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200305220657.46800-1-jannh@google.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e587ce7
    • Nathan Chancellor's avatar
      lib/mpi: Fix 64-bit MIPS build with Clang · ed3cbbfe
      Nathan Chancellor authored
      [ Upstream commit 18f1ca46 ]
      
      When building 64r6_defconfig with CONFIG_MIPS32_O32 disabled and
      CONFIG_CRYPTO_RSA enabled:
      
      lib/mpi/generic_mpih-mul1.c:37:24: error: invalid use of a cast in a
      inline asm context requiring an l-value: remove the cast
      or build with -fheinous-gnu-extensions
                      umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      lib/mpi/longlong.h:664:22: note: expanded from macro 'umul_ppmm'
                       : "=d" ((UDItype)(w0))
                               ~~~~~~~~~~^~~
      lib/mpi/generic_mpih-mul1.c:37:13: error: invalid use of a cast in a
      inline asm context requiring an l-value: remove the cast
      or build with -fheinous-gnu-extensions
                      umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb);
                      ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      lib/mpi/longlong.h:668:22: note: expanded from macro 'umul_ppmm'
                       : "=d" ((UDItype)(w1))
                               ~~~~~~~~~~^~~
      2 errors generated.
      
      This special case for umul_ppmm for MIPS64r6 was added in
      commit bbc25bee ("lib/mpi: Fix umul_ppmm() for MIPS64r6"), due to
      GCC being inefficient and emitting a __multi3 intrinsic.
      
      There is no such issue with clang; with this patch applied, I can build
      this configuration without any problems and there are no link errors
      like mentioned in the commit above (which I can still reproduce with
      GCC 9.3.0 when that commit is reverted). Only use this definition when
      GCC is being used.
      
      This really should have been caught by commit b0c091ae ("lib/mpi:
      Eliminate unused umul_ppmm definitions for MIPS") when I was messing
      around in this area but I was not testing 64-bit MIPS at the time.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/885Reported-by: default avatarDmitry Golovin <dima@golovin.in>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ed3cbbfe
    • Pablo Neira Ayuso's avatar
      netfilter: nft_nat: return EOPNOTSUPP if type or flags are not supported · fbe0bd6f
      Pablo Neira Ayuso authored
      [ Upstream commit 0d7c8346 ]
      
      Instead of EINVAL which should be used for malformed netlink messages.
      
      Fixes: eb31628e ("netfilter: nf_tables: Add support for IPv6 NAT")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fbe0bd6f
    • Tiezhu Yang's avatar
      MIPS: Make sparse_init() using top-down allocation · 6ff43399
      Tiezhu Yang authored
      [ Upstream commit 269b3a9a ]
      
      In the current code, if CONFIG_SWIOTLB is set, when failed to get IO TLB
      memory from the low pages by plat_swiotlb_setup(), it may lead to the boot
      process failed with kernel panic.
      
      (1) On the Loongson and SiByte platform
      arch/mips/loongson64/dma.c
      arch/mips/sibyte/common/dma.c
      void __init plat_swiotlb_setup(void)
      {
      	swiotlb_init(1);
      }
      
      kernel/dma/swiotlb.c
      void  __init
      swiotlb_init(int verbose)
      {
      ...
      	vstart = memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE);
      	if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
      		return;
      ...
      	pr_warn("Cannot allocate buffer");
      	no_iotlb_memory = true;
      }
      
      phys_addr_t swiotlb_tbl_map_single()
      {
      ...
      	if (no_iotlb_memory)
      		panic("Can not allocate SWIOTLB buffer earlier ...");
      ...
      }
      
      (2) On the Cavium OCTEON platform
      arch/mips/cavium-octeon/dma-octeon.c
      void __init plat_swiotlb_setup(void)
      {
      ...
      	octeon_swiotlb = memblock_alloc_low(swiotlbsize, PAGE_SIZE);
      	if (!octeon_swiotlb)
      		panic("%s: Failed to allocate %zu bytes align=%lx\n",
      		      __func__, swiotlbsize, PAGE_SIZE);
      ...
      }
      
      Because IO_TLB_DEFAULT_SIZE is 64M, if the rest size of low memory is less
      than 64M when call plat_swiotlb_setup(), we can easily reproduce the panic
      case.
      
      In order to reduce the possibility of kernel panic when failed to get IO
      TLB memory under CONFIG_SWIOTLB, it is better to allocate low memory as
      small as possible before plat_swiotlb_setup(), so make sparse_init() using
      top-down allocation.
      Reported-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Co-developed-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Signed-off-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ff43399
    • Kieran Bingham's avatar
      media: platform: fcp: Set appropriate DMA parameters · 6ac24bdb
      Kieran Bingham authored
      [ Upstream commit dd844fb8 ]
      
      Enabling CONFIG_DMA_API_DEBUG=y and CONFIG_DMA_API_DEBUG_SG=y will
      enable extra validation on DMA operations ensuring that the size
      restraints are met.
      
      When using the FCP in conjunction with the VSP1/DU, and display frames,
      the size of the DMA operations is larger than the default maximum
      segment size reported by the DMA core (64K). With the DMA debug enabled,
      this produces a warning such as the following:
      
      "DMA-API: rcar-fcp fea27000.fcp: mapping sg segment longer than device
      claims to support [len=3145728] [max=65536]"
      
      We have no specific limitation on the segment size which isn't already
      handled by the VSP1/DU which actually handles the DMA allcoations and
      buffer management, so define a maximum segment size of up to 4GB (a 32
      bit mask).
      Reported-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Fixes: 7b49235e ("[media] v4l: Add Renesas R-Car FCP driver")
      Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ac24bdb