08 Jul, 2018

29 commits

  • commit ad9d9e85072b668731f356be0a3750a3ba22a607 upstream.

    This patch fixes the following splat.

    [118709.054937] BUG: using smp_processor_id() in preemptible [00000000] code: test/1571
    [118709.054970] caller is nft_update_chain_stats.isra.4+0x53/0x97 [nf_tables]
    [118709.054980] CPU: 2 PID: 1571 Comm: test Not tainted 4.17.0-rc6+ #335
    [...]
    [118709.054992] Call Trace:
    [118709.055011] dump_stack+0x5f/0x86
    [118709.055026] check_preemption_disabled+0xd4/0xe4

    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit 97a0549b15a0b466c47f6a0143a490a082c64b4e upstream.

    In the nft_meta_set_eval, nftrace value is dereferenced as u32 from sreg.
    But correct type is u8. so that sometimes incorrect value is dereferenced.

    Steps to reproduce:

    %nft add table ip filter
    %nft add chain ip filter input { type filter hook input priority 4\; }
    %nft add rule ip filter input nftrace set 0
    %nft monitor

    Sometimes, we can see trace messages.

    trace id 16767227 ip filter input packet: iif "enp2s0"
    ether saddr xx:xx:xx:xx:xx:xx ether daddr xx:xx:xx:xx:xx:xx
    ip saddr 192.168.0.1 ip daddr 255.255.255.255 ip dscp cs0
    ip ecn not-ect ip
    trace id 16767227 ip filter input rule nftrace set 0 (verdict continue)
    trace id 16767227 ip filter input verdict continue
    trace id 16767227 ip filter input

    Signed-off-by: Taehee Yoo
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Taehee Yoo
     
  • commit bb7b40aecbf778c0c83a5bd62b0f03ca9f49a618 upstream.

    When removing a rule that jumps to chain and such chain in the same
    batch, this bogusly hits EBUSY. Add activate and deactivate operations
    to expression that can be called from the preparation and the
    commit/abort phases.

    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Pablo Neira Ayuso
     
  • commit 009240940e84c1c089af88b454f7e804a4c5bd1b upstream.

    nft_chain_stats_replace() and all other spots assume ->stats can be
    NULL, but nft_update_chain_stats does not. It must do this check,
    just because the jump label is set doesn't mean all basechains have stats
    assigned.

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit 732a8049f365f514d0607e03938491bf6cb0d620 upstream.

    currently matchinfo gets stored in the expression, but some xt matches
    are very large.

    To handle those we either need to switch nft core to kvmalloc and increase
    size limit, or allocate the info blob of large matches separately.

    This does the latter, this limits the scope of the changes to
    nft_compat.

    I picked a threshold of 192, this allows most matches to work as before and
    handle only few ones via separate alloation (cgroup, u32, sctp, rt).

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit 8bdf164744b2c7f63561846c01cff3db597f282d upstream.

    Next patch will make it possible for *info to be stored in
    a separate allocation instead of the expr private area.

    This removes the 'expr priv area is info blob' assumption
    from the match init/destroy/eval functions.

    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit b8e9dc1c75714ceb53615743e1036f76e00f5a17 upstream.

    Taehee Yoo reported following bug:
    iptables-compat -I OUTPUT -m cpu --cpu 0
    iptables-compat -F
    lsmod |grep xt_cpu
    xt_cpu 16384 1

    Quote:
    "When above command is given, a netlink message has two expressions that
    are the cpu compat and the nft_counter.
    The nft_expr_type_get() in the nf_tables_expr_parse() successes
    first expression then, calls select_ops callback.
    (allocates memory and holds module)
    But, second nft_expr_type_get() in the nf_tables_expr_parse()
    returns -EAGAIN because of request_module().
    In that point, by the 'goto err1',
    the 'module_put(info[i].ops->type->owner)' is called.
    There is no release routine."

    The core problem is that unlike all other expression,
    nft_compat select_ops has side effects.

    1. it allocates dynamic memory which holds an nft ops struct.
    In all other expressions, ops has static storage duration.
    2. It grabs references to the xt module that it is supposed to
    invoke.

    Depending on where things go wrong, error unwinding doesn't
    always do the right thing.

    In the above scenario, a new nft_compat_expr is created and
    xt_cpu module gets loaded with a refcount of 1.

    Due to to -EAGAIN, the netlink messages get re-parsed.
    When that happens, nft_compat finds that xt_cpu is already present
    and increments module refcount again.

    This fixes the problem by making select_ops to have no visible
    side effects and removes all extra module_get/put.

    When select_ops creates a new nft_compat expression, the new
    expression has a refcount of 0, and the xt module gets its refcount
    incremented.

    When error happens, the next call finds existing entry, but will no
    longer increase the reference count -- the presence of existing
    nft_xt means we already hold a module reference.

    Because nft_xt_put is only called from nft_compat destroy hook,
    it will never see the initial zero reference count.
    ->destroy can only be called after ->init(), and that will increase the
    refcount.

    Lastly, we now free nft_xt struct with kfree_rcu.
    Else, we get use-after free in nf_tables_rule_destroy:

    while (expr != nft_expr_last(rule) && expr->ops) {
    nf_tables_expr_destroy(ctx, expr);
    expr = nft_expr_next(expr); // here

    nft_expr_next() dereferences expr->ops. This is safe
    for all users, as ops have static storage duration.
    In nft_compat case however, its ->destroy callback can
    free the memory that hold the ops structure.

    Tested-by: Taehee Yoo
    Reported-by: Taehee Yoo
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • commit 7a3727f385dc64773db1c144f6b15c1e9d4735bb upstream.

    The SF and clipper units mishandle the provoking vertex in some cases,
    which can cause misrendering with shaders that use flat shaded inputs.

    There are chicken bits in 3D_CHICKEN3 (for SF) and FF_SLICE_CHICKEN
    (for the clipper) that work around the issue. These registers are
    unfortunately not part of the logical context (even the power context),
    and so we must reload them every time we start executing in a context.

    Bugzilla: https://bugs.freedesktop.org/103047
    Signed-off-by: Kenneth Graunke
    Signed-off-by: Chris Wilson
    Link: https://patchwork.freedesktop.org/patch/msgid/20180615190605.16238-1-chris@chris-wilson.co.uk
    Reviewed-by: Joonas Lahtinen
    Cc: stable@vger.kernel.org
    (cherry picked from commit b77422f80337d363eed60c8c48db9cb6e33085c9)
    Signed-off-by: Jani Nikula
    Signed-off-by: Greg Kroah-Hartman

    Kenneth Graunke
     
  • commit 5e9244ff585239630f15f8ad8e676bc91a94ca9e upstream.

    Preparation for the following fix, no functional change intended.

    Cc: stable@vger.kernel.org
    Signed-off-by: Michel Dänzer
    Reviewed-by: Christian König
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Michel Dänzer
     
  • commit 6fa39bc1e01dab8b4f54b23e95a181a2ed5a2d38 upstream.

    It can be quite big, and there's no need for it to be physically
    contiguous. This is less likely to fail under memory pressure (has
    actually happened while running piglit).

    Cc: stable@vger.kernel.org
    Signed-off-by: Michel Dänzer
    Reviewed-by: Christian König
    Signed-off-by: Alex Deucher
    Signed-off-by: Greg Kroah-Hartman

    Michel Dänzer
     
  • commit 9fcf2b3c1c0276650fea537c71b513d27d929b05 upstream.

    The statement always evaluates to true since the struct fields
    are arrays. This has shown up as a warning when compiling with
    clang:
    warning: address of array 'desc->layout.xstride' will always
    evaluate to 'true' [-Wpointer-bool-conversion]

    Check for values in the first plane instead.

    Fixes: 1a396789f65a ("drm: add Atmel HLCDC Display Controller support")
    Cc:
    Signed-off-by: Stefan Agner
    Signed-off-by: Boris Brezillon
    Link: https://patchwork.freedesktop.org/patch/msgid/20180617084826.31885-1-stefan@agner.ch
    Signed-off-by: Greg Kroah-Hartman

    Stefan Agner
     
  • commit 889ad63d41eea20184b0483e7e585e5b20fb6cfe upstream.

    "qxl_bo_unref" may sleep, but calling "qxl_release_map" causes
    "preempt_disable()" to be called and "preempt_enable()" isn't called
    until "qxl_release_unmap" is used. Move the call to "qxl_bo_unref" out
    from in between the two to avoid sleeping from an atomic context.

    This issue can be demonstrated on a kernel with CONFIG_LOCKDEP=y by
    creating a VM using QXL, using a desktop environment using Xorg, then
    moving the cursor on or off a window.

    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1571128
    Fixes: 9428088c90b6 ("drm/qxl: reapply cursor after resetting primary")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jeremy Cline
    Link: http://patchwork.freedesktop.org/patch/msgid/20180601200532.13619-1-jcline@redhat.com
    Signed-off-by: Gerd Hoffmann
    Signed-off-by: Greg Kroah-Hartman

    Jeremy Cline
     
  • commit a0b2ac29415bb44d1c212184c1385a1abe68db5c upstream.

    It missed vcn.fw_version setting when init vcn microcode, and it will be used to
    report vcn ucode version via amdgpu_firmware_info sysfs interface.

    Signed-off-by: Huang Rui
    Reviewed-by: Christian König
    Signed-off-by: Alex Deucher
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Huang Rui
     
  • commit 08ebb6e9f4fd7098c28e0ebbb42847cf0488ebb8 upstream.

    1. fix set vce clocks failed on Cz/St
    which lead 1s delay when boot up.
    2. remove the workaround in vce_v3_0.c

    Reviewed-by: Alex Deucher
    Reviewed-by: Huang Rui
    Acked-by: Christian König
    Acked-by: Shirish S
    Signed-off-by: Rex Zhu
    Signed-off-by: Alex Deucher
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Rex Zhu
     
  • commit 819a23f83e3b2513cffbef418458a47ca02c36b3 upstream.

    fix the issue set uvd clock failed on CZ/ST
    which lead 1s delay when boot up.

    Reviewed-by: Alex Deucher
    Reviewed-by: Huang Rui
    Acked-by: Christian König
    Acked-by: Shirish S
    Signed-off-by: Rex Zhu
    Signed-off-by: Alex Deucher
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Rex Zhu
     
  • commit 21eff69aaaa0e766ca0ce445b477698dc6a9f55a upstream.

    KMSAN reported an infoleak when reading from /dev/vcs*:

    BUG: KMSAN: kernel-infoleak in vcs_read+0x18ba/0x1cc0
    Call Trace:
    ...
    kmsan_copy_to_user+0x7a/0x160 mm/kmsan/kmsan.c:1253
    copy_to_user ./include/linux/uaccess.h:184
    vcs_read+0x18ba/0x1cc0 drivers/tty/vt/vc_screen.c:352
    __vfs_read+0x1b2/0x9d0 fs/read_write.c:416
    vfs_read+0x36c/0x6b0 fs/read_write.c:452
    ...
    Uninit was created at:
    kmsan_save_stack_with_flags mm/kmsan/kmsan.c:279
    kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:189
    kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:315
    __kmalloc+0x13a/0x350 mm/slub.c:3818
    kmalloc ./include/linux/slab.h:517
    vc_allocate+0x438/0x800 drivers/tty/vt/vt.c:787
    con_install+0x8c/0x640 drivers/tty/vt/vt.c:2880
    tty_driver_install_tty drivers/tty/tty_io.c:1224
    tty_init_dev+0x1b5/0x1020 drivers/tty/tty_io.c:1324
    tty_open_by_driver drivers/tty/tty_io.c:1959
    tty_open+0x17b4/0x2ed0 drivers/tty/tty_io.c:2007
    chrdev_open+0xc25/0xd90 fs/char_dev.c:417
    do_dentry_open+0xccc/0x1440 fs/open.c:794
    vfs_open+0x1b6/0x2f0 fs/open.c:908
    ...
    Bytes 0-79 of 240 are uninitialized

    Consistently allocating |vc_screenbuf| with kzalloc() fixes the problem

    Reported-by: syzbot+17a8efdf800000@syzkaller.appspotmail.com
    Signed-off-by: Alexander Potapenko
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Alexander Potapenko
     
  • commit bc6cf3669d22371f573ab0305b3abf13887c0786 upstream.

    Make sure to free all resources associated with the ida on module
    exit.

    Fixes: cd6484e1830b ("serdev: Introduce new bus for serial attached devices")
    Cc: stable # 4.11
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     
  • commit 20dcff436e9fcd2e106b0ccc48a52206bc176d70 upstream.

    After the commit

    7d8905d06405 ("serial: 8250_pci: Enable device after we check black list")

    pure serial multi-port cards, such as CH355, got blacklisted and thus
    not being enumerated anymore. Previously, it seems, blacklisting them
    was on purpose to shut up pciserial_init_one() about record duplication.

    So, remove the entries from blacklist in order to get cards enumerated.

    Fixes: 7d8905d06405 ("serial: 8250_pci: Enable device after we check black list")
    Reported-by: Matt Turner
    Cc: Sergej Pupykin
    Cc: Alexandr Petrenko
    Signed-off-by: Andy Shevchenko
    Reviewed-and-Tested-by: Matt Turner
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Andy Shevchenko
     
  • commit 0a2bc00341dcfcc793c0dbf4f8d43adf60458b05 upstream.

    The expected return value from ion_map_kernel is an ERR_PTR. The error
    path for a vmalloc failure currently just returns NULL, triggering
    a warning in ion_buffer_kmap_get. Encode the vmalloc failure as an ERR_PTR.

    Reported-by: syzbot+55b1d9f811650de944c6@syzkaller.appspotmail.com
    Signed-off-by: Laura Abbott
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Laura Abbott
     
  • commit ebec3f8f5271139df618ebdf8427e24ba102ba94 upstream.

    syzbot is reporting stalls at __process_echoes() [1]. This is because
    since ldata->echo_commit < ldata->echo_tail becomes true for some reason,
    the discard loop is serving as almost infinite loop. This patch tries to
    avoid falling into ldata->echo_commit < ldata->echo_tail situation by
    making access to echo_* variables more carefully.

    Since reset_buffer_flags() is called without output_lock held, it should
    not touch echo_* variables. And omit a call to reset_buffer_flags() from
    n_tty_open() by using vzalloc().

    Since add_echo_byte() is called without output_lock held, it needs memory
    barrier between storing into echo_buf[] and incrementing echo_head counter.
    echo_buf() needs corresponding memory barrier before reading echo_buf[].
    Lack of handling the possibility of not-yet-stored multi-byte operation
    might be the reason of falling into ldata->echo_commit < ldata->echo_tail
    situation, for if I do WARN_ON(ldata->echo_commit == tail + 1) prior to
    echo_buf(ldata, tail + 1), the WARN_ON() fires.

    Also, explicitly masking with buffer for the former "while" loop, and
    use ldata->echo_commit > tail for the latter "while" loop.

    [1] https://syzkaller.appspot.com/bug?id=17f23b094cd80df750e5b0f8982c521ee6bcbf40

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Cc: Peter Hurley
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     
  • commit 3d63b7e4ae0dc5e02d28ddd2fa1f945defc68d81 upstream.

    syzbot is reporting stalls at n_tty_receive_char_special() [1]. This is
    because comparison is not working as expected since ldata->read_head can
    change at any moment. Mitigate this by explicitly masking with buffer size
    when checking condition for "while" loops.

    [1] https://syzkaller.appspot.com/bug?id=3d7481a346958d9469bebbeb0537d5f056bdd6e8

    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Fixes: bc5a5e3f45d04784 ("n_tty: Don't wrap input buffer indices at buffer size")
    Cc: stable
    Cc: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Tetsuo Handa
     
  • commit d850c1658328e757635a46763783c6fd56390dcb upstream.

    commit 44a182b9d177 ("xhci: Fix use-after-free in xhci_free_virt_device")
    set dev->udev pointer to NULL in xhci_free_dev(), it will cause kernel
    panic in trace_xhci_free_virt_device. This patch reimplement the trace
    function trace_xhci_free_virt_device, remove dev->udev dereference and
    added more useful parameters to show in the trace function,it also makes
    sure dev->udev is not NULL before calling trace_xhci_free_virt_device.
    This issue happened when xhci-hcd trace is enabled and USB devices hot
    plug test. Original use-after-free patch went to stable so this needs so
    be applied there as well.

    [ 1092.022457] usb 2-4: USB disconnect, device number 6
    [ 1092.092772] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
    [ 1092.101694] PGD 0 P4D 0
    [ 1092.104601] Oops: 0000 [#1] SMP
    [ 1092.207734] Workqueue: usb_hub_wq hub_event
    [ 1092.212507] RIP: 0010:trace_event_raw_event_xhci_log_virt_dev+0x6c/0xf0
    [ 1092.220050] RSP: 0018:ffff8c252e883d28 EFLAGS: 00010086
    [ 1092.226024] RAX: ffff8c24af86fa84 RBX: 0000000000000003 RCX: ffff8c25255c2a01
    [ 1092.234130] RDX: 0000000000000000 RSI: 00000000aef55009 RDI: ffff8c252e883d28
    [ 1092.242242] RBP: ffff8c252550e2c0 R08: ffff8c24af86fa84 R09: 0000000000000a70
    [ 1092.250364] R10: 0000000000000a70 R11: 0000000000000000 R12: ffff8c251f21a000
    [ 1092.258468] R13: 000000000000000c R14: ffff8c251f21a000 R15: ffff8c251f432f60
    [ 1092.266572] FS: 0000000000000000(0000) GS:ffff8c252e880000(0000) knlGS:0000000000000000
    [ 1092.275757] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 1092.282281] CR2: 0000000000000000 CR3: 0000000154209001 CR4: 00000000003606e0
    [ 1092.290384] Call Trace:
    [ 1092.293156]
    [ 1092.295439] xhci_free_virt_device.part.34+0x182/0x1a0
    [ 1092.301288] handle_cmd_completion+0x7ac/0xfa0
    [ 1092.306336] ? trace_event_raw_event_xhci_log_trb+0x6e/0xa0
    [ 1092.312661] xhci_irq+0x3e8/0x1f60
    [ 1092.316524] __handle_irq_event_percpu+0x75/0x180
    [ 1092.321876] handle_irq_event_percpu+0x20/0x50
    [ 1092.326922] handle_irq_event+0x36/0x60
    [ 1092.331273] handle_edge_irq+0x6d/0x180
    [ 1092.335644] handle_irq+0x16/0x20
    [ 1092.339417] do_IRQ+0x41/0xc0
    [ 1092.342782] common_interrupt+0xf/0xf
    [ 1092.346955]

    Fixes: 44a182b9d177 ("xhci: Fix use-after-free in xhci_free_virt_device")
    Cc:
    Signed-off-by: Zhengjun Xing
    Signed-off-by: Mathias Nyman
    Signed-off-by: Greg Kroah-Hartman

    Zhengjun Xing
     
  • commit 68816e16b4789f2d05e77b6dcb77564cf5d6a8d8 upstream.

    According to UCSI Specification, Connector Change Event only
    means a change in the Connector Status and Operation Mode
    fields of the STATUS data structure. So any other change
    should create another event.

    Unfortunately on some platforms the firmware acting as PPM
    (platform policy manager - usually embedded controller
    firmware) still does not report any other status changes if
    there is a connector change event. So if the connector power
    or data role was changed when a device was plugged to the
    connector, the driver does not get any indication about
    that. The port will show wrong roles if that happens.

    To fix the issue, always checking the data and power role
    together with a connector change event.

    Fixes: c1b0bc2dabfa ("usb: typec: Add support for UCSI interface")
    Signed-off-by: Heikki Krogerus
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • commit 1f9f9d168ce619608572b01771c47a41b15429e6 upstream.

    This fixes an issue where the driver fails with an error:

    ioremap error for 0x3f799000-0x3f79a000, requested 0x2, got 0x0

    On some platforms the UCSI ACPI mailbox SystemMemory
    Operation Region may be setup before the driver has been
    loaded. That will lead into the driver failing to map the
    mailbox region, as it has been already marked as write-back
    memory. acpi_os_ioremap() for x86 uses ioremap_cache()
    unconditionally.

    When the issue happens, the embedded controller has a
    pending query event for the UCSI notification right after
    boot-up which causes the operation region to be setup before
    UCSI driver has been loaded.

    The fix is to notify acpi core that the driver is about to
    access memory region which potentially overlaps with an
    operation region right before mapping it.
    acpi_release_memory() will check if the memory has already
    been setup (mapped) by acpi core, and deactivate it (unmap)
    if it has. The driver is then able to map the memory with
    ioremap_nocache() and set the memtype to uncached for the
    region.

    Reported-by: Paul Menzel
    Fixes: 8243edf44152 ("usb: typec: ucsi: Add ACPI driver")
    Cc: stable@vger.kernel.org
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • commit d2d2e3c46be5d6dd8001d0eebdf7cafb9bc7006b upstream.

    Sometimes memory resource may be overlapping with
    SystemMemory Operation Region by design, for example if the
    memory region is used as a mailbox for communication with a
    firmware in the system. One occasion of such mailboxes is
    USB Type-C Connector System Software Interface (UCSI).

    With regions like that, it is important that the driver is
    able to map the memory with the requirements it has. For
    example, the driver should be allowed to map the memory as
    non-cached memory. However, if the operation region has been
    accessed before the driver has mapped the memory, the memory
    has been marked as write-back by the time the driver is
    loaded. That means the driver will fail to map the memory
    if it expects non-cached memory.

    To work around the problem, introducing helper that the
    drivers can use to temporarily deactivate (unmap)
    SystemMemory Operation Regions that overlap with their
    IO memory.

    Fixes: 8243edf44152 ("usb: typec: ucsi: Add ACPI driver")
    Cc: stable@vger.kernel.org
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Heikki Krogerus
    Signed-off-by: Greg Kroah-Hartman

    Heikki Krogerus
     
  • commit 8760675932ddb614e83702117d36ea644050c609 upstream.

    The dwc2_get_ls_map() use ttport to reference into the
    bitmap if we're on a multi_tt hub. But the bitmaps index
    from 0 to (hub->maxchild - 1), while the ttport index from
    1 to hub->maxchild. This will cause invalid memory access
    when the number of ttport is hub->maxchild.

    Without this patch, I can easily meet a Kernel panic issue
    if connect a low-speed USB mouse with the max port of FE2.1
    multi-tt hub (1a40:0201) on rk3288 platform.

    Fixes: 9f9f09b048f5 ("usb: dwc2: host: Totally redo the microframe scheduler")
    Cc:
    Reviewed-by: Douglas Anderson
    Acked-by: Minas Harutyunyan hminas@synopsys.com>
    Signed-off-by: William Wu
    Signed-off-by: Felipe Balbi
    Signed-off-by: Greg Kroah-Hartman

    William Wu
     
  • commit 2f839823382748664b643daa73f41ee0cc01ced6 upstream.

    Silicon Labs defines alternative VID/PID pairs for some chips that when
    used will automatically install drivers for Windows users without manual
    intervention. Unfortunately, these IDs are not recognized by the Linux
    module, so using these IDs improves user experience on one platform but
    degrades it on Linux. This patch addresses this problem.

    Signed-off-by: Karoly Pados
    Cc: stable
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Karoly Pados
     
  • commit 24160628a34af962ac99f2f58e547ac3c4cbd26f upstream.

    Add device ids for CESINEL products.

    Reported-by: Carlos Barcala Lara
    Cc: stable
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     
  • commit 4a762569a2722b8a48066c7bacf0e1dc67d17fa1 upstream.

    Uniden UBC125 radio scanner has USB interface which fails to work
    with cdc_acm driver:
    usb 1-1.5: new full-speed USB device number 4 using xhci_hcd
    cdc_acm 1-1.5:1.0: Zero length descriptor references
    cdc_acm: probe of 1-1.5:1.0 failed with error -22

    Adding the NO_UNION_NORMAL quirk for the device fixes the issue:
    usb 1-4: new full-speed USB device number 15 using xhci_hcd
    usb 1-4: New USB device found, idVendor=1965, idProduct=0018
    usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 1-4: Product: UBC125XLT
    usb 1-4: Manufacturer: Uniden Corp.
    usb 1-4: SerialNumber: 0001
    cdc_acm 1-4:1.0: ttyACM0: USB ACM device

    `lsusb -v` of the device:

    Bus 001 Device 015: ID 1965:0018 Uniden Corporation
    Device Descriptor:
    bLength 18
    bDescriptorType 1
    bcdUSB 2.00
    bDeviceClass 2 Communications
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 64
    idVendor 0x1965 Uniden Corporation
    idProduct 0x0018
    bcdDevice 0.01
    iManufacturer 1 Uniden Corp.
    iProduct 2 UBC125XLT
    iSerial 3 0001
    bNumConfigurations 1
    Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 48
    bNumInterfaces 2
    bConfigurationValue 1
    iConfiguration 0
    bmAttributes 0x80
    (Bus Powered)
    MaxPower 500mA
    Interface Descriptor:
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 0
    bAlternateSetting 0
    bNumEndpoints 1
    bInterfaceClass 2 Communications
    bInterfaceSubClass 2 Abstract (modem)
    bInterfaceProtocol 0 None
    iInterface 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x87 EP 7 IN
    bmAttributes 3
    Transfer Type Interrupt
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0008 1x 8 bytes
    bInterval 10
    Interface Descriptor:
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 1
    bAlternateSetting 0
    bNumEndpoints 2
    bInterfaceClass 10 CDC Data
    bInterfaceSubClass 0 Unused
    bInterfaceProtocol 0
    iInterface 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x81 EP 1 IN
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0040 1x 64 bytes
    bInterval 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x02 EP 2 OUT
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0040 1x 64 bytes
    bInterval 0
    Device Status: 0x0000
    (Bus Powered)

    Signed-off-by: Houston Yaroschoff
    Cc: stable
    Acked-by: Oliver Neukum
    Signed-off-by: Greg Kroah-Hartman

    Houston Yaroschoff
     

03 Jul, 2018

11 commits

  • Greg Kroah-Hartman
     
  • commit 44a182b9d17765514fa2b1cc911e4e65134eef93 upstream.

    KASAN found a use-after-free in xhci_free_virt_device+0x33b/0x38e
    where xhci_free_virt_device() sets slot id to 0 if udev exists:
    if (dev->udev && dev->udev->slot_id)
    dev->udev->slot_id = 0;

    dev->udev will be true even if udev is freed because dev->udev is
    not set to NULL.

    set dev->udev pointer to NULL in xhci_free_dev()

    The original patch went to stable so this fix needs to be applied
    there as well.

    Fixes: a400efe455f7 ("xhci: zero usb device slot_id member when disabling and freeing a xhci slot")
    Cc:
    Reported-by: Guenter Roeck
    Reviewed-by: Guenter Roeck
    Tested-by: Guenter Roeck
    Signed-off-by: Mathias Nyman
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Mathias Nyman
     
  • commit a685557fbbc3122ed11e8ad3fa63a11ebc5de8c3 upstream.

    Discards issued to a DM thin device can complete to userspace (via
    fstrim) _before_ the metadata changes associated with the discards is
    reflected in the thinp superblock (e.g. free blocks). As such, if a
    user constructs a test that loops repeatedly over these steps, block
    allocation can fail due to discards not having completed yet:
    1) fill thin device via filesystem file
    2) remove file
    3) fstrim

    From initial report, here:
    https://www.redhat.com/archives/dm-devel/2018-April/msg00022.html

    "The root cause of this issue is that dm-thin will first remove
    mapping and increase corresponding blocks' reference count to prevent
    them from being reused before DISCARD bios get processed by the
    underlying layers. However. increasing blocks' reference count could
    also increase the nr_allocated_this_transaction in struct sm_disk
    which makes smd->old_ll.nr_allocated +
    smd->nr_allocated_this_transaction bigger than smd->old_ll.nr_blocks.
    In this case, alloc_data_block() will never commit metadata to reset
    the begin pointer of struct sm_disk, because sm_disk_get_nr_free()
    always return an underflow value."

    While there is room for improvement to the space-map accounting that
    thinp is making use of: the reality is this test is inherently racey and
    will result in the previous iteration's fstrim's discard(s) completing
    vs concurrent block allocation, via dd, in the next iteration of the
    loop.

    No amount of space map accounting improvements will be able to allow
    user's to use a block before a discard of that block has completed.

    So the best we can really do is allow DM thinp to gracefully handle such
    aggressive use of all the pool's data by degrading the pool into
    out-of-data-space (OODS) mode. We _should_ get that behaviour already
    (if space map accounting didn't falsely cause alloc_data_block() to
    believe free space was available).. but short of that we handle the
    current reality that dm_pool_alloc_data_block() can return -ENOSPC.

    Reported-by: Dennis Yang
    Cc: stable@vger.kernel.org
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Mike Snitzer
     
  • commit 2d0b2d64d325e22939d9db3ba784f1236459ed98 upstream.

    This patch avoids that lockdep reports the following:

    ======================================================
    WARNING: possible circular locking dependency detected
    4.18.0-rc1 #62 Not tainted
    ------------------------------------------------------
    kswapd0/84 is trying to acquire lock:
    00000000c313516d (&xfs_nondir_ilock_class){++++}, at: xfs_free_eofblocks+0xa2/0x1e0

    but task is already holding lock:
    00000000591c83ae (fs_reclaim){+.+.}, at: __fs_reclaim_acquire+0x5/0x30

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #2 (fs_reclaim){+.+.}:
    kmem_cache_alloc+0x2c/0x2b0
    radix_tree_node_alloc.constprop.19+0x3d/0xc0
    __radix_tree_create+0x161/0x1c0
    __radix_tree_insert+0x45/0x210
    dmz_map+0x245/0x2d0 [dm_zoned]
    __map_bio+0x40/0x260
    __split_and_process_non_flush+0x116/0x220
    __split_and_process_bio+0x81/0x180
    __dm_make_request.isra.32+0x5a/0x100
    generic_make_request+0x36e/0x690
    submit_bio+0x6c/0x140
    mpage_readpages+0x19e/0x1f0
    read_pages+0x6d/0x1b0
    __do_page_cache_readahead+0x21b/0x2d0
    force_page_cache_readahead+0xc4/0x100
    generic_file_read_iter+0x7c6/0xd20
    __vfs_read+0x102/0x180
    vfs_read+0x9b/0x140
    ksys_read+0x55/0xc0
    do_syscall_64+0x5a/0x1f0
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    -> #1 (&dmz->chunk_lock){+.+.}:
    dmz_map+0x133/0x2d0 [dm_zoned]
    __map_bio+0x40/0x260
    __split_and_process_non_flush+0x116/0x220
    __split_and_process_bio+0x81/0x180
    __dm_make_request.isra.32+0x5a/0x100
    generic_make_request+0x36e/0x690
    submit_bio+0x6c/0x140
    _xfs_buf_ioapply+0x31c/0x590
    xfs_buf_submit_wait+0x73/0x520
    xfs_buf_read_map+0x134/0x2f0
    xfs_trans_read_buf_map+0xc3/0x580
    xfs_read_agf+0xa5/0x1e0
    xfs_alloc_read_agf+0x59/0x2b0
    xfs_alloc_pagf_init+0x27/0x60
    xfs_bmap_longest_free_extent+0x43/0xb0
    xfs_bmap_btalloc_nullfb+0x7f/0xf0
    xfs_bmap_btalloc+0x428/0x7c0
    xfs_bmapi_write+0x598/0xcc0
    xfs_iomap_write_allocate+0x15a/0x330
    xfs_map_blocks+0x1cf/0x3f0
    xfs_do_writepage+0x15f/0x7b0
    write_cache_pages+0x1ca/0x540
    xfs_vm_writepages+0x65/0xa0
    do_writepages+0x48/0xf0
    __writeback_single_inode+0x58/0x730
    writeback_sb_inodes+0x249/0x5c0
    wb_writeback+0x11e/0x550
    wb_workfn+0xa3/0x670
    process_one_work+0x228/0x670
    worker_thread+0x3c/0x390
    kthread+0x11c/0x140
    ret_from_fork+0x3a/0x50

    -> #0 (&xfs_nondir_ilock_class){++++}:
    down_read_nested+0x43/0x70
    xfs_free_eofblocks+0xa2/0x1e0
    xfs_fs_destroy_inode+0xac/0x270
    dispose_list+0x51/0x80
    prune_icache_sb+0x52/0x70
    super_cache_scan+0x127/0x1a0
    shrink_slab.part.47+0x1bd/0x590
    shrink_node+0x3b5/0x470
    balance_pgdat+0x158/0x3b0
    kswapd+0x1ba/0x600
    kthread+0x11c/0x140
    ret_from_fork+0x3a/0x50

    other info that might help us debug this:

    Chain exists of:
    &xfs_nondir_ilock_class --> &dmz->chunk_lock --> fs_reclaim

    Possible unsafe locking scenario:

    CPU0 CPU1
    ---- ----
    lock(fs_reclaim);
    lock(&dmz->chunk_lock);
    lock(fs_reclaim);
    lock(&xfs_nondir_ilock_class);

    Bart Van Assche
     
  • commit cfe19577047e74cdac5826adbdc2337d8437f8fb upstream.

    Open-coded page table entry checks don't work correctly when we fold the
    page table level at runtime.

    pgd_present() on 4-level paging machine always returns true, but
    open-coded version of the check may return false-negative result and
    we silently skip the rest of the loop body in efi_call_phys_epilog().

    Replace open-coded checks with proper helpers.

    Signed-off-by: Kirill A. Shutemov
    Acked-by: Ard Biesheuvel
    Cc: Andrey Ryabinin
    Cc: Baoquan He
    Cc: Linus Torvalds
    Cc: Matt Fleming
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: stable@vger.kernel.org # v4.12+
    Fixes: 94133e46a0f5 ("x86/efi: Correct EFI identity mapping under 'efi=old_map' when KASLR is enabled")
    Link: http://lkml.kernel.org/r/20180625120852.18300-1-kirill.shutemov@linux.intel.com
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Kirill A. Shutemov
     
  • commit 297ba57dcdec7ea37e702bcf1a577ac32a034e21 upstream.

    This patch avoids that removing a path controlled by the dm-mpath driver
    while mkfs is running triggers the following kernel bug:

    kernel BUG at block/blk-core.c:3347!
    invalid opcode: 0000 [#1] PREEMPT SMP KASAN
    CPU: 20 PID: 24369 Comm: mkfs.ext4 Not tainted 4.18.0-rc1-dbg+ #2
    RIP: 0010:blk_end_request_all+0x68/0x70
    Call Trace:

    dm_softirq_done+0x326/0x3d0 [dm_mod]
    blk_done_softirq+0x19b/0x1e0
    __do_softirq+0x128/0x60d
    irq_exit+0x100/0x110
    smp_call_function_single_interrupt+0x90/0x330
    call_function_single_interrupt+0xf/0x20

    Fixes: f9d03f96b988 ("block: improve handling of the magic discard payload")
    Reviewed-by: Ming Lei
    Reviewed-by: Christoph Hellwig
    Acked-by: Mike Snitzer
    Signed-off-by: Bart Van Assche
    Cc: Hannes Reinecke
    Cc: Johannes Thumshirn
    Cc:
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Bart Van Assche
     
  • commit 15bfd21fbc5d35834b9ea383dc458a1f0c9e3434 upstream.

    A device may have boundary restrictions where the number of sectors
    between boundaries exceeds its max transfer size. In this case, we need
    to cap the max size to the smaller of the two limits.

    Reported-by: Jitendra Bhivare
    Tested-by: Jitendra Bhivare
    Cc:
    Reviewed-by: Martin K. Petersen
    Signed-off-by: Keith Busch
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Keith Busch
     
  • commit d50d82faa0c964e31f7a946ba8aba7c715ca7ab0 upstream.

    In kernel 4.17 I removed some code from dm-bufio that did slab cache
    merging (commit 21bb13276768: "dm bufio: remove code that merges slab
    caches") - both slab and slub support merging caches with identical
    attributes, so dm-bufio now just calls kmem_cache_create and relies on
    implicit merging.

    This uncovered a bug in the slub subsystem - if we delete a cache and
    immediatelly create another cache with the same attributes, it fails
    because of duplicate filename in /sys/kernel/slab/. The slub subsystem
    offloads freeing the cache to a workqueue - and if we create the new
    cache before the workqueue runs, it complains because of duplicate
    filename in sysfs.

    This patch fixes the bug by moving the call of kobject_del from
    sysfs_slab_remove_workfn to shutdown_cache. kobject_del must be called
    while we hold slab_mutex - so that the sysfs entry is deleted before a
    cache with the same attributes could be created.

    Running device-mapper-test-suite with:

    dmtest run --suite thin-provisioning -n /commit_failure_causes_fallback/

    triggered:

    Buffer I/O error on dev dm-0, logical block 1572848, async page read
    device-mapper: thin: 253:1: metadata operation 'dm_pool_alloc_data_block' failed: error = -5
    device-mapper: thin: 253:1: aborting current metadata transaction
    sysfs: cannot create duplicate filename '/kernel/slab/:a-0000144'
    CPU: 2 PID: 1037 Comm: kworker/u48:1 Not tainted 4.17.0.snitm+ #25
    Hardware name: Supermicro SYS-1029P-WTR/X11DDW-L, BIOS 2.0a 12/06/2017
    Workqueue: dm-thin do_worker [dm_thin_pool]
    Call Trace:
    dump_stack+0x5a/0x73
    sysfs_warn_dup+0x58/0x70
    sysfs_create_dir_ns+0x77/0x80
    kobject_add_internal+0xba/0x2e0
    kobject_init_and_add+0x70/0xb0
    sysfs_slab_add+0xb1/0x250
    __kmem_cache_create+0x116/0x150
    create_cache+0xd9/0x1f0
    kmem_cache_create_usercopy+0x1c1/0x250
    kmem_cache_create+0x18/0x20
    dm_bufio_client_create+0x1ae/0x410 [dm_bufio]
    dm_block_manager_create+0x5e/0x90 [dm_persistent_data]
    __create_persistent_data_objects+0x38/0x940 [dm_thin_pool]
    dm_pool_abort_metadata+0x64/0x90 [dm_thin_pool]
    metadata_operation_failed+0x59/0x100 [dm_thin_pool]
    alloc_data_block.isra.53+0x86/0x180 [dm_thin_pool]
    process_cell+0x2a3/0x550 [dm_thin_pool]
    do_worker+0x28d/0x8f0 [dm_thin_pool]
    process_one_work+0x171/0x370
    worker_thread+0x49/0x3f0
    kthread+0xf8/0x130
    ret_from_fork+0x35/0x40
    kobject_add_internal failed for :a-0000144 with -EEXIST, don't try to register things with the same name in the same directory.
    kmem_cache_create(dm_bufio_buffer-16) failed with error -17

    Link: http://lkml.kernel.org/r/alpine.LRH.2.02.1806151817130.6333@file01.intranet.prod.int.rdu2.redhat.com
    Signed-off-by: Mikulas Patocka
    Reported-by: Mike Snitzer
    Tested-by: Mike Snitzer
    Cc: Christoph Lameter
    Cc: Pekka Enberg
    Cc: David Rientjes
    Cc: Joonsoo Kim
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Greg Kroah-Hartman

    Mikulas Patocka
     
  • commit e41fc8c5bd41b96bfae5ce4c66bee6edabc932e8 upstream.

    We have 3 more Lenovo machines, they all have 2 front mics on them,
    so they need the fixup to change the location for one of two mics.

    Among these 3 Lenovo machines, one of them has the same pin cfg as the
    machine with subid 0x17aa3138, so use the pin cfg table to apply fixup
    for them. The rest machines don't share the same pin cfg, so far use
    the subid to apply fixup for them.

    Fixes: a3dafb2200bf ("ALSA: hda/realtek - adjust the location of one mic")
    Cc:
    Signed-off-by: Hui Wang
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Hui Wang
     
  • commit 275ec0cb946cb75ac8977f662e608fce92f8b8a8 upstream.

    Fujitsu Seimens ESPRIMO Mobile U9210 requires the same fixup as H270
    for the correct pin configs.

    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200107
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai
     
  • commit d5a6cabf02210b896a60eee7c04c670ee9ba6dca upstream.

    Some Lenovo laptops, e.g. Lenovo P50, showed the pop noise at resume
    or runtime resume. It turned out to be reduced by applying
    alc_no_shutup() just like TPT440 quirk does.

    Since there are many Lenovo models showing the same behavior, put this
    workaround in ALC269_FIXUP_THINKPAD_ACPI entry so that it's applied
    commonly to all such Lenovo machines.

    Reported-by: Hans de Goede
    Tested-by: Benjamin Berg
    Cc:
    Signed-off-by: Takashi Iwai
    Signed-off-by: Greg Kroah-Hartman

    Takashi Iwai