1. 13 Nov, 2018 40 commits
    • Breno Leitao's avatar
      HID: hiddev: fix potential Spectre v1 · dd0ee8a4
      Breno Leitao authored
      commit f1127439 upstream.
      
      uref->usage_index can be indirectly controlled by userspace, hence leading
      to a potential exploitation of the Spectre variant 1 vulnerability.
      
      This field is used as an array index by the hiddev_ioctl_usage() function,
      when 'cmd' is either HIDIOCGCOLLECTIONINDEX, HIDIOCGUSAGES or
      HIDIOCSUSAGES.
      
      For cmd == HIDIOCGCOLLECTIONINDEX case, uref->usage_index is compared to
      field->maxusage and then used as an index to dereference field->usage
      array. The same thing happens to the cmd == HIDIOC{G,S}USAGES cases, where
      uref->usage_index is checked against an array maximum value and then it is
      used as an index in an array.
      
      This is a summary of the HIDIOCGCOLLECTIONINDEX case, which matches the
      traditional Spectre V1 first load:
      
      	copy_from_user(uref, user_arg, sizeof(*uref))
      	if (uref->usage_index >= field->maxusage)
      		goto inval;
      	i = field->usage[uref->usage_index].collection_index;
      	return i;
      
      This patch fixes this by sanitizing field uref->usage_index before using it
      to index field->usage (HIDIOCGCOLLECTIONINDEX) or field->value in
      HIDIOC{G,S}USAGES arrays, thus, avoiding speculation in the first load.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarBreno Leitao <leitao@debian.org>
      v2: Contemplate cmd == HIDIOC{G,S}USAGES case
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd0ee8a4
    • Wang Shilong's avatar
      ext4: propagate error from dquot_initialize() in EXT4_IOC_FSSETXATTR · 8e30869f
      Wang Shilong authored
      commit 182a79e0 upstream.
      
      We return most failure of dquota_initialize() except
      inode evict, this could make a bit sense, for example
      we allow file removal even quota files are broken?
      
      But it dosen't make sense to allow setting project
      if quota files etc are broken.
      Signed-off-by: default avatarWang Shilong <wshilong@ddn.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e30869f
    • Lukas Czerner's avatar
      ext4: initialize retries variable in ext4_da_write_inline_data_begin() · 4c196200
      Lukas Czerner authored
      commit 625ef8a3 upstream.
      
      Variable retries is not initialized in ext4_da_write_inline_data_begin()
      which can lead to nondeterministic number of retries in case we hit
      ENOSPC. Initialize retries to zero as we do everywhere else.
      Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Fixes: bc0ca9df ("ext4: retry allocation when inline->extent conversion failed")
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c196200
    • Al Viro's avatar
      gfs2_meta: ->mount() can get NULL dev_name · 4b347ab6
      Al Viro authored
      commit 3df629d8 upstream.
      
      get in sync with mount_bdev() handling of the same
      
      Reported-by: syzbot+c54f8e94e6bba03b04e9@syzkaller.appspotmail.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4b347ab6
    • Jan Kara's avatar
      jbd2: fix use after free in jbd2_log_do_checkpoint() · 2613e759
      Jan Kara authored
      commit ccd3c437 upstream.
      
      The code cleaning transaction's lists of checkpoint buffers has a bug
      where it increases bh refcount only after releasing
      journal->j_list_lock. Thus the following race is possible:
      
      CPU0					CPU1
      jbd2_log_do_checkpoint()
      					jbd2_journal_try_to_free_buffers()
      					  __journal_try_to_free_buffer(bh)
        ...
        while (transaction->t_checkpoint_io_list)
        ...
          if (buffer_locked(bh)) {
      
      <-- IO completes now, buffer gets unlocked -->
      
            spin_unlock(&journal->j_list_lock);
      					    spin_lock(&journal->j_list_lock);
      					    __jbd2_journal_remove_checkpoint(jh);
      					    spin_unlock(&journal->j_list_lock);
      					  try_to_free_buffers(page);
            get_bh(bh) <-- accesses freed bh
      
      Fix the problem by grabbing bh reference before unlocking
      journal->j_list_lock.
      
      Fixes: dc6e8d66 ("jbd2: don't call get_bh() before calling __jbd2_journal_remove_checkpoint()")
      Fixes: be1158cc ("jbd2: fold __process_buffer() into jbd2_log_do_checkpoint()")
      Reported-by: syzbot+7f4a27091759e2fe7453@syzkaller.appspotmail.com
      CC: stable@vger.kernel.org
      Reviewed-by: default avatarLukas Czerner <lczerner@redhat.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2613e759
    • Takashi Iwai's avatar
      ASoC: intel: skylake: Add missing break in skl_tplg_get_token() · b85c6659
      Takashi Iwai authored
      commit 9c80c5a8 upstream.
      
      skl_tplg_get_token() misses a break in the big switch() block for
      SKL_TKN_U8_CORE_ID entry.
      Spotted nicely by -Wimplicit-fallthrough compiler option.
      
      Fixes: 6277e832 ("ASoC: Intel: Skylake: Parse vendor tokens to build module data")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b85c6659
    • Alexander Duyck's avatar
      libnvdimm: Hold reference on parent while scheduling async init · 3e63a7f2
      Alexander Duyck authored
      commit b6eae0f6 upstream.
      
      Unlike asynchronous initialization in the core we have not yet associated
      the device with the parent, and as such the device doesn't hold a reference
      to the parent.
      
      In order to resolve that we should be holding a reference on the parent
      until the asynchronous initialization has completed.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 4d88a97a ("libnvdimm: ...base ... infrastructure")
      Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e63a7f2
    • Stefan Nuernberger's avatar
      net/ipv4: defensive cipso option parsing · b6b45bc4
      Stefan Nuernberger authored
      commit 076ed3da upstream.
      
      commit 40413955 ("Cipso: cipso_v4_optptr enter infinite loop") fixed
      a possible infinite loop in the IP option parsing of CIPSO. The fix
      assumes that ip_options_compile filtered out all zero length options and
      that no other one-byte options beside IPOPT_END and IPOPT_NOOP exist.
      While this assumption currently holds true, add explicit checks for zero
      length and invalid length options to be safe for the future. Even though
      ip_options_compile should have validated the options, the introduction of
      new one-byte options can still confuse this code without the additional
      checks.
      Signed-off-by: default avatarStefan Nuernberger <snu@amazon.com>
      Cc: David Woodhouse <dwmw@amazon.co.uk>
      Cc: Simon Veith <sveith@amazon.de>
      Cc: stable@vger.kernel.org
      Acked-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6b45bc4
    • Luca Coelho's avatar
      iwlwifi: mvm: check return value of rs_rate_from_ucode_rate() · 4579824b
      Luca Coelho authored
      commit 3d71c3f1 upstream.
      
      The rs_rate_from_ucode_rate() function may return -EINVAL if the rate
      is invalid, but none of the callsites check for the error, potentially
      making us access arrays with index IWL_RATE_INVALID, which is larger
      than the arrays, causing an out-of-bounds access.  This will trigger
      KASAN warnings, such as the one reported in the bugzilla issue
      mentioned below.
      
      This fixes https://bugzilla.kernel.org/show_bug.cgi?id=200659
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4579824b
    • Shuah Khan (Samsung OSG)'s avatar
      usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten · 37ef739a
      Shuah Khan (Samsung OSG) authored
      commit e28fd56a upstream.
      
      In rmmod path, usbip_vudc does platform_device_put() twice once from
      platform_device_unregister() and then from put_vudc_device().
      
      The second put results in:
      
      BUG kmalloc-2048 (Not tainted): Poison overwritten error or
      BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
      enabled.
      
      [  169.042156] calling  init+0x0/0x1000 [usbip_vudc] @ 1697
      [  169.042396] =============================================================================
      [  169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs
      [  169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten
      [  169.044509] -----------------------------------------------------------------------------
      ...
      [  169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693
      [  169.057852] 	kobject_put+0x86/0x1b0
      [  169.057853] 	0xffffffffc0c30a96
      [  169.057855] 	__x64_sys_delete_module+0x157/0x240
      
      Fix it to call platform_device_del() instead and let put_vudc_device() do
      the platform_device_put().
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37ef739a
    • Lubomir Rintel's avatar
      libertas: don't set URB_ZERO_PACKET on IN USB transfer · 8eca5196
      Lubomir Rintel authored
      commit 6528d880 upstream.
      
      The USB core gets rightfully upset:
      
        usb 1-1: BOGUS urb flags, 240 --> 200
        WARNING: CPU: 0 PID: 60 at drivers/usb/core/urb.c:503 usb_submit_urb+0x2f8/0x3ed
        Modules linked in:
        CPU: 0 PID: 60 Comm: kworker/0:3 Not tainted 4.19.0-rc6-00319-g5206d00a45c7 #39
        Hardware name: OLPC XO/XO, BIOS OLPC Ver 1.00.01 06/11/2014
        Workqueue: events request_firmware_work_func
        EIP: usb_submit_urb+0x2f8/0x3ed
        Code: 75 06 8b 8f 80 00 00 00 8d 47 78 89 4d e4 89 55 e8 e8 35 1c f6 ff 8b 55 e8 56 52 8b 4d e4 51 50 68 e3 ce c7 c0 e8 ed 18 c6 ff <0f> 0b 83 c4 14 80 7d ef 01 74 0a 80 7d ef 03 0f 85 b8 00 00 00 8b
        EAX: 00000025 EBX: ce7d4980 ECX: 00000000 EDX: 00000001
        ESI: 00000200 EDI: ce7d8800 EBP: ce7f5ea8 ESP: ce7f5e70
        DS: 007b ES: 007b FS: 0000 GS: 00e0 SS: 0068 EFLAGS: 00210292
        CR0: 80050033 CR2: 00000000 CR3: 00e80000 CR4: 00000090
        Call Trace:
         ? if_usb_fw_timeo+0x64/0x64
         __if_usb_submit_rx_urb+0x85/0xe6
         ? if_usb_fw_timeo+0x64/0x64
         if_usb_submit_rx_urb_fwload+0xd/0xf
         if_usb_prog_firmware+0xc0/0x3db
         ? _request_firmware+0x54/0x47b
         ? _request_firmware+0x89/0x47b
         ? if_usb_probe+0x412/0x412
         lbs_fw_loaded+0x55/0xa6
         ? debug_smp_processor_id+0x12/0x14
         helper_firmware_cb+0x3c/0x3f
         request_firmware_work_func+0x37/0x6f
         process_one_work+0x164/0x25a
         worker_thread+0x1c4/0x284
         kthread+0xec/0xf1
         ? cancel_delayed_work_sync+0xf/0xf
         ? kthread_create_on_node+0x1a/0x1a
         ret_from_fork+0x2e/0x38
        ---[ end trace 3ef1e3b2dd53852f ]---
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLubomir Rintel <lkundrak@v3.sk>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8eca5196
    • Juergen Gross's avatar
      xen: make xen_qlock_wait() nestable · 00893f46
      Juergen Gross authored
      commit a8565319 upstream.
      
      xen_qlock_wait() isn't safe for nested calls due to interrupts. A call
      of xen_qlock_kick() might be ignored in case a deeper nesting level
      was active right before the call of xen_poll_irq():
      
      CPU 1:                                   CPU 2:
      spin_lock(lock1)
                                               spin_lock(lock1)
                                               -> xen_qlock_wait()
                                                  -> xen_clear_irq_pending()
                                                  Interrupt happens
      spin_unlock(lock1)
      -> xen_qlock_kick(CPU 2)
      spin_lock_irqsave(lock2)
                                               spin_lock_irqsave(lock2)
                                               -> xen_qlock_wait()
                                                  -> xen_clear_irq_pending()
                                                     clears kick for lock1
                                                  -> xen_poll_irq()
      spin_unlock_irq_restore(lock2)
      -> xen_qlock_kick(CPU 2)
                                                  wakes up
                                               spin_unlock_irq_restore(lock2)
                                               IRET
                                                 resumes in xen_qlock_wait()
                                                 -> xen_poll_irq()
                                                 never wakes up
      
      The solution is to disable interrupts in xen_qlock_wait() and not to
      poll for the irq in case xen_qlock_wait() is called in nmi context.
      
      Cc: stable@vger.kernel.org
      Cc: Waiman.Long@hp.com
      Cc: peterz@infradead.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00893f46
    • Juergen Gross's avatar
      xen: fix race in xen_qlock_wait() · 95f5d10f
      Juergen Gross authored
      commit 2ac2a7d4 upstream.
      
      In the following situation a vcpu waiting for a lock might not be
      woken up from xen_poll_irq():
      
      CPU 1:                CPU 2:                      CPU 3:
      takes a spinlock
                            tries to get lock
                            -> xen_qlock_wait()
      frees the lock
      -> xen_qlock_kick(cpu2)
                              -> xen_clear_irq_pending()
      
      takes lock again
                                                        tries to get lock
                                                        -> *lock = _Q_SLOW_VAL
                              -> *lock == _Q_SLOW_VAL ?
                              -> xen_poll_irq()
      frees the lock
      -> xen_qlock_kick(cpu3)
      
      And cpu 2 will sleep forever.
      
      This can be avoided easily by modifying xen_qlock_wait() to call
      xen_poll_irq() only if the related irq was not pending and to call
      xen_clear_irq_pending() only if it was pending.
      
      Cc: stable@vger.kernel.org
      Cc: Waiman.Long@hp.com
      Cc: peterz@infradead.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarJan Beulich <jbeulich@suse.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95f5d10f
    • Vasilis Liaskovitis's avatar
      xen/blkfront: avoid NULL blkfront_info dereference on device removal · c29b0cc6
      Vasilis Liaskovitis authored
      commit f92898e7 upstream.
      
      If a block device is hot-added when we are out of grants,
      gnttab_grant_foreign_access fails with -ENOSPC (log message "28
      granting access to ring page") in this code path:
      
        talk_to_blkback ->
      	setup_blkring ->
      		xenbus_grant_ring ->
      			gnttab_grant_foreign_access
      
      and the failing path in talk_to_blkback sets the driver_data to NULL:
      
       destroy_blkring:
              blkif_free(info, 0);
      
              mutex_lock(&blkfront_mutex);
              free_info(info);
              mutex_unlock(&blkfront_mutex);
      
              dev_set_drvdata(&dev->dev, NULL);
      
      This results in a NULL pointer BUG when blkfront_remove and blkif_free
      try to access the failing device's NULL struct blkfront_info.
      
      Cc: stable@vger.kernel.org # 4.5 and later
      Signed-off-by: default avatarVasilis Liaskovitis <vliaskovitis@suse.com>
      Reviewed-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c29b0cc6
    • Dr. Greg Wettstein's avatar
      tpm: Restore functionality to xen vtpm driver. · 5a5bc211
      Dr. Greg Wettstein authored
      commit e487a0f5 upstream.
      
      Functionality of the xen-tpmfront driver was lost secondary to
      the introduction of xenbus multi-page support in commit ccc9d90a
      ("xenbus_client: Extend interface to support multi-page ring").
      
      In this commit pointer to location of where the shared page address
      is stored was being passed to the xenbus_grant_ring() function rather
      then the address of the shared page itself. This resulted in a situation
      where the driver would attach to the vtpm-stubdom but any attempt
      to send a command to the stub domain would timeout.
      
      A diagnostic finding for this regression is the following error
      message being generated when the xen-tpmfront driver probes for a
      device:
      
      <3>vtpm vtpm-0: tpm_transmit: tpm_send: error -62
      
      <3>vtpm vtpm-0: A TPM error (-62) occurred attempting to determine
      the timeouts
      
      This fix is relevant to all kernels from 4.1 forward which is the
      release in which multi-page xenbus support was introduced.
      
      Daniel De Graaf formulated the fix by code inspection after the
      regression point was located.
      
      Fixes: ccc9d90a ("xenbus_client: Extend interface to support multi-page ring")
      Signed-off-by: default avatarDr. Greg Wettstein <greg@enjellic.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      [boris: Updated commit message, added Fixes tag]
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: stable@vger.kernel.org # v4.1+
      Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      5a5bc211
    • Joe Jin's avatar
      xen-swiotlb: use actually allocated size on check physical continuous · 9b4cb632
      Joe Jin authored
      commit 7250f422 upstream.
      
      xen_swiotlb_{alloc,free}_coherent() allocate/free memory based on the
      order of the pages and not size argument (bytes). This is inconsistent with
      range_straddles_page_boundary and memset which use the 'size' value,
      which may lead to not exchanging memory with Xen (range_straddles_page_boundary()
      returned true). And then the call to xen_swiotlb_free_coherent() would
      actually try to exchange the memory with Xen, leading to the kernel
      hitting an BUG (as the hypercall returned an error).
      
      This patch fixes it by making the 'size' variable be of the same size
      as the amount of memory allocated.
      
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarJoe Jin <joe.jin@oracle.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Christoph Helwig <hch@lst.de>
      Cc: Dongli Zhang <dongli.zhang@oracle.com>
      Cc: John Sobecki <john.sobecki@oracle.com>
      Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b4cb632
    • Marek Szyprowski's avatar
      ARM: dts: exynos: Mark 1 GHz CPU OPP as suspend OPP on Exynos5250 · add34b86
      Marek Szyprowski authored
      commit 645b23da upstream.
      
      1 GHz CPU OPP is the default boot value for the Exynos5250 SOC, so mark it
      as suspend OPP. This fixes suspend/resume on Samsung Exynos5250 Snow
      Chomebook, which was broken since switching to generic cpufreq-dt driver
      in v4.3.
      
      Cc: <stable@vger.kernel.org> # 4.3.x: cd6f5545: ARM: dts: exynos: Remove "cooling-{min|max}-level" for CPU nodes
      Cc: <stable@vger.kernel.org> # 4.3.x: 672f3319: arm: dts: exynos: Add missing cooling device properties for CPUs
      Cc: <stable@vger.kernel.org> # 4.3.x
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Acked-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      add34b86
    • Marek Szyprowski's avatar
      ARM: dts: exynos: Convert exynos5250.dtsi to opp-v2 bindings · 0c0996cd
      Marek Szyprowski authored
      commit eb9e16d8 upstream.
      
      Convert Exynos5250 to OPP-v2 bindings. This is a preparation to add proper
      support for suspend operation point, which cannot be marked in opp-v1.
      
      Cc: <stable@vger.kernel.org> # 4.3.x: cd6f5545: ARM: dts: exynos: Remove "cooling-{min|max}-level" for CPU nodes
      Cc: <stable@vger.kernel.org> # 4.3.x: 672f3319: arm: dts: exynos: Add missing cooling device properties for CPUs
      Cc: <stable@vger.kernel.org> # 4.3.x
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Acked-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c0996cd
    • Viresh Kumar's avatar
      arm: dts: exynos: Add missing cooling device properties for CPUs · 744ed1c1
      Viresh Kumar authored
      commit 672f3319 upstream.
      
      The cooling device properties, like "#cooling-cells" and
      "dynamic-power-coefficient", should either be present for all the CPUs
      of a cluster or none. If these are present only for a subset of CPUs of
      a cluster then things will start falling apart as soon as the CPUs are
      brought online in a different order. For example, this will happen
      because the operating system looks for such properties in the CPU node
      it is trying to bring up, so that it can register a cooling device.
      
      Add such missing properties.
      
      Fix other missing properties (clocks, OPP, clock latency) as well to
      make it all work.
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      744ed1c1
    • Viresh Kumar's avatar
      ARM: dts: exynos: Remove "cooling-{min|max}-level" for CPU nodes · b5c33c25
      Viresh Kumar authored
      commit cd6f5545 upstream.
      
      The "cooling-min-level" and "cooling-max-level" properties are not
      parsed by any part of the kernel currently and the max cooling state of
      a CPU cooling device is found by referring to the cpufreq table instead.
      
      Remove the unused properties from the CPU nodes.
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5c33c25
    • Takashi Iwai's avatar
      ALSA: hda: Check the non-cached stream buffers more explicitly · 430c6345
      Takashi Iwai authored
      [ Upstream commit 78c9be61 ]
      
      Introduce a new flag, uc_buffer, to indicate that the controller
      requires the non-cached pages for stream buffers, either as a
      chip-specific requirement or specified via snoop=0 option.
      This improves the code-readability.
      
      Also, this patch fixes the incorrect behavior for C-Media chip where
      the stream buffers were never handled as non-cached due to the check
      of driver_type even if you pass snoop=0 option.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      430c6345
    • Paul Cercueil's avatar
      dmaengine: dma-jz4780: Return error if not probed from DT · e0362b43
      Paul Cercueil authored
      [ Upstream commit 54f919a0 ]
      
      The driver calls clk_get() with the clock name set to NULL, which means
      that the driver could only work when probed from devicetree. From now
      on, we explicitly require the driver to be probed from devicetree.
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Tested-by: default avatarMathieu Malaterre <malat@debian.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0362b43
    • Eric W. Biederman's avatar
      signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init · ba277fec
      Eric W. Biederman authored
      [ Upstream commit 3597dfe0 ]
      
      Instead of playing whack-a-mole and changing SEND_SIG_PRIV to
      SEND_SIG_FORCED throughout the kernel to ensure a pid namespace init
      gets signals sent by the kernel, stop allowing a pid namespace init to
      ignore SIGKILL or SIGSTOP sent by the kernel.  A pid namespace init is
      only supposed to be able to ignore signals sent from itself and
      children with SIG_DFL.
      
      Fixes: 921cf9f6 ("signals: protect cinit from unblocked SIG_DFL signals")
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba277fec
    • James Smart's avatar
      scsi: lpfc: Correct soft lockup when running mds diagnostics · 93feaa02
      James Smart authored
      [ Upstream commit 0ef01a2d ]
      
      When running an mds diagnostic that passes frames with the switch, soft
      lockups are detected. The driver is in a CQE processing loop and has
      sufficient amount of traffic that it never exits the ring processing routine,
      thus the "lockup".
      
      Cap the number of elements in the work processing routine to 64 elements. This
      ensures that the cpu will be given up and the handler reschedule to process
      additional items.
      Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
      Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93feaa02
    • Alexandre Belloni's avatar
      uio: ensure class is registered before devices · e2274c76
      Alexandre Belloni authored
      [ Upstream commit ae61cf5b ]
      
      When both uio and the uio drivers are built in the kernel, it is possible
      for a driver to register devices before the uio class is registered.
      
      This may result in a NULL pointer dereference later on in
      get_device_parent() when accessing the class glue_dirs spinlock.
      
      The trace looks like that:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000140
      [...]
      [<ffff0000089cc234>] _raw_spin_lock+0x14/0x48
      [<ffff0000084f56bc>] device_add+0x154/0x6a0
      [<ffff0000084f5e48>] device_create_groups_vargs+0x120/0x128
      [<ffff0000084f5edc>] device_create+0x54/0x60
      [<ffff0000086e72c0>] __uio_register_device+0x120/0x4a8
      [<ffff000008528b7c>] jaguar2_pci_probe+0x2d4/0x558
      [<ffff0000083fc18c>] local_pci_probe+0x3c/0xb8
      [<ffff0000083fd81c>] pci_device_probe+0x11c/0x180
      [<ffff0000084f88bc>] driver_probe_device+0x22c/0x2d8
      [<ffff0000084f8a24>] __driver_attach+0xbc/0xc0
      [<ffff0000084f69fc>] bus_for_each_dev+0x4c/0x98
      [<ffff0000084f81b8>] driver_attach+0x20/0x28
      [<ffff0000084f7d08>] bus_add_driver+0x1b8/0x228
      [<ffff0000084f93c0>] driver_register+0x60/0xf8
      [<ffff0000083fb918>] __pci_register_driver+0x40/0x48
      
      Return EPROBE_DEFER in that case so the driver can register the device
      later.
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2274c76
    • Waiman Long's avatar
      driver/dma/ioat: Call del_timer_sync() without holding prep_lock · 479cd3e8
      Waiman Long authored
      [ Upstream commit cfb03be6 ]
      
      The following lockdep splat was observed:
      
      [ 1222.241750] ======================================================
      [ 1222.271301] WARNING: possible circular locking dependency detected
      [ 1222.301060] 4.16.0-10.el8+5.x86_64+debug #1 Not tainted
      [ 1222.326659] ------------------------------------------------------
      [ 1222.356565] systemd-shutdow/1 is trying to acquire lock:
      [ 1222.382660]  ((&ioat_chan->timer)){+.-.}, at: [<00000000f71e1a28>] del_timer_sync+0x5/0xf0
      [ 1222.422928]
      [ 1222.422928] but task is already holding lock:
      [ 1222.451743]  (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]
         :
      [ 1223.524987] Chain exists of:
      [ 1223.524987]   (&ioat_chan->timer) --> &(&ioat_chan->cleanup_lock)->rlock --> &(&ioat_chan->prep_lock)->rlock
      [ 1223.524987]
      [ 1223.594082]  Possible unsafe locking scenario:
      [ 1223.594082]
      [ 1223.622630]        CPU0                    CPU1
      [ 1223.645080]        ----                    ----
      [ 1223.667404]   lock(&(&ioat_chan->prep_lock)->rlock);
      [ 1223.691535]                                lock(&(&ioat_chan->cleanup_lock)->rlock);
      [ 1223.728657]                                lock(&(&ioat_chan->prep_lock)->rlock);
      [ 1223.765122]   lock((&ioat_chan->timer));
      [ 1223.784095]
      [ 1223.784095]  *** DEADLOCK ***
      [ 1223.784095]
      [ 1223.813492] 4 locks held by systemd-shutdow/1:
      [ 1223.834677]  #0:  (reboot_mutex){+.+.}, at: [<0000000056d33456>] SYSC_reboot+0x10f/0x300
      [ 1223.873310]  #1:  (&dev->mutex){....}, at: [<00000000258dfdd7>] device_shutdown+0x1c8/0x660
      [ 1223.913604]  #2:  (&dev->mutex){....}, at: [<0000000068331147>] device_shutdown+0x1d6/0x660
      [ 1223.954000]  #3:  (&(&ioat_chan->prep_lock)->rlock){+.-.}, at: [<000000008ea98b12>] ioat_shutdown+0x86/0x100 [ioatdma]
      
      In the ioat_shutdown() function:
      
      	spin_lock_bh(&ioat_chan->prep_lock);
      	set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
      	del_timer_sync(&ioat_chan->timer);
      	spin_unlock_bh(&ioat_chan->prep_lock);
      
      According to the synchronization rule for the del_timer_sync() function,
      the caller must not hold locks which would prevent completion of the
      timer's handler.
      
      The timer structure has its own lock that manages its synchronization.
      Setting the IOAT_CHAN_DOWN bit should prevent other CPUs from
      trying to use that device anyway, there is probably no need to call
      del_timer_sync() while holding the prep_lock. So the del_timer_sync()
      call is now moved outside of the prep_lock critical section to prevent
      the circular lock dependency.
      Signed-off-by: default avatarWaiman Long <longman@redhat.com>
      Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      479cd3e8
    • Loic Poulain's avatar
      usb: chipidea: Prevent unbalanced IRQ disable · ae893bc6
      Loic Poulain authored
      [ Upstream commit 8b97d73c ]
      
      The ChipIdea IRQ is disabled before scheduling the otg work and
      re-enabled on otg work completion. However if the job is already
      scheduled we have to undo the effect of disable_irq int order to
      balance the IRQ disable-depth value.
      
      Fixes: be6b0c1b ("usb: chipidea: using one inline function to cover queue work operations")
      Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ae893bc6
    • Horia Geantă's avatar
      crypto: caam - fix implicit casts in endianness helpers · ffa426d6
      Horia Geantă authored
      [ Upstream commit aae733a3 ]
      
      Fix the following sparse endianness warnings:
      
      drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@    expected unsigned int @@    got restricted __le32unsigned int @@
      drivers/crypto/caam/regs.h:95:1:    expected unsigned int
      drivers/crypto/caam/regs.h:95:1:    got restricted __le32 [usertype] <noident>
      drivers/crypto/caam/regs.h:95:1: sparse: incorrect type in return expression (different base types) @@    expected unsigned int @@    got restricted __be32unsigned int @@
      drivers/crypto/caam/regs.h:95:1:    expected unsigned int
      drivers/crypto/caam/regs.h:95:1:    got restricted __be32 [usertype] <noident>
      
      drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __le32
      drivers/crypto/caam/regs.h:92:1: sparse: cast to restricted __be32
      
      Fixes: 261ea058 ("crypto: caam - handle core endianness != caam endianness")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffa426d6
    • Suzuki K Poulose's avatar
      coresight: etb10: Fix handling of perf mode · 2048b787
      Suzuki K Poulose authored
      [ Upstream commit 987d1e8d ]
      
      If the ETB is already enabled in sysfs mode, the ETB reports
      success even if a perf mode is requested. Fix this by checking
      the requested mode.
      
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2048b787
    • Tonghao Zhang's avatar
      PCI/MSI: Warn and return error if driver enables MSI/MSI-X twice · a8433138
      Tonghao Zhang authored
      [ Upstream commit 4c1ef72e ]
      
      It is a serious driver defect to enable MSI or MSI-X more than once.  Doing
      so may panic the kernel as in the stack trace below:
      
        Call Trace:
          sysfs_add_one+0xa5/0xd0
          create_dir+0x7c/0xe0
          sysfs_create_subdir+0x1c/0x20
          internal_create_group+0x6d/0x290
          sysfs_create_groups+0x4a/0xa0
          populate_msi_sysfs+0x1cd/0x210
          pci_enable_msix+0x31c/0x3e0
          igbuio_pci_open+0x72/0x300 [igb_uio]
          uio_open+0xcc/0x120 [uio]
          chrdev_open+0xa1/0x1e0
          [...]
          do_sys_open+0xf3/0x1f0
          SyS_open+0x1e/0x20
          system_call_fastpath+0x16/0x1b
          ---[ end trace 11042e2848880209 ]---
          Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffffa056b4fa
      
      We want to keep the WARN_ON() and stack trace so the driver can be fixed,
      but we can avoid the kernel panic by returning an error.  We may still get
      warnings like this:
      
        Call Trace:
          pci_enable_msix+0x3c9/0x3e0
          igbuio_pci_open+0x72/0x300 [igb_uio]
          uio_open+0xcc/0x120 [uio]
          chrdev_open+0xa1/0x1e0
          [...]
          do_sys_open+0xf3/0x1f0
          SyS_open+0x1e/0x20
          system_call_fastpath+0x16/0x1b
          ------------[ cut here ]------------
          WARNING: at fs/sysfs/dir.c:526 sysfs_add_one+0xa5/0xd0()
          sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:03.0/0000:01:00.1/msi_irqs'
      Signed-off-by: default avatarTonghao Zhang <xiangxia.m.yue@gmail.com>
      [bhelgaas: changelog, fix patch whitespace, remove !!]
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8433138
    • Shaohua Li's avatar
      MD: fix invalid stored role for a disk · 4e1fabdd
      Shaohua Li authored
      [ Upstream commit d595567d ]
      
      If we change the number of array's device after device is removed from array,
      then add the device back to array, we can see that device is added as active
      role instead of spare which we expected.
      
      Please see the below link for details:
      https://marc.info/?l=linux-raid&m=153736982015076&w=2
      
      This is caused by that we prefer to use device's previous role which is
      recorded by saved_raid_disk, but we should respect the new number of
      conf->raid_disks since it could be changed after device is removed.
      Reported-by: default avatarGioh Kim <gi-oh.kim@profitbricks.com>
      Tested-by: default avatarGioh Kim <gi-oh.kim@profitbricks.com>
      Acked-by: default avatarGuoqing Jiang <gqjiang@suse.com>
      Signed-off-by: default avatarShaohua Li <shli@fb.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e1fabdd
    • Theodore Ts'o's avatar
      ext4: fix argument checking in EXT4_IOC_MOVE_EXT · 44760d8a
      Theodore Ts'o authored
      [ Upstream commit f18b2b83 ]
      
      If the starting block number of either the source or destination file
      exceeds the EOF, EXT4_IOC_MOVE_EXT should return EINVAL.
      
      Also fixed the helper function mext_check_coverage() so that if the
      logical block is beyond EOF, make it return immediately, instead of
      looping until the block number wraps all the away around.  This takes
      long enough that if there are multiple threads trying to do pound on
      an the same inode doing non-sensical things, it can end up triggering
      the kernel's soft lockup detector.
      
      Reported-by: syzbot+c61979f6f2cba5cb3c06@syzkaller.appspotmail.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44760d8a
    • Alexandre Belloni's avatar
      usb: gadget: udc: atmel: handle at91sam9rl PMC · e9f5a3d1
      Alexandre Belloni authored
      [ Upstream commit bb80e4fa ]
      
      The at91sam9rl PMC is not quite the same as the at91sam9g45 one and now has
      its own compatible string. Add support for that.
      
      Fixes: 217bace8e548 ("ARM: dts: fix PMC compatible")
      Acked-by: default avatarCristian Birsan <cristian.birsan@microchip.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9f5a3d1
    • Jorgen Hansen's avatar
      VMCI: Resource wildcard match fixed · 2b049a3b
      Jorgen Hansen authored
      [ Upstream commit 11924ba5 ]
      
      When adding a VMCI resource, the check for an existing entry
      would ignore that the new entry could be a wildcard. This could
      result in multiple resource entries that would match a given
      handle. One disastrous outcome of this is that the
      refcounting used to ensure that delayed callbacks for VMCI
      datagrams have run before the datagram is destroyed can be
      wrong, since the refcount could be increased on the duplicate
      entry. This in turn leads to a use after free bug. This issue
      was discovered by Hangbin Liu using KASAN and syzkaller.
      
      Fixes: bc63dedb ("VMCI: resource object implementation")
      Reported-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Reviewed-by: default avatarAdit Ranadive <aditr@vmware.com>
      Reviewed-by: default avatarVishnu Dasa <vdasa@vmware.com>
      Signed-off-by: default avatarJorgen Hansen <jhansen@vmware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b049a3b
    • Javier Martinez Canillas's avatar
      tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated · e269ca18
      Javier Martinez Canillas authored
      [ Upstream commit 0d6d0d62 ]
      
      For TPM 1.2 chips the system setup utility allows to set the TPM device in
      one of the following states:
      
        * Active: Security chip is functional
        * Inactive: Security chip is visible, but is not functional
        * Disabled: Security chip is hidden and is not functional
      
      When choosing the "Inactive" state, the TPM 1.2 device is enumerated and
      registered, but sending TPM commands fail with either TPM_DEACTIVATED or
      TPM_DISABLED depending if the firmware deactivated or disabled the TPM.
      
      Since these TPM 1.2 error codes don't have special treatment, inactivating
      the TPM leads to a very noisy kernel log buffer that shows messages like
      the following:
      
        tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78)
        tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
        tpm tpm0: TPM is disabled/deactivated (0x6)
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting to read a pcr value
        ima: No TPM chip found, activating TPM-bypass! (rc=6)
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
        tpm tpm0: A TPM error (6) occurred attempting get random
      
      Let's just suppress error log messages for the TPM_{DEACTIVATED,DISABLED}
      return codes, since this is expected when the TPM 1.2 is set to Inactive.
      
      In that case the kernel log is cleaner and less confusing for users, i.e:
      
        tpm_tis 00:05: 1.2 TPM (device-id 0x0, rev-id 78)
        tpm tpm0: TPM is disabled/deactivated (0x6)
        ima: No TPM chip found, activating TPM-bypass! (rc=6)
      Reported-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e269ca18
    • Denis Drozdov's avatar
      IB/ipoib: Clear IPCB before icmp_send · a48a3a51
      Denis Drozdov authored
      [ Upstream commit 4d6e4d12 ]
      
      IPCB should be cleared before icmp_send, since it may contain data from
      previous layers and the data could be misinterpreted as ip header options,
      which later caused the ihl to be set to an invalid value and resulted in
      the following stack corruption:
      
      [ 1083.031512] ib0: packet len 57824 (> 2048) too long to send, dropping
      [ 1083.031843] ib0: packet len 37904 (> 2048) too long to send, dropping
      [ 1083.032004] ib0: packet len 4040 (> 2048) too long to send, dropping
      [ 1083.032253] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.032481] ib0: packet len 23960 (> 2048) too long to send, dropping
      [ 1083.033149] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.033439] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.033700] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.034124] ib0: packet len 63800 (> 2048) too long to send, dropping
      [ 1083.034387] ==================================================================
      [ 1083.034602] BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0xf08/0x1310
      [ 1083.034798] Write of size 4 at addr ffff880353457c5f by task kworker/u16:0/7
      [ 1083.034990]
      [ 1083.035104] CPU: 7 PID: 7 Comm: kworker/u16:0 Tainted: G           O      4.19.0-rc5+ #1
      [ 1083.035316] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu2 04/01/2014
      [ 1083.035573] Workqueue: ipoib_wq ipoib_cm_skb_reap [ib_ipoib]
      [ 1083.035750] Call Trace:
      [ 1083.035888]  dump_stack+0x9a/0xeb
      [ 1083.036031]  print_address_description+0xe3/0x2e0
      [ 1083.036213]  kasan_report+0x18a/0x2e0
      [ 1083.036356]  ? __ip_options_echo+0xf08/0x1310
      [ 1083.036522]  __ip_options_echo+0xf08/0x1310
      [ 1083.036688]  icmp_send+0x7b9/0x1cd0
      [ 1083.036843]  ? icmp_route_lookup.constprop.9+0x1070/0x1070
      [ 1083.037018]  ? netif_schedule_queue+0x5/0x200
      [ 1083.037180]  ? debug_show_all_locks+0x310/0x310
      [ 1083.037341]  ? rcu_dynticks_curr_cpu_in_eqs+0x85/0x120
      [ 1083.037519]  ? debug_locks_off+0x11/0x80
      [ 1083.037673]  ? debug_check_no_obj_freed+0x207/0x4c6
      [ 1083.037841]  ? check_flags.part.27+0x450/0x450
      [ 1083.037995]  ? debug_check_no_obj_freed+0xc3/0x4c6
      [ 1083.038169]  ? debug_locks_off+0x11/0x80
      [ 1083.038318]  ? skb_dequeue+0x10e/0x1a0
      [ 1083.038476]  ? ipoib_cm_skb_reap+0x2b5/0x650 [ib_ipoib]
      [ 1083.038642]  ? netif_schedule_queue+0xa8/0x200
      [ 1083.038820]  ? ipoib_cm_skb_reap+0x544/0x650 [ib_ipoib]
      [ 1083.038996]  ipoib_cm_skb_reap+0x544/0x650 [ib_ipoib]
      [ 1083.039174]  process_one_work+0x912/0x1830
      [ 1083.039336]  ? wq_pool_ids_show+0x310/0x310
      [ 1083.039491]  ? lock_acquire+0x145/0x3a0
      [ 1083.042312]  worker_thread+0x87/0xbb0
      [ 1083.045099]  ? process_one_work+0x1830/0x1830
      [ 1083.047865]  kthread+0x322/0x3e0
      [ 1083.050624]  ? kthread_create_worker_on_cpu+0xc0/0xc0
      [ 1083.053354]  ret_from_fork+0x3a/0x50
      
      For instance __ip_options_echo is failing to proceed with invalid srr and
      optlen passed from another layer via IPCB
      
      [  762.139568] IPv4: __ip_options_echo rr=0 ts=0 srr=43 cipso=0
      [  762.139720] IPv4: ip_options_build: IPCB 00000000f3cd969e opt 000000002ccb3533
      [  762.139838] IPv4: __ip_options_echo in srr: optlen 197 soffset 84
      [  762.139852] IPv4: ip_options_build srr=0 is_frag=0 rr_needaddr=0 ts_needaddr=0 ts_needtime=0 rr=0 ts=0
      [  762.140269] ==================================================================
      [  762.140713] IPv4: __ip_options_echo rr=0 ts=0 srr=0 cipso=0
      [  762.141078] BUG: KASAN: stack-out-of-bounds in __ip_options_echo+0x12ec/0x1680
      [  762.141087] Write of size 4 at addr ffff880353457c7f by task kworker/u16:0/7
      Signed-off-by: default avatarDenis Drozdov <denisd@mellanox.com>
      Reviewed-by: default avatarErez Shitrit <erezsh@mellanox.com>
      Reviewed-by: default avatarFeras Daoud <ferasda@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      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>
      a48a3a51
    • Parav Pandit's avatar
      RDMA/core: Do not expose unsupported counters · 2537f9ad
      Parav Pandit authored
      [ Upstream commit 0f6ef65d ]
      
      If the provider driver (such as rdma_rxe) doesn't support pma counters,
      avoid exposing its directory similar to optional hw_counters directory.
      If core fails to read the PMA counter, return an error so that user can
      retry later if needed.
      
      Fixes: 35c4cbb1 ("IB/core: Create get_perf_mad function in sysfs.c")
      Reported-by: default avatarHolger Hoffstätte <holger@applied-asynchrony.com>
      Tested-by: default avatarHolger Hoffstätte <holger@applied-asynchrony.com>
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2537f9ad
    • Wenwen Wang's avatar
      scsi: megaraid_sas: fix a missing-check bug · b18de4e8
      Wenwen Wang authored
      [ Upstream commit 47db7873 ]
      
      In megasas_mgmt_compat_ioctl_fw(), to handle the structure
      compat_megasas_iocpacket 'cioc', a user-space structure megasas_iocpacket
      'ioc' is allocated before megasas_mgmt_ioctl_fw() is invoked to handle
      the packet. Since the two data structures have different fields, the data
      is copied from 'cioc' to 'ioc' field by field. In the copy process,
      'sense_ptr' is prepared if the field 'sense_len' is not null, because it
      will be used in megasas_mgmt_ioctl_fw(). To prepare 'sense_ptr', the
      user-space data 'ioc->sense_off' and 'cioc->sense_off' are copied and
      saved to kernel-space variables 'local_sense_off' and 'user_sense_off'
      respectively. Given that 'ioc->sense_off' is also copied from
      'cioc->sense_off', 'local_sense_off' and 'user_sense_off' should have the
      same value. However, 'cioc' is in the user space and a malicious user can
      race to change the value of 'cioc->sense_off' after it is copied to
      'ioc->sense_off' but before it is copied to 'user_sense_off'. By doing
      so, the attacker can inject different values into 'local_sense_off' and
      'user_sense_off'. This can cause undefined behavior in the following
      execution, because the two variables are supposed to be same.
      
      This patch enforces a check on the two kernel variables 'local_sense_off'
      and 'user_sense_off' to make sure they are the same after the copy. In
      case they are not, an error code EINVAL will be returned.
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b18de4e8
    • Finn Thain's avatar
      scsi: esp_scsi: Track residual for PIO transfers · 57589690
      Finn Thain authored
      [ Upstream commit fd47d919 ]
      
      If a target disconnects during a PIO data transfer the command may fail
      when the target reconnects:
      
      scsi host1: DMA length is zero!
      scsi host1: cur adr[04380000] len[00000000]
      
      The scsi bus is then reset. This happens because the residual reached
      zero before the transfer was completed.
      
      The usual residual calculation relies on the Transfer Count registers.
      That works for DMA transfers but not for PIO transfers. Fix the problem
      by storing the PIO transfer residual and using that to correctly
      calculate bytes_sent.
      
      Fixes: 6fe07aaf ("[SCSI] m68k: new mac_esp scsi driver")
      Tested-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57589690
    • Michal Hocko's avatar
      cgroup, netclassid: add a preemption point to write_classid · 3f413ec0
      Michal Hocko authored
      [ Upstream commit a90e90b7 ]
      
      We have seen a customer complaining about soft lockups on !PREEMPT
      kernel config with 4.4 based kernel
      
      [1072141.435366] NMI watchdog: BUG: soft lockup - CPU#21 stuck for 22s! [systemd:1]
      [1072141.444090] Modules linked in: mpt3sas raid_class binfmt_misc af_packet 8021q garp mrp stp llc xfs libcrc32c bonding iscsi_ibft iscsi_boot_sysfs msr ext4 crc16 jbd2 mbcache cdc_ether usbnet mii joydev hid_generic usbhid intel_rapl x86_pkg_temp_thermal intel_powerclamp coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel ipmi_ssif mgag200 i2c_algo_bit ttm ipmi_devintf drbg ixgbe drm_kms_helper vxlan ansi_cprng ip6_udp_tunnel drm aesni_intel udp_tunnel aes_x86_64 iTCO_wdt syscopyarea ptp xhci_pci lrw iTCO_vendor_support pps_core gf128mul ehci_pci glue_helper sysfillrect mdio pcspkr sb_edac ablk_helper cryptd ehci_hcd sysimgblt xhci_hcd fb_sys_fops edac_core mei_me lpc_ich ses usbcore enclosure dca mfd_core ipmi_si mei i2c_i801 scsi_transport_sas usb_common ipmi_msghandler shpchp fjes wmi processor button acpi_pad btrfs xor raid6_pq sd_mod crc32c_intel megaraid_sas sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc scsi_dh_alua scsi_mod md_mod autofs4
      [1072141.444146] Supported: Yes
      [1072141.444149] CPU: 21 PID: 1 Comm: systemd Not tainted 4.4.121-92.80-default #1
      [1072141.444150] Hardware name: LENOVO Lenovo System x3650 M5 -[5462P4U]- -[5462P4U]-/01GR451, BIOS -[TCE136H-2.70]- 06/13/2018
      [1072141.444151] task: ffff880191bd0040 ti: ffff880191bd4000 task.ti: ffff880191bd4000
      [1072141.444153] RIP: 0010:[<ffffffff815229f9>]  [<ffffffff815229f9>] update_classid_sock+0x29/0x40
      [1072141.444157] RSP: 0018:ffff880191bd7d58  EFLAGS: 00000286
      [1072141.444158] RAX: ffff883b177cb7c0 RBX: 0000000000000000 RCX: 0000000000000000
      [1072141.444159] RDX: 00000000000009c7 RSI: ffff880191bd7d5c RDI: ffff8822e29bb200
      [1072141.444160] RBP: ffff883a72230980 R08: 0000000000000101 R09: 0000000000000000
      [1072141.444161] R10: 0000000000000008 R11: f000000000000000 R12: ffffffff815229d0
      [1072141.444162] R13: 0000000000000000 R14: ffff881fd0a47ac0 R15: ffff880191bd7f28
      [1072141.444163] FS:  00007f3e2f1eb8c0(0000) GS:ffff882000340000(0000) knlGS:0000000000000000
      [1072141.444164] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [1072141.444165] CR2: 00007f3e2f200000 CR3: 0000001ffea4e000 CR4: 00000000001606f0
      [1072141.444166] Stack:
      [1072141.444166]  ffffffa800000246 00000000000009c7 ffffffff8121d583 ffff8818312a05c0
      [1072141.444168]  ffff8818312a1100 ffff880197c3b280 ffff881861422858 ffffffffffffffea
      [1072141.444170]  ffffffff81522b1c ffffffff81d0ca20 ffff8817fa17b950 ffff883fdd8121e0
      [1072141.444171] Call Trace:
      [1072141.444179]  [<ffffffff8121d583>] iterate_fd+0x53/0x80
      [1072141.444182]  [<ffffffff81522b1c>] write_classid+0x4c/0x80
      [1072141.444187]  [<ffffffff8111328b>] cgroup_file_write+0x9b/0x100
      [1072141.444193]  [<ffffffff81278bcb>] kernfs_fop_write+0x11b/0x150
      [1072141.444198]  [<ffffffff81201566>] __vfs_write+0x26/0x100
      [1072141.444201]  [<ffffffff81201bed>] vfs_write+0x9d/0x190
      [1072141.444203]  [<ffffffff812028c2>] SyS_write+0x42/0xa0
      [1072141.444207]  [<ffffffff815f58c3>] entry_SYSCALL_64_fastpath+0x1e/0xca
      [1072141.445490] DWARF2 unwinder stuck at entry_SYSCALL_64_fastpath+0x1e/0xca
      
      If a cgroup has many tasks with many open file descriptors then we would
      end up in a large loop without any rescheduling point throught the
      operation. Add cond_resched once per task.
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f413ec0