1. 12 Oct, 2017 25 commits
    • Martin K. Petersen's avatar
      scsi: sd: Do not override max_sectors_kb sysfs setting · 9e78ac87
      Martin K. Petersen authored
      commit 77082ca5 upstream.
      
      A user may lower the max_sectors_kb setting in sysfs to accommodate
      certain workloads. Previously we would always set the max I/O size to
      either the block layer default or the optional preferred I/O size
      reported by the device.
      
      Keep the current heuristics for the initial setting of max_sectors_kb.
      For subsequent invocations, only update the current queue limit if it
      exceeds the capabilities of the hardware.
      Reported-by: default avatarDon Brace <don.brace@microsemi.com>
      Reviewed-by: default avatarMartin Wilck <mwilck@suse.com>
      Tested-by: default avatarDon Brace <don.brace@microsemi.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e78ac87
    • Luca Coelho's avatar
      iwlwifi: add workaround to disable wide channels in 5GHz · fc29713f
      Luca Coelho authored
      commit 01a9c948 upstream.
      
      The OTP in some SKUs have erroneously allowed 40MHz and 80MHz channels
      in the 5.2GHz band.  The firmware has been modified to not allow this
      in those SKUs, so the driver needs to do the same otherwise the
      firmware will assert when we try to use it.
      Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      fc29713f
    • Adrian Salido's avatar
      HID: i2c-hid: allocate hid buffers for real worst case · 146a9dc9
      Adrian Salido authored
      commit 8320caee upstream.
      
      The buffer allocation is not currently accounting for an extra byte for
      the report id. This can cause an out of bounds access in function
      i2c_hid_set_or_send_report() with reportID > 15.
      Signed-off-by: default avatarAdrian Salido <salidoa@google.com>
      Reviewed-by: default avatarBenson Leung <bleung@chromium.org>
      Signed-off-by: default avatarGuenter Roeck <groeck@chromium.org>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      146a9dc9
    • Shu Wang's avatar
      ftrace: Fix kmemleak in unregister_ftrace_graph · 87509592
      Shu Wang authored
      commit 2b0b8499 upstream.
      
      The trampoline allocated by function tracer was overwriten by function_graph
      tracer, and caused a memory leak. The save_global_trampoline should have
      saved the previous trampoline in register_ftrace_graph() and restored it in
      unregister_ftrace_graph(). But as it is implemented, save_global_trampoline was
      only used in unregister_ftrace_graph as default value 0, and it overwrote the
      previous trampoline's value. Causing the previous allocated trampoline to be
      lost.
      
      kmmeleak backtrace:
          kmemleak_vmalloc+0x77/0xc0
          __vmalloc_node_range+0x1b5/0x2c0
          module_alloc+0x7c/0xd0
          arch_ftrace_update_trampoline+0xb5/0x290
          ftrace_startup+0x78/0x210
          register_ftrace_function+0x8b/0xd0
          function_trace_init+0x4f/0x80
          tracing_set_tracer+0xe6/0x170
          tracing_set_trace_write+0x90/0xd0
          __vfs_write+0x37/0x170
          vfs_write+0xb2/0x1b0
          SyS_write+0x55/0xc0
          do_syscall_64+0x67/0x180
          return_from_SYSCALL_64+0x0/0x6a
      
      [
        Looking further into this, I found that this was left over from when the
        function and function graph tracers shared the same ftrace_ops. But in
        commit 5f151b24 ("ftrace: Fix function_profiler and function tracer
        together"), the two were separated, and the save_global_trampoline no
        longer was necessary (and it may have been broken back then too).
        -- Steven Rostedt
      ]
      
      Link: http://lkml.kernel.org/r/20170912021454.5976-1-shuwang@redhat.com
      
      Fixes: 5f151b24 ("ftrace: Fix function_profiler and function tracer together")
      Signed-off-by: default avatarShu Wang <shuwang@redhat.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87509592
    • Alexander Shishkin's avatar
      stm class: Fix a use-after-free · 60623d7c
      Alexander Shishkin authored
      commit fd085bb1 upstream.
      
      For reasons unknown, the stm_source removal path uses device_destroy()
      to kill the underlying device object. Because device_destroy() uses
      devt to look for the device to destroy and the fact that stm_source
      devices don't have one (or all have the same one), it just picks the
      first device in the class, which may well be the wrong one.
      
      That is, loading stm_console and stm_heartbeat and then removing both
      will die in dereferencing a freed object.
      
      Since this should have been device_unregister() in the first place,
      use it instead of device_destroy().
      Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Fixes: 7bd1d409 ("stm class: Introduce an abstraction for System Trace Module devices")
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      60623d7c
    • Olaf Hering's avatar
      Drivers: hv: fcopy: restore correct transfer length · c85e9442
      Olaf Hering authored
      commit 549e658a upstream.
      
      Till recently the expected length of bytes read by the
      daemon did depend on the context. It was either hv_start_fcopy or
      hv_do_fcopy. The daemon had a buffer size of two pages, which was much
      larger than needed.
      
      Now the expected length of bytes read by the
      daemon changed slightly. For START_FILE_COPY it is still the size of
      hv_start_fcopy.  But for WRITE_TO_FILE and the other operations it is as
      large as the buffer that arrived via vmbus. In case of WRITE_TO_FILE
      that is slightly larger than a struct hv_do_fcopy. Since the buffer in
      the daemon was still larger everything was fine.
      
      Currently, the daemon reads only what is actually needed.
      The new buffer layout is as large as a struct hv_do_fcopy, for the
      WRITE_TO_FILE operation. Since the kernel expects a slightly larger
      size, hvt_op_read will return -EINVAL because the daemon will read
      slightly less than expected. Address this by restoring the expected
      buffer size in case of WRITE_TO_FILE.
      
      Fixes: 'c7e490fc ("Drivers: hv: fcopy: convert to hv_utils_transport")'
      Fixes: '3f2baa8a ("Tools: hv: update buffer handling in hv_fcopy_daemon")'
      Signed-off-by: default avatarOlaf Hering <olaf@aepfle.de>
      Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c85e9442
    • Nicolai Stange's avatar
      driver core: platform: Don't read past the end of "driver_override" buffer · 2b91a52e
      Nicolai Stange authored
      commit bf563b01 upstream.
      
      When printing the driver_override parameter when it is 4095 and 4094 bytes
      long, the printing code would access invalid memory because we need count+1
      bytes for printing.
      
      Reject driver_override values of these lengths in driver_override_store().
      
      This is in close analogy to commit 4efe874a ("PCI: Don't read past the
      end of sysfs "driver_override" buffer") from Sasha Levin.
      
      Fixes: 3d713e0e ("driver core: platform: add device binding path 'driver_override'")
      Signed-off-by: default avatarNicolai Stange <nstange@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2b91a52e
    • Takashi Iwai's avatar
      ALSA: usx2y: Suppress kernel warning at page allocation failures · 6d1bc9ee
      Takashi Iwai authored
      commit 7682e399 upstream.
      
      The usx2y driver allocates the stream read/write buffers in continuous
      pages depending on the stream setup, and this may spew the kernel
      warning messages with a stack trace like:
        WARNING: CPU: 1 PID: 1846 at mm/page_alloc.c:3883
        __alloc_pages_slowpath+0x1ef2/0x2d70
        Modules linked in:
        CPU: 1 PID: 1846 Comm: kworker/1:2 Not tainted
        ....
      
      It may confuse user as if it were any serious error, although this is
      no fatal error and the driver handles the error case gracefully.
      Since the driver has already some sanity check of the given size (128
      and 256 pages), it can't pass any crazy value.  So it's merely page
      fragmentation.
      
      This patch adds __GFP_NOWARN to each caller for suppressing such
      kernel warnings.  The original issue was spotted by syzkaller.
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d1bc9ee
    • Guneshwor Singh's avatar
      ALSA: compress: Remove unused variable · 8cff1556
      Guneshwor Singh authored
      commit a931b9ce upstream.
      
      Commit 04c5d5a4 ("ALSA: compress: Embed struct device") removed
      the statement that used 'str' but didn't remove the variable itself.
      So remove it.
      
      [Adding stable to Cc since pr_debug() may refer to the uninitialized
       buffer -- tiwai]
      
      Fixes: 04c5d5a4 ("ALSA: compress: Embed struct device")
      Signed-off-by: default avatarGuneshwor Singh <guneshwor.o.singh@intel.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8cff1556
    • Casey Schaufler's avatar
      lsm: fix smack_inode_removexattr and xattr_getsecurity memleak · dd1f96a0
      Casey Schaufler authored
      commit 57e7ba04 upstream.
      
      security_inode_getsecurity() provides the text string value
      of a security attribute. It does not provide a "secctx".
      The code in xattr_getsecurity() that calls security_inode_getsecurity()
      and then calls security_release_secctx() happened to work because
      SElinux and Smack treat the attribute and the secctx the same way.
      It fails for cap_inode_getsecurity(), because that module has no
      secctx that ever needs releasing. It turns out that Smack is the
      one that's doing things wrong by not allocating memory when instructed
      to do so by the "alloc" parameter.
      
      The fix is simple enough. Change the security_release_secctx() to
      kfree() because it isn't a secctx being returned by
      security_inode_getsecurity(). Change Smack to allocate the string when
      told to do so.
      
      Note: this also fixes memory leaks for LSMs which implement
      inode_getsecurity but not release_secctx, such as capabilities.
      Signed-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Reported-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd1f96a0
    • Alan Stern's avatar
      USB: g_mass_storage: Fix deadlock when driver is unbound · a44be3e5
      Alan Stern authored
      commit 1fbbb78f upstream.
      
      As a holdover from the old g_file_storage gadget, the g_mass_storage
      legacy gadget driver attempts to unregister itself when its main
      operating thread terminates (if it hasn't been unregistered already).
      This is not strictly necessary; it was never more than an attempt to
      have the gadget fail cleanly if something went wrong and the main
      thread was killed.
      
      However, now that the UDC core manages gadget drivers independently of
      UDC drivers, this scheme doesn't work any more.  A simple test:
      
      	modprobe dummy-hcd
      	modprobe g-mass-storage file=...
      	rmmod dummy-hcd
      
      ends up in a deadlock with the following backtrace:
      
       sysrq: SysRq : Show Blocked State
         task                PC stack   pid father
       file-storage    D    0  1130      2 0x00000000
       Call Trace:
        __schedule+0x53e/0x58c
        schedule+0x6e/0x77
        schedule_preempt_disabled+0xd/0xf
        __mutex_lock.isra.1+0x129/0x224
        ? _raw_spin_unlock_irqrestore+0x12/0x14
        __mutex_lock_slowpath+0x12/0x14
        mutex_lock+0x28/0x2b
        usb_gadget_unregister_driver+0x29/0x9b [udc_core]
        usb_composite_unregister+0x10/0x12 [libcomposite]
        msg_cleanup+0x1d/0x20 [g_mass_storage]
        msg_thread_exits+0xd/0xdd7 [g_mass_storage]
        fsg_main_thread+0x1395/0x13d6 [usb_f_mass_storage]
        ? __schedule+0x573/0x58c
        kthread+0xd9/0xdb
        ? do_set_interface+0x25c/0x25c [usb_f_mass_storage]
        ? init_completion+0x1e/0x1e
        ret_from_fork+0x19/0x24
       rmmod           D    0  1155    683 0x00000000
       Call Trace:
        __schedule+0x53e/0x58c
        schedule+0x6e/0x77
        schedule_timeout+0x26/0xbc
        ? __schedule+0x573/0x58c
        do_wait_for_common+0xb3/0x128
        ? usleep_range+0x81/0x81
        ? wake_up_q+0x3f/0x3f
        wait_for_common+0x2e/0x45
        wait_for_completion+0x17/0x19
        fsg_common_put+0x34/0x81 [usb_f_mass_storage]
        fsg_free_inst+0x13/0x1e [usb_f_mass_storage]
        usb_put_function_instance+0x1a/0x25 [libcomposite]
        msg_unbind+0x2a/0x42 [g_mass_storage]
        __composite_unbind+0x4a/0x6f [libcomposite]
        composite_unbind+0x12/0x14 [libcomposite]
        usb_gadget_remove_driver+0x4f/0x77 [udc_core]
        usb_del_gadget_udc+0x52/0xcc [udc_core]
        dummy_udc_remove+0x27/0x2c [dummy_hcd]
        platform_drv_remove+0x1d/0x31
        device_release_driver_internal+0xe9/0x16d
        device_release_driver+0x11/0x13
        bus_remove_device+0xd2/0xe2
        device_del+0x19f/0x221
        ? selinux_capable+0x22/0x27
        platform_device_del+0x21/0x63
        platform_device_unregister+0x10/0x1a
        cleanup+0x20/0x817 [dummy_hcd]
        SyS_delete_module+0x10c/0x197
        ? ____fput+0xd/0xf
        ? task_work_run+0x55/0x62
        ? prepare_exit_to_usermode+0x65/0x75
        do_fast_syscall_32+0x86/0xc3
        entry_SYSENTER_32+0x4e/0x7c
      
      What happens is that removing the dummy-hcd driver causes the UDC core
      to unbind the gadget driver, which it does while holding the udc_lock
      mutex.  The unbind routine in g_mass_storage tells the main thread to
      exit and waits for it to terminate.
      
      But as mentioned above, when the main thread exits it tries to
      unregister the mass-storage function driver.  Via the composite
      framework this ends up calling usb_gadget_unregister_driver(), which
      tries to acquire the udc_lock mutex.  The result is deadlock.
      
      The simplest way to fix the problem is not to be so clever: The main
      thread doesn't have to unregister the function driver.  The side
      effects won't be so terrible; if the gadget is still attached to a USB
      host when the main thread is killed, it will appear to the host as
      though the gadget's firmware has crashed -- a reasonably accurate
      interpretation, and an all-too-common occurrence for USB mass-storage
      devices.
      
      In fact, the code to unregister the driver when the main thread exits
      is specific to g-mass-storage; it is not used when f-mass-storage is
      included as a function in a larger composite device.  Therefore the
      entire mechanism responsible for this (the fsg_operations structure
      with its ->thread_exits method, the fsg_common_set_ops() routine, and
      the msg_thread_exits() callback routine) can all be eliminated.  Even
      the msg_registered bitflag can be removed, because now the driver is
      unregistered in only one place rather than in two places.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Acked-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Acked-by: default avatarMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a44be3e5
    • Li Jun's avatar
      usb: gadget: mass_storage: set msg_registered after msg registered · 2efab2c3
      Li Jun authored
      commit 8e55d303 upstream.
      
      If there is no UDC available, the msg register will fail and this
      flag will not be set, but the driver is already added into pending
      driver list, then the module removal modprobe -r can not remove
      the driver from the pending list.
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2efab2c3
    • Dan Carpenter's avatar
      USB: devio: Don't corrupt user memory · b74a4545
      Dan Carpenter authored
      commit fa1ed74e upstream.
      
      The user buffer has "uurb->buffer_length" bytes.  If the kernel has more
      information than that, we should truncate it instead of writing past
      the end of the user's buffer.  I added a WARN_ONCE() to help the user
      debug the issue.
      Reported-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b74a4545
    • Alan Stern's avatar
      USB: dummy-hcd: Fix erroneous synchronization change · e84b4a00
      Alan Stern authored
      commit 7dbd8f4c upstream.
      
      A recent change to the synchronization in dummy-hcd was incorrect.
      The issue was that dummy_udc_stop() contained no locking and therefore
      could race with various gadget driver callbacks, and the fix was to
      add locking and issue the callbacks with the private spinlock held.
      
      UDC drivers aren't supposed to do this.  Gadget driver callback
      routines are allowed to invoke functions in the UDC driver, and these
      functions will generally try to acquire the private spinlock.  This
      would deadlock the driver.
      
      The correct solution is to drop the spinlock before issuing callbacks,
      and avoid races by emulating the synchronize_irq() call that all real
      UDC drivers must perform in their ->udc_stop() routines after
      disabling interrupts.  This involves adding a flag to dummy-hcd's
      private structure to keep track of whether interrupts are supposed to
      be enabled, and adding a counter to keep track of ongoing callbacks so
      that dummy_udc_stop() can wait for them all to finish.
      
      A real UDC driver won't receive disconnect, reset, suspend, resume, or
      setup events once it has disabled interrupts.  dummy-hcd will receive
      them but won't try to issue any gadget driver callbacks, which should
      be just as good.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks")
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e84b4a00
    • Alan Stern's avatar
      USB: dummy-hcd: fix infinite-loop resubmission bug · d1a0787b
      Alan Stern authored
      commit 0173a68b upstream.
      
      The dummy-hcd HCD/UDC emulator tries not to do too much work during
      each timer interrupt.  But it doesn't try very hard; currently all
      it does is limit the total amount of bulk data transferred.  Other
      transfer types aren't limited, and URBs that transfer no data (because
      of an error, perhaps) don't count toward the limit, even though on a
      real USB bus they would consume at least a minimum overhead.
      
      This means it's possible to get the driver stuck in an infinite loop,
      for example, if the host class driver resubmits an URB every time it
      completes (which is common for interrupt URBs).  Each time the URB is
      resubmitted it gets added to the end of the pending-URBs list, and
      dummy-hcd doesn't stop until that list is empty.  Andrey Konovalov was
      able to trigger this failure mode using the syzkaller fuzzer.
      
      This patch fixes the infinite-loop problem by restricting the URBs
      handled during each timer interrupt to those that were already on the
      pending list when the interrupt routine started.  Newly added URBs
      won't be processed until the next timer interrupt.  The problem of
      properly accounting for non-bulk bandwidth (as well as packet and
      transaction overhead) is not addressed here.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1a0787b
    • Alan Stern's avatar
      USB: dummy-hcd: fix connection failures (wrong speed) · d25a65e0
      Alan Stern authored
      commit fe659bcc upstream.
      
      The dummy-hcd UDC driver is not careful about the way it handles
      connection speeds.  It ignores the module parameter that is supposed
      to govern the maximum connection speed and it doesn't set the HCD
      flags properly for the case where it ends up running at full speed.
      
      The result is that in many cases, gadget enumeration over dummy-hcd
      fails because the bMaxPacketSize byte in the device descriptor is set
      incorrectly.  For example, the default settings call for a high-speed
      connection, but the maxpacket value for ep0 ends up being set for a
      Super-Speed connection.
      
      This patch fixes the problem by initializing the gadget's max_speed
      and the HCD flags correctly.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d25a65e0
    • Jim Dickerson's avatar
      usb: pci-quirks.c: Corrected timeout values used in handshake · da358168
      Jim Dickerson authored
      commit 114ec3a6 upstream.
      
      Servers were emitting failed handoff messages but were not
      waiting the full 1 second as designated in section 4.22.1 of
      the eXtensible Host Controller Interface specifications. The
      handshake was using wrong units so calls were made with milliseconds
      not microseconds. Comments referenced 5 seconds not 1 second as
      in specs.
      
      The wrong units were also corrected in a second handshake call.
      Signed-off-by: default avatarJim Dickerson <jim.dickerson@hpe.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da358168
    • Takashi Iwai's avatar
      ALSA: usb-audio: Check out-of-bounds access by corrupted buffer descriptor · 46c7b1fa
      Takashi Iwai authored
      commit bfc81a8b upstream.
      
      When a USB-audio device receives a maliciously adjusted or corrupted
      buffer descriptor, the USB-audio driver may access an out-of-bounce
      value at its parser.  This was detected by syzkaller, something like:
      
        BUG: KASAN: slab-out-of-bounds in usb_audio_probe+0x27b2/0x2ab0
        Read of size 1 at addr ffff88006b83a9e8 by task kworker/0:1/24
        CPU: 0 PID: 24 Comm: kworker/0:1 Not tainted 4.14.0-rc1-42251-gebb2c243 #224
        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
         snd_usb_create_streams sound/usb/card.c:248
         usb_audio_probe+0x27b2/0x2ab0 sound/usb/card.c:605
         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
      
      This patch adds the checks of out-of-bounce accesses at appropriate
      places and bails out when it goes out of the given buffer.
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46c7b1fa
    • Yoshihiro Shimoda's avatar
      usb: renesas_usbhs: fix usbhsf_fifo_clear() for RX direction · ccc6a475
      Yoshihiro Shimoda authored
      commit 0a2ce62b upstream.
      
      This patch fixes an issue that the usbhsf_fifo_clear() is possible
      to cause 10 msec delay if the pipe is RX direction and empty because
      the FRDY bit will never be set to 1 in such case.
      
      Fixes: e8d548d5 ("usb: renesas_usbhs: fifo became independent from pipe.")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ccc6a475
    • Yoshihiro Shimoda's avatar
      usb: renesas_usbhs: fix the BCLR setting condition for non-DCP pipe · a7131ed8
      Yoshihiro Shimoda authored
      commit 6124607a upstream.
      
      This patch fixes an issue that the driver sets the BCLR bit of
      {C,Dn}FIFOCTR register to 1 even when it's non-DCP pipe and
      the FRDY bit of {C,Dn}FIFOCTR register is set to 1.
      
      Fixes: e8d548d5 ("usb: renesas_usbhs: fifo became independent from pipe.")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7131ed8
    • Alan Stern's avatar
      usb-storage: unusual_devs entry to fix write-access regression for Seagate external drives · e85bd5be
      Alan Stern authored
      commit 113f6eb6 upstream.
      
      Kris Lindgren reports that without the NO_WP_DETECT flag, his Seagate
      external disk drive fails all write accesses.  This regresssion dates
      back approximately to the start of the 4.x kernel releases.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarKris Lindgren <kris.lindgren@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e85bd5be
    • Nicolas Ferre's avatar
      usb: gadget: udc: atmel: set vbus irqflags explicitly · 86377bf3
      Nicolas Ferre authored
      commit 6baeda12 upstream.
      
      The driver triggers actions on both edges of the vbus signal.
      
      The former PIO controller was triggering IRQs on both falling and rising edges
      by default. Newer PIO controller don't, so it's better to set it explicitly to
      IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING.
      
      Without this patch we may trigger the connection with host but only on some
      bouncing signal conditions and thus lose connecting events.
      Acked-by: default avatarLudovic Desroches <ludovic.desroches@microchip.com>
      Signed-off-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86377bf3
    • Alan Stern's avatar
      USB: gadgetfs: fix copy_to_user while holding spinlock · f72264e7
      Alan Stern authored
      commit 6e76c01e upstream.
      
      The gadgetfs driver as a long-outstanding FIXME, regarding a call of
      copy_to_user() made while holding a spinlock.  This patch fixes the
      issue by dropping the spinlock and using the dev->udc_usage mechanism
      introduced by another recent patch to guard against status changes
      while the lock isn't held.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Acked-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f72264e7
    • Alan Stern's avatar
      USB: gadgetfs: Fix crash caused by inadequate synchronization · d20fff0b
      Alan Stern authored
      commit 520b72fc upstream.
      
      The gadgetfs driver (drivers/usb/gadget/legacy/inode.c) was written
      before the UDC and composite frameworks were adopted; it is a legacy
      driver.  As such, it expects that once bound to a UDC controller, it
      will not be unbound until it unregisters itself.
      
      However, the UDC framework does unbind function drivers while they are
      still registered.  When this happens, it can cause the gadgetfs driver
      to misbehave or crash.  For example, userspace can cause a crash by
      opening the device file and doing an ioctl call before setting up a
      configuration (found by Andrey Konovalov using the syzkaller fuzzer).
      
      This patch adds checks and synchronization to prevent these bad
      behaviors.  It adds a udc_usage counter that the driver increments at
      times when it is using a gadget interface without holding the private
      spinlock.  The unbind routine waits for this counter to go to 0 before
      returning, thereby ensuring that the UDC is no longer in use.
      
      The patch also adds a check in the dev_ioctl() routine to make sure
      the driver is bound to a UDC before dereferencing the gadget pointer,
      and it makes destroy_ep_files() synchronize with the endpoint I/O
      routines, to prevent the user from accessing an endpoint data
      structure after it has been removed.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Acked-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d20fff0b
    • David Eccher's avatar
      usb: gadget: inode.c: fix unbalanced spin_lock in ep0_write · c2eb312f
      David Eccher authored
      commit b7bd98b7 upstream.
      
      Fix bad unlock balance: ep0_write enter with the locks locked from
      inode.c:1769, hence it must exit with spinlock held to avoid double
      unlock in dev_config.
      Signed-off-by: default avatarDavid Eccher <d.eccher@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2eb312f
  2. 08 Oct, 2017 15 commits