1. 18 Oct, 2017 10 commits
    • Jaejoong Kim's avatar
      HID: usbhid: fix out-of-bounds bug · 2929cb99
      Jaejoong Kim authored
      commit f043bfc9 upstream.
      
      The hid descriptor identifies the length and type of subordinate
      descriptors for a device. If the received hid descriptor is smaller than
      the size of the struct hid_descriptor, it is possible to cause
      out-of-bounds.
      
      In addition, if bNumDescriptors of the hid descriptor have an incorrect
      value, this can also cause out-of-bounds while approaching hdesc->desc[n].
      
      So check the size of hid descriptor and bNumDescriptors.
      
      	BUG: KASAN: slab-out-of-bounds in usbhid_parse+0x9b1/0xa20
      	Read of size 1 at addr ffff88006c5f8edf by task kworker/1:2/1261
      
      	CPU: 1 PID: 1261 Comm: kworker/1:2 Not tainted
      	4.14.0-rc1-42251-gebb2c243 #169
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
      	Workqueue: usb_hub_wq hub_event
      	Call Trace:
      	__dump_stack lib/dump_stack.c:16
      	dump_stack+0x292/0x395 lib/dump_stack.c:52
      	print_address_description+0x78/0x280 mm/kasan/report.c:252
      	kasan_report_error mm/kasan/report.c:351
      	kasan_report+0x22f/0x340 mm/kasan/report.c:409
      	__asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:427
      	usbhid_parse+0x9b1/0xa20 drivers/hid/usbhid/hid-core.c:1004
      	hid_add_device+0x16b/0xb30 drivers/hid/hid-core.c:2944
      	usbhid_probe+0xc28/0x1100 drivers/hid/usbhid/hid-core.c:1369
      	usb_probe_interface+0x35d/0x8e0 drivers/usb/core/driver.c:361
      	really_probe drivers/base/dd.c:413
      	driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
      	__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
      	bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
      	__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
      	device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
      	bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
      	device_add+0xd0b/0x1660 drivers/base/core.c:1835
      	usb_set_configuration+0x104e/0x1870 drivers/usb/core/message.c:1932
      	generic_probe+0x73/0xe0 drivers/usb/core/generic.c:174
      	usb_probe_device+0xaf/0xe0 drivers/usb/core/driver.c:266
      	really_probe drivers/base/dd.c:413
      	driver_probe_device+0x610/0xa00 drivers/base/dd.c:557
      	__device_attach_driver+0x230/0x290 drivers/base/dd.c:653
      	bus_for_each_drv+0x161/0x210 drivers/base/bus.c:463
      	__device_attach+0x26e/0x3d0 drivers/base/dd.c:710
      	device_initial_probe+0x1f/0x30 drivers/base/dd.c:757
      	bus_probe_device+0x1eb/0x290 drivers/base/bus.c:523
      	device_add+0xd0b/0x1660 drivers/base/core.c:1835
      	usb_new_device+0x7b8/0x1020 drivers/usb/core/hub.c:2457
      	hub_port_connect drivers/usb/core/hub.c:4903
      	hub_port_connect_change drivers/usb/core/hub.c:5009
      	port_event drivers/usb/core/hub.c:5115
      	hub_event+0x194d/0x3740 drivers/usb/core/hub.c:5195
      	process_one_work+0xc7f/0x1db0 kernel/workqueue.c:2119
      	worker_thread+0x221/0x1850 kernel/workqueue.c:2253
      	kthread+0x3a1/0x470 kernel/kthread.c:231
      	ret_from_fork+0x2a/0x40 arch/x86/entry/entry_64.S:431
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarJaejoong Kim <climbbb.kim@gmail.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2929cb99
    • Peter Ujfalusi's avatar
      dmaengine: edma: Align the memcpy acnt array size with the transfer · e7485f0f
      Peter Ujfalusi authored
      commit 87a2f622 upstream.
      
      Memory to Memory transfers does not have any special alignment needs
      regarding to acnt array size, but if one of the areas are in memory mapped
      regions (like PCIe memory), we need to make sure that the acnt array size
      is aligned with the mem copy parameters.
      
      Before "dmaengine: edma: Optimize memcpy operation" change the memcpy was set
      up in a different way: acnt == number of bytes in a word based on
      __ffs((src | dest | len), bcnt and ccnt for looping the necessary number of
      words to comlete the trasnfer.
      
      Instead of reverting the commit we can fix it to make sure that the ACNT size
      is aligned to the traswnfer.
      
      Fixes: df6694f8 (dmaengine: edma: Optimize memcpy operation)
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
      Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e7485f0f
    • Paul Burton's avatar
      MIPS: math-emu: Remove pr_err() calls from fpu_emu() · 29b202eb
      Paul Burton authored
      commit ca8eb05b upstream.
      
      The FPU emulator includes 2 calls to pr_err() which are triggered by
      invalid instruction encodings for MIPSr6 cmp.cond.fmt instructions.
      These cases are not kernel errors, merely invalid instructions which are
      already handled by delivering a SIGILL which will provide notification
      that something failed in cases where that makes sense.
      
      In cases where that SIGILL is somewhat expected & being handled, for
      example when crashme happens to generate one of the affected bad
      encodings, the message is printed with no useful context about what
      triggered it & spams the kernel log for no good reason.
      
      Remove the pr_err() calls to make crashme run silently & treat the bad
      encodings the same way we do others, with a SIGILL & no further kernel
      log output.
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Fixes: f8c3c671 ("MIPS: math-emu: Add support for the CMP.condn.fmt R6 instruction")
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/17253/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29b202eb
    • Alan Stern's avatar
      USB: dummy-hcd: Fix deadlock caused by disconnect detection · 2fff3c5c
      Alan Stern authored
      commit ab219221 upstream.
      
      The dummy-hcd driver calls the gadget driver's disconnect callback
      under the wrong conditions.  It should invoke the callback when Vbus
      power is turned off, but instead it does so when the D+ pullup is
      turned off.
      
      This can cause a deadlock in the composite core when a gadget driver
      is unregistered:
      
      [   88.361471] ============================================
      [   88.362014] WARNING: possible recursive locking detected
      [   88.362580] 4.14.0-rc2+ #9 Not tainted
      [   88.363010] --------------------------------------------
      [   88.363561] v4l_id/526 is trying to acquire lock:
      [   88.364062]  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547e03>] composite_disconnect+0x43/0x100 [libcomposite]
      [   88.365051]
      [   88.365051] but task is already holding lock:
      [   88.365826]  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
      [   88.366858]
      [   88.366858] other info that might help us debug this:
      [   88.368301]  Possible unsafe locking scenario:
      [   88.368301]
      [   88.369304]        CPU0
      [   88.369701]        ----
      [   88.370101]   lock(&(&cdev->lock)->rlock);
      [   88.370623]   lock(&(&cdev->lock)->rlock);
      [   88.371145]
      [   88.371145]  *** DEADLOCK ***
      [   88.371145]
      [   88.372211]  May be due to missing lock nesting notation
      [   88.372211]
      [   88.373191] 2 locks held by v4l_id/526:
      [   88.373715]  #0:  (&(&cdev->lock)->rlock){....}, at: [<ffffffffa0547b09>] usb_function_deactivate+0x29/0x80 [libcomposite]
      [   88.374814]  #1:  (&(&dum_hcd->dum->lock)->rlock){....}, at: [<ffffffffa05bd48d>] dummy_pullup+0x7d/0xf0 [dummy_hcd]
      [   88.376289]
      [   88.376289] stack backtrace:
      [   88.377726] CPU: 0 PID: 526 Comm: v4l_id Not tainted 4.14.0-rc2+ #9
      [   88.378557] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
      [   88.379504] Call Trace:
      [   88.380019]  dump_stack+0x86/0xc7
      [   88.380605]  __lock_acquire+0x841/0x1120
      [   88.381252]  lock_acquire+0xd5/0x1c0
      [   88.381865]  ? composite_disconnect+0x43/0x100 [libcomposite]
      [   88.382668]  _raw_spin_lock_irqsave+0x40/0x54
      [   88.383357]  ? composite_disconnect+0x43/0x100 [libcomposite]
      [   88.384290]  composite_disconnect+0x43/0x100 [libcomposite]
      [   88.385490]  set_link_state+0x2d4/0x3c0 [dummy_hcd]
      [   88.386436]  dummy_pullup+0xa7/0xf0 [dummy_hcd]
      [   88.387195]  usb_gadget_disconnect+0xd8/0x160 [udc_core]
      [   88.387990]  usb_gadget_deactivate+0xd3/0x160 [udc_core]
      [   88.388793]  usb_function_deactivate+0x64/0x80 [libcomposite]
      [   88.389628]  uvc_function_disconnect+0x1e/0x40 [usb_f_uvc]
      
      This patch changes the code to test the port-power status bit rather
      than the port-connect status bit when deciding whether to isue the
      callback.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarDavid Tulloh <david@tulloh.id.au>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2fff3c5c
    • Paul E. McKenney's avatar
      rcu: Allow for page faults in NMI handlers · 5fd45516
      Paul E. McKenney authored
      commit 28585a83 upstream.
      
      A number of architecture invoke rcu_irq_enter() on exception entry in
      order to allow RCU read-side critical sections in the exception handler
      when the exception is from an idle or nohz_full CPU.  This works, at
      least unless the exception happens in an NMI handler.  In that case,
      rcu_nmi_enter() would already have exited the extended quiescent state,
      which would mean that rcu_irq_enter() would (incorrectly) cause RCU
      to think that it is again in an extended quiescent state.  This will
      in turn result in lockdep splats in response to later RCU read-side
      critical sections.
      
      This commit therefore causes rcu_irq_enter() and rcu_irq_exit() to
      take no action if there is an rcu_nmi_enter() in effect, thus avoiding
      the unscheduled return to RCU quiescent state.  This in turn should
      make the kernel safe for on-demand RCU voyeurism.
      
      Link: http://lkml.kernel.org/r/20170922211022.GA18084@linux.vnet.ibm.com
      
      Cc: stable@vger.kernel.org
      Fixes: 0be964be ("module: Sanitize RCU usage and locking")
      Reported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fd45516
    • Luca Coelho's avatar
      iwlwifi: mvm: use IWL_HCMD_NOCOPY for MCAST_FILTER_CMD · 45bd4e40
      Luca Coelho authored
      commit 97bce57b upstream.
      
      The MCAST_FILTER_CMD can get quite large when we have many mcast
      addresses to set (we support up to 255).  So the command should be
      send as NOCOPY to prevent a warning caused by too-long commands:
      
      WARNING: CPU: 0 PID: 9700 at /root/iwlwifi/stack-dev/drivers/net/wireless/intel/iwlwifi/pcie/tx.c:1550 iwl_pcie_enqueue_hcmd+0x8c7/0xb40 [iwlwifi]
      Command MCAST_FILTER_CMD (0x1d0) is too large (328 bytes)
      
      This fixes: https://bugzilla.kernel.org/show_bug.cgi?id=196743Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      45bd4e40
    • Peng Xu's avatar
      nl80211: Define policy for packet pattern attributes · 6a6c61d8
      Peng Xu authored
      commit ad670233 upstream.
      
      Define a policy for packet pattern attributes in order to fix a
      potential read over the end of the buffer during nla_get_u32()
      of the NL80211_PKTPAT_OFFSET attribute.
      
      Note that the data there can always be read due to SKB allocation
      (with alignment and struct skb_shared_info at the end), but the
      data might be uninitialized. This could be used to leak some data
      from uninitialized vmalloc() memory, but most drivers don't allow
      an offset (so you'd just get -EINVAL if the data is non-zero) or
      just allow it with a fixed value - 100 or 128 bytes, so anything
      above that would get -EINVAL. With brcmfmac the limit is 1500 so
      (at least) one byte could be obtained.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarPeng Xu <pxu@qti.qualcomm.com>
      Signed-off-by: default avatarJouni Malinen <jouni@qca.qualcomm.com>
      [rewrite description based on SKB allocation knowledge]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a6c61d8
    • Pavel Shilovsky's avatar
      CIFS: Reconnect expired SMB sessions · f2bb4bcc
      Pavel Shilovsky authored
      commit 511c54a2 upstream.
      
      According to the MS-SMB2 spec (3.2.5.1.6) once the client receives
      STATUS_NETWORK_SESSION_EXPIRED error code from a server it should
      reconnect the current SMB session. Currently the client doesn't do
      that. This can result in subsequent client requests failing by
      the server. The patch adds an additional logic to the demultiplex
      thread to identify expired sessions and reconnect them.
      Signed-off-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: default avatarSteve French <smfrench@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2bb4bcc
    • Darrick J. Wong's avatar
      ext4: in ext4_seek_{hole,data}, return -ENXIO for negative offsets · bd368269
      Darrick J. Wong authored
      commit 1bd8d6cd upstream.
      
      In the ext4 implementations of SEEK_HOLE and SEEK_DATA, make sure we
      return -ENXIO for negative offsets instead of banging around inside
      the extent code and returning -EFSCORRUPTED.
      Reported-by: default avatarMateusz S <muttdini@gmail.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd368269
    • Arend Van Spriel's avatar
      brcmfmac: add length check in brcmf_cfg80211_escan_handler() · 6721969c
      Arend Van Spriel authored
      commit 17df6453 upstream.
      
      Upon handling the firmware notification for scans the length was
      checked properly and may result in corrupting kernel heap memory
      due to buffer overruns. This fix addresses CVE-2017-0786.
      
      Cc: Kevin Cernekee <cernekee@chromium.org>
      Reviewed-by: default avatarHante Meuleman <hante.meuleman@broadcom.com>
      Reviewed-by: default avatarPieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
      Reviewed-by: default avatarFranky Lin <franky.lin@broadcom.com>
      Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6721969c
  2. 12 Oct, 2017 30 commits