30 May, 2018

40 commits

  • [ Upstream commit 3de59bb9d551428cbdc76a9ea57883f82e350b4d ]

    In handle_write_finished(), if r1_bio->bios[m] != NULL, it thinks
    the corresponding conf->mirrors[m].rdev is also not NULL. But, it
    is not always true.

    Even if some io hold replacement rdev(i.e. rdev->nr_pending.count > 0),
    raid1_remove_disk() can also set the rdev as NULL. That means,
    bios[m] != NULL, but mirrors[m].rdev is NULL, resulting in NULL
    pointer dereference in handle_write_finished and sync_request_write.

    This patch can fix BUGs as follows:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000140
    IP: [] raid1d+0x2bd/0xfc0
    PGD 12ab52067 PUD 12f587067 PMD 0
    Oops: 0000 [#1] SMP
    CPU: 1 PID: 2008 Comm: md3_raid1 Not tainted 4.1.44+ #130
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 04/01/2014
    Call Trace:
    ? schedule+0x37/0x90
    ? prepare_to_wait_event+0x83/0xf0
    md_thread+0x144/0x150
    ? wake_atomic_t_function+0x70/0x70
    ? md_start_sync+0xf0/0xf0
    kthread+0xd8/0xf0
    ? kthread_worker_fn+0x160/0x160
    ret_from_fork+0x42/0x70
    ? kthread_worker_fn+0x160/0x160

    BUG: unable to handle kernel NULL pointer dereference at 00000000000000b8
    IP: sync_request_write+0x9e/0x980
    PGD 800000007c518067 P4D 800000007c518067 PUD 8002b067 PMD 0
    Oops: 0000 [#1] SMP PTI
    CPU: 24 PID: 2549 Comm: md3_raid1 Not tainted 4.15.0+ #118
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc26 04/01/2014
    Call Trace:
    ? sched_clock+0x5/0x10
    ? sched_clock_cpu+0xc/0xb0
    ? flush_pending_writes+0x3a/0xd0
    ? pick_next_task_fair+0x4d5/0x5f0
    ? __switch_to+0xa2/0x430
    raid1d+0x65a/0x870
    ? find_pers+0x70/0x70
    ? find_pers+0x70/0x70
    ? md_thread+0x11c/0x160
    md_thread+0x11c/0x160
    ? finish_wait+0x80/0x80
    kthread+0x111/0x130
    ? kthread_create_worker_on_cpu+0x70/0x70
    ? do_syscall_64+0x6f/0x190
    ? SyS_exit_group+0x10/0x10
    ret_from_fork+0x35/0x40

    Reviewed-by: NeilBrown
    Signed-off-by: Yufen Yu
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Yufen Yu
     
  • [ Upstream commit 8876391e440ba615b10eef729576e111f0315f87 ]

    There is a potential deadlock if mount/umount happens when
    raid5_finish_reshape() tries to grow the size of emulated disk.

    How the deadlock happens?
    1) The raid5 resync thread finished reshape (expanding array).
    2) The mount or umount thread holds VFS sb->s_umount lock and tries to
    write through critical data into raid5 emulated block device. So it
    waits for raid5 kernel thread handling stripes in order to finish it
    I/Os.
    3) In the routine of raid5 kernel thread, md_check_recovery() will be
    called first in order to reap the raid5 resync thread. That is,
    raid5_finish_reshape() will be called. In this function, it will try
    to update conf and call VFS revalidate_disk() to grow the raid5
    emulated block device. It will try to acquire VFS sb->s_umount lock.
    The raid5 kernel thread cannot continue, so no one can handle mount/
    umount I/Os (stripes). Once the write-through I/Os cannot be finished,
    mount/umount will not release sb->s_umount lock. The deadlock happens.

    The raid5 kernel thread is an emulated block device. It is responible to
    handle I/Os (stripes) from upper layers. The emulated block device
    should not request any I/Os on itself. That is, it should not call VFS
    layer functions. (If it did, it will try to acquire VFS locks to
    guarantee the I/Os sequence.) So we have the resync thread to send
    resync I/O requests and to wait for the results.

    For solving this potential deadlock, we can put the size growth of the
    emulated block device as the final step of reshape thread.

    2017/12/29:
    Thanks to Guoqing Jiang ,
    we confirmed that there is the same deadlock issue in raid10. It's
    reproducible and can be fixed by this patch. For raid10.c, we can remove
    the similar code to prevent deadlock as well since they has been called
    before.

    Reported-by: Alex Wu
    Reviewed-by: Alex Wu
    Reviewed-by: Chung-Chiang Cheng
    Signed-off-by: BingJing Chang
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    BingJing Chang
     
  • [ Upstream commit 4e14bf4236490306004782813b8b4494b18f5e60 ]

    The following use-after-free was reported by KASan when running
    LTP macvtap01 test on 4.16-rc2:

    [10642.528443] BUG: KASAN: use-after-free in
    macvlan_common_newlink+0x12ef/0x14a0 [macvlan]
    [10642.626607] Read of size 8 at addr ffff880ba49f2100 by task ip/18450
    ...
    [10642.963873] Call Trace:
    [10642.994352] dump_stack+0x5c/0x7c
    [10643.035325] print_address_description+0x75/0x290
    [10643.092938] kasan_report+0x28d/0x390
    [10643.137971] ? macvlan_common_newlink+0x12ef/0x14a0 [macvlan]
    [10643.207963] macvlan_common_newlink+0x12ef/0x14a0 [macvlan]
    [10643.275978] macvtap_newlink+0x171/0x260 [macvtap]
    [10643.334532] rtnl_newlink+0xd4f/0x1300
    ...
    [10646.256176] Allocated by task 18450:
    [10646.299964] kasan_kmalloc+0xa6/0xd0
    [10646.343746] kmem_cache_alloc_trace+0xf1/0x210
    [10646.397826] macvlan_common_newlink+0x6de/0x14a0 [macvlan]
    [10646.464386] macvtap_newlink+0x171/0x260 [macvtap]
    [10646.522728] rtnl_newlink+0xd4f/0x1300
    ...
    [10647.022028] Freed by task 18450:
    [10647.061549] __kasan_slab_free+0x138/0x180
    [10647.111468] kfree+0x9e/0x1c0
    [10647.147869] macvlan_port_destroy+0x3db/0x650 [macvlan]
    [10647.211411] rollback_registered_many+0x5b9/0xb10
    [10647.268715] rollback_registered+0xd9/0x190
    [10647.319675] register_netdevice+0x8eb/0xc70
    [10647.370635] macvlan_common_newlink+0xe58/0x14a0 [macvlan]
    [10647.437195] macvtap_newlink+0x171/0x260 [macvtap]

    Commit d02fd6e7d293 ("macvlan: Fix one possible double free") handles
    the case when register_netdevice() invokes ndo_uninit() on error and
    as a result free the port. But 'macvlan_port_get_rtnl(dev))' check
    (returns dev->rx_handler_data), which was added by this commit in order
    to prevent double free, is not quite correct:

    * for macvlan it always returns NULL because 'lowerdev' is the one that
    was used to register rx handler (port) in macvlan_port_create() as
    well as to unregister it in macvlan_port_destroy().
    * for macvtap it always returns a valid pointer because macvtap registers
    its own rx handler before macvlan_common_newlink().

    Fixes: d02fd6e7d293 ("macvlan: Fix one possible double free")
    Signed-off-by: Alexey Kodanev
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexey Kodanev
     
  • [ Upstream commit 88e80c62671ceecdbb77c902731ec95a4bfa62f9 ]

    If an attempt is made to disable RX checksums, USB adapter is changed
    but netdev->features is not, because smsc75xx_set_features() returns a
    non zero value.

    This throws errors from netdev_rx_csum_fault() :
    : hw csum failure

    Signed-off-by: Eric Dumazet
    Cc: Steve Glendinning
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     
  • [ Upstream commit 410d5e13e7638bc146321671e223d56495fbf3c7 ]

    When we terminate driver I/O (because we need to stop using a certain
    channel path) we also need to ensure that a timer (which may have been
    set up using ccw_device_start_timeout) is cleared.

    Signed-off-by: Sebastian Ott
    Signed-off-by: Martin Schwidefsky
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Ott
     
  • [ Upstream commit 770b55c995d171f026a9efb85e71e3b1ea47b93d ]

    When a timeout occurs for users of ccw_device_start_timeout
    we will stop the IO and call the drivers int handler with
    the irb pointer set to ERR_PTR(-ETIMEDOUT). Sometimes
    however we'd set the irb pointer to ERR_PTR(-EIO) which is
    not intended. Just set the correct value in all codepaths.

    Reported-by: Julian Wiedmann
    Signed-off-by: Sebastian Ott
    Signed-off-by: Martin Schwidefsky
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Ott
     
  • [ Upstream commit f97a6b6c47d2f329a24f92cc0ca3c6df5727ba73 ]

    There are cases a device driver can't start IO because the device is
    currently in use by cio. In this case the device driver is notified
    when the device is usable again.

    Using ccw_device_start_timeout we would set the timeout (and change
    an existing timeout) before we test for internal usage. Worst case
    this could lead to an unexpected timer deletion.

    Fix this by setting the timeout after we test for internal usage.

    Signed-off-by: Sebastian Ott
    Signed-off-by: Martin Schwidefsky
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Ott
     
  • [ Upstream commit 7801c545e706674aeed40256eb806ad37b18ad71 ]

    If power domain information are missing in the device tree, no
    power domains get initialized. However, imx_gpc_remove tries to
    remove power domains always in the old DT binding case. Only
    remove power domains when imx_gpc_probe initialized them in
    first place.

    Fixes: 721cabf6c660 ("soc: imx: move PGC handling to a new GPC driver")
    Signed-off-by: Stefan Agner
    Reviewed-by: Lucas Stach
    Reviewed-by: Fabio Estevam
    Signed-off-by: Shawn Guo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Stefan Agner
     
  • [ Upstream commit 95dbe9e7b3720efa5cf83d21f44f6d953f7cf4a2 ]

    When configuring virtio_net to use the code path 'receive_small()',
    in-order to get correct XDP_REDIRECT support, I discovered TCP packets
    would get silently dropped when loading an XDP program action XDP_PASS.

    The bug seems to be that receive_small() when XDP is loaded check that
    hdr->hdr.flags is zero, which seems wrong as hdr.flags contains the
    flags VIRTIO_NET_HDR_F_* :
    #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */
    #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */

    TCP got dropped as it had the VIRTIO_NET_HDR_F_DATA_VALID flag set.

    The flags that are relevant here are the VIRTIO_NET_HDR_GSO_* flags
    stored in hdr->hdr.gso_type. Thus, the fix is just check that none of
    the gso_type flags have been set.

    Fixes: bb91accf2733 ("virtio-net: XDP support for small buffers")
    Signed-off-by: Jesper Dangaard Brouer
    Acked-by: John Fastabend
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jesper Dangaard Brouer
     
  • [ Upstream commit 53b8d89ddbdbb0e4625a46d2cdbb6f106c52f801 ]

    gcc warns about a possible overflow of the kmem_cache string, when adding
    four characters to a string of the same length:

    drivers/md/raid5.c: In function 'setup_conf':
    drivers/md/raid5.c:2207:34: error: '-alt' directive writing 4 bytes into a region of size between 1 and 32 [-Werror=format-overflow=]
    sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
    ^~~~
    drivers/md/raid5.c:2207:2: note: 'sprintf' output between 5 and 36 bytes into a destination of size 32
    sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    If I'm counting correctly, we need 11 characters for the fixed part
    of the string and 18 characters for a 64-bit pointer (when no gendisk
    is used), so that leaves three characters for conf->level, which should
    always be sufficient.

    This makes the code use snprintf() with the correct length, to
    make the code more robust against changes, and to get the compiler
    to shut up.

    In commit f4be6b43f1ac ("md/raid5: ensure we create a unique name for
    kmem_cache when mddev has no gendisk") from 2010, Neil said that
    the pointer could be removed "shortly" once devices without gendisk
    are disallowed. I have no idea if that happened, but if it did, that
    should probably be changed as well.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • [ Upstream commit 001a2fc0c8cc29241305e44ffbce52d1daf8782b ]

    This isn't supported when we emulate eswitch vlan push action which
    is the current state of things.

    Fixes: 8b32580df1cb ('net/mlx5e: Add TC vlan action for SRIOV offloads')
    Signed-off-by: Or Gerlitz
    Reviewed-by: Mark Bloch
    Signed-off-by: Saeed Mahameed
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Or Gerlitz
     
  • [ Upstream commit abe27a885d9e6575e663a16176dabc58ce9d7188 ]

    After introduction of commit d0869c0071e4, there were some instances of
    RX queue entries from a previous session (before the device was closed
    and reopened) returned to the NAPI polling routine. Since the corresponding
    socket buffers were freed, this resulted in a panic on reopen. Include
    a check for a NULL skb here to avoid this.

    Fixes: d0869c0071e4 ("ibmvnic: Clean RX pool buffers during device close")
    Signed-off-by: Thomas Falcon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Falcon
     
  • [ Upstream commit dcdaba08062b4726500b9456f8664bfda896c664 ]

    During driver unload, the driver proceeds with cleanup
    without waiting for the scheduled events. So the device
    pointers get freed up and driver crashes when the events
    are scheduled later.

    Flush the bnxt_re_task work queue before starting
    device removal.

    Signed-off-by: Selvin Xavier
    Signed-off-by: Doug Ledford
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Selvin Xavier
     
  • [ Upstream commit 6b4521f5174c26020ae0deb3ef7f2c28557cf445 ]

    Driver leaves the QP memory pinned if QP create command
    fails from the FW. Avoids this scenario by adding a proper
    exit path if the FW command fails.

    Signed-off-by: Devesh Sharma
    Signed-off-by: Selvin Xavier
    Signed-off-by: Doug Ledford
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Devesh Sharma
     
  • [ Upstream commit e88230a3744a71a0b5ecfb45e08ddfe1c884e50d ]

    The plane buffer address/stride/height was incorrectly updated in the
    plane_atomic_update operation instead of the vsync irq.
    This patch delays this operation in the vsync irq along with the
    other plane delayed setup.

    This issue was masked using legacy framebuffer and X11 modesetting, but
    is clearly visible using gbm rendering when buffer is submitted late after
    vblank, like using software decoding and OpenGL rendering in Kodi.
    With this patch, tearing and other artifacts disappears completely.

    Cc: Michal Lazo
    Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
    Signed-off-by: Neil Armstrong
    Acked-by: Daniel Vetter
    Link: https://patchwork.freedesktop.org/patch/msgid/1518689976-23292-1-git-send-email-narmstrong@baylibre.com
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Neil Armstrong
     
  • [ Upstream commit 1293b6191010672c0c9dacae8f71c6f3e4d70cbe ]

    Due to a typo, the mask was destroyed by a comparison instead of a bit
    shift.

    Signed-off-by: Wolfram Sang
    Signed-off-by: Inki Dae
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Wolfram Sang
     
  • [ Upstream commit a588a8bb7b25a3fb4f7fed00feb7aec541fc2632 ]

    The exynos DRM driver uses real-time 'struct timeval' values
    for exporting its timestamps to user space. This has multiple
    problems:

    1. signed seconds overflow in y2038
    2. the 'struct timeval' definition is deprecated in the kernel
    3. time may jump or go backwards after a 'settimeofday()' syscall
    4. other DRM timestamps are in CLOCK_MONOTONIC domain, so they
    can't be compared
    5. exporting microseconds requires a division by 1000, which may
    be slow on some architectures.

    The code existed in two places before, but the IPP portion was
    removed in 8ded59413ccc ("drm/exynos: ipp: Remove Exynos DRM
    IPP subsystem"), so we no longer need to worry about it.

    Ideally timestamps should just use 64-bit nanoseconds instead, but
    of course we can't change that now. Instead, this tries to address
    the first four points above by using monotonic 'timespec' values.

    According to Tobias Jakobi, user space doesn't care about the
    timestamp at the moment, so we can change the format. Even if
    there is something looking at them, it will work just fine with
    monotonic times as long as the application only looks at the
    relative values between two events.

    Link: https://patchwork.kernel.org/patch/10038593/
    Cc: Tobias Jakobi
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Tobias Jakobi
    Signed-off-by: Inki Dae
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • [ Upstream commit 01a69cab01c184d3786af09e9339311123d63d22 ]

    In the case of 'recover', an r10bio with R10BIO_WriteError &
    R10BIO_IsRecover will be progressed by handle_write_completed().
    This function traverses all r10bio->devs[copies].
    If devs[m].repl_bio != NULL, it thinks conf->mirrors[dev].replacement
    is also not NULL. However, this is not always true.

    When there is an rdev of raid10 has replacement, then each r10bio
    ->devs[m].repl_bio != NULL in conf->r10buf_pool. However, in 'recover',
    even if corresponded replacement is NULL, it doesn't clear r10bio
    ->devs[m].repl_bio, resulting in replacement NULL deference.

    This bug was introduced when replacement support for raid10 was
    added in Linux 3.3.

    As NeilBrown suggested:
    Elsewhere the determination of "is this device part of the
    resync/recovery" is made by resting bio->bi_end_io.
    If this is end_sync_write, then we tried to write here.
    If it is NULL, then we didn't try to write.

    Fixes: 9ad1aefc8ae8 ("md/raid10: Handle replacement devices during resync.")
    Cc: stable (V3.3+)
    Suggested-by: NeilBrown
    Signed-off-by: Yufen Yu
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Yufen Yu
     
  • [ Upstream commit 3addaba8141bc6a4f649a48f46e552af32922147 ]

    Before returning, call of_node_put() for the device node returned by
    of_parse_phandle().

    Fixes: ea9c260514c1 ("gpu: ipu-v3: add driver for Prefetch Resolve Gasket")
    Signed-off-by: Tobias Jordan
    Signed-off-by: Philipp Zabel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Tobias Jordan
     
  • [ Upstream commit c795f3052b60b01e80485fad98c53e5e67d093c9 ]

    Before returning, call of_node_put() for the device node returned by
    of_parse_phandle().

    Fixes: d2a34232580a ("gpu: ipu-v3: add driver for Prefetch Resolve Engine")
    Signed-off-by: Tobias Jordan
    Signed-off-by: Philipp Zabel
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Tobias Jordan
     
  • [ Upstream commit 9487cfd3430d07366801886bdf185799a2b6f066 ]

    Internal DASD device driver I/O such as query host access count or
    path verification is started using the _sleep_on() function.
    To mark a request as started or ended the callback_data is set to either
    DASD_SLEEPON_START_TAG or DASD_SLEEPON_END_TAG.

    In cases where the request has to be stopped unconditionally the status is
    set to DASD_SLEEPON_END_TAG as well which leads to immediate clearing of
    the request.
    But the request might still be on a device request queue for normal
    operation which might lead to a panic because of a BUG() statement in
    __dasd_device_process_final_queue() or a list corruption of the device
    request queue.

    Fix by removing the setting of DASD_SLEEPON_END_TAG in the
    dasd_cancel_req() and dasd_generic_requeue_all_requests() functions and
    ensure that the request is not deleted in the requeue function.
    Trigger the device tasklet in the requeue function and let the normal
    processing cleanup the request.

    Signed-off-by: Stefan Haberland
    Reviewed-by: Jan Hoeppner
    Signed-off-by: Martin Schwidefsky
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Stefan Haberland
     
  • [ Upstream commit 4b6c1060eaa6495aa5b0032e8f2d51dd936b1257 ]

    If no metadata devices are configured on raid1/4/5/6/10
    (e.g. via dm-raid), md_write_start() unconditionally waits
    for superblocks to be written thus deadlocking.

    Fix introduces mddev->has_superblocks bool, defines it in md_run()
    and checks for it in md_write_start() to conditionally avoid waiting.

    Once on it, check for non-existing superblocks in md_super_write().

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=198647
    Fixes: cc27b0c78c796 ("md: fix deadlock between mddev_suspend() and md_write_start()")

    Signed-off-by: Heinz Mauelshagen
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Heinz Mauelshagen
     
  • [ Upstream commit b126194cbb799f9980b92a77e58db6ad794c8082 ]

    Signed-off-by: Xiao Ni
    Acked-by: Guoqing Jiang
    Signed-off-by: Shaohua Li
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Xiao Ni
     
  • [ Upstream commit 6b7a5aea71b342ec0593d23b08383e1f33da4c9a ]

    In AP mode, when a new station associates, rs is initialized immediately
    upon association completion, before the phy context is updated with the
    association parameters, so the sta bandwidth might be wider than the phy
    context allows.
    To avoid this issue, always initialize rs with 20mhz bandwidth rate, and
    after authorization, when the phy context is already up-to-date, re-init
    rs with the correct bw.

    Signed-off-by: Naftali Goldstein
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Naftali Goldstein
     
  • [ Upstream commit fc07bd8ce19bff9e7479c04077ddb5957d1a27be ]

    In IBSS, the mac80211 sets the cab_queue to be invalid.

    However, the multicast station uses it, so we need to override it.

    A previous patch did it, but it was nested inside the if's and was
    applied only for legacy FWs that don't support the new station type
    API, instead of being applied for all paths.

    In addition, add a missing NL80211_IFTYPE_ADHOC to the initialization
    of the queues in iwl_mvm_mac_ctxt_init()

    Fixes: ee48b72211f8 ("iwlwifi: mvm: support ibss in dqa mode")
    Signed-off-by: Sara Sharon
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sara Sharon
     
  • [ Upstream commit 5ab2ba931255d8bf03009c06d58dce97de32797c ]

    A previous patch allowed the same PN for packets originating from the
    same AMSDU by copying PN only for the last packet in the series.

    This however is bogus since we cannot assume the last frame will be
    received on the same queue, and if it is received on a different ueue
    we will end up not incrementing the PN and possibly let the next
    packet to have the same PN and pass through.

    Change the logic instead to driver explicitly indicate for the second
    sub frame and on to be allowed to have the same PN as the first
    subframe. Indicate it to mac80211 as well for the fallback queue.

    Fixes: f1ae02b186d9 ("iwlwifi: mvm: allow same PN for de-aggregated AMSDU")
    Signed-off-by: Sara Sharon
    Signed-off-by: Luca Coelho
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sara Sharon
     
  • [ Upstream commit ec6f8401c48a86809237e86878a6fac6b281118f ]

    If remove_commit fails then the lock is left locked while the uobj still
    exists. Eventually the kernel will deadlock.

    lockdep detects this and says:

    test/4221 is leaving the kernel with locks still held!
    1 lock held by test/4221:
    #0: (&ucontext->cleanup_rwsem){.+.+}, at: [] rdma_explicit_destroy+0x37/0x120 [ib_uverbs]

    Fixes: 4da70da23e9b ("IB/core: Explicitly destroy an object while keeping uobject")
    Signed-off-by: Leon Romanovsky
    Reviewed-by: Dennis Dalessandro
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jason Gunthorpe
     
  • [ Upstream commit 4d39a959bc1f3d164b5a54147fdeb19f84b1ed58 ]

    If the same attribute is listed twice by the user in the ioctl attribute
    list then error unwind can cause the kernel to deref garbage.

    This happens when an object with WRITE access is sent twice. The second
    parse properly fails but corrupts the state required for the error unwind
    it triggers.

    Fixing this by making duplicates in the attribute list invalid. This is
    not something we need to support.

    The ioctl interface is currently recommended to be disabled in kConfig.

    Signed-off-by: Matan Barak
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Matan Barak
     
  • [ Upstream commit 3d89459e2ef92cc0e5a50dde868780ccda9786c1 ]

    Fix a bug in uverbs_ioctl_merge that looked at the object's iterator
    number instead of the method's iterator number when merging methods.

    While we're at it, make the uverbs_ioctl_merge code a bit more clear
    and faster.

    Fixes: 118620d3686b ('IB/core: Add uverbs merge trees functionality')
    Signed-off-by: Matan Barak
    Signed-off-by: Leon Romanovsky
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Matan Barak
     
  • [ Upstream commit bde0716d1f076e4c913c7946bcc858f71243c7a0 ]

    For AMD Promontory xHCI host, although you can disable USB ports in
    BIOS settings, those ports will be enabled anyway after you remove a
    device on that port and re-plug it in again. It's a known limitation of
    the chip. As a workaround we can clear the PORT_WAKE_BITS.

    [commit and code comment rephrasing -Mathias]
    Signed-off-by: Joe Lee
    Signed-off-by: Mathias Nyman
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Joe Lee
     
  • [ Upstream commit d0869c0071e40c4407d1a4d7c9497653cf47253b ]

    During device close or reset, there were some cases of outstanding
    RX socket buffers not being freed. Include a function similar to the
    one that already exists to clean TX socket buffers in this case.

    Signed-off-by: Thomas Falcon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Falcon
     
  • [ Upstream commit 4b9b0f01350500173f17e2b2e65beb4df4ef99c7 ]

    If a RX buffer is returned to the client driver with an error, free the
    corresponding socket buffer before continuing.

    Signed-off-by: Thomas Falcon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Falcon
     
  • [ Upstream commit cc85c02edfe48a34865ae00f7d22298a3fdd17aa ]

    Pushes back setting the carrier on until the end of the reset
    code. This resolves a bug where a watchdog timer was detecting
    that a TX queue had stalled before the adapter reset was complete.

    Signed-off-by: Thomas Falcon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Falcon
     
  • [ Upstream commit 0d3e45bc6507bd1f8728bf586ebd16c2d9e40613 ]

    This fixs the following comile warnings with ATA_DEBUG enabled,
    which detected by Linaro GCC 5.2-2015.11:

    drivers/ata/libata-scsi.c: In function 'ata_scsi_dump_cdb':
    ./include/linux/kern_levels.h:5:18: warning: format '%d' expects
    argument of type 'int', but argument 6 has type 'u64 {aka long
    long unsigned int}' [-Wformat=]

    tj: Patch hand-applied and description trimmed.

    Signed-off-by: Dong Bo
    Signed-off-by: Tejun Heo
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dong Bo
     
  • commit f7068114d45ec55996b9040e98111afa56e010fe upstream.

    We're casting the CDROM layer request_sense to the SCSI sense
    buffer, but the former is 64 bytes and the latter is 96 bytes.
    As we generally allocate these on the stack, we end up blowing
    up the stack.

    Fix this by wrapping the scsi_execute() call with a properly
    sized sense buffer, and copying back the bits for the CDROM
    layer.

    Cc: stable@vger.kernel.org
    Reported-by: Piotr Gabriel Kosinski
    Reported-by: Daniel Shapira
    Tested-by: Kees Cook
    Fixes: 82ed4db499b8 ("block: split scsi_request out of struct request")
    Signed-off-by: Jens Axboe
    Signed-off-by: Greg Kroah-Hartman

    Jens Axboe
     
  • commit 8e907ed4882714fd13cfe670681fc6cb5284c780 upstream.

    User-space may invoke ibv_reg_mr and ibv_dereg_mr in different threads.

    If ibv_dereg_mr is called after the thread which invoked ibv_reg_mr has
    exited, get_pid_task will return NULL and ib_umem_release will not
    decrease mm->pinned_vm.

    Instead of using threads to locate the mm, use the overall tgid from the
    ib_ucontext struct instead. This matches the behavior of ODP and
    disassociate in handling the mm of the process that called ibv_reg_mr.

    Cc:
    Fixes: 87773dd56d54 ("IB: ib_umem_release() should decrement mm->pinned_vm from ib_umem_get")
    Signed-off-by: Lidong Chen
    Signed-off-by: Jason Gunthorpe
    Signed-off-by: Greg Kroah-Hartman

    Lidong Chen
     
  • commit f9e76ca3771bf23d2142a81a88ddd8f31f5c4c03 upstream.

    A pio send egress error can occur when the PSM library attempts to
    to send a bad packet. That issue is still being investigated.

    The pio error interrupt handler then attempts to progress the recovery
    of the errored pio send context.

    Code inspection reveals that the handling lacks the necessary locking
    if that recovery interleaves with a PSM close of the "context" object
    contains the pio send context.

    The lack of the locking can cause the recovery to access the already
    freed pio send context object and incorrectly deduce that the pio
    send context is actually a kernel pio send context as shown by the
    NULL deref stack below:

    [] _dev_info+0x6c/0x90
    [] sc_restart+0x70/0x1f0 [hfi1]
    [] ? __schedule+0x424/0x9b0
    [] sc_halted+0x15/0x20 [hfi1]
    [] process_one_work+0x17a/0x440
    [] worker_thread+0x126/0x3c0
    [] ? manage_workers.isra.24+0x2a0/0x2a0
    [] kthread+0xcf/0xe0
    [] ? insert_kthread_work+0x40/0x40
    [] ret_from_fork+0x58/0x90
    [] ? insert_kthread_work+0x40/0x40

    This is the best case scenario and other scenarios can corrupt the
    already freed memory.

    Fix by adding the necessary locking in the pio send context error
    handler.

    Cc: # 4.9.x
    Reviewed-by: Mike Marciniszyn
    Reviewed-by: Dennis Dalessandro
    Signed-off-by: Michael J. Ruhl
    Signed-off-by: Dennis Dalessandro
    Signed-off-by: Doug Ledford
    Signed-off-by: Greg Kroah-Hartman

    Michael J. Ruhl
     
  • commit 938ae7259c908ad031da35d551da297640bb640c upstream.

    Depending on whether the kernel is compiled with frame-pointer or not,
    the temporary memory location used for the bp parameter in these macros
    is referenced relative to the stack pointer or the frame pointer.
    Hence we can never reference that parameter when we've modified either
    the stack pointer or the frame pointer, because then the compiler would
    generate an incorrect stack reference.

    Fix this by pushing the temporary memory parameter on a known location on
    the stack before modifying the stack- and frame pointers.

    Cc:
    Signed-off-by: Thomas Hellstrom
    Reviewed-by: Brian Paul
    Reviewed-by: Sinclair Yeh
    Signed-off-by: Greg Kroah-Hartman

    Thomas Hellstrom
     
  • commit 4855c92dbb7b3b85c23e88ab7ca04f99b9677b41 upstream.

    When run raidconfig from Dom0 we found that the Xen DMA heap is reduced,
    but Dom Heap is increased by the same size. Tracing raidconfig we found
    that the related ioctl() in megaraid_sas will call dma_alloc_coherent()
    to apply memory. If the memory allocated by Dom0 is not in the DMA area,
    it will exchange memory with Xen to meet the requiment. Later drivers
    call dma_free_coherent() to free the memory, on xen_swiotlb_free_coherent()
    the check condition (dev_addr + size - 1
    Tested-by: John Sobecki
    Reviewed-by: Rzeszutek Wilk
    Cc: stable@vger.kernel.org
    Signed-off-by: Konrad Rzeszutek Wilk
    Signed-off-by: Greg Kroah-Hartman

    Joe Jin
     
  • commit 136d769e0b3475d71350aa3648a116a6ee7a8f6c upstream.

    While whitelisting Micron M500DC drives, the tweaked blacklist entry
    enabled queued TRIM from M500IT variants also. But these do not support
    queued TRIM. And while using those SSDs with the latest kernel we have
    seen errors and even the partition table getting corrupted.

    Some part from the dmesg:
    [ 6.727384] ata1.00: ATA-9: Micron_M500IT_MTFDDAK060MBD, MU01, max UDMA/133
    [ 6.727390] ata1.00: 117231408 sectors, multi 16: LBA48 NCQ (depth 31/32), AA
    [ 6.741026] ata1.00: supports DRM functions and may not be fully accessible
    [ 6.759887] ata1.00: configured for UDMA/133
    [ 6.762256] scsi 0:0:0:0: Direct-Access ATA Micron_M500IT_MT MU01 PQ: 0 ANSI: 5

    and then for the error:
    [ 120.860334] ata1.00: exception Emask 0x1 SAct 0x7ffc0007 SErr 0x0 action 0x6 frozen
    [ 120.860338] ata1.00: irq_stat 0x40000008
    [ 120.860342] ata1.00: failed command: SEND FPDMA QUEUED
    [ 120.860351] ata1.00: cmd 64/01:00:00:00:00/00:00:00:00:00/a0 tag 0 ncq dma 512 out
    res 40/00:00:00:00:00/00:00:00:00:00/00 Emask 0x5 (timeout)
    [ 120.860353] ata1.00: status: { DRDY }
    [ 120.860543] ata1: hard resetting link
    [ 121.166128] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
    [ 121.166376] ata1.00: supports DRM functions and may not be fully accessible
    [ 121.186238] ata1.00: supports DRM functions and may not be fully accessible
    [ 121.204445] ata1.00: configured for UDMA/133
    [ 121.204454] ata1.00: device reported invalid CHS sector 0
    [ 121.204541] sd 0:0:0:0: [sda] tag#18 UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
    [ 121.204546] sd 0:0:0:0: [sda] tag#18 Sense Key : 0x5 [current]
    [ 121.204550] sd 0:0:0:0: [sda] tag#18 ASC=0x21 ASCQ=0x4
    [ 121.204555] sd 0:0:0:0: [sda] tag#18 CDB: opcode=0x93 93 08 00 00 00 00 00 04 28 80 00 00 00 30 00 00
    [ 121.204559] print_req_error: I/O error, dev sda, sector 272512

    After few reboots with these errors, and the SSD is corrupted.
    After blacklisting it, the errors are not seen and the SSD does not get
    corrupted any more.

    Fixes: 243918be6393 ("libata: Do not blacklist Micron M500DC")
    Cc: Martin K. Petersen
    Cc: stable@vger.kernel.org
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Tejun Heo
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee