1. 21 Dec, 2019 40 commits
    • Tejun Heo's avatar
      workqueue: Fix pwq ref leak in rescuer_thread() · 4f5b0c73
      Tejun Heo authored
      commit e66b39af upstream.
      
      008847f6 ("workqueue: allow rescuer thread to do more work.") made
      the rescuer worker requeue the pwq immediately if there may be more
      work items which need rescuing instead of waiting for the next mayday
      timer expiration.  Unfortunately, it doesn't check whether the pwq is
      already on the mayday list and unconditionally gets the ref and moves
      it onto the list.  This doesn't corrupt the list but creates an
      additional reference to the pwq.  It got queued twice but will only be
      removed once.
      
      This leak later can trigger pwq refcnt warning on workqueue
      destruction and prevent freeing of the workqueue.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: "Williams, Gerald S" <gerald.s.williams@intel.com>
      Cc: NeilBrown <neilb@suse.de>
      Cc: stable@vger.kernel.org # v3.19+
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f5b0c73
    • Tejun Heo's avatar
      workqueue: Fix spurious sanity check failures in destroy_workqueue() · 54f859a3
      Tejun Heo authored
      commit def98c84 upstream.
      
      Before actually destrying a workqueue, destroy_workqueue() checks
      whether it's actually idle.  If it isn't, it prints out a bunch of
      warning messages and leaves the workqueue dangling.  It unfortunately
      has a couple issues.
      
      * Mayday list queueing increments pwq's refcnts which gets detected as
        busy and fails the sanity checks.  However, because mayday list
        queueing is asynchronous, this condition can happen without any
        actual work items left in the workqueue.
      
      * Sanity check failure leaves the sysfs interface behind too which can
        lead to init failure of newer instances of the workqueue.
      
      This patch fixes the above two by
      
      * If a workqueue has a rescuer, disable and kill the rescuer before
        sanity checks.  Disabling and killing is guaranteed to flush the
        existing mayday list.
      
      * Remove sysfs interface before sanity checks.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reported-by: default avatarMarcin Pawlowski <mpawlowski@fb.com>
      Reported-by: default avatar"Williams, Gerald S" <gerald.s.williams@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54f859a3
    • Takashi Iwai's avatar
      ALSA: hda - Fix pending unsol events at shutdown · 6693e85b
      Takashi Iwai authored
      [ Upstream commit ca58f551 ]
      
      This is an alternative fix attemp for the issue reported in the commit
      caa8422d ("ALSA: hda: Flush interrupts on disabling") that was
      reverted later due to regressions.  Instead of tweaking the hardware
      disablement order and the enforced irq flushing, do calling
      cancel_work_sync() of the unsol work early enough, and explicitly
      ignore the unsol events during the shutdown by checking the
      bus->shutdown flag.
      
      Fixes: caa8422d ("ALSA: hda: Flush interrupts on disabling")
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Link: https://lore.kernel.org/r/s5h1ruxt9cz.wl-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6693e85b
    • Greg Kroah-Hartman's avatar
      lib: raid6: fix awk build warnings · 4d1f99ad
      Greg Kroah-Hartman authored
      commit 702600ee upstream.
      
      Newer versions of awk spit out these fun warnings:
      	awk: ../lib/raid6/unroll.awk:16: warning: regexp escape sequence `\#' is not a known regexp operator
      
      As commit 700c1018 ("x86/insn: Fix awk regexp warnings") showed, it
      turns out that there are a number of awk strings that do not need to be
      escaped and newer versions of awk now warn about this.
      
      Fix the string up so that no warning is produced.  The exact same kernel
      module gets created before and after this patch, showing that it wasn't
      needed.
      
      Link: https://lore.kernel.org/r/20191206152600.GA75093@kroah.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d1f99ad
    • Larry Finger's avatar
      rtlwifi: rtl8192de: Fix missing enable interrupt flag · ec3b069b
      Larry Finger authored
      commit 330bb711 upstream.
      
      In commit 38506ece ("rtlwifi: rtl_pci: Start modification for
      new drivers"), the flag that indicates that interrupts are enabled was
      never set.
      
      In addition, there are several places when enable/disable interrupts
      were commented out are restored. A sychronize_interrupts() call is
      removed.
      
      Fixes: 38506ece ("rtlwifi: rtl_pci: Start modification for new drivers")
      Cc: Stable <stable@vger.kernel.org>	# v3.18+
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec3b069b
    • Larry Finger's avatar
      rtlwifi: rtl8192de: Fix missing callback that tests for hw release of buffer · f35cbf67
      Larry Finger authored
      commit 3155db76 upstream.
      
      In commit 38506ece ("rtlwifi: rtl_pci: Start modification for
      new drivers"), a callback needed to check if the hardware has released
      a buffer indicating that a DMA operation is completed was not added.
      
      Fixes: 38506ece ("rtlwifi: rtl_pci: Start modification for new drivers")
      Cc: Stable <stable@vger.kernel.org>	# v3.18+
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f35cbf67
    • Larry Finger's avatar
      rtlwifi: rtl8192de: Fix missing code to retrieve RX buffer address · 48179bd0
      Larry Finger authored
      commit 0e531cc5 upstream.
      
      In commit 38506ece ("rtlwifi: rtl_pci: Start modification for
      new drivers"), a callback to get the RX buffer address was added to
      the PCI driver. Unfortunately, driver rtl8192de was not modified
      appropriately and the code runs into a WARN_ONCE() call. The use
      of an incorrect array is also fixed.
      
      Fixes: 38506ece ("rtlwifi: rtl_pci: Start modification for new drivers")
      Cc: Stable <stable@vger.kernel.org> # 3.18+
      Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      48179bd0
    • Josef Bacik's avatar
      btrfs: record all roots for rename exchange on a subvol · b2d65356
      Josef Bacik authored
      commit 3e174099 upstream.
      
      Testing with the new fsstress support for subvolumes uncovered a pretty
      bad problem with rename exchange on subvolumes.  We're modifying two
      different subvolumes, but we only start the transaction on one of them,
      so the other one is not added to the dirty root list.  This is caught by
      btrfs_cow_block() with a warning because the root has not been updated,
      however if we do not modify this root again we'll end up pointing at an
      invalid root because the root item is never updated.
      
      Fix this by making sure we add the destination root to the trans list,
      the same as we do with normal renames.  This fixes the corruption.
      
      Fixes: cdd1fedf ("btrfs: add support for RENAME_EXCHANGE and RENAME_WHITEOUT")
      CC: stable@vger.kernel.org # 4.9+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2d65356
    • Filipe Manana's avatar
      Btrfs: send, skip backreference walking for extents with many references · b6af12ab
      Filipe Manana authored
      commit fd0ddbe2 upstream.
      
      Backreference walking, which is used by send to figure if it can issue
      clone operations instead of write operations, can be very slow and use
      too much memory when extents have many references. This change simply
      skips backreference walking when an extent has more than 64 references,
      in which case we fallback to a write operation instead of a clone
      operation. This limit is conservative and in practice I observed no
      signicant slowdown with up to 100 references and still low memory usage
      up to that limit.
      
      This is a temporary workaround until there are speedups in the backref
      walking code, and as such it does not attempt to add extra interfaces or
      knobs to tweak the threshold.
      Reported-by: default avatarAtemu <atemu.main@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CAE4GHgkvqVADtS4AzcQJxo0Q1jKQgKaW3JGp3SGdoinVo=C9eQ@mail.gmail.com/T/#me55dc0987f9cc2acaa54372ce0492c65782be3fa
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6af12ab
    • Qu Wenruo's avatar
      btrfs: Remove btrfs_bio::flags member · 77774ead
      Qu Wenruo authored
      commit 34b127ae upstream.
      
      The last user of btrfs_bio::flags was removed in commit 326e1dbb
      ("block: remove management of bi_remaining when restoring original
      bi_end_io"), remove it.
      
      (Tagged for stable as the structure is heavily used and space savings
      are desirable.)
      
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77774ead
    • Josef Bacik's avatar
      btrfs: check page->mapping when loading free space cache · 2e7647fc
      Josef Bacik authored
      commit 3797136b upstream.
      
      While testing 5.2 we ran into the following panic
      
      [52238.017028] BUG: kernel NULL pointer dereference, address: 0000000000000001
      [52238.105608] RIP: 0010:drop_buffers+0x3d/0x150
      [52238.304051] Call Trace:
      [52238.308958]  try_to_free_buffers+0x15b/0x1b0
      [52238.317503]  shrink_page_list+0x1164/0x1780
      [52238.325877]  shrink_inactive_list+0x18f/0x3b0
      [52238.334596]  shrink_node_memcg+0x23e/0x7d0
      [52238.342790]  ? do_shrink_slab+0x4f/0x290
      [52238.350648]  shrink_node+0xce/0x4a0
      [52238.357628]  balance_pgdat+0x2c7/0x510
      [52238.365135]  kswapd+0x216/0x3e0
      [52238.371425]  ? wait_woken+0x80/0x80
      [52238.378412]  ? balance_pgdat+0x510/0x510
      [52238.386265]  kthread+0x111/0x130
      [52238.392727]  ? kthread_create_on_node+0x60/0x60
      [52238.401782]  ret_from_fork+0x1f/0x30
      
      The page we were trying to drop had a page->private, but had no
      page->mapping and so called drop_buffers, assuming that we had a
      buffer_head on the page, and then panic'ed trying to deref 1, which is
      our page->private for data pages.
      
      This is happening because we're truncating the free space cache while
      we're trying to load the free space cache.  This isn't supposed to
      happen, and I'll fix that in a followup patch.  However we still
      shouldn't allow those sort of mistakes to result in messing with pages
      that do not belong to us.  So add the page->mapping check to verify that
      we still own this page after dropping and re-acquiring the page lock.
      
      This page being unlocked as:
      btrfs_readpage
        extent_read_full_page
          __extent_read_full_page
            __do_readpage
              if (!nr)
      	   unlock_page  <-- nr can be 0 only if submit_extent_page
      			    returns an error
      
      CC: stable@vger.kernel.org # 4.4+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      [ add callchain ]
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e7647fc
    • David Hildenbrand's avatar
      virtio-balloon: fix managed page counts when migrating pages between zones · 834b9aa4
      David Hildenbrand authored
      commit 63341ab0 upstream.
      
      In case we have to migrate a ballon page to a newpage of another zone, the
      managed page count of both zones is wrong. Paired with memory offlining
      (which will adjust the managed page count), we can trigger kernel crashes
      and all kinds of different symptoms.
      
      One way to reproduce:
      1. Start a QEMU guest with 4GB, no NUMA
      2. Hotplug a 1GB DIMM and online the memory to ZONE_NORMAL
      3. Inflate the balloon to 1GB
      4. Unplug the DIMM (be quick, otherwise unmovable data ends up on it)
      5. Observe /proc/zoneinfo
        Node 0, zone   Normal
          pages free     16810
                min      24848885473806
                low      18471592959183339
                high     36918337032892872
                spanned  262144
                present  262144
                managed  18446744073709533486
      6. Do anything that requires some memory (e.g., inflate the balloon some
      more). The OOM goes crazy and the system crashes
        [  238.324946] Out of memory: Killed process 537 (login) total-vm:27584kB, anon-rss:860kB, file-rss:0kB, shmem-rss:00
        [  238.338585] systemd invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
        [  238.339420] CPU: 0 PID: 1 Comm: systemd Tainted: G      D W         5.4.0-next-20191204+ #75
        [  238.340139] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu4
        [  238.341121] Call Trace:
        [  238.341337]  dump_stack+0x8f/0xd0
        [  238.341630]  dump_header+0x61/0x5ea
        [  238.341942]  oom_kill_process.cold+0xb/0x10
        [  238.342299]  out_of_memory+0x24d/0x5a0
        [  238.342625]  __alloc_pages_slowpath+0xd12/0x1020
        [  238.343024]  __alloc_pages_nodemask+0x391/0x410
        [  238.343407]  pagecache_get_page+0xc3/0x3a0
        [  238.343757]  filemap_fault+0x804/0xc30
        [  238.344083]  ? ext4_filemap_fault+0x28/0x42
        [  238.344444]  ext4_filemap_fault+0x30/0x42
        [  238.344789]  __do_fault+0x37/0x1a0
        [  238.345087]  __handle_mm_fault+0x104d/0x1ab0
        [  238.345450]  handle_mm_fault+0x169/0x360
        [  238.345790]  do_user_addr_fault+0x20d/0x490
        [  238.346154]  do_page_fault+0x31/0x210
        [  238.346468]  async_page_fault+0x43/0x50
        [  238.346797] RIP: 0033:0x7f47eba4197e
        [  238.347110] Code: Bad RIP value.
        [  238.347387] RSP: 002b:00007ffd7c0c1890 EFLAGS: 00010293
        [  238.347834] RAX: 0000000000000002 RBX: 000055d196a20a20 RCX: 00007f47eba4197e
        [  238.348437] RDX: 0000000000000033 RSI: 00007ffd7c0c18c0 RDI: 0000000000000004
        [  238.349047] RBP: 00007ffd7c0c1c20 R08: 0000000000000000 R09: 0000000000000033
        [  238.349660] R10: 00000000ffffffff R11: 0000000000000293 R12: 0000000000000001
        [  238.350261] R13: ffffffffffffffff R14: 0000000000000000 R15: 00007ffd7c0c18c0
        [  238.350878] Mem-Info:
        [  238.351085] active_anon:3121 inactive_anon:51 isolated_anon:0
        [  238.351085]  active_file:12 inactive_file:7 isolated_file:0
        [  238.351085]  unevictable:0 dirty:0 writeback:0 unstable:0
        [  238.351085]  slab_reclaimable:5565 slab_unreclaimable:10170
        [  238.351085]  mapped:3 shmem:111 pagetables:155 bounce:0
        [  238.351085]  free:720717 free_pcp:2 free_cma:0
        [  238.353757] Node 0 active_anon:12484kB inactive_anon:204kB active_file:48kB inactive_file:28kB unevictable:0kB iss
        [  238.355979] Node 0 DMA free:11556kB min:36kB low:48kB high:60kB reserved_highatomic:0KB active_anon:152kB inactivB
        [  238.358345] lowmem_reserve[]: 0 2955 2884 2884 2884
        [  238.358761] Node 0 DMA32 free:2677864kB min:7004kB low:10028kB high:13052kB reserved_highatomic:0KB active_anon:0B
        [  238.361202] lowmem_reserve[]: 0 0 72057594037927865 72057594037927865 72057594037927865
        [  238.361888] Node 0 Normal free:193448kB min:99395541895224kB low:73886371836733356kB high:147673348131571488kB reB
        [  238.364765] lowmem_reserve[]: 0 0 0 0 0
        [  238.365101] Node 0 DMA: 7*4kB (U) 5*8kB (UE) 6*16kB (UME) 2*32kB (UM) 1*64kB (U) 2*128kB (UE) 3*256kB (UME) 2*512B
        [  238.366379] Node 0 DMA32: 0*4kB 1*8kB (U) 2*16kB (UM) 2*32kB (UM) 2*64kB (UM) 1*128kB (U) 1*256kB (U) 1*512kB (U)B
        [  238.367654] Node 0 Normal: 1985*4kB (UME) 1321*8kB (UME) 844*16kB (UME) 524*32kB (UME) 300*64kB (UME) 138*128kB (B
        [  238.369184] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
        [  238.369915] 130 total pagecache pages
        [  238.370241] 0 pages in swap cache
        [  238.370533] Swap cache stats: add 0, delete 0, find 0/0
        [  238.370981] Free swap  = 0kB
        [  238.371239] Total swap = 0kB
        [  238.371488] 1048445 pages RAM
        [  238.371756] 0 pages HighMem/MovableOnly
        [  238.372090] 306992 pages reserved
        [  238.372376] 0 pages cma reserved
        [  238.372661] 0 pages hwpoisoned
      
      In another instance (older kernel), I was able to observe this
      (negative page count :/):
        [  180.896971] Offlined Pages 32768
        [  182.667462] Offlined Pages 32768
        [  184.408117] Offlined Pages 32768
        [  186.026321] Offlined Pages 32768
        [  187.684861] Offlined Pages 32768
        [  189.227013] Offlined Pages 32768
        [  190.830303] Offlined Pages 32768
        [  190.833071] Built 1 zonelists, mobility grouping on.  Total pages: -36920272750453009
      
      In another instance (older kernel), I was no longer able to start any
      process:
        [root@vm ~]# [  214.348068] Offlined Pages 32768
        [  215.973009] Offlined Pages 32768
        cat /proc/meminfo
        -bash: fork: Cannot allocate memory
        [root@vm ~]# cat /proc/meminfo
        -bash: fork: Cannot allocate memory
      
      Fix it by properly adjusting the managed page count when migrating if
      the zone changed. The managed page count of the zones now looks after
      unplug of the DIMM (and after deflating the balloon) just like before
      inflating the balloon (and plugging+onlining the DIMM).
      
      We'll temporarily modify the totalram page count. If this ever becomes a
      problem, we can fine tune by providing helpers that don't touch
      the totalram pages (e.g., adjust_zone_managed_page_count()).
      
      Please note that fixing up the managed page count is only necessary when
      we adjusted the managed page count when inflating - only if we
      don't have VIRTIO_BALLOON_F_DEFLATE_ON_OOM. With that feature, the
      managed page count is not touched when inflating/deflating.
      Reported-by: default avatarYumei Huang <yuhuang@redhat.com>
      Fixes: 3dcc0571 ("mm: correctly update zone->managed_pages")
      Cc: <stable@vger.kernel.org> # v3.11+
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: Jiang Liu <liuj97@gmail.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Igor Mammedov <imammedo@redhat.com>
      Cc: virtualization@lists.linux-foundation.org
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      834b9aa4
    • Miquel Raynal's avatar
      mtd: spear_smi: Fix Write Burst mode · 3776fc67
      Miquel Raynal authored
      commit 69c7f461 upstream.
      
      Any write with either dd or flashcp to a device driven by the
      spear_smi.c driver will pass through the spear_smi_cpy_toio()
      function. This function will get called for chunks of up to 256 bytes.
      If the amount of data is smaller, we may have a problem if the data
      length is not 4-byte aligned. In this situation, the kernel panics
      during the memcpy:
      
          # dd if=/dev/urandom bs=1001 count=1 of=/dev/mtd6
          spear_smi_cpy_toio [620] dest c9070000, src c7be8800, len 256
          spear_smi_cpy_toio [620] dest c9070100, src c7be8900, len 256
          spear_smi_cpy_toio [620] dest c9070200, src c7be8a00, len 256
          spear_smi_cpy_toio [620] dest c9070300, src c7be8b00, len 233
          Unhandled fault: external abort on non-linefetch (0x808) at 0xc90703e8
          [...]
          PC is at memcpy+0xcc/0x330
      
      The above error occurs because the implementation of memcpy_toio()
      tries to optimize the number of I/O by writing 4 bytes at a time as
      much as possible, until there are less than 4 bytes left and then
      switches to word or byte writes.
      
      Unfortunately, the specification states about the Write Burst mode:
      
              "the next AHB Write request should point to the next
      	incremented address and should have the same size (byte,
      	half-word or word)"
      
      This means ARM architecture implementation of memcpy_toio() cannot
      reliably be used blindly here. Workaround this situation by update the
      write path to stick to byte access when the burst length is not
      multiple of 4.
      
      Fixes: f18dbbb1 ("mtd: ST SPEAr: Add SMI driver for serial NOR flash")
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Boris Brezillon <boris.brezillon@collabora.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Reviewed-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3776fc67
    • Pete Zaitcev's avatar
      usb: mon: Fix a deadlock in usbmon between mmap and read · 9b109580
      Pete Zaitcev authored
      commit 19e6317d upstream.
      
      The problem arises because our read() function grabs a lock of the
      circular buffer, finds something of interest, then invokes copy_to_user()
      straight from the buffer, which in turn takes mm->mmap_sem. In the same
      time, the callback mon_bin_vma_fault() is invoked under mm->mmap_sem.
      It attempts to take the fetch lock and deadlocks.
      
      This patch does away with protecting of our page list with any
      semaphores, and instead relies on the kernel not close the device
      while mmap is active in a process.
      
      In addition, we prohibit re-sizing of a buffer while mmap is active.
      This way, when (now unlocked) fault is processed, it works with the
      page that is intended to be mapped-in, and not some other random page.
      Note that this may have an ABI impact, but hopefully no legitimate
      program is this wrong.
      Signed-off-by: default avatarPete Zaitcev <zaitcev@redhat.com>
      Reported-by: syzbot+56f9673bb4cdcbeb0e92@syzkaller.appspotmail.com
      Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: 46eb14a6 ("USB: fix usbmon BUG trigger")
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191204203941.3503452b@suzdal.zaitcev.lanSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b109580
    • Emiliano Ingrassia's avatar
      usb: core: urb: fix URB structure initialization function · d262c1a4
      Emiliano Ingrassia authored
      commit 1cd17f7f upstream.
      
      Explicitly initialize URB structure urb_list field in usb_init_urb().
      This field can be potentially accessed uninitialized and its
      initialization is coherent with the usage of list_del_init() in
      usb_hcd_unlink_urb_from_ep() and usb_giveback_urb_bh() and its
      explicit initialization in usb_hcd_submit_urb() error path.
      Signed-off-by: default avatarEmiliano Ingrassia <ingrassia@epigenesys.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191127160355.GA27196@ingrassia.epigenesys.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d262c1a4
    • Johan Hovold's avatar
      USB: adutux: fix interface sanity check · 72e96b95
      Johan Hovold authored
      commit 3c11c4be upstream.
      
      Make sure to use the current alternate setting when verifying the
      interface descriptors to avoid binding to an invalid interface.
      
      Failing to do so could cause the driver to misbehave or trigger a WARN()
      in usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: 03270634 ("USB: Add ADU support for Ontrak ADU devices")
      Cc: stable <stable@vger.kernel.org>     # 2.6.19
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210112601.3561-3-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72e96b95
    • Johan Hovold's avatar
      USB: serial: io_edgeport: fix epic endpoint lookup · 1e63d9a7
      Johan Hovold authored
      commit 7c5a2df3 upstream.
      
      Make sure to use the current alternate setting when looking up the
      endpoints on epic devices to avoid binding to an invalid interface.
      
      Failing to do so could cause the driver to misbehave or trigger a WARN()
      in usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: 6e8cf775 ("USB: add EPIC support to the io_edgeport driver")
      Cc: stable <stable@vger.kernel.org>     # 2.6.21
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210112601.3561-5-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e63d9a7
    • Johan Hovold's avatar
      USB: idmouse: fix interface sanity checks · 6ca5c81b
      Johan Hovold authored
      commit 59920635 upstream.
      
      Make sure to use the current alternate setting when verifying the
      interface descriptors to avoid binding to an invalid interface.
      
      Failing to do so could cause the driver to misbehave or trigger a WARN()
      in usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210112601.3561-4-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ca5c81b
    • Johan Hovold's avatar
      USB: atm: ueagle-atm: add missing endpoint check · 0847df79
      Johan Hovold authored
      commit 09068c1a upstream.
      
      Make sure that the interrupt interface has an endpoint before trying to
      access its endpoint descriptors to avoid dereferencing a NULL pointer.
      
      The driver binds to the interrupt interface with interface number 0, but
      must not assume that this interface or its current alternate setting are
      the first entries in the corresponding configuration arrays.
      
      Fixes: b72458a8 ("[PATCH] USB: Eagle and ADI 930 usb adsl modem driver")
      Cc: stable <stable@vger.kernel.org>     # 2.6.16
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210112601.3561-2-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0847df79
    • Chris Lesiak's avatar
      iio: humidity: hdc100x: fix IIO_HUMIDITYRELATIVE channel reporting · 2a0fb947
      Chris Lesiak authored
      commit 342a6928 upstream.
      
      The IIO_HUMIDITYRELATIVE channel was being incorrectly reported back
      as percent when it should have been milli percent. This is via an
      incorrect scale value being returned to userspace.
      Signed-off-by: default avatarChris Lesiak <chris.lesiak@licor.com>
      Acked-by: default avatarMatt Ranostay <matt.ranostay@konsulko.com>
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a0fb947
    • H. Nikolaus Schaller's avatar
      ARM: dts: pandora-common: define wl1251 as child node of mmc3 · 140cbcf8
      H. Nikolaus Schaller authored
      commit 4f9007d6 upstream.
      
      Since v4.7 the dma initialization requires that there is a
      device tree property for "rx" and "tx" channels which is
      not provided by the pdata-quirks initialization.
      
      By conversion of the mmc3 setup to device tree this will
      finally allows to remove the OpenPandora wlan specific omap3
      data-quirks.
      
      Fixes: 81eef6ca ("mmc: omap_hsmmc: Use dma_request_chan() for requesting DMA channel")
      Signed-off-by: default avatarH. Nikolaus Schaller <hns@goldelico.com>
      Cc: <stable@vger.kernel.org> # v4.7+
      Acked-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      140cbcf8
    • Kai-Heng Feng's avatar
      xhci: Increase STS_HALT timeout in xhci_suspend() · e3b11282
      Kai-Heng Feng authored
      commit 7c67cf66 upstream.
      
      I've recently observed failed xHCI suspend attempt on AMD Raven Ridge
      system:
      kernel: xhci_hcd 0000:04:00.4: WARN: xHC CMD_RUN timeout
      kernel: PM: suspend_common(): xhci_pci_suspend+0x0/0xd0 returns -110
      kernel: PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -110
      kernel: PM: dpm_run_callback(): pci_pm_suspend+0x0/0x150 returns -110
      kernel: PM: Device 0000:04:00.4 failed to suspend async: error -110
      
      Similar to commit ac343366 ("xhci: Increase STS_SAVE timeout in
      xhci_suspend()") we also need to increase the HALT timeout to make it be
      able to suspend again.
      
      Cc: <stable@vger.kernel.org> # 5.2+
      Fixes: f7fac17c ("xhci: Convert xhci_handshake() to use readl_poll_timeout_atomic()")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Link: https://lore.kernel.org/r/20191211142007.8847-5-mathias.nyman@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3b11282
    • Johan Hovold's avatar
      staging: gigaset: add endpoint-type sanity check · 70a7762b
      Johan Hovold authored
      commit ed9ed5a8 upstream.
      
      Add missing endpoint-type sanity checks to probe.
      
      This specifically prevents a warning in USB core on URB submission when
      fuzzing USB descriptors.
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191202085610.12719-4-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70a7762b
    • Johan Hovold's avatar
      staging: gigaset: fix illegal free on probe errors · 6ac38d52
      Johan Hovold authored
      commit 84f60ca7 upstream.
      
      The driver failed to initialise its receive-buffer pointer, something
      which could lead to an illegal free on late probe errors.
      
      Fix this by making sure to clear all driver data at allocation.
      
      Fixes: 2032e2c2 ("usb_gigaset: code cleanup")
      Cc: stable <stable@vger.kernel.org>     # 2.6.33
      Cc: Tilman Schmidt <tilman@imap.cc>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191202085610.12719-3-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6ac38d52
    • Johan Hovold's avatar
      staging: gigaset: fix general protection fault on probe · 82acad8e
      Johan Hovold authored
      commit 53f35a39 upstream.
      
      Fix a general protection fault when accessing the endpoint descriptors
      which could be triggered by a malicious device due to missing sanity
      checks on the number of endpoints.
      
      Reported-by: syzbot+35b1c403a14f5c89eba7@syzkaller.appspotmail.com
      Fixes: 07dc1f9f ("[PATCH] isdn4linux: Siemens Gigaset drivers - M105 USB DECT adapter")
      Cc: stable <stable@vger.kernel.org>     # 2.6.17
      Cc: Hansjoerg Lipp <hjlipp@web.de>
      Cc: Tilman Schmidt <tilman@imap.cc>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191202085610.12719-2-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82acad8e
    • Johan Hovold's avatar
      staging: rtl8712: fix interface sanity check · c7fbb198
      Johan Hovold authored
      commit c724f776 upstream.
      
      Make sure to use the current alternate setting when verifying the
      interface descriptors to avoid binding to an invalid interface.
      
      Failing to do so could cause the driver to misbehave or trigger a WARN()
      in usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: 2865d42c ("staging: r8712u: Add the new driver to the mainline kernel")
      Cc: stable <stable@vger.kernel.org>     # 2.6.37
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210114751.5119-3-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7fbb198
    • Johan Hovold's avatar
      staging: rtl8188eu: fix interface sanity check · cc2f9754
      Johan Hovold authored
      commit 74ca3411 upstream.
      
      Make sure to use the current alternate setting when verifying the
      interface descriptors to avoid binding to an invalid interface.
      
      Failing to do so could cause the driver to misbehave or trigger a WARN()
      in usb_submit_urb() that kernels with panic_on_warn set would choke on.
      
      Fixes: c2478d39 ("staging: r8188eu: Add files for new driver - part 20")
      Cc: stable <stable@vger.kernel.org>     # 3.12
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Link: https://lore.kernel.org/r/20191210114751.5119-2-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc2f9754
    • Kai-Heng Feng's avatar
      usb: Allow USB device to be warm reset in suspended state · 6a80ee6a
      Kai-Heng Feng authored
      commit e76b3bf7 upstream.
      
      On Dell WD15 dock, sometimes USB ethernet cannot be detected after plugging
      cable to the ethernet port, the hub and roothub get runtime resumed and
      runtime suspended immediately:
      ...
      [  433.315169] xhci_hcd 0000:3a:00.0: hcd_pci_runtime_resume: 0
      [  433.315204] usb usb4: usb auto-resume
      [  433.315226] hub 4-0:1.0: hub_resume
      [  433.315239] xhci_hcd 0000:3a:00.0: Get port status 4-1 read: 0x10202e2, return 0x10343
      [  433.315264] usb usb4-port1: status 0343 change 0001
      [  433.315279] xhci_hcd 0000:3a:00.0: clear port1 connect change, portsc: 0x10002e2
      [  433.315293] xhci_hcd 0000:3a:00.0: Get port status 4-2 read: 0x2a0, return 0x2a0
      [  433.317012] xhci_hcd 0000:3a:00.0: xhci_hub_status_data: stopping port polling.
      [  433.422282] xhci_hcd 0000:3a:00.0: Get port status 4-1 read: 0x10002e2, return 0x343
      [  433.422307] usb usb4-port1: do warm reset
      [  433.422311] usb 4-1: device reset not allowed in state 8
      [  433.422339] hub 4-0:1.0: state 7 ports 2 chg 0002 evt 0000
      [  433.422346] xhci_hcd 0000:3a:00.0: Get port status 4-1 read: 0x10002e2, return 0x343
      [  433.422356] usb usb4-port1: do warm reset
      [  433.422358] usb 4-1: device reset not allowed in state 8
      [  433.422428] xhci_hcd 0000:3a:00.0: set port remote wake mask, actual port 0 status  = 0xf0002e2
      [  433.422455] xhci_hcd 0000:3a:00.0: set port remote wake mask, actual port 1 status  = 0xe0002a0
      [  433.422465] hub 4-0:1.0: hub_suspend
      [  433.422475] usb usb4: bus auto-suspend, wakeup 1
      [  433.426161] xhci_hcd 0000:3a:00.0: xhci_hub_status_data: stopping port polling.
      [  433.466209] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.510204] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.554051] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.598235] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.642154] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.686204] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.730205] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.774203] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.818207] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.862040] xhci_hcd 0000:3a:00.0: port 0 polling in bus suspend, waiting
      [  433.862053] xhci_hcd 0000:3a:00.0: xhci_hub_status_data: stopping port polling.
      [  433.862077] xhci_hcd 0000:3a:00.0: xhci_suspend: stopping port polling.
      [  433.862096] xhci_hcd 0000:3a:00.0: // Setting command ring address to 0x8578fc001
      [  433.862312] xhci_hcd 0000:3a:00.0: hcd_pci_runtime_suspend: 0
      [  433.862445] xhci_hcd 0000:3a:00.0: PME# enabled
      [  433.902376] xhci_hcd 0000:3a:00.0: restoring config space at offset 0xc (was 0x0, writing 0x20)
      [  433.902395] xhci_hcd 0000:3a:00.0: restoring config space at offset 0x4 (was 0x100000, writing 0x100403)
      [  433.902490] xhci_hcd 0000:3a:00.0: PME# disabled
      [  433.902504] xhci_hcd 0000:3a:00.0: enabling bus mastering
      [  433.902547] xhci_hcd 0000:3a:00.0: // Setting command ring address to 0x8578fc001
      [  433.902649] pcieport 0000:00:1b.0: PME: Spurious native interrupt!
      [  433.902839] xhci_hcd 0000:3a:00.0: Port change event, 4-1, id 3, portsc: 0xb0202e2
      [  433.902842] xhci_hcd 0000:3a:00.0: resume root hub
      [  433.902845] xhci_hcd 0000:3a:00.0: handle_port_status: starting port polling.
      [  433.902877] xhci_hcd 0000:3a:00.0: xhci_resume: starting port polling.
      [  433.902889] xhci_hcd 0000:3a:00.0: xhci_hub_status_data: stopping port polling.
      [  433.902891] xhci_hcd 0000:3a:00.0: hcd_pci_runtime_resume: 0
      [  433.902919] usb usb4: usb wakeup-resume
      [  433.902942] usb usb4: usb auto-resume
      [  433.902966] hub 4-0:1.0: hub_resume
      ...
      
      As Mathias pointed out, the hub enters Cold Attach Status state and
      requires a warm reset. However usb_reset_device() bails out early when
      the device is in suspended state, as its callers port_event() and
      hub_event() don't always resume the device.
      
      Since there's nothing wrong to reset a suspended device, allow
      usb_reset_device() to do so to solve the issue.
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191106062710.29880-1-kai.heng.feng@canonical.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a80ee6a
    • Oliver Neukum's avatar
      USB: uas: heed CAPACITY_HEURISTICS · 7e2ae629
      Oliver Neukum authored
      commit 335cbbd5 upstream.
      
      There is no need to ignore this flag. We should be as close
      to storage in that regard as makes sense, so honor flags whose
      cost is tiny.
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191114112758.32747-3-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e2ae629
    • Oliver Neukum's avatar
      USB: uas: honor flag to avoid CAPACITY16 · 4b88131b
      Oliver Neukum authored
      commit bff000ca upstream.
      
      Copy the support over from usb-storage to get feature parity
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191114112758.32747-2-oneukum@suse.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b88131b
    • Wei Yongjun's avatar
      usb: gadget: configfs: Fix missing spin_lock_init() · be17a738
      Wei Yongjun authored
      commit 093edc2b upstream.
      
      The driver allocates the spinlock but not initialize it.
      Use spin_lock_init() on it to initialize it correctly.
      
      This is detected by Coccinelle semantic patch.
      
      Fixes: 1a1c851b ("usb: gadget: configfs: fix concurrent issue between composite APIs")
      Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarPeter Chen <peter.chen@nxp.com>
      Link: https://lore.kernel.org/r/20191030034046.188808-1-weiyongjun1@huawei.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be17a738
    • YueHaibing's avatar
      appletalk: Set error code if register_snap_client failed · a2f50a54
      YueHaibing authored
      commit c93ad133 upstream.
      
      If register_snap_client fails in atalk_init,
      error code should be set, otherwise it will
      triggers NULL pointer dereference while unloading
      module.
      
      Fixes: 9804501f ("appletalk: Fix potential NULL pointer dereference in unregister_snap_client")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2f50a54
    • YueHaibing's avatar
      appletalk: Fix potential NULL pointer dereference in unregister_snap_client · 540b3410
      YueHaibing authored
      commit 9804501f upstream.
      
      register_snap_client may return NULL, all the callers
      check it, but only print a warning. This will result in
      NULL pointer dereference in unregister_snap_client and other
      places.
      
      It has always been used like this since v2.6
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [bwh: Backported to <4.15: adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      540b3410
    • Paolo Bonzini's avatar
      KVM: x86: fix out-of-bounds write in KVM_GET_EMULATED_CPUID (CVE-2019-19332) · 8b587e3f
      Paolo Bonzini authored
      commit 433f4ba1 upstream.
      
      The bounds check was present in KVM_GET_SUPPORTED_CPUID but not
      KVM_GET_EMULATED_CPUID.
      
      Reported-by: syzbot+e3f4897236c4eeb8af4f@syzkaller.appspotmail.com
      Fixes: 84cffe49 ("kvm: Emulate MOVBE", 2013-10-29)
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b587e3f
    • Wei Wang's avatar
      thermal: Fix deadlock in thermal thermal_zone_device_check · a7577abb
      Wei Wang authored
      commit 163b00cd upstream.
      
      1851799e ("thermal: Fix use-after-free when unregistering thermal zone
      device") changed cancel_delayed_work to cancel_delayed_work_sync to avoid
      a use-after-free issue. However, cancel_delayed_work_sync could be called
      insides the WQ causing deadlock.
      
      [54109.642398] c0   1162 kworker/u17:1   D    0 11030      2 0x00000000
      [54109.642437] c0   1162 Workqueue: thermal_passive_wq thermal_zone_device_check
      [54109.642447] c0   1162 Call trace:
      [54109.642456] c0   1162  __switch_to+0x138/0x158
      [54109.642467] c0   1162  __schedule+0xba4/0x1434
      [54109.642480] c0   1162  schedule_timeout+0xa0/0xb28
      [54109.642492] c0   1162  wait_for_common+0x138/0x2e8
      [54109.642511] c0   1162  flush_work+0x348/0x40c
      [54109.642522] c0   1162  __cancel_work_timer+0x180/0x218
      [54109.642544] c0   1162  handle_thermal_trip+0x2c4/0x5a4
      [54109.642553] c0   1162  thermal_zone_device_update+0x1b4/0x25c
      [54109.642563] c0   1162  thermal_zone_device_check+0x18/0x24
      [54109.642574] c0   1162  process_one_work+0x3cc/0x69c
      [54109.642583] c0   1162  worker_thread+0x49c/0x7c0
      [54109.642593] c0   1162  kthread+0x17c/0x1b0
      [54109.642602] c0   1162  ret_from_fork+0x10/0x18
      [54109.643051] c0   1162 kworker/u17:2   D    0 16245      2 0x00000000
      [54109.643067] c0   1162 Workqueue: thermal_passive_wq thermal_zone_device_check
      [54109.643077] c0   1162 Call trace:
      [54109.643085] c0   1162  __switch_to+0x138/0x158
      [54109.643095] c0   1162  __schedule+0xba4/0x1434
      [54109.643104] c0   1162  schedule_timeout+0xa0/0xb28
      [54109.643114] c0   1162  wait_for_common+0x138/0x2e8
      [54109.643122] c0   1162  flush_work+0x348/0x40c
      [54109.643131] c0   1162  __cancel_work_timer+0x180/0x218
      [54109.643141] c0   1162  handle_thermal_trip+0x2c4/0x5a4
      [54109.643150] c0   1162  thermal_zone_device_update+0x1b4/0x25c
      [54109.643159] c0   1162  thermal_zone_device_check+0x18/0x24
      [54109.643167] c0   1162  process_one_work+0x3cc/0x69c
      [54109.643177] c0   1162  worker_thread+0x49c/0x7c0
      [54109.643186] c0   1162  kthread+0x17c/0x1b0
      [54109.643195] c0   1162  ret_from_fork+0x10/0x18
      [54109.644500] c0   1162 cat             D    0  7766      1 0x00000001
      [54109.644515] c0   1162 Call trace:
      [54109.644524] c0   1162  __switch_to+0x138/0x158
      [54109.644536] c0   1162  __schedule+0xba4/0x1434
      [54109.644546] c0   1162  schedule_preempt_disabled+0x80/0xb0
      [54109.644555] c0   1162  __mutex_lock+0x3a8/0x7f0
      [54109.644563] c0   1162  __mutex_lock_slowpath+0x14/0x20
      [54109.644575] c0   1162  thermal_zone_get_temp+0x84/0x360
      [54109.644586] c0   1162  temp_show+0x30/0x78
      [54109.644609] c0   1162  dev_attr_show+0x5c/0xf0
      [54109.644628] c0   1162  sysfs_kf_seq_show+0xcc/0x1a4
      [54109.644636] c0   1162  kernfs_seq_show+0x48/0x88
      [54109.644656] c0   1162  seq_read+0x1f4/0x73c
      [54109.644664] c0   1162  kernfs_fop_read+0x84/0x318
      [54109.644683] c0   1162  __vfs_read+0x50/0x1bc
      [54109.644692] c0   1162  vfs_read+0xa4/0x140
      [54109.644701] c0   1162  SyS_read+0xbc/0x144
      [54109.644708] c0   1162  el0_svc_naked+0x34/0x38
      [54109.845800] c0   1162 D 720.000s 1->7766->7766 cat [panic]
      
      Fixes: 1851799e ("thermal: Fix use-after-free when unregistering thermal zone device")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWei Wang <wvw@google.com>
      Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7577abb
    • Viresh Kumar's avatar
      RDMA/qib: Validate ->show()/store() callbacks before calling them · d471e34d
      Viresh Kumar authored
      commit 7ee23491 upstream.
      
      The permissions of the read-only or write-only sysfs files can be
      changed (as root) and the user can then try to read a write-only file or
      write to a read-only file which will lead to kernel crash here.
      
      Protect against that by always validating the show/store callbacks.
      
      Link: https://lore.kernel.org/r/d45cc26361a174ae12dbb86c994ef334d257924b.1573096807.git.viresh.kumar@linaro.orgSigned-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d471e34d
    • Gregory CLEMENT's avatar
      spi: atmel: Fix CS high support · 1e4c21a3
      Gregory CLEMENT authored
      commit 7cbb16b2 upstream.
      
      Until a few years ago, this driver was only used with CS GPIO. The
      only exception is CS0 on AT91RM9200 which has to use internal CS. A
      limitation of the internal CS is that they don't support CS High.
      
      So by using the CS GPIO the CS high configuration was available except
      for the particular case CS0 on RM9200.
      
      When the support for the internal chip-select was added, the check of
      the CS high support was not updated. Due to this the driver accepts
      this configuration for all the SPI controller v2 (used by all SoCs
      excepting the AT91RM9200) whereas the hardware doesn't support it for
      infernal CS.
      
      This patch fixes the test to match the hardware capabilities.
      
      Fixes: 48203034 ("spi: atmel: add support for the internal chip-select of the spi controller")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGregory CLEMENT <gregory.clement@bootlin.com>
      Link: https://lore.kernel.org/r/20191017141846.7523-3-gregory.clement@bootlin.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e4c21a3
    • Navid Emamdoost's avatar
      crypto: user - fix memory leak in crypto_report · f427e1fc
      Navid Emamdoost authored
      commit ffdde593 upstream.
      
      In crypto_report, a new skb is created via nlmsg_new(). This skb should
      be released if crypto_report_alg() fails.
      
      Fixes: a38f7907 ("crypto: Add userspace configuration API")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f427e1fc
    • Ard Biesheuvel's avatar
      crypto: ecdh - fix big endian bug in ECC library · e4895f5e
      Ard Biesheuvel authored
      commit f398243e upstream.
      
      The elliptic curve arithmetic library used by the EC-DH KPP implementation
      assumes big endian byte order, and unconditionally reverses the byte
      and word order of multi-limb quantities. On big endian systems, the byte
      reordering is not necessary, while the word ordering needs to be retained.
      
      So replace the __swab64() invocation with a call to be64_to_cpu() which
      should do the right thing for both little and big endian builds.
      
      Fixes: 3c4b2390 ("crypto: ecdh - Add ECDH software support")
      Cc: <stable@vger.kernel.org> # v4.9+
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4895f5e
    • Mark Salter's avatar
      crypto: ccp - fix uninitialized list head · d63fe94b
      Mark Salter authored
      commit 691505a8 upstream.
      
      A NULL-pointer dereference was reported in fedora bz#1762199 while
      reshaping a raid6 array after adding a fifth drive to an existing
      array.
      
      [   47.343549] md/raid:md0: raid level 6 active with 3 out of 5 devices, algorithm 2
      [   47.804017] md0: detected capacity change from 0 to 7885289422848
      [   47.822083] Unable to handle kernel read from unreadable memory at virtual address 0000000000000000
      ...
      [   47.940477] CPU: 1 PID: 14210 Comm: md0_raid6 Tainted: G        W         5.2.18-200.fc30.aarch64 #1
      [   47.949594] Hardware name: AMD Overdrive/Supercharger/To be filled by O.E.M., BIOS ROD1002C 04/08/2016
      [   47.958886] pstate: 00400085 (nzcv daIf +PAN -UAO)
      [   47.963668] pc : __list_del_entry_valid+0x2c/0xa8
      [   47.968366] lr : ccp_tx_submit+0x84/0x168 [ccp]
      [   47.972882] sp : ffff00001369b970
      [   47.976184] x29: ffff00001369b970 x28: ffff00001369bdb8
      [   47.981483] x27: 00000000ffffffff x26: ffff8003b758af70
      [   47.986782] x25: ffff8003b758b2d8 x24: ffff8003e6245818
      [   47.992080] x23: 0000000000000000 x22: ffff8003e62450c0
      [   47.997379] x21: ffff8003dfd6add8 x20: 0000000000000003
      [   48.002678] x19: ffff8003e6245100 x18: 0000000000000000
      [   48.007976] x17: 0000000000000000 x16: 0000000000000000
      [   48.013274] x15: 0000000000000000 x14: 0000000000000000
      [   48.018572] x13: ffff7e000ef83a00 x12: 0000000000000001
      [   48.023870] x11: ffff000010eff998 x10: 00000000000019a0
      [   48.029169] x9 : 0000000000000000 x8 : ffff8003e6245180
      [   48.034467] x7 : 0000000000000000 x6 : 000000000000003f
      [   48.039766] x5 : 0000000000000040 x4 : ffff8003e0145080
      [   48.045064] x3 : dead000000000200 x2 : 0000000000000000
      [   48.050362] x1 : 0000000000000000 x0 : ffff8003e62450c0
      [   48.055660] Call trace:
      [   48.058095]  __list_del_entry_valid+0x2c/0xa8
      [   48.062442]  ccp_tx_submit+0x84/0x168 [ccp]
      [   48.066615]  async_tx_submit+0x224/0x368 [async_tx]
      [   48.071480]  async_trigger_callback+0x68/0xfc [async_tx]
      [   48.076784]  ops_run_biofill+0x178/0x1e8 [raid456]
      [   48.081566]  raid_run_ops+0x248/0x818 [raid456]
      [   48.086086]  handle_stripe+0x864/0x1208 [raid456]
      [   48.090781]  handle_active_stripes.isra.0+0xb0/0x278 [raid456]
      [   48.096604]  raid5d+0x378/0x618 [raid456]
      [   48.100602]  md_thread+0xa0/0x150
      [   48.103905]  kthread+0x104/0x130
      [   48.107122]  ret_from_fork+0x10/0x18
      [   48.110686] Code: d2804003 f2fbd5a3 eb03003f 54000320 (f9400021)
      [   48.116766] ---[ end trace 23f390a527f7ad77 ]---
      
      ccp_tx_submit is passed a dma_async_tx_descriptor which is contained in
      a ccp_dma_desc and adds it to a ccp channel's pending list:
      
      	list_del(&desc->entry);
      	list_add_tail(&desc->entry, &chan->pending);
      
      The problem is that desc->entry may be uninitialized in the
      async_trigger_callback path where the descriptor was gotten
      from ccp_prep_dma_interrupt which got it from ccp_alloc_dma_desc
      which doesn't initialize the desc->entry list head. So, just
      initialize the list head to avoid the problem.
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarSahaj Sarup <sahajsarup@gmail.com>
      Signed-off-by: default avatarMark Salter <msalter@redhat.com>
      Acked-by: default avatarGary R Hook <gary.hook@amd.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d63fe94b