1. 15 Sep, 2016 6 commits
  2. 07 Sep, 2016 34 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.4.20 · 2cb99ded
      Greg Kroah-Hartman authored
      2cb99ded
    • Konstantin Khlebnikov's avatar
      sysfs: correctly handle read offset on PREALLOC attrs · 625ddb78
      Konstantin Khlebnikov authored
      commit 17d0774f upstream.
      
      Attributes declared with __ATTR_PREALLOC use sysfs_kf_read() which returns
      zero bytes for non-zero offset. This breaks script checkarray in mdadm tool
      in debian where /bin/sh is 'dash' because its builtin 'read' reads only one
      byte at a time. Script gets 'i' instead of 'idle' when reads current action
      from /sys/block/$dev/md/sync_action and as a result does nothing.
      
      This patch adds trivial implementation of partial read: generate whole
      string and move required part into buffer head.
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Fixes: 4ef67a8c ("sysfs/kernfs: make read requests on pre-alloc files use the buffer.")
      Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787950Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      625ddb78
    • Quentin Schulz's avatar
      hwmon: (iio_hwmon) fix memory leak in name attribute · dde898fb
      Quentin Schulz authored
      commit 5d17d3b4 upstream.
      
      The "name" variable's memory is now freed when the device is destructed
      thanks to devm function.
      Signed-off-by: default avatarQuentin Schulz <quentin.schulz@free-electrons.com>
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Fixes: e0f8a24e ("staging:iio::hwmon interface client driver.")
      Fixes: 61bb53bc ("hwmon: (iio_hwmon) Add support for humidity sensors")
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dde898fb
    • Andrej Krutak's avatar
      ALSA: line6: Fix POD sysfs attributes segfault · a2d9e40c
      Andrej Krutak authored
      commit b027d112 upstream.
      
      The commit 02fc76f6 changed base of the sysfs attributes from device to card.
      The "show" callbacks dereferenced wrong objects because of this.
      
      Fixes: 02fc76f6 ('ALSA: line6: Create sysfs via snd_card_add_dev_attr()')
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: default avatarAndrej Krutak <dev@andree.sk>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a2d9e40c
    • Andrej Krutak's avatar
      ALSA: line6: Give up on the lock while URBs are released. · d21befeb
      Andrej Krutak authored
      commit adc8a43a upstream.
      
      Done, because line6_stream_stop() locks and calls line6_unlink_audio_urbs(),
      which in turn invokes audio_out_callback(), which tries to lock 2nd time.
      
      Fixes:
      
      =============================================
      [ INFO: possible recursive locking detected ]
      4.4.15+ #15 Not tainted
      ---------------------------------------------
      mplayer/3591 is trying to acquire lock:
       (&(&line6pcm->out.lock)->rlock){-.-...}, at: [<bfa27655>] audio_out_callback+0x70/0x110 [snd_usb_line6]
      
      but task is already holding lock:
       (&(&line6pcm->out.lock)->rlock){-.-...}, at: [<bfa26aad>] line6_stream_stop+0x24/0x5c [snd_usb_line6]
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(&(&line6pcm->out.lock)->rlock);
        lock(&(&line6pcm->out.lock)->rlock);
      
       *** DEADLOCK ***
      
       May be due to missing lock nesting notation
      
      3 locks held by mplayer/3591:
       #0:  (snd_pcm_link_rwlock){.-.-..}, at: [<bf8d49a7>] snd_pcm_stream_lock+0x1e/0x40 [snd_pcm]
       #1:  (&(&substream->self_group.lock)->rlock){-.-...}, at: [<bf8d49af>] snd_pcm_stream_lock+0x26/0x40 [snd_pcm]
       #2:  (&(&line6pcm->out.lock)->rlock){-.-...}, at: [<bfa26aad>] line6_stream_stop+0x24/0x5c [snd_usb_line6]
      
      stack backtrace:
      CPU: 0 PID: 3591 Comm: mplayer Not tainted 4.4.15+ #15
      Hardware name: Generic AM33XX (Flattened Device Tree)
      [<c0015d85>] (unwind_backtrace) from [<c001253d>] (show_stack+0x11/0x14)
      [<c001253d>] (show_stack) from [<c02f1bdf>] (dump_stack+0x8b/0xac)
      [<c02f1bdf>] (dump_stack) from [<c0076f43>] (__lock_acquire+0xc8b/0x1780)
      [<c0076f43>] (__lock_acquire) from [<c007810d>] (lock_acquire+0x99/0x1c0)
      [<c007810d>] (lock_acquire) from [<c06171e7>] (_raw_spin_lock_irqsave+0x3f/0x4c)
      [<c06171e7>] (_raw_spin_lock_irqsave) from [<bfa27655>] (audio_out_callback+0x70/0x110 [snd_usb_line6])
      [<bfa27655>] (audio_out_callback [snd_usb_line6]) from [<c04294db>] (__usb_hcd_giveback_urb+0x53/0xd0)
      [<c04294db>] (__usb_hcd_giveback_urb) from [<c046388d>] (musb_giveback+0x3d/0x98)
      [<c046388d>] (musb_giveback) from [<c04647f5>] (musb_urb_dequeue+0x6d/0x114)
      [<c04647f5>] (musb_urb_dequeue) from [<c042ac11>] (usb_hcd_unlink_urb+0x39/0x98)
      [<c042ac11>] (usb_hcd_unlink_urb) from [<bfa26a87>] (line6_unlink_audio_urbs+0x6a/0x6c [snd_usb_line6])
      [<bfa26a87>] (line6_unlink_audio_urbs [snd_usb_line6]) from [<bfa26acb>] (line6_stream_stop+0x42/0x5c [snd_usb_line6])
      [<bfa26acb>] (line6_stream_stop [snd_usb_line6]) from [<bfa26fe7>] (snd_line6_trigger+0xb6/0xf4 [snd_usb_line6])
      [<bfa26fe7>] (snd_line6_trigger [snd_usb_line6]) from [<bf8d47b7>] (snd_pcm_do_stop+0x36/0x38 [snd_pcm])
      [<bf8d47b7>] (snd_pcm_do_stop [snd_pcm]) from [<bf8d462f>] (snd_pcm_action_single+0x22/0x40 [snd_pcm])
      [<bf8d462f>] (snd_pcm_action_single [snd_pcm]) from [<bf8d46f9>] (snd_pcm_action+0xac/0xb0 [snd_pcm])
      [<bf8d46f9>] (snd_pcm_action [snd_pcm]) from [<bf8d4b61>] (snd_pcm_drop+0x38/0x64 [snd_pcm])
      [<bf8d4b61>] (snd_pcm_drop [snd_pcm]) from [<bf8d6233>] (snd_pcm_common_ioctl1+0x7fe/0xbe8 [snd_pcm])
      [<bf8d6233>] (snd_pcm_common_ioctl1 [snd_pcm]) from [<bf8d6779>] (snd_pcm_playback_ioctl1+0x15c/0x51c [snd_pcm])
      [<bf8d6779>] (snd_pcm_playback_ioctl1 [snd_pcm]) from [<bf8d6b59>] (snd_pcm_playback_ioctl+0x20/0x28 [snd_pcm])
      [<bf8d6b59>] (snd_pcm_playback_ioctl [snd_pcm]) from [<c016714b>] (do_vfs_ioctl+0x3af/0x5c8)
      
      Fixes: 63e20df1 ('ALSA: line6: Reorganize PCM stream handling')
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: default avatarAndrej Krutak <dev@andree.sk>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d21befeb
    • Andrej Krutak's avatar
      ALSA: line6: Remove double line6_pcm_release() after failed acquire. · 85db22a1
      Andrej Krutak authored
      commit 7e4379ea upstream.
      
      If there's an error, pcm is released in line6_pcm_acquire already.
      
      Fixes: 247d95ee ('ALSA: line6: Handle error from line6_pcm_acquire()')
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: default avatarAndrej Krutak <dev@andree.sk>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      85db22a1
    • Lukasz Anaczkowski's avatar
      ACPI / SRAT: fix SRAT parsing order with both LAPIC and X2APIC present · 37e16dc9
      Lukasz Anaczkowski authored
      commit 702b07fc upstream.
      
      SRAT maps APIC ID to proximity domains ids (PXM). Mapping from PXM to
      NUMA node ids is based on order of entries in SRAT table.
      SRAT table has just LAPIC entires or mix of LAPIC and X2APIC entries.
      As long as there are only LAPIC entires, mapping from proximity domain
      id to NUMA node id is as assumed by BIOS. However, once APIC entries are
      mixed, X2APIC entries would be first mapped which causes unexpected NUMA
      node mapping.
      
      To fix that, change parsing to check each entry against both LAPIC and
      X2APIC so mapping is in the SRAT/PXM order.
      
      This is supplemental change to the fix made by commit d81056b5
      (Handle apic/x2apic entries in MADT in correct order) and using the
      mechanism introduced by 9b3fedde (ACPI / tables: Add acpi_subtable_proc
      to ACPI table parsers).
      
      Fixes: d81056b5 (Handle apic/x2apic entries in MADT in correct order)
      Signed-off-by: default avatarLukasz Anaczkowski <lukasz.anaczkowski@intel.com>
      [ rjw : Subject & changelog ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      37e16dc9
    • Dan Carpenter's avatar
      ACPI / sysfs: fix error code in get_status() · a37b8344
      Dan Carpenter authored
      commit f18ebc21 upstream.
      
      The problem with ornamental, do-nothing gotos is that they lead to
      "forgot to set the error code" bugs.  We should be returning -EINVAL
      here but we don't.  It leads to an uninitalized variable in
      counter_show():
      
          drivers/acpi/sysfs.c:603 counter_show()
          error: uninitialized symbol 'status'.
      
      Fixes: 1c8fce27 (ACPI: introduce drivers/acpi/sysfs.c)
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a37b8344
    • Lorenzo Pieralisi's avatar
      ACPI / drivers: replace acpi_probe_lock spinlock with mutex · b0917f5d
      Lorenzo Pieralisi authored
      commit 5331d9ca upstream.
      
      Commit e647b532 ("ACPI: Add early device probing infrastructure")
      introduced code that allows inserting driver specific
      struct acpi_probe_entry probe entries into ACPI linker sections
      (one per-subsystem, eg irqchip, clocksource) that are then walked
      to retrieve the data and function hooks required to probe the
      respective kernel components.
      
      Probing for all entries in a section is triggered through
      the __acpi_probe_device_table() function, that in turn, according
      to the table ID a given probe entry reports parses the table
      with the function retrieved from the respective section structures
      (ie struct acpi_probe_entry). Owing to the current ACPI table
      parsing implementation, the __acpi_probe_device_table() function
      has to share global variables with the acpi_match_madt() function, so
      in order to guarantee mutual exclusion locking is required
      between the two functions.
      
      Current kernel code implements the locking through the acpi_probe_lock
      spinlock; this has the side effect of requiring all code called
      within the lock (ie struct acpi_probe_entry.probe_{table/subtbl} hooks)
      not to sleep.
      
      However, kernel subsystems that make use of the early probing
      infrastructure are relying on kernel APIs that may sleep (eg
      irq_domain_alloc_fwnode(), among others) in the function calls
      pointed at by struct acpi_probe_entry.{probe_table/subtbl} entries
      (eg gic_v2_acpi_init()), which is a bug.
      
      Since __acpi_probe_device_table() is called from context
      that is allowed to sleep the acpi_probe_lock spinlock can be replaced
      with a mutex; this fixes the issue whilst still guaranteeing
      mutual exclusion.
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Fixes: e647b532 (ACPI: Add early device probing infrastructure)
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b0917f5d
    • Lorenzo Pieralisi's avatar
      ACPI / drivers: fix typo in ACPI_DECLARE_PROBE_ENTRY macro · 0b21b21b
      Lorenzo Pieralisi authored
      commit 3feab13c upstream.
      
      When the ACPI_DECLARE_PROBE_ENTRY macro was added in
      commit e647b532 ("ACPI: Add early device probing infrastructure"),
      a stub macro adding an unused entry was added for the !CONFIG_ACPI
      Kconfig option case to make sure kernel code making use of the
      macro did not require to be guarded within CONFIG_ACPI in order to
      be compiled.
      
      The stub macro was never used since all kernel code that defines
      ACPI_DECLARE_PROBE_ENTRY entries is currently guarded within
      CONFIG_ACPI; it contains a typo that should be nonetheless fixed.
      
      Fix the typo in the stub (ie !CONFIG_ACPI) ACPI_DECLARE_PROBE_ENTRY()
      macro so that it can actually be used if needed.
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Fixes: e647b532 (ACPI: Add early device probing infrastructure)
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b21b21b
    • Ian Abbott's avatar
      staging: comedi: ni_mio_common: fix wrong insn_write handler · fbde41fa
      Ian Abbott authored
      commit 5ca05345 upstream.
      
      For counter subdevices, the `s->insn_write` handler is being set to the
      wrong function, `ni_tio_insn_read()`.  It should be
      `ni_tio_insn_write()`.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reported-by: default avatarÉric Piel <piel@delmic.com>
      Fixes: 10f74377 ("staging: comedi: ni_tio: make ni_tio_winsn() a
        proper comedi (*insn_write)"
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fbde41fa
    • Ian Abbott's avatar
      staging: comedi: ni_mio_common: fix AO inttrig backwards compatibility · b03ee3d0
      Ian Abbott authored
      commit f0f4b0cc upstream.
      
      Commit ebb657ba ("staging: comedi: ni_mio_common: clarify the
      cmd->start_arg validation and use") introduced a backwards compatibility
      issue in the use of asynchronous commands on the AO subdevice when
      `start_src` is `TRIG_EXT`.  Valid values for `start_src` are `TRIG_INT`
      (for internal, software trigger), and `TRIG_EXT` (for external trigger).
      When set to `TRIG_EXT`.  In both cases, the driver relies on an
      internal, software trigger to set things up (allowing the user
      application to write sufficient samples to the data buffer before the
      trigger), so it acts as a software "pre-trigger" in the `TRIG_EXT` case.
      The software trigger is handled by `ni_ao_inttrig()`.
      
      Prior to the above change, when `start_src` was `TRIG_INT`, `start_arg`
      was required to be 0, and `ni_ao_inttrig()` checked that the software
      trigger number was also 0.  After the above change, when `start_src` was
      `TRIG_INT`, any value was allowed for `start_arg`, and `ni_ao_inttrig()`
      checked that the software trigger number matched this `start_arg` value.
      The backwards compatibility issue is that the internal trigger number
      now has to match `start_arg` when `start_src` is `TRIG_EXT` when it
      previously had to be 0.
      
      Fix the backwards compatibility issue in `ni_ao_inttrig()` by always
      allowing software trigger number 0 when `start_src` is something other
      than `TRIG_INT`.
      
      Thanks to Spencer Olson for reporting the issue.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Reported-by: default avatarSpencer Olson <olsonse@umich.edu>
      Fixes: ebb657ba ("staging: comedi: ni_mio_common: clarify the cmd->start_arg validation and use")
      Reviewed-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b03ee3d0
    • Ian Abbott's avatar
      staging: comedi: comedi_test: fix timer race conditions · fd514089
      Ian Abbott authored
      commit 403fe7f3 upstream.
      
      Commit 73e0e4df ("staging: comedi: comedi_test: fix timer lock-up")
      fixed a lock-up in the timer routine `waveform_ai_timer()` (which was
      called `waveform_ai_interrupt()` at the time) caused by
      commit 24051247 ("staging: comedi: comedi_test: use
      comedi_handle_events()").  However, it introduced a race condition that
      can result in the timer routine misbehaving, such as accessing freed
      memory or dereferencing a NULL pointer.
      
      73e0... changed the timer routine to do nothing unless a
      `WAVEFORM_AI_RUNNING` flag was set, and changed `waveform_ai_cancel()`
      to clear the flag and replace a call to `del_timer_sync()` with a call
      to `del_timer()`.  `waveform_ai_cancel()` may be called from the timer
      routine itself (via `comedi_handle_events()`), or from `do_cancel()`.
      (`do_cancel()` is called as a result of a file operation (usually a
      `COMEDI_CANCEL` ioctl command, or a release), or during device removal.)
      When called from `do_cancel()`, the call to `waveform_ai_cancel()` is
      followed by a call to `do_become_nonbusy()`, which frees up stuff for
      the current asynchronous command under the assumption that it is now
      safe to do so.  The race condition occurs when the timer routine
      `waveform_ai_timer()` checks the `WAVEFORM_AI_RUNNING` flag just before
      it is cleared by `waveform_ai_cancel()`, and is still running during the
      call to `do_become_nonbusy()`.  In particular, it can lead to a NULL
      pointer dereference:
      
      BUG: unable to handle kernel NULL pointer dereference at (null)
      IP: [<ffffffffc0c63add>] waveform_ai_timer+0x17d/0x290 [comedi_test]
      
      That corresponds to this line in `waveform_ai_timer()`:
      
      		unsigned int chanspec = cmd->chanlist[async->cur_chan];
      
      but `do_become_nonbusy()` frees `cmd->chanlist` and sets it to `NULL`.
      
      Fix the race by calling `del_timer_sync()` instead of `del_timer()` in
      `waveform_ai_cancel()` when not in an interrupt context.  The only time
      `waveform_ai_cancel()` is called in an interrupt context is when it is
      called from the timer routine itself, via `comedi_handle_events()`.
      
      There is no longer any need for the `WAVEFORM_AI_RUNNING` flag, so get
      rid of it.
      
      The bug was copied from the AI subdevice to the AO when support for
      commands on the AO subdevice was added by commit 0cf55bbe ("staging:
      comedi: comedi_test: implement commands on AO subdevice").  That
      involves the timer routine `waveform_ao_timer()`, the comedi "cancel"
      routine `waveform_ao_cancel()`, and the flag `WAVEFORM_AO_RUNNING`.  Fix
      it in the same way as for the AI subdevice.
      
      Fixes: 73e0e4df ("staging: comedi: comedi_test: fix timer lock-up")
      Fixes: 0cf55bbe ("staging: comedi: comedi_test: implement commands
       on AO subdevice")
      Reported-by: default avatarÉric Piel <piel@delmic.com>
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Cc: Éric Piel <piel@delmic.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd514089
    • Ian Abbott's avatar
      staging: comedi: daqboard2000: bug fix board type matching code · bc93350c
      Ian Abbott authored
      commit 80e162ee upstream.
      
      `daqboard2000_find_boardinfo()` is supposed to check if the
      DaqBoard/2000 series model is supported, based on the PCI subvendor and
      subdevice ID.  The current code is wrong as it is comparing the PCI
      device's subdevice ID to an expected, fixed value for the subvendor ID.
      It should be comparing the PCI device's subvendor ID to this fixed
      value.  Correct it.
      
      Fixes: 7e8401b2 ("staging: comedi: daqboard2000: add back subsystem_device check")
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc93350c
    • Aleksandr Makarov's avatar
      USB: serial: option: add WeTelecom 0x6802 and 0x6803 products · 1b3b122f
      Aleksandr Makarov authored
      commit 40d9c325 upstream.
      
      These product IDs are listed in Windows driver.
      0x6803 corresponds to WeTelecom WM-D300.
      0x6802 name is unknown.
      Signed-off-by: default avatarAleksandr Makarov <aleksandr.o.makarov@gmail.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b3b122f
    • Aleksandr Makarov's avatar
      USB: serial: option: add WeTelecom WM-D200 · fed48a26
      Aleksandr Makarov authored
      commit 6695593e upstream.
      
      Add support for WeTelecom WM-D200.
      
      T:  Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  4 Spd=12  MxCh= 0
      D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=22de ProdID=6801 Rev=00.00
      S:  Manufacturer=WeTelecom Incorporated
      S:  Product=WeTelecom Mobile Products
      C:  #Ifs= 4 Cfg#= 1 Atr=80 MxPwr=500mA
      I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
      I:  If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
      I:  If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
      I:  If#= 3 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
      Signed-off-by: default avatarAleksandr Makarov <aleksandr.o.makarov@gmail.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fed48a26
    • Alexey Khoroshilov's avatar
      USB: serial: mos7840: fix non-atomic allocation in write path · 201cb6d4
      Alexey Khoroshilov authored
      commit 3b7c7e52 upstream.
      
      There is an allocation with GFP_KERNEL flag in mos7840_write(),
      while it may be called from interrupt context.
      
      Follow-up for commit 19125283 ("USB: kobil_sct: fix non-atomic
      allocation in write path")
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      201cb6d4
    • Alexey Khoroshilov's avatar
      USB: serial: mos7720: fix non-atomic allocation in write path · e5d33f10
      Alexey Khoroshilov authored
      commit 5a5a1d61 upstream.
      
      There is an allocation with GFP_KERNEL flag in mos7720_write(),
      while it may be called from interrupt context.
      
      Follow-up for commit 19125283 ("USB: kobil_sct: fix non-atomic
      allocation in write path")
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e5d33f10
    • Alan Stern's avatar
      USB: fix typo in wMaxPacketSize validation · 6e0b5f82
      Alan Stern authored
      commit 6c73358c upstream.
      
      The maximum value allowed for wMaxPacketSize of a high-speed interrupt
      endpoint is 1024 bytes, not 1023.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: aed9d65a ("USB: validate wMaxPacketValue entries in endpoint descriptors")
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e0b5f82
    • Li Jun's avatar
      usb: chipidea: udc: don't touch DP when controller is in host mode · 8136b595
      Li Jun authored
      commit c4e94174 upstream.
      
      When the controller is configured to be dual role and it's in host mode,
      if bind udc and gadgt driver, those gadget operations will do gadget
      disconnect and finally pull down DP line, which will break host function.
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8136b595
    • Alan Stern's avatar
      USB: avoid left shift by -1 · 5ab968f2
      Alan Stern authored
      commit 53e5f36f upstream.
      
      UBSAN complains about a left shift by -1 in proc_do_submiturb().  This
      can occur when an URB is submitted for a bulk or control endpoint on
      a high-speed device, since the code doesn't bother to check the
      endpoint type; normally only interrupt or isochronous endpoints have
      a nonzero bInterval value.
      
      Aside from the fact that the operation is illegal, it shouldn't matter
      because the result isn't used.  Still, in theory it could cause a
      hardware exception or other problem, so we should work around it.
      This patch avoids doing the left shift unless the shift amount is >= 0.
      
      The same piece of code has another problem.  When checking the device
      speed (the exponential encoding for interrupt endpoints is used only
      by high-speed or faster devices), we need to look for speed >=
      USB_SPEED_SUPER as well as speed == USB_SPEED HIGH.  The patch adds
      this check.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarVittorio Zecca <zeccav@gmail.com>
      Tested-by: default avatarVittorio Zecca <zeccav@gmail.com>
      Suggested-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5ab968f2
    • Yoshihiro Shimoda's avatar
      dmaengine: usb-dmac: check CHCR.DE bit in usb_dmac_isr_channel() · e879dae5
      Yoshihiro Shimoda authored
      commit 626d2f07 upstream.
      
      The USB-DMAC's interruption happens even if the CHCR.DE is not set to 1
      because CHCR.NULLE is set to 1. So, this driver should call
      usb_dmac_isr_transfer_end() if the DE bit is set to 1 only. Otherwise,
      the desc is possible to be NULL in the usb_dmac_isr_transfer_end().
      
      Fixes: 0c1c8ff3 ("dmaengine: usb-dmac: Add Renesas USB DMA Controller (USB-DMAC) driver)
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e879dae5
    • Giovanni Cabiddu's avatar
      crypto: qat - fix aes-xts key sizes · ac069dea
      Giovanni Cabiddu authored
      commit 10bb087c upstream.
      
      Increase value of supported key sizes for qat_aes_xts.
      aes-xts keys consists of keys of equal size concatenated.
      
      Fixes: def14bfa ("crypto: qat - add support for ctr(aes) and xts(aes)")
      Reported-by: default avatarWenqian Yu <wenqian.yu@intel.com>
      Signed-off-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac069dea
    • Dan Carpenter's avatar
      crypto: nx - off by one bug in nx_of_update_msc() · 71d27af2
      Dan Carpenter authored
      commit e514cc0a upstream.
      
      The props->ap[] array is defined like this:
      
      	struct alg_props ap[NX_MAX_FC][NX_MAX_MODE][3];
      
      So we can see that if msc->fc and msc->mode are == to NX_MAX_FC or
      NX_MAX_MODE then we're off by one.
      
      Fixes: ae0222b7 ('powerpc/crypto: nx driver code supporting nx encryption')
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71d27af2
    • Dmitry Torokhov's avatar
      Input: i8042 - set up shared ps2_cmd_mutex for AUX ports · 9781b971
      Dmitry Torokhov authored
      commit 47af45d6 upstream.
      
      The commit 40974618 ("Input: i8042 - break load dependency ...")
      correctly set up ps2_cmd_mutex pointer for the KBD port but forgot to do
      the same for AUX port(s), which results in communication on KBD and AUX
      ports to clash with each other.
      
      Fixes: 40974618 ("Input: i8042 - break load dependency ...")
      Reported-by: default avatarBruno Wolff III <bruno@wolff.to>
      Tested-by: default avatarBruno Wolff III <bruno@wolff.to>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9781b971
    • Dmitry Torokhov's avatar
      Input: i8042 - break load dependency between atkbd/psmouse and i8042 · 11dd037e
      Dmitry Torokhov authored
      commit 40974618 upstream.
      
      As explained in 1407814240-4275-1-git-send-email-decui@microsoft.com we
      have a hard load dependency between i8042 and atkbd which prevents
      keyboard from working on Gen2 Hyper-V VMs.
      
      > hyperv_keyboard invokes serio_interrupt(), which needs a valid serio
      > driver like atkbd.c.  atkbd.c depends on libps2.c because it invokes
      > ps2_command().  libps2.c depends on i8042.c because it invokes
      > i8042_check_port_owner().  As a result, hyperv_keyboard actually
      > depends on i8042.c.
      >
      > For a Generation 2 Hyper-V VM (meaning no i8042 device emulated), if a
      > Linux VM (like Arch Linux) happens to configure CONFIG_SERIO_I8042=m
      > rather than =y, atkbd.ko can't load because i8042.ko can't load(due to
      > no i8042 device emulated) and finally hyperv_keyboard can't work and
      > the user can't input: https://bugs.archlinux.org/task/39820
      > (Ubuntu/RHEL/SUSE aren't affected since they use CONFIG_SERIO_I8042=y)
      
      To break the dependency we move away from using i8042_check_port_owner()
      and instead allow serio port owner specify a mutex that clients should use
      to serialize PS/2 command stream.
      Reported-by: default avatarMark Laws <mdl@60hz.org>
      Tested-by: default avatarMark Laws <mdl@60hz.org>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      11dd037e
    • Masahiro Yamada's avatar
      Input: tegra-kbc - fix inverted reset logic · d6720176
      Masahiro Yamada authored
      commit fae16989 upstream.
      
      Commit fe6b0dfa ("Input: tegra-kbc - use reset framework")
      accidentally converted _deassert to _assert, so there is no code
      to wake up this hardware.
      
      Fixes: fe6b0dfa ("Input: tegra-kbc - use reset framework")
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarThierry Reding <treding@nvidia.com>
      Acked-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6720176
    • Jeff Mahoney's avatar
      btrfs: properly track when rescan worker is running · cc79d398
      Jeff Mahoney authored
      commit d2c609b8 upstream.
      
      The qgroup_flags field is overloaded such that it reflects the on-disk
      status of qgroups and the runtime state.  The BTRFS_QGROUP_STATUS_FLAG_RESCAN
      flag is used to indicate that a rescan operation is in progress, but if
      the file system is unmounted while a rescan is running, the rescan
      operation is paused.  If the file system is then mounted read-only,
      the flag will still be present but the rescan operation will not have
      been resumed.  When we go to umount, btrfs_qgroup_wait_for_completion
      will see the flag and interpret it to mean that the rescan worker is
      still running and will wait for a completion that will never come.
      
      This patch uses a separate flag to indicate when the worker is
      running.  The locking and state surrounding the qgroup rescan worker
      needs a lot of attention beyond this patch but this is enough to
      avoid a hung umount.
      
      Signed-off-by; Jeff Mahoney <jeffm@suse.com>
      Reviewed-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      cc79d398
    • Jeff Mahoney's avatar
      btrfs: waiting on qgroup rescan should not always be interruptible · f31d48a0
      Jeff Mahoney authored
      commit d06f23d6 upstream.
      
      We wait on qgroup rescan completion in three places: file system
      shutdown, the quota disable ioctl, and the rescan wait ioctl.  If the
      user sends a signal while we're waiting, we continue happily along.  This
      is expected behavior for the rescan wait ioctl.  It's racy in the shutdown
      path but mostly works due to other unrelated synchronization points.
      In the quota disable path, it Oopses the kernel pretty much immediately.
      Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarChris Mason <clm@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f31d48a0
    • Vegard Nossum's avatar
      fs/seq_file: fix out-of-bounds read · 104b0d19
      Vegard Nossum authored
      commit 088bf2ff upstream.
      
      seq_read() is a nasty piece of work, not to mention buggy.
      
      It has (I think) an old bug which allows unprivileged userspace to read
      beyond the end of m->buf.
      
      I was getting these:
      
          BUG: KASAN: slab-out-of-bounds in seq_read+0xcd2/0x1480 at addr ffff880116889880
          Read of size 2713 by task trinity-c2/1329
          CPU: 2 PID: 1329 Comm: trinity-c2 Not tainted 4.8.0-rc1+ #96
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
          Call Trace:
            kasan_object_err+0x1c/0x80
            kasan_report_error+0x2cb/0x7e0
            kasan_report+0x4e/0x80
            check_memory_region+0x13e/0x1a0
            kasan_check_read+0x11/0x20
            seq_read+0xcd2/0x1480
            proc_reg_read+0x10b/0x260
            do_loop_readv_writev.part.5+0x140/0x2c0
            do_readv_writev+0x589/0x860
            vfs_readv+0x7b/0xd0
            do_readv+0xd8/0x2c0
            SyS_readv+0xb/0x10
            do_syscall_64+0x1b3/0x4b0
            entry_SYSCALL64_slow_path+0x25/0x25
          Object at ffff880116889100, in cache kmalloc-4096 size: 4096
          Allocated:
          PID = 1329
            save_stack_trace+0x26/0x80
            save_stack+0x46/0xd0
            kasan_kmalloc+0xad/0xe0
            __kmalloc+0x1aa/0x4a0
            seq_buf_alloc+0x35/0x40
            seq_read+0x7d8/0x1480
            proc_reg_read+0x10b/0x260
            do_loop_readv_writev.part.5+0x140/0x2c0
            do_readv_writev+0x589/0x860
            vfs_readv+0x7b/0xd0
            do_readv+0xd8/0x2c0
            SyS_readv+0xb/0x10
            do_syscall_64+0x1b3/0x4b0
            return_from_SYSCALL_64+0x0/0x6a
          Freed:
          PID = 0
          (stack is not available)
          Memory state around the buggy address:
           ffff88011688a000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
           ffff88011688a080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
          >ffff88011688a100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      		       ^
           ffff88011688a180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
           ffff88011688a200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
          ==================================================================
          Disabling lock debugging due to kernel taint
      
      This seems to be the same thing that Dave Jones was seeing here:
      
        https://lkml.org/lkml/2016/8/12/334
      
      There are multiple issues here:
      
        1) If we enter the function with a non-empty buffer, there is an attempt
           to flush it. But it was not clearing m->from after doing so, which
           means that if we try to do this flush twice in a row without any call
           to traverse() in between, we are going to be reading from the wrong
           place -- the splat above, fixed by this patch.
      
        2) If there's a short write to userspace because of page faults, the
           buffer may already contain multiple lines (i.e. pos has advanced by
           more than 1), but we don't save the progress that was made so the
           next call will output what we've already returned previously. Since
           that is a much less serious issue (and I have a headache after
           staring at seq_read() for the past 8 hours), I'll leave that for now.
      
      Link: http://lkml.kernel.org/r/1471447270-32093-1-git-send-email-vegard.nossum@oracle.comSigned-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Reported-by: default avatarDave Jones <davej@codemonkey.org.uk>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      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>
      104b0d19
    • Linus Walleij's avatar
      gpio: Fix OF build problem on UM · 3e7c26db
      Linus Walleij authored
      commit 2527ecc9 upstream.
      
      The UserMode (UM) Linux build was failing in gpiolib-of as it requires
      ioremap()/iounmap() to exist, which is absent from UM. The non-existence
      of IO memory is negatively defined as CONFIG_NO_IOMEM which means we
      need to depend on HAS_IOMEM.
      
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3e7c26db
    • Wei Yongjun's avatar
      usb: renesas_usbhs: gadget: fix return value check in usbhs_mod_gadget_probe() · 13371687
      Wei Yongjun authored
      commit 3295235f upstream.
      
      In case of error, the function usb_get_phy() returns ERR_PTR() and never
      returns NULL. The NULL test in the return value check should be replaced
      with IS_ERR().
      
      Fixes: b5a28756 ("usb: renesas_usbhs: Allow an OTG PHY driver to
      	provide VBUS")
      Acked-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarWei Yongjun <weiyj.lk@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13371687
    • Yinghai Lu's avatar
      megaraid_sas: Fix probing cards without io port · bbaf7193
      Yinghai Lu authored
      commit e7f85168 upstream.
      
      Found one megaraid_sas HBA probe fails,
      
      [  187.235190] scsi host2: Avago SAS based MegaRAID driver
      [  191.112365] megaraid_sas 0000:89:00.0: BAR 0: can't reserve [io  0x0000-0x00ff]
      [  191.120548] megaraid_sas 0000:89:00.0: IO memory region busy!
      
      and the card has resource like,
      [  125.097714] pci 0000:89:00.0: [1000:005d] type 00 class 0x010400
      [  125.104446] pci 0000:89:00.0: reg 0x10: [io  0x0000-0x00ff]
      [  125.110686] pci 0000:89:00.0: reg 0x14: [mem 0xce400000-0xce40ffff 64bit]
      [  125.118286] pci 0000:89:00.0: reg 0x1c: [mem 0xce300000-0xce3fffff 64bit]
      [  125.125891] pci 0000:89:00.0: reg 0x30: [mem 0xce200000-0xce2fffff pref]
      
      that does not io port resource allocated from BIOS, and kernel can not
      assign one as io port shortage.
      
      The driver is only looking for MEM, and should not fail.
      
      It turns out megasas_init_fw() etc are using bar index as mask.  index 1
      is used as mask 1, so that pci_request_selected_regions() is trying to
      request BAR0 instead of BAR1.
      
      Fix all related reference.
      
      Fixes: b6d5d880 ("megaraid_sas: Use lowest memory bar for SR-IOV VF support")
      Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
      Acked-by: default avatarKashyap Desai <kashyap.desai@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbaf7193
    • Greg Edwards's avatar
      mpt3sas: Fix resume on WarpDrive flash cards · 7386f927
      Greg Edwards authored
      commit ce7c6c9e upstream.
      
      mpt3sas crashes on resume after suspend with WarpDrive flash cards.  The
      reply_post_host_index array is not set back up after the resume, and we
      deference a stale pointer in _base_interrupt().
      
      [   47.309711] BUG: unable to handle kernel paging request at ffffc90001f8006c
      [   47.318289] IP: [<ffffffffc00863ef>] _base_interrupt+0x49f/0xa30 [mpt3sas]
      [   47.326749] PGD 41ccaa067 PUD 41ccab067 PMD 3466c067 PTE 0
      [   47.333848] Oops: 0002 [#1] SMP
      ...
      [   47.452708] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.7.0 #6
      [   47.460506] Hardware name: Dell Inc. OptiPlex 990/06D7TR, BIOS A18 09/24/2013
      [   47.469629] task: ffffffff81c0d500 ti: ffffffff81c00000 task.ti: ffffffff81c00000
      [   47.479112] RIP: 0010:[<ffffffffc00863ef>]  [<ffffffffc00863ef>] _base_interrupt+0x49f/0xa30 [mpt3sas]
      [   47.490466] RSP: 0018:ffff88041d203e30  EFLAGS: 00010002
      [   47.497801] RAX: 0000000000000001 RBX: ffff880033f4c000 RCX: 0000000000000001
      [   47.506973] RDX: ffffc90001f8006c RSI: 0000000000000082 RDI: 0000000000000082
      [   47.516141] RBP: ffff88041d203eb0 R08: ffff8804118e2820 R09: 0000000000000001
      [   47.525300] R10: 0000000000000001 R11: 00000000100c0000 R12: 0000000000000000
      [   47.534457] R13: ffff880412c487e0 R14: ffff88041a8987d8 R15: 0000000000000001
      [   47.543632] FS:  0000000000000000(0000) GS:ffff88041d200000(0000) knlGS:0000000000000000
      [   47.553796] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   47.561632] CR2: ffffc90001f8006c CR3: 0000000001c06000 CR4: 00000000000406f0
      [   47.570883] Stack:
      [   47.575015]  000000001d211228 ffff88041d2100c0 ffff8800c47d8130 0000000000000100
      [   47.584625]  ffff8804100c0000 100c000000000000 ffff88041a8992a0 ffff88041a8987f8
      [   47.594230]  ffff88041d203e00 ffffffff81111e55 000000000000038c ffff880414ad4280
      [   47.603862] Call Trace:
      [   47.608474]  <IRQ>
      [   47.610413]  [<ffffffff81111e55>] ? call_timer_fn+0x35/0x120
      [   47.620539]  [<ffffffff81100a1f>] handle_irq_event_percpu+0x7f/0x1c0
      [   47.629061]  [<ffffffff81100b8c>] handle_irq_event+0x2c/0x50
      [   47.636859]  [<ffffffff81103fff>] handle_edge_irq+0x6f/0x130
      [   47.644654]  [<ffffffff8102fbf3>] handle_irq+0x73/0x120
      [   47.652011]  [<ffffffff810c6ada>] ? atomic_notifier_call_chain+0x1a/0x20
      [   47.660854]  [<ffffffff817e374b>] do_IRQ+0x4b/0xd0
      [   47.667777]  [<ffffffff817e160c>] common_interrupt+0x8c/0x8c
      [   47.675635]  <EOI>
      
      Move the reply_post_host_index array setup into
      mpt3sas_base_map_resources(), which is also in the resume path.
      Signed-off-by: default avatarGreg Edwards <gedwards@fireweed.org>
      Acked-by: default avatarChaitra P B <chaitra.basappa@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7386f927