1. 25 8月, 2019 5 次提交
  2. 16 8月, 2019 8 次提交
    • G
      usb: typec: tcpm: Ignore unsupported/unknown alternate mode requests · 9479a058
      Guenter Roeck 提交于
      commit 88d02c9ba2e83fc22d37ccb1f11c62ea6fc9ae50 upstream.
      
      TCPM may receive PD messages associated with unknown or unsupported
      alternate modes. If that happens, calls to typec_match_altmode()
      will return NULL. The tcpm code does not currently take this into
      account. This results in crashes.
      
      Unable to handle kernel NULL pointer dereference at virtual address 000001f0
      pgd = 41dad9a1
      [000001f0] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 2338 Comm: kworker/u2:0 Not tainted 5.1.18-sama5-armv7-r2 #6
      Hardware name: Atmel SAMA5
      Workqueue: 2-0050 tcpm_pd_rx_handler [tcpm]
      PC is at typec_altmode_attention+0x0/0x14
      LR is at tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm]
      ...
      [<c03fbee8>] (typec_altmode_attention) from [<bf8030fb>]
      				(tcpm_pd_rx_handler+0xa3b/0xda0 [tcpm])
      [<bf8030fb>] (tcpm_pd_rx_handler [tcpm]) from [<c012082b>]
      				(process_one_work+0x123/0x2a8)
      [<c012082b>] (process_one_work) from [<c0120a6d>]
      				(worker_thread+0xbd/0x3b0)
      [<c0120a6d>] (worker_thread) from [<c012431f>] (kthread+0xcf/0xf4)
      [<c012431f>] (kthread) from [<c01010f9>] (ret_from_fork+0x11/0x38)
      
      Ignore PD messages if the associated alternate mode is not supported.
      
      Fixes: e9576fe8 ("usb: typec: tcpm: Support for Alternate Modes")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: NDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Acked-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Tested-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/1564761822-13984-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9479a058
    • G
      usb: typec: tcpm: Add NULL check before dereferencing config · 3f524b63
      Guenter Roeck 提交于
      commit 1957de95d425d1c06560069dc7277a73a8b28683 upstream.
      
      When instantiating tcpm on an NXP OM 13588 board with NXP PTN5110,
      the following crash is seen when writing into the 'preferred_role'
      sysfs attribute.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000028
      pgd = f69149ad
      [00000028] *pgd=00000000
      Internal error: Oops: 5 [#1] THUMB2
      Modules linked in: tcpci tcpm
      CPU: 0 PID: 1882 Comm: bash Not tainted 5.1.18-sama5-armv7-r2 #4
      Hardware name: Atmel SAMA5
      PC is at tcpm_try_role+0x3a/0x4c [tcpm]
      LR is at tcpm_try_role+0x15/0x4c [tcpm]
      pc : [<bf8000e2>]    lr : [<bf8000bd>]    psr: 60030033
      sp : dc1a1e88  ip : c03fb47d  fp : 00000000
      r10: dc216190  r9 : dc1a1f78  r8 : 00000001
      r7 : df4ae044  r6 : dd032e90  r5 : dd1ce340  r4 : df4ae054
      r3 : 00000000  r2 : 00000000  r1 : 00000000  r0 : df4ae044
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA Thumb  Segment none
      Control: 50c53c7d  Table: 3efec059  DAC: 00000051
      Process bash (pid: 1882, stack limit = 0x6a6d4aa5)
      Stack: (0xdc1a1e88 to 0xdc1a2000)
      1e80:                   dd05d808 dd1ce340 00000001 00000007 dd1ce340 c03fb4a7
      1ea0: 00000007 00000007 dc216180 00000000 00000000 c01e1e03 00000000 00000000
      1ec0: c0907008 dee98b40 c01e1d5d c06106c4 00000000 00000000 00000007 c0194e8b
      1ee0: 0000000a 00000400 00000000 c01a97db dc22bf00 ffffe000 df4b6a00 df745900
      1f00: 00000001 00000001 000000dd c01a9c2f 7aeab3be c0907008 00000000 dc22bf00
      1f20: c0907008 00000000 00000000 00000000 00000000 7aeab3be 00000007 dee98b40
      1f40: 005dc318 dc1a1f78 00000000 00000000 00000007 c01969f7 0000000a c01a20cb
      1f60: dee98b40 c0907008 dee98b40 005dc318 00000000 c0196b9b 00000000 00000000
      1f80: dee98b40 7aeab3be 00000074 005dc318 b6f3bdb0 00000004 c0101224 dc1a0000
      1fa0: 00000004 c0101001 00000074 005dc318 00000001 005dc318 00000007 00000000
      1fc0: 00000074 005dc318 b6f3bdb0 00000004 00000007 00000007 00000000 00000000
      1fe0: 00000004 be800880 b6ed35b3 b6e5c746 60030030 00000001 00000000 00000000
      [<bf8000e2>] (tcpm_try_role [tcpm]) from [<c03fb4a7>] (preferred_role_store+0x2b/0x5c)
      [<c03fb4a7>] (preferred_role_store) from [<c01e1e03>] (kernfs_fop_write+0xa7/0x150)
      [<c01e1e03>] (kernfs_fop_write) from [<c0194e8b>] (__vfs_write+0x1f/0x104)
      [<c0194e8b>] (__vfs_write) from [<c01969f7>] (vfs_write+0x6b/0x104)
      [<c01969f7>] (vfs_write) from [<c0196b9b>] (ksys_write+0x43/0x94)
      [<c0196b9b>] (ksys_write) from [<c0101001>] (ret_fast_syscall+0x1/0x62)
      
      Since commit 96232cbc ("usb: typec: tcpm: support get typec and pd
      config from device properties"), the 'config' pointer in struct tcpc_dev
      is optional when registering a Type-C port. Since it is optional, we have
      to check if it is NULL before dereferencing it.
      Reported-by: NDouglas Gilbert <dgilbert@interlog.com>
      Cc: Douglas Gilbert <dgilbert@interlog.com>
      Fixes: 96232cbc ("usb: typec: tcpm: support get typec and pd config from device properties")
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: NJun Li <jun.li@nxp.com>
      Reviewed-by: NHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/1563979112-22483-1-git-send-email-linux@roeck-us.netSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f524b63
    • L
      usb: typec: tcpm: remove tcpm dir if no children · bbc2e820
      Li Jun 提交于
      commit 12ca7297b8855c0af1848503d37196159b24e6b9 upstream.
      
      If config tcpm as module, module unload will not remove tcpm dir,
      then the next module load will have problem: the rootdir is NULL
      but tcpm dir is still there, so tcpm_debugfs_init() will create
      tcpm dir again with failure, fix it by remove the tcpm dir if no
      children.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-2-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bbc2e820
    • L
      usb: typec: tcpm: free log buf memory when remove debug file · 2ec5c9b7
      Li Jun 提交于
      commit fd5da3e2cc61b4a7c877172fdc9348c82cf6ccfc upstream.
      
      The logbuffer memory should be freed when remove debug file.
      
      Cc: stable@vger.kernel.org # v4.15+
      Fixes: 4b4e02c8 ("typec: tcpm: Move out of staging")
      Signed-off-by: NLi Jun <jun.li@nxp.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20190717080646.30421-1-jun.li@nxp.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ec5c9b7
    • S
      usb: yurex: Fix use-after-free in yurex_delete · 33f2240a
      Suzuki K Poulose 提交于
      commit fc05481b2fcabaaeccf63e32ac1baab54e5b6963 upstream.
      
      syzbot reported the following crash [0]:
      
      BUG: KASAN: use-after-free in usb_free_coherent+0x79/0x80
      drivers/usb/core/usb.c:928
      Read of size 8 at addr ffff8881b18599c8 by task syz-executor.4/16007
      
      CPU: 0 PID: 16007 Comm: syz-executor.4 Not tainted 5.3.0-rc2+ #23
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Call Trace:
        __dump_stack lib/dump_stack.c:77 [inline]
        dump_stack+0xca/0x13e lib/dump_stack.c:113
        print_address_description+0x6a/0x32c mm/kasan/report.c:351
        __kasan_report.cold+0x1a/0x33 mm/kasan/report.c:482
        kasan_report+0xe/0x12 mm/kasan/common.c:612
        usb_free_coherent+0x79/0x80 drivers/usb/core/usb.c:928
        yurex_delete+0x138/0x330 drivers/usb/misc/yurex.c:100
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x413511
      Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48
      83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48
      89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
      RSP: 002b:00007ffc424ea2e0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
      RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413511
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006
      RBP: 0000000000000001 R08: 0000000029a2fc22 R09: 0000000029a2fc26
      R10: 00007ffc424ea3c0 R11: 0000000000000293 R12: 000000000075c9a0
      R13: 000000000075c9a0 R14: 0000000000761938 R15: ffffffffffffffff
      
      Allocated by task 2776:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_kmalloc mm/kasan/common.c:487 [inline]
        __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:460
        kmalloc include/linux/slab.h:552 [inline]
        kzalloc include/linux/slab.h:748 [inline]
        usb_alloc_dev+0x51/0xf95 drivers/usb/core/usb.c:583
        hub_port_connect drivers/usb/core/hub.c:5004 [inline]
        hub_port_connect_change drivers/usb/core/hub.c:5213 [inline]
        port_event drivers/usb/core/hub.c:5359 [inline]
        hub_event+0x15c0/0x3640 drivers/usb/core/hub.c:5441
        process_one_work+0x92b/0x1530 kernel/workqueue.c:2269
        worker_thread+0x96/0xe20 kernel/workqueue.c:2415
        kthread+0x318/0x420 kernel/kthread.c:255
        ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
      
      Freed by task 16007:
        save_stack+0x1b/0x80 mm/kasan/common.c:69
        set_track mm/kasan/common.c:77 [inline]
        __kasan_slab_free+0x130/0x180 mm/kasan/common.c:449
        slab_free_hook mm/slub.c:1423 [inline]
        slab_free_freelist_hook mm/slub.c:1470 [inline]
        slab_free mm/slub.c:3012 [inline]
        kfree+0xe4/0x2f0 mm/slub.c:3953
        device_release+0x71/0x200 drivers/base/core.c:1064
        kobject_cleanup lib/kobject.c:693 [inline]
        kobject_release lib/kobject.c:722 [inline]
        kref_put include/linux/kref.h:65 [inline]
        kobject_put+0x171/0x280 lib/kobject.c:739
        put_device+0x1b/0x30 drivers/base/core.c:2213
        usb_put_dev+0x1f/0x30 drivers/usb/core/usb.c:725
        yurex_delete+0x40/0x330 drivers/usb/misc/yurex.c:95
        kref_put include/linux/kref.h:65 [inline]
        yurex_release+0x66/0x90 drivers/usb/misc/yurex.c:392
        __fput+0x2d7/0x840 fs/file_table.c:280
        task_work_run+0x13f/0x1c0 kernel/task_work.c:113
        tracehook_notify_resume include/linux/tracehook.h:188 [inline]
        exit_to_usermode_loop+0x1d2/0x200 arch/x86/entry/common.c:163
        prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
        syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
        do_syscall_64+0x45f/0x580 arch/x86/entry/common.c:299
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      The buggy address belongs to the object at ffff8881b1859980
        which belongs to the cache kmalloc-2k of size 2048
      The buggy address is located 72 bytes inside of
        2048-byte region [ffff8881b1859980, ffff8881b185a180)
      The buggy address belongs to the page:
      page:ffffea0006c61600 refcount:1 mapcount:0 mapping:ffff8881da00c000
      index:0x0 compound_mapcount: 0
      flags: 0x200000000010200(slab|head)
      raw: 0200000000010200 0000000000000000 0000000100000001 ffff8881da00c000
      raw: 0000000000000000 00000000000f000f 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
        ffff8881b1859880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
        ffff8881b1859900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      > ffff8881b1859980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                     ^
        ffff8881b1859a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        ffff8881b1859a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      A quick look at the yurex_delete() shows that we drop the reference
      to the usb_device before releasing any buffers associated with the
      device. Delay the reference drop until we have finished the cleanup.
      
      [0] https://lore.kernel.org/lkml/0000000000003f86d8058f0bd671@google.com/
      
      Fixes: 6bc235a2 ("USB: add driver for Meywa-Denki & Kayac YUREX")
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Tomoki Sekiyama <tomoki.sekiyama@gmail.com>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: andreyknvl@google.com
      Cc: gregkh@linuxfoundation.org
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: syzkaller-bugs@googlegroups.com
      Cc: dtor@chromium.org
      Reported-by: syzbot+d1fedb1c1fdb07fca507@syzkaller.appspotmail.com
      Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190805111528.6758-1-suzuki.poulose@arm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f2240a
    • Y
      usb: host: xhci-rcar: Fix timeout in xhci_suspend() · 49888a4f
      Yoshihiro Shimoda 提交于
      commit 783bda5e41acc71f98336e1a402c180f9748e5dc upstream.
      
      When a USB device is connected to the host controller and
      the system enters suspend, the following error happens
      in xhci_suspend():
      
      	xhci-hcd ee000000.usb: WARN: xHC CMD_RUN timeout
      
      Since the firmware/internal CPU control the USBSTS.STS_HALT
      and the process speed is down when the roothub port enters U3,
      long delay for the handshake of STS_HALT is neeed in xhci_suspend().
      So, this patch adds to set the XHCI_SLOW_SUSPEND.
      
      Fixes: 435cc113 ("usb: host: xhci-plat: set resume_quirk() for R-Car controllers")
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Link: https://lore.kernel.org/r/1564734815-17964-1-git-send-email-yoshihiro.shimoda.uh@renesas.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49888a4f
    • O
      usb: iowarrior: fix deadlock on disconnect · d397091d
      Oliver Neukum 提交于
      commit c468a8aa790e0dfe0a7f8a39db282d39c2c00b46 upstream.
      
      We have to drop the mutex before we close() upon disconnect()
      as close() needs the lock. This is safe to do by dropping the
      mutex as intfdata is already set to NULL, so open() will fail.
      
      Fixes: 03f36e88 ("USB: open disconnect race in iowarrior")
      Reported-by: syzbot+a64a382964bf6c71a9c0@syzkaller.appspotmail.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NOliver Neukum <oneukum@suse.com>
      Link: https://lore.kernel.org/r/20190808092728.23417-1-oneukum@suse.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d397091d
    • G
      usb: usbfs: fix double-free of usb memory upon submiturb error · b43611cd
      Gavin Li 提交于
      commit c43f28dfdc4654e738aa6d3fd08a105b2bee758d upstream.
      
      Upon an error within proc_do_submiturb(), dec_usb_memory_use_count()
      gets called once by the error handling tail and again by free_async().
      Remove the first call.
      Signed-off-by: NGavin Li <git@thegavinli.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20190804235044.22327-1-gavinli@thegavinli.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b43611cd
  3. 04 8月, 2019 2 次提交
  4. 31 7月, 2019 4 次提交
  5. 26 7月, 2019 1 次提交
    • L
      usb: Handle USB3 remote wakeup for LPM enabled devices correctly · 91da712f
      Lee, Chiasheng 提交于
      commit e244c4699f859cf7149b0781b1894c7996a8a1df upstream.
      
      With Link Power Management (LPM) enabled USB3 links transition to low
      power U1/U2 link states from U0 state automatically.
      
      Current hub code detects USB3 remote wakeups by checking if the software
      state still shows suspended, but the link has transitioned from suspended
      U3 to enabled U0 state.
      
      As it takes some time before the hub thread reads the port link state
      after a USB3 wake notification, the link may have transitioned from U0
      to U1/U2, and wake is not detected by hub code.
      
      Fix this by handling U1/U2 states in the same way as U0 in USB3 wakeup
      handling
      
      This patch should be added to stable kernels since 4.13 where LPM was
      kept enabled during suspend/resume
      
      Cc: <stable@vger.kernel.org> # v4.13+
      Signed-off-by: NLee, Chiasheng <chiasheng.lee@intel.com>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91da712f
  6. 14 7月, 2019 7 次提交
  7. 10 7月, 2019 2 次提交
  8. 03 7月, 2019 10 次提交
  9. 25 6月, 2019 1 次提交
    • M
      usb: xhci: Don't try to recover an endpoint if port is in error state. · 17027034
      Mathias Nyman 提交于
      commit b8c3b718087bf7c3c8e388eb1f72ac1108a4926e upstream.
      
      A USB3 device needs to be reset and re-enumarated if the port it
      connects to goes to a error state, with link state inactive.
      
      There is no use in trying to recover failed transactions by resetting
      endpoints at this stage. Tests show that in rare cases, after multiple
      endpoint resets of a roothub port the whole host controller might stop
      completely.
      
      Several retries to recover from transaction error can happen as
      it can take a long time before the hub thread discovers the USB3
      port error and inactive link.
      
      We can't reliably detect the port error from slot or endpoint context
      due to a limitation in xhci, see xhci specs section 4.8.3:
      "There are several cases where the EP State field in the Output
      Endpoint Context may not reflect the current state of an endpoint"
      and
      "Software should maintain an accurate value for EP State, by tracking it
      with an internal variable that is driven by Events and Doorbell accesses"
      
      Same appears to be true for slot state.
      
      set a flag to the corresponding slot if a USB3 roothub port link goes
      inactive to prevent both queueing new URBs and resetting endpoints.
      Reported-by: NRapolu Chiranjeevi <chiranjeevi.rapolu@intel.com>
      Tested-by: NRapolu Chiranjeevi <chiranjeevi.rapolu@intel.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      17027034