1. 11 Jul, 2018 26 commits
  2. 03 Jul, 2018 14 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.9.111 · e692f66f
      Greg Kroah-Hartman authored
      e692f66f
    • Bjørn Mork's avatar
      cdc_ncm: avoid padding beyond end of skb · 35fd10ae
      Bjørn Mork authored
      commit 49c2c3f2 upstream.
      
      Commit 4a0e3e98 ("cdc_ncm: Add support for moving NDP to end
      of NCM frame") added logic to reserve space for the NDP at the
      end of the NTB/skb.  This reservation did not take the final
      alignment of the NDP into account, causing us to reserve too
      little space. Additionally the padding prior to NDP addition did
      not ensure there was enough space for the NDP.
      
      The NTB/skb with the NDP appended would then exceed the configured
      max size. This caused the final padding of the NTB to use a
      negative count, padding to almost INT_MAX, and resulting in:
      
      [60103.825970] BUG: unable to handle kernel paging request at ffff9641f2004000
      [60103.825998] IP: __memset+0x24/0x30
      [60103.826001] PGD a6a06067 P4D a6a06067 PUD 4f65a063 PMD 72003063 PTE 0
      [60103.826013] Oops: 0002 [#1] SMP NOPTI
      [60103.826018] Modules linked in: (removed(
      [60103.826158] CPU: 0 PID: 5990 Comm: Chrome_DevTools Tainted: G           O 4.14.0-3-amd64 #1 Debian 4.14.17-1
      [60103.826162] Hardware name: LENOVO 20081 BIOS 41CN28WW(V2.04) 05/03/2012
      [60103.826166] task: ffff964193484fc0 task.stack: ffffb2890137c000
      [60103.826171] RIP: 0010:__memset+0x24/0x30
      [60103.826174] RSP: 0000:ffff964316c03b68 EFLAGS: 00010216
      [60103.826178] RAX: 0000000000000000 RBX: 00000000fffffffd RCX: 000000001ffa5000
      [60103.826181] RDX: 0000000000000005 RSI: 0000000000000000 RDI: ffff9641f2003ffc
      [60103.826184] RBP: ffff964192f6c800 R08: 00000000304d434e R09: ffff9641f1d2c004
      [60103.826187] R10: 0000000000000002 R11: 00000000000005ae R12: ffff9642e6957a80
      [60103.826190] R13: ffff964282ff2ee8 R14: 000000000000000d R15: ffff9642e4843900
      [60103.826194] FS:  00007f395aaf6700(0000) GS:ffff964316c00000(0000) knlGS:0000000000000000
      [60103.826197] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [60103.826200] CR2: ffff9641f2004000 CR3: 0000000013b0c000 CR4: 00000000000006f0
      [60103.826204] Call Trace:
      [60103.826212]  <IRQ>
      [60103.826225]  cdc_ncm_fill_tx_frame+0x5e3/0x740 [cdc_ncm]
      [60103.826236]  cdc_ncm_tx_fixup+0x57/0x70 [cdc_ncm]
      [60103.826246]  usbnet_start_xmit+0x5d/0x710 [usbnet]
      [60103.826254]  ? netif_skb_features+0x119/0x250
      [60103.826259]  dev_hard_start_xmit+0xa1/0x200
      [60103.826267]  sch_direct_xmit+0xf2/0x1b0
      [60103.826273]  __dev_queue_xmit+0x5e3/0x7c0
      [60103.826280]  ? ip_finish_output2+0x263/0x3c0
      [60103.826284]  ip_finish_output2+0x263/0x3c0
      [60103.826289]  ? ip_output+0x6c/0xe0
      [60103.826293]  ip_output+0x6c/0xe0
      [60103.826298]  ? ip_forward_options+0x1a0/0x1a0
      [60103.826303]  tcp_transmit_skb+0x516/0x9b0
      [60103.826309]  tcp_write_xmit+0x1aa/0xee0
      [60103.826313]  ? sch_direct_xmit+0x71/0x1b0
      [60103.826318]  tcp_tasklet_func+0x177/0x180
      [60103.826325]  tasklet_action+0x5f/0x110
      [60103.826332]  __do_softirq+0xde/0x2b3
      [60103.826337]  irq_exit+0xae/0xb0
      [60103.826342]  do_IRQ+0x81/0xd0
      [60103.826347]  common_interrupt+0x98/0x98
      [60103.826351]  </IRQ>
      [60103.826355] RIP: 0033:0x7f397bdf2282
      [60103.826358] RSP: 002b:00007f395aaf57d8 EFLAGS: 00000206 ORIG_RAX: ffffffffffffff6e
      [60103.826362] RAX: 0000000000000000 RBX: 00002f07bc6d0900 RCX: 00007f39752d7fe7
      [60103.826365] RDX: 0000000000000022 RSI: 0000000000000147 RDI: 00002f07baea02c0
      [60103.826368] RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
      [60103.826371] R10: 00000000ffffffff R11: 0000000000000000 R12: 00002f07baea02c0
      [60103.826373] R13: 00002f07bba227a0 R14: 00002f07bc6d090c R15: 0000000000000000
      [60103.826377] Code: 90 90 90 90 90 90 90 0f 1f 44 00 00 49 89 f9 48 89 d1 83
      e2 07 48 c1 e9 03 40 0f b6 f6 48 b8 01 01 01 01 01 01 01 01 48 0f af c6 <f3> 48
      ab 89 d1 f3 aa 4c 89 c8 c3 90 49 89 f9 40 88 f0 48 89 d1
      [60103.826442] RIP: __memset+0x24/0x30 RSP: ffff964316c03b68
      [60103.826444] CR2: ffff9641f2004000
      
      Commit e1069bbf ("net: cdc_ncm: Reduce memory use when kernel
      memory low") made this bug much more likely to trigger by reducing
      the NTB size under memory pressure.
      
      Link: https://bugs.debian.org/893393Reported-by: default avatarГорбешко Богдан <bodqhrohro@gmail.com>
      Reported-and-tested-by: default avatarDennis Wassenberg <dennis.wassenberg@secunet.com>
      Cc: Enrico Mioso <mrkiko.rs@gmail.com>
      Fixes: 4a0e3e98 ("cdc_ncm: Add support for moving NDP to end of NCM frame")
      [ bmork:  tx_curr_size => tx_max and context fixup for v4.12 and older ]
      Signed-off-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35fd10ae
    • Mike Snitzer's avatar
      dm thin: handle running out of data space vs concurrent discard · f2bc5d18
      Mike Snitzer authored
      commit a685557f upstream.
      
      Discards issued to a DM thin device can complete to userspace (via
      fstrim) _before_ the metadata changes associated with the discards is
      reflected in the thinp superblock (e.g. free blocks).  As such, if a
      user constructs a test that loops repeatedly over these steps, block
      allocation can fail due to discards not having completed yet:
      1) fill thin device via filesystem file
      2) remove file
      3) fstrim
      
      From initial report, here:
      https://www.redhat.com/archives/dm-devel/2018-April/msg00022.html
      
      "The root cause of this issue is that dm-thin will first remove
      mapping and increase corresponding blocks' reference count to prevent
      them from being reused before DISCARD bios get processed by the
      underlying layers. However. increasing blocks' reference count could
      also increase the nr_allocated_this_transaction in struct sm_disk
      which makes smd->old_ll.nr_allocated +
      smd->nr_allocated_this_transaction bigger than smd->old_ll.nr_blocks.
      In this case, alloc_data_block() will never commit metadata to reset
      the begin pointer of struct sm_disk, because sm_disk_get_nr_free()
      always return an underflow value."
      
      While there is room for improvement to the space-map accounting that
      thinp is making use of: the reality is this test is inherently racey and
      will result in the previous iteration's fstrim's discard(s) completing
      vs concurrent block allocation, via dd, in the next iteration of the
      loop.
      
      No amount of space map accounting improvements will be able to allow
      user's to use a block before a discard of that block has completed.
      
      So the best we can really do is allow DM thinp to gracefully handle such
      aggressive use of all the pool's data by degrading the pool into
      out-of-data-space (OODS) mode.  We _should_ get that behaviour already
      (if space map accounting didn't falsely cause alloc_data_block() to
      believe free space was available).. but short of that we handle the
      current reality that dm_pool_alloc_data_block() can return -ENOSPC.
      Reported-by: default avatarDennis Yang <dennisyang@qnap.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2bc5d18
    • Keith Busch's avatar
      block: Fix transfer when chunk sectors exceeds max · 17057c59
      Keith Busch authored
      commit 15bfd21f upstream.
      
      A device may have boundary restrictions where the number of sectors
      between boundaries exceeds its max transfer size. In this case, we need
      to cap the max size to the smaller of the two limits.
      Reported-by: default avatarJitendra Bhivare <jitendra.bhivare@broadcom.com>
      Tested-by: default avatarJitendra Bhivare <jitendra.bhivare@broadcom.com>
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarKeith Busch <keith.busch@intel.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      17057c59
    • Takashi Iwai's avatar
      ALSA: hda/realtek - Add a quirk for FSC ESPRIMO U9210 · afd82d07
      Takashi Iwai authored
      commit 275ec0cb upstream.
      
      Fujitsu Seimens ESPRIMO Mobile U9210 requires the same fixup as H270
      for the correct pin configs.
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200107
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      afd82d07
    • Takashi Iwai's avatar
      ALSA: hda/realtek - Fix pop noise on Lenovo P50 & co · 6008de29
      Takashi Iwai authored
      commit d5a6cabf upstream.
      
      Some Lenovo laptops, e.g. Lenovo P50, showed the pop noise at resume
      or runtime resume.  It turned out to be reduced by applying
      alc_no_shutup() just like TPT440 quirk does.
      
      Since there are many Lenovo models showing the same behavior, put this
      workaround in ALC269_FIXUP_THINKPAD_ACPI entry so that it's applied
      commonly to all such Lenovo machines.
      Reported-by: default avatarHans de Goede <hdegoede@redhat.com>
      Tested-by: default avatarBenjamin Berg <bberg@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6008de29
    • ???'s avatar
      Input: elantech - fix V4 report decoding for module with middle key · 58d81031
      ??? authored
      commit e0ae2519 upstream.
      
      Some touchpad has middle key and it will be indicated in bit 2 of packet[0].
      We need to fix V4 formation's byte mask to prevent error decoding.
      Signed-off-by: default avatarKT Liao <kt.liao@emc.com.tw>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58d81031
    • Aaron Ma's avatar
      Input: elantech - enable middle button of touchpads on ThinkPad P52 · 465e965f
      Aaron Ma authored
      commit 24bb555e upstream.
      
      PNPID is better way to identify the type of touchpads.
      Enable middle button support on 2 types of touchpads on Lenovo P52.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAaron Ma <aaron.ma@canonical.com>
      Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      465e965f
    • Ben Hutchings's avatar
      Input: elan_i2c_smbus - fix more potential stack buffer overflows · 54ae564b
      Ben Hutchings authored
      commit 50fc7b61 upstream.
      
      Commit 40f7090b ("Input: elan_i2c_smbus - fix corrupted stack")
      fixed most of the functions using i2c_smbus_read_block_data() to
      allocate a buffer with the maximum block size.  However three
      functions were left unchanged:
      
      * In elan_smbus_initialize(), increase the buffer size in the same
        way.
      * In elan_smbus_calibrate_result(), the buffer is provided by the
        caller (calibrate_store()), so introduce a bounce buffer.  Also
        name the result buffer size.
      * In elan_smbus_get_report(), the buffer is provided by the caller
        but happens to be the right length.  Add a compile-time assertion
        to ensure this remains the case.
      
      Cc: <stable@vger.kernel.org> # 3.19+
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      54ae564b
    • Jan Kara's avatar
      udf: Detect incorrect directory size · 2a1b1234
      Jan Kara authored
      commit fa65653e upstream.
      
      Detect when a directory entry is (possibly partially) beyond directory
      size and return EIO in that case since it means the filesystem is
      corrupted. Otherwise directory operations can further corrupt the
      directory and possibly also oops the kernel.
      
      CC: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
      CC: stable@vger.kernel.org
      Reported-and-tested-by: default avatarAnatoly Trosinenko <anatoly.trosinenko@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a1b1234
    • Boris Ostrovsky's avatar
      xen: Remove unnecessary BUG_ON from __unbind_from_irq() · 3cac26f2
      Boris Ostrovsky authored
      commit eef04c7b upstream.
      
      Commit 910f8bef ("xen/pirq: fix error path cleanup when binding
      MSIs") fixed a couple of errors in error cleanup path of
      xen_bind_pirq_msi_to_irq(). This cleanup allowed a call to
      __unbind_from_irq() with an unbound irq, which would result in
      triggering the BUG_ON there.
      
      Since there is really no reason for the BUG_ON (xen_free_irq() can
      operate on unbound irqs) we can remove it.
      Reported-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3cac26f2
    • Dan Williams's avatar
      mm: fix devmem_is_allowed() for sub-page System RAM intersections · 6d28f2d6
      Dan Williams authored
      commit 2bdce744 upstream.
      
      Hussam reports:
      
          I was poking around and for no real reason, I did cat /dev/mem and
          strings /dev/mem.  Then I saw the following warning in dmesg. I saved it
          and rebooted immediately.
      
           memremap attempted on mixed range 0x000000000009c000 size: 0x1000
           ------------[ cut here ]------------
           WARNING: CPU: 0 PID: 11810 at kernel/memremap.c:98 memremap+0x104/0x170
           [..]
           Call Trace:
            xlate_dev_mem_ptr+0x25/0x40
            read_mem+0x89/0x1a0
            __vfs_read+0x36/0x170
      
      The memremap() implementation checks for attempts to remap System RAM
      with MEMREMAP_WB and instead redirects those mapping attempts to the
      linear map.  However, that only works if the physical address range
      being remapped is page aligned.  In low memory we have situations like
      the following:
      
          00000000-00000fff : Reserved
          00001000-0009fbff : System RAM
          0009fc00-0009ffff : Reserved
      
      ...where System RAM intersects Reserved ranges on a sub-page page
      granularity.
      
      Given that devmem_is_allowed() special cases any attempt to map System
      RAM in the first 1MB of memory, replace page_is_ram() with the more
      precise region_intersects() to trap attempts to map disallowed ranges.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=199999
      Link: http://lkml.kernel.org/r/152856436164.18127.2847888121707136898.stgit@dwillia2-desk3.amr.corp.intel.com
      Fixes: 92281dee ("arch: introduce memremap()")
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Reported-by: default avatarHussam Al-Tayeb <me@hussam.eu.org>
      Tested-by: default avatarHussam Al-Tayeb <me@hussam.eu.org>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d28f2d6
    • Dongsheng Yang's avatar
      rbd: flush rbd_dev->watch_dwork after watch is unregistered · 1f00b1fc
      Dongsheng Yang authored
      commit 23edca86 upstream.
      
      There is a problem if we are going to unmap a rbd device and the
      watch_dwork is going to queue delayed work for watch:
      
      unmap Thread                    watch Thread                  timer
      do_rbd_remove
        cancel_tasks_sync(rbd_dev)
                                      queue_delayed_work for watch
        destroy_workqueue(rbd_dev->task_wq)
          drain_workqueue(wq)
          destroy other resources in wq
                                                                    call_timer_fn
                                                                      __queue_work()
      
      Then the delayed work escape the cancel_tasks_sync() and
      destroy_workqueue() and we will get an user-after-free call trace:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
        PGD 0 P4D 0
        Oops: 0000 [#1] SMP PTI
        Modules linked in:
        CPU: 7 PID: 0 Comm: swapper/7 Tainted: G           OE     4.17.0-rc6+ #13
        Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
        RIP: 0010:__queue_work+0x6a/0x3b0
        RSP: 0018:ffff9427df1c3e90 EFLAGS: 00010086
        RAX: ffff9427deca8400 RBX: 0000000000000000 RCX: 0000000000000000
        RDX: ffff9427deca8400 RSI: ffff9427df1c3e50 RDI: 0000000000000000
        RBP: ffff942783e39e00 R08: ffff9427deca8400 R09: ffff9427df1c3f00
        R10: 0000000000000004 R11: 0000000000000005 R12: ffff9427cfb85970
        R13: 0000000000002000 R14: 000000000001eca0 R15: 0000000000000007
        FS:  0000000000000000(0000) GS:ffff9427df1c0000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000000 CR3: 00000004c900a005 CR4: 00000000000206e0
        Call Trace:
         <IRQ>
         ? __queue_work+0x3b0/0x3b0
         call_timer_fn+0x2d/0x130
         run_timer_softirq+0x16e/0x430
         ? tick_sched_timer+0x37/0x70
         __do_softirq+0xd2/0x280
         irq_exit+0xd5/0xe0
         smp_apic_timer_interrupt+0x6c/0x130
         apic_timer_interrupt+0xf/0x20
      
      [ Move rbd_dev->watch_dwork cancellation so that rbd_reregister_watch()
        either bails out early because the watch is UNREGISTERED at that point
        or just gets cancelled. ]
      
      Cc: stable@vger.kernel.org
      Fixes: 99d16943 ("rbd: retry watch re-registration periodically")
      Signed-off-by: default avatarDongsheng Yang <dongsheng.yang@easystack.cn>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f00b1fc
    • Hans de Goede's avatar
      pwm: lpss: platform: Save/restore the ctrl register over a suspend/resume · 037aca0e
      Hans de Goede authored
      commit 1d375b58 upstream.
      
      On some devices the contents of the ctrl register get lost over a
      suspend/resume and the PWM comes back up disabled after the resume.
      
      This is seen on some Bay Trail devices with the PWM in ACPI enumerated
      mode, so it shows up as a platform device instead of a PCI device.
      
      If we still think it is enabled and then try to change the duty-cycle
      after this, we end up with a "PWM_SW_UPDATE was not cleared" error and
      the PWM is stuck in that state from then on.
      
      This commit adds suspend and resume pm callbacks to the pwm-lpss-platform
      code, which save/restore the ctrl register over a suspend/resume, fixing
      this.
      
      Note that:
      
      1) There is no need to do this over a runtime suspend, since we
      only runtime suspend when disabled and then we properly set the enable
      bit and reprogram the timings when we re-enable the PWM.
      
      2) This may be happening on more systems then we realize, but has been
      covered up sofar by a bug in the acpi-lpss.c code which was save/restoring
      the regular device registers instead of the lpss private registers due to
      lpss_device_desc.prv_offset not being set. This is fixed by a later patch
      in this series.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      037aca0e