1. 14 Jan, 2020 8 commits
    • Alan Stern's avatar
      HID: Fix slab-out-of-bounds read in hid_field_extract · 2aa4a4c5
      Alan Stern authored
      commit 8ec321e9 upstream.
      
      The syzbot fuzzer found a slab-out-of-bounds bug in the HID report
      handler.  The bug was caused by a report descriptor which included a
      field with size 12 bits and count 4899, for a total size of 7349
      bytes.
      
      The usbhid driver uses at most a single-page 4-KB buffer for reports.
      In the test there wasn't any problem about overflowing the buffer,
      since only one byte was received from the device.  Rather, the bug
      occurred when the HID core tried to extract the data from the report
      fields, which caused it to try reading data beyond the end of the
      allocated buffer.
      
      This patch fixes the problem by rejecting any report whose total
      length exceeds the HID_MAX_BUFFER_SIZE limit (minus one byte to allow
      for a possible report index).  In theory a device could have a report
      longer than that, but if there was such a thing we wouldn't handle it
      correctly anyway.
      
      Reported-and-tested-by: syzbot+09ef48aa58261464b621@syzkaller.appspotmail.com
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2aa4a4c5
    • Steven Rostedt (VMware)'s avatar
      tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined · 5cd0449a
      Steven Rostedt (VMware) authored
      commit b8299d36 upstream.
      
      On some archs with some configurations, MCOUNT_INSN_SIZE is not defined, and
      this makes the stack tracer fail to compile. Just define it to zero in this
      case.
      
      Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com
      
      Cc: stable@vger.kernel.org
      Fixes: 4df29712 ("tracing: Remove most or all of stack tracer stack size from stack_max_size")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5cd0449a
    • Kaitao Cheng's avatar
      kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail · 62599bee
      Kaitao Cheng authored
      commit 50f9ad60 upstream.
      
      In the function, if register_trace_sched_migrate_task() returns error,
      sched_switch/sched_wakeup_new/sched_wakeup won't unregister. That is
      why fail_deprobe_sched_switch was added.
      
      Link: http://lkml.kernel.org/r/20191231133530.2794-1-pilgrimtao@gmail.com
      
      Cc: stable@vger.kernel.org
      Fixes: 478142c3 ("tracing: do not grab lock in wakeup latency function tracing")
      Signed-off-by: default avatarKaitao Cheng <pilgrimtao@gmail.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62599bee
    • Marcelo Ricardo Leitner's avatar
      tcp: minimize false-positives on TCP/GRO check · 638b632d
      Marcelo Ricardo Leitner authored
      commit 0b9aefea upstream.
      
      Markus Trippelsdorf reported that after commit dcb17d22 ("tcp: warn
      on bogus MSS and try to amend it") the kernel started logging the
      warning for a NIC driver that doesn't even support GRO.
      
      It was diagnosed that it was possibly caused on connections that were
      using TCP Timestamps but some packets lacked the Timestamps option. As
      we reduce rcv_mss when timestamps are used, the lack of them would cause
      the packets to be bigger than expected, although this is a valid case.
      
      As this warning is more as a hint, getting a clean-cut on the
      threshold is probably not worth the execution time spent on it. This
      patch thus alleviates the false-positives with 2 quick checks: by
      accounting for the entire TCP option space and also checking against the
      interface MTU if it's available.
      
      These changes, specially the MTU one, might mask some real positives,
      though if they are really happening, it's possible that sooner or later
      it will be triggered anyway.
      Reported-by: default avatarMarkus Trippelsdorf <markus@trippelsdorf.de>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Salvatore Bonaccorso <carnil@debian.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      638b632d
    • Takashi Iwai's avatar
      ALSA: usb-audio: Apply the sample rate quirk for Bose Companion 5 · 1b2e7f70
      Takashi Iwai authored
      commit 51d4efab upstream.
      
      Bose Companion 5 (with USB ID 05a7:1020) doesn't seem supporting
      reading back the sample rate, so the existing quirk is needed.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206063
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200104110936.14288-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b2e7f70
    • Guenter Roeck's avatar
      usb: chipidea: host: Disable port power only if previously enabled · e0cedaf2
      Guenter Roeck authored
      commit c1ffba30 upstream.
      
      On shutdown, ehci_power_off() is called unconditionally to power off
      each port, even if it was never called to power on the port.
      For chipidea, this results in a call to ehci_ci_portpower() with a request
      to power off ports even if the port was never powered on.
      This results in the following warning from the regulator code.
      
      WARNING: CPU: 0 PID: 182 at drivers/regulator/core.c:2596 _regulator_disable+0x1a8/0x210
      unbalanced disables for usb_otg2_vbus
      Modules linked in:
      CPU: 0 PID: 182 Comm: init Not tainted 5.4.6 #1
      Hardware name: Freescale i.MX7 Dual (Device Tree)
      [<c0313658>] (unwind_backtrace) from [<c030d698>] (show_stack+0x10/0x14)
      [<c030d698>] (show_stack) from [<c1133afc>] (dump_stack+0xe0/0x10c)
      [<c1133afc>] (dump_stack) from [<c0349098>] (__warn+0xf4/0x10c)
      [<c0349098>] (__warn) from [<c0349128>] (warn_slowpath_fmt+0x78/0xbc)
      [<c0349128>] (warn_slowpath_fmt) from [<c09f36ac>] (_regulator_disable+0x1a8/0x210)
      [<c09f36ac>] (_regulator_disable) from [<c09f374c>] (regulator_disable+0x38/0xe8)
      [<c09f374c>] (regulator_disable) from [<c0df7bac>] (ehci_ci_portpower+0x38/0xdc)
      [<c0df7bac>] (ehci_ci_portpower) from [<c0db4fa4>] (ehci_port_power+0x50/0xa4)
      [<c0db4fa4>] (ehci_port_power) from [<c0db5420>] (ehci_silence_controller+0x5c/0xc4)
      [<c0db5420>] (ehci_silence_controller) from [<c0db7644>] (ehci_stop+0x3c/0xcc)
      [<c0db7644>] (ehci_stop) from [<c0d5bdc4>] (usb_remove_hcd+0xe0/0x19c)
      [<c0d5bdc4>] (usb_remove_hcd) from [<c0df7638>] (host_stop+0x38/0xa8)
      [<c0df7638>] (host_stop) from [<c0df2f34>] (ci_hdrc_remove+0x44/0xe4)
      ...
      
      Keeping track of the power enable state avoids the warning and traceback.
      
      Fixes: c8679a2f ("usb: chipidea: host: add portpower override")
      Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
      Cc: Peter Chen <peter.chen@freescale.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Acked-by: default avatarPeter Chen <peter.chen@nxp.com>
      Link: https://lore.kernel.org/r/20191226155754.25451-1-linux@roeck-us.netSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e0cedaf2
    • Will Deacon's avatar
      chardev: Avoid potential use-after-free in 'chrdev_open()' · d2c9ee45
      Will Deacon authored
      commit 68faa679 upstream.
      
      'chrdev_open()' calls 'cdev_get()' to obtain a reference to the
      'struct cdev *' stashed in the 'i_cdev' field of the target inode
      structure. If the pointer is NULL, then it is initialised lazily by
      looking up the kobject in the 'cdev_map' and so the whole procedure is
      protected by the 'cdev_lock' spinlock to serialise initialisation of
      the shared pointer.
      
      Unfortunately, it is possible for the initialising thread to fail *after*
      installing the new pointer, for example if the subsequent '->open()' call
      on the file fails. In this case, 'cdev_put()' is called, the reference
      count on the kobject is dropped and, if nobody else has taken a reference,
      the release function is called which finally clears 'inode->i_cdev' from
      'cdev_purge()' before potentially freeing the object. The problem here
      is that a racing thread can happily take the 'cdev_lock' and see the
      non-NULL pointer in the inode, which can result in a refcount increment
      from zero and a warning:
      
        |  ------------[ cut here ]------------
        |  refcount_t: addition on 0; use-after-free.
        |  WARNING: CPU: 2 PID: 6385 at lib/refcount.c:25 refcount_warn_saturate+0x6d/0xf0
        |  Modules linked in:
        |  CPU: 2 PID: 6385 Comm: repro Not tainted 5.5.0-rc2+ #22
        |  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
        |  RIP: 0010:refcount_warn_saturate+0x6d/0xf0
        |  Code: 05 55 9a 15 01 01 e8 9d aa c8 ff 0f 0b c3 80 3d 45 9a 15 01 00 75 ce 48 c7 c7 00 9c 62 b3 c6 08
        |  RSP: 0018:ffffb524c1b9bc70 EFLAGS: 00010282
        |  RAX: 0000000000000000 RBX: ffff9e9da1f71390 RCX: 0000000000000000
        |  RDX: ffff9e9dbbd27618 RSI: ffff9e9dbbd18798 RDI: ffff9e9dbbd18798
        |  RBP: 0000000000000000 R08: 000000000000095f R09: 0000000000000039
        |  R10: 0000000000000000 R11: ffffb524c1b9bb20 R12: ffff9e9da1e8c700
        |  R13: ffffffffb25ee8b0 R14: 0000000000000000 R15: ffff9e9da1e8c700
        |  FS:  00007f3b87d26700(0000) GS:ffff9e9dbbd00000(0000) knlGS:0000000000000000
        |  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        |  CR2: 00007fc16909c000 CR3: 000000012df9c000 CR4: 00000000000006e0
        |  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        |  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        |  Call Trace:
        |   kobject_get+0x5c/0x60
        |   cdev_get+0x2b/0x60
        |   chrdev_open+0x55/0x220
        |   ? cdev_put.part.3+0x20/0x20
        |   do_dentry_open+0x13a/0x390
        |   path_openat+0x2c8/0x1470
        |   do_filp_open+0x93/0x100
        |   ? selinux_file_ioctl+0x17f/0x220
        |   do_sys_open+0x186/0x220
        |   do_syscall_64+0x48/0x150
        |   entry_SYSCALL_64_after_hwframe+0x44/0xa9
        |  RIP: 0033:0x7f3b87efcd0e
        |  Code: 89 54 24 08 e8 a3 f4 ff ff 8b 74 24 0c 48 8b 3c 24 41 89 c0 44 8b 54 24 08 b8 01 01 00 00 89 f4
        |  RSP: 002b:00007f3b87d259f0 EFLAGS: 00000293 ORIG_RAX: 0000000000000101
        |  RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3b87efcd0e
        |  RDX: 0000000000000000 RSI: 00007f3b87d25a80 RDI: 00000000ffffff9c
        |  RBP: 00007f3b87d25e90 R08: 0000000000000000 R09: 0000000000000000
        |  R10: 0000000000000000 R11: 0000000000000293 R12: 00007ffe188f504e
        |  R13: 00007ffe188f504f R14: 00007f3b87d26700 R15: 0000000000000000
        |  ---[ end trace 24f53ca58db8180a ]---
      
      Since 'cdev_get()' can already fail to obtain a reference, simply move
      it over to use 'kobject_get_unless_zero()' instead of 'kobject_get()',
      which will cause the racing thread to return -ENXIO if the initialising
      thread fails unexpectedly.
      
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Reported-by: syzbot+82defefbbd8527e1c2cb@syzkaller.appspotmail.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20191219120203.32691-1-will@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2c9ee45
    • Jan Kara's avatar
      kobject: Export kobject_get_unless_zero() · 475c1471
      Jan Kara authored
      commit c70c176f upstream.
      
      Make the function available for outside use and fortify it against NULL
      kobject.
      
      CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reviewed-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
      Acked-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@fb.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      475c1471
  2. 12 Jan, 2020 32 commits