commit f63b2b3204ea962e9cc34a223771ec973694f8bf
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Fri Jun 1 00:30:27 2018 +0100

    Linux 3.2.102

commit 0b8479056e90225a9f913d7eee4876295989ca62
Author: Linus Walleij <linus.walleij@linaro.org>
Date:   Sat Mar 3 23:29:03 2018 +0100

    mtd: jedec_probe: Fix crash in jedec_read_mfr()
    
    commit 87a73eb5b56fd6e07c8e499fe8608ef2d8912b82 upstream.
    
    It turns out that the loop where we read manufacturer
    jedec_read_mfd() can under some circumstances get a
    CFI_MFR_CONTINUATION repeatedly, making the loop go
    over all banks and eventually hit the end of the
    map and crash because of an access violation:
    
    Unable to handle kernel paging request at virtual address c4980000
    pgd = (ptrval)
    [c4980000] *pgd=03808811, *pte=00000000, *ppte=00000000
    Internal error: Oops: 7 [#1] PREEMPT ARM
    CPU: 0 PID: 1 Comm: swapper Not tainted 4.16.0-rc1+ #150
    Hardware name: Gemini (Device Tree)
    PC is at jedec_probe_chip+0x6ec/0xcd0
    LR is at 0x4
    pc : [<c03a2bf4>]    lr : [<00000004>]    psr: 60000013
    sp : c382dd18  ip : 0000ffff  fp : 00000000
    r10: c0626388  r9 : 00020000  r8 : c0626340
    r7 : 00000000  r6 : 00000001  r5 : c3a71afc  r4 : c382dd70
    r3 : 00000001  r2 : c4900000  r1 : 00000002  r0 : 00080000
    Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
    Control: 0000397f  Table: 00004000  DAC: 00000053
    Process swapper (pid: 1, stack limit = 0x(ptrval))
    
    Fix this by breaking the loop with a return 0 if
    the offset exceeds the map size.
    
    Fixes: 5c9c11e1c47c ("[MTD] [NOR] Add support for flash chips with ID in bank other than 0")
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b9bae75805932048d0b5172cd63f83b28668eb02
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Sun Mar 25 11:39:05 2018 +0300

    RDMA/ucma: Check that device exists prior to accessing it
    
    commit c8d3bcbfc5eab3f01cf373d039af725f3b488813 upstream.
    
    Ensure that device exists prior to accessing its properties.
    
    Reported-by: <syzbot+71655d44855ac3e76366@syzkaller.appspotmail.com>
    Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bf66bb07cb394f68e75b547e558a945563a70d63
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Sun Mar 25 11:23:55 2018 +0300

    RDMA/ucma: Check that device is connected prior to access it
    
    commit 4b658d1bbc16605330694bb3ef2570c465ef383d upstream.
    
    Add missing check that device is connected prior to access it.
    
    [   55.358652] BUG: KASAN: null-ptr-deref in rdma_init_qp_attr+0x4a/0x2c0
    [   55.359389] Read of size 8 at addr 00000000000000b0 by task qp/618
    [   55.360255]
    [   55.360432] CPU: 1 PID: 618 Comm: qp Not tainted 4.16.0-rc1-00071-gcaf61b1b8b88 #91
    [   55.361693] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014
    [   55.363264] Call Trace:
    [   55.363833]  dump_stack+0x5c/0x77
    [   55.364215]  kasan_report+0x163/0x380
    [   55.364610]  ? rdma_init_qp_attr+0x4a/0x2c0
    [   55.365238]  rdma_init_qp_attr+0x4a/0x2c0
    [   55.366410]  ucma_init_qp_attr+0x111/0x200
    [   55.366846]  ? ucma_notify+0xf0/0xf0
    [   55.367405]  ? _get_random_bytes+0xea/0x1b0
    [   55.367846]  ? urandom_read+0x2f0/0x2f0
    [   55.368436]  ? kmem_cache_alloc_trace+0xd2/0x1e0
    [   55.369104]  ? refcount_inc_not_zero+0x9/0x60
    [   55.369583]  ? refcount_inc+0x5/0x30
    [   55.370155]  ? rdma_create_id+0x215/0x240
    [   55.370937]  ? _copy_to_user+0x4f/0x60
    [   55.371620]  ? mem_cgroup_commit_charge+0x1f5/0x290
    [   55.372127]  ? _copy_from_user+0x5e/0x90
    [   55.372720]  ucma_write+0x174/0x1f0
    [   55.373090]  ? ucma_close_id+0x40/0x40
    [   55.373805]  ? __lru_cache_add+0xa8/0xd0
    [   55.374403]  __vfs_write+0xc4/0x350
    [   55.374774]  ? kernel_read+0xa0/0xa0
    [   55.375173]  ? fsnotify+0x899/0x8f0
    [   55.375544]  ? fsnotify_unmount_inodes+0x170/0x170
    [   55.376689]  ? __fsnotify_update_child_dentry_flags+0x30/0x30
    [   55.377522]  ? handle_mm_fault+0x174/0x320
    [   55.378169]  vfs_write+0xf7/0x280
    [   55.378864]  SyS_write+0xa1/0x120
    [   55.379270]  ? SyS_read+0x120/0x120
    [   55.379643]  ? mm_fault_error+0x180/0x180
    [   55.380071]  ? task_work_run+0x7d/0xd0
    [   55.380910]  ? __task_pid_nr_ns+0x120/0x140
    [   55.381366]  ? SyS_read+0x120/0x120
    [   55.381739]  do_syscall_64+0xeb/0x250
    [   55.382143]  entry_SYSCALL_64_after_hwframe+0x21/0x86
    [   55.382841] RIP: 0033:0x7fc2ef803e99
    [   55.383227] RSP: 002b:00007fffcc5f3be8 EFLAGS: 00000217 ORIG_RAX: 0000000000000001
    [   55.384173] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc2ef803e99
    [   55.386145] RDX: 0000000000000057 RSI: 0000000020000080 RDI: 0000000000000003
    [   55.388418] RBP: 00007fffcc5f3c00 R08: 0000000000000000 R09: 0000000000000000
    [   55.390542] R10: 0000000000000000 R11: 0000000000000217 R12: 0000000000400480
    [   55.392916] R13: 00007fffcc5f3cf0 R14: 0000000000000000 R15: 0000000000000000
    [   55.521088] Code: e5 4d 1e ff 48 89 df 44 0f b6 b3 b8 01 00 00 e8 65 50 1e ff 4c 8b 2b 49
    8d bd b0 00 00 00 e8 56 50 1e ff 41 0f b6 c6 48 c1 e0 04 <49> 03 85 b0 00 00 00 48 8d 78 08
    48 89 04 24 e8 3a 4f 1e ff 48
    [   55.525980] RIP: rdma_init_qp_attr+0x52/0x2c0 RSP: ffff8801e2c2f9d8
    [   55.532648] CR2: 00000000000000b0
    [   55.534396] ---[ end trace 70cee64090251c0b ]---
    
    Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
    Fixes: d541e45500bd ("IB/core: Convert ah_attr from OPA to IB when copying to user")
    Reported-by: <syzbot+7b62c837c2516f8f38c8@syzkaller.appspotmail.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3cc0730eef779b6d7e27d6dfa5bd81f76a2baa0c
Author: Eran Ben Elisha <eranbe@mellanox.com>
Date:   Tue Mar 27 14:41:18 2018 +0300

    net/mlx4_en: Fix mixed PFC and Global pause user control requests
    
    commit 6e8814ceb7e8f468659ef9253bd212c07ae19584 upstream.
    
    Global pause and PFC configuration should be mutually exclusive (i.e. only
    one of them at most can be set). However, once PFC was turned off,
    driver automatically turned Global pause on. This is a bug.
    
    Fix the driver behaviour to turn off PFC/Global once the user turned the
    other on.
    
    This also fixed a weird behaviour that at a current time, the profile
    had both PFC and global pause configuration turned on, which is
    Hardware-wise impossible and caused returning false positive indication
    to query tools.
    
    In addition, fix error code when setting global pause or PFC to change
    metadata only upon successful change.
    
    Also, removed useless debug print.
    
    Fixes: af7d51852631 ("net/mlx4_en: Add DCB PFC support through CEE netlink commands")
    Fixes: c27a02cd94d6 ("mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC")
    Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
    Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2:
     - Drop changes in en_dcb_nl.c
     - Don't call mlx4_en_update_pfc_stats_bitmap()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f43a81763f525db5509177e36e04a6927a80c14e
Author: Ivan Vecera <ivecera@redhat.com>
Date:   Mon Sep 8 18:46:53 2014 +0200

    net/mlx4_en: do not ignore autoneg in mlx4_en_set_pauseparam()
    
    commit 278d436a476f69fc95d5c82bf61b6c2d02f4d44e upstream.
    
    The driver does not support pause autonegotiation so it should return
    -EINVAL when the function is called with non-zero autoneg.
    
    Cc: Amir Vadai <amirv@mellanox.com>
    Signed-off-by: Ivan Vecera <ivecera@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9f249188a2927b7809ed790e4b568ea82039d919
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Mar 27 16:07:52 2018 +0300

    ALSA: pcm: potential uninitialized return values
    
    commit 5607dddbfca774fb38bffadcb077fe03aa4ac5c6 upstream.
    
    Smatch complains that "tmp" can be uninitialized if we do a zero size
    write.
    
    Fixes: 02a5d6925cd3 ("ALSA: pcm: Avoid potential races between OSS ioctls and read/write")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 19277917a0db893344f247d2ed4ac920c874f0d6
Author: Xin Long <lucien.xin@gmail.com>
Date:   Mon Mar 26 01:16:47 2018 +0800

    bonding: process the err returned by dev_set_allmulti properly in bond_enslave
    
    commit 9f5a90c107741b864398f4ac0014711a8c1d8474 upstream.
    
    When dev_set_promiscuity(1) succeeds but dev_set_allmulti(1) fails,
    dev_set_promiscuity(-1) should be done before going to the err path.
    Otherwise, dev->promiscuity will leak.
    
    Fixes: 7e1a1ac1fbaa ("bonding: Check return of dev_set_promiscuity/allmulti")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Andy Gospodarek <andy@greyhouse.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1731866a8cdbf8b8c49348083c565ba0f2b6abff
Author: Stefan Roese <sr@denx.de>
Date:   Mon Mar 26 16:10:21 2018 +0200

    ALSA: pcm: Use dma_bytes as size parameter in dma_mmap_coherent()
    
    commit 9066ae7ff5d89c0b5daa271e2d573540097a94fa upstream.
    
    When trying to use the driver (e.g. aplay *.wav), the 4MiB DMA buffer
    will get mmapp'ed in 16KiB chunks. But this fails with the 2nd 16KiB
    area, as the page offset is outside of the VMA range (size), which is
    currently used as size parameter in snd_pcm_lib_default_mmap(). By
    using the DMA buffer size (dma_bytes) instead, the complete DMA buffer
    can be mmapp'ed and the issue is fixed.
    
    This issue was detected on an ARM platform (TI AM57xx) using the RME
    HDSP MADI PCIe soundcard.
    
    Fixes: 657b1989dacf ("ALSA: pcm - Use dma_mmap_coherent() if available")
    Signed-off-by: Stefan Roese <sr@denx.de>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 85612401b97f42ca3addf3d5786cc6de4fcb8fda
Author: Alexander Potapenko <glider@google.com>
Date:   Fri Mar 23 13:49:02 2018 +0100

    netlink: make sure nladdr has correct size in netlink_connect()
    
    commit 7880287981b60a6808f39f297bb66936e8bdf57a upstream.
    
    KMSAN reports use of uninitialized memory in the case when |alen| is
    smaller than sizeof(struct sockaddr_nl), and therefore |nladdr| isn't
    fully copied from the userspace.
    
    Signed-off-by: Alexander Potapenko <glider@google.com>
    Fixes: 1da177e4c3f41524 ("Linux-2.6.12-rc2")
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 303f7c4c27da1ba0d54c62eb1ae66330bc1c835e
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sat Mar 24 10:43:26 2018 +0100

    tty: vt: fix up tabstops properly
    
    commit f1869a890cdedb92a3fab969db5d0fd982850273 upstream.
    
    Tabs on a console with long lines do not wrap properly, so correctly
    account for the line length when computing the tab placement location.
    
    Reported-by: James Holderness <j4_james@hotmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bd7c606e6724adc01009d8551b7666a8bcb64a5c
Author: Masami Hiramatsu <mhiramat@kernel.org>
Date:   Sat Mar 17 21:38:10 2018 +0900

    tracing: probeevent: Fix to support minus offset from symbol
    
    commit c5d343b6b7badd1f5fe0873eff2e8d63a193e732 upstream.
    
    In Documentation/trace/kprobetrace.txt, it says
    
     @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
    
    However, the parser doesn't parse minus offset correctly, since
    commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be
    unsigned") drops minus ("-") offset support for kprobe probe
    address usage.
    
    This fixes the traceprobe_split_symbol_offset() to parse minus
    offset again with checking the offset range, and add a minus
    offset check in kprobe probe address usage.
    
    Link: http://lkml.kernel.org/r/152129028983.31874.13419301530285775521.stgit@devbox
    
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
    Fixes: 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned")
    Acked-by: Namhyung Kim <namhyung@kernel.org>
    Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    [bwh: Backported to 3.2: adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c218eb3152efa5b424e3c6951d6796a357a45f05
Author: Yisheng Xie <xieyisheng1@huawei.com>
Date:   Thu Mar 22 16:17:02 2018 -0700

    mm/mempolicy.c: avoid use uninitialized preferred_node
    
    commit 8970a63e965b43288c4f5f40efbc2bbf80de7f16 upstream.
    
    Alexander reported a use of uninitialized memory in __mpol_equal(),
    which is caused by incorrect use of preferred_node.
    
    When mempolicy in mode MPOL_PREFERRED with flags MPOL_F_LOCAL, it uses
    numa_node_id() instead of preferred_node, however, __mpol_equal() uses
    preferred_node without checking whether it is MPOL_F_LOCAL or not.
    
    [akpm@linux-foundation.org: slight comment tweak]
    Link: http://lkml.kernel.org/r/4ebee1c2-57f6-bcb8-0e2d-1833d1ee0bb7@huawei.com
    Fixes: fc36b8d3d819 ("mempolicy: use MPOL_F_LOCAL to Indicate Preferred Local Policy")
    Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
    Reported-by: Alexander Potapenko <glider@google.com>
    Tested-by: Alexander Potapenko <glider@google.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Dmitriy Vyukov <dvyukov@google.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Michal Hocko <mhocko@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b4eeaa94d0eb1a4b84361c941056f28c8ca314a6
Author: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Date:   Tue Mar 20 07:59:12 2018 +0100

    s390/qeth: free netdevice when removing a card
    
    commit 6be687395b3124f002a653c1a50b3260222b3cd7 upstream.
    
    On removal, a qeth card's netdevice is currently not properly freed
    because the call chain looks as follows:
    
    qeth_core_remove_device(card)
            lx_remove_device(card)
                    unregister_netdev(card->dev)
                    card->dev = NULL                        !!!
            qeth_core_free_card(card)
                    if (card->dev)                          !!!
                            free_netdev(card->dev)
    
    Fix it by free'ing the netdev straight after unregistering. This also
    fixes the sysfs-driven layer switch case (qeth_dev_layer2_store()),
    where the need to free the current netdevice was not considered at all.
    
    Note that free_netdev() takes care of the netif_napi_del() for us too.
    
    Fixes: 4a71df50047f ("qeth: new qeth device driver")
    Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
    Reviewed-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6812610424262b90d3e5635291b1e4933cf8bd89
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Thu Feb 15 17:21:55 2018 +0100

    posix-timers: Protect posix clock array access against speculation
    
    commit 19b558db12f9f4e45a22012bae7b4783e62224da upstream.
    
    The clockid argument of clockid_to_kclock() comes straight from user space
    via various syscalls and is used as index into the posix_clocks array.
    
    Protect it against spectre v1 array out of bounds speculation. Remove the
    redundant check for !posix_clock[id] as this is another source for
    speculation and does not provide any advantage over the return
    posix_clock[id] path which returns NULL in that case anyway.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Acked-by: Dan Williams <dan.j.williams@intel.com>
    Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
    Cc: Greg KH <gregkh@linuxfoundation.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1802151718320.1296@nanos.tec.linutronix.de
    [bwh: Backported to 3.2:
     - Move the test of the clock_getres field below the lookup using
       array_index_nospec()
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6acf1f11d393616cfd6cd8417e2dfe7da89bf9eb
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Mar 22 10:40:27 2018 +0100

    ALSA: aloop: Fix access to not-yet-ready substream via cable
    
    commit 8e6b1a72a75bb5067ccb6b56d8ca4aa3a300a64e upstream.
    
    In loopback_open() and loopback_close(), we assign and release the
    substream object to the corresponding cable in a racy way.  It's
    neither locked nor done in the right position.  The open callback
    assigns the substream before its preparation finishes, hence the other
    side of the cable may pick it up, which may lead to the invalid memory
    access.
    
    This patch addresses these: move the assignment to the end of the open
    callback, and wrap with cable->lock for avoiding concurrent accesses.
    
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dc602c18947a838a422071849965ce611f9a18e1
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Mar 22 08:56:06 2018 +0100

    ALSA: aloop: Sync stale timer before release
    
    commit 67a01afaf3d34893cf7d2ea19b34555d6abb7cb0 upstream.
    
    The aloop driver tries to stop the pending timer via timer_del() in
    the trigger callback and in the close callback.  The former is
    correct, as it's an atomic operation, while the latter expects that
    the timer gets really removed and proceeds the resource releases after
    that.  But timer_del() doesn't synchronize, hence the running timer
    may still access the released resources.
    
    A similar situation can be also seen in the prepare callback after
    trigger(STOP) where the prepare tries to re-initialize the things
    while a timer is still running.
    
    The problems like the above are seen indirectly in some syzkaller
    reports (although it's not 100% clear whether this is the only cause,
    as the race condition is quite narrow and not always easy to
    trigger).
    
    For addressing these issues, this patch adds the explicit alls of
    timer_del_sync() in some places, so that the pending timer is properly
    killed / synced.
    
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b5f21d80f536b5987ff6e209e6d57d4e39c2caab
Author: Chien Tin Tung <chien.tin.tung@intel.com>
Date:   Wed Mar 21 13:09:25 2018 -0500

    RDMA/ucma: Correct option size check using optlen
    
    commit 5f3e3b85cc0a5eae1c46d72e47d3de7bf208d9e2 upstream.
    
    The option size check is using optval instead of optlen
    causing the set option call to fail. Use the correct
    field, optlen, for size check.
    
    Fixes: 6a21dfc0d0db ("RDMA/ucma: Limit possible option size")
    Signed-off-by: Chien Tin Tung <chien.tin.tung@intel.com>
    Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
    Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b37e09dd6279b2d04ab8ca7a0d7058d48e494c18
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Tue Mar 20 17:05:13 2018 +0200

    RDMA/ucma: Ensure that CM_ID exists prior to access it
    
    commit e8980d67d6017c8eee8f9c35f782c4bd68e004c9 upstream.
    
    Prior to access UCMA commands, the context should be initialized
    and connected to CM_ID with ucma_create_id(). In case user skips
    this step, he can provide non-valid ctx without CM_ID and cause
    to multiple NULL dereferences.
    
    Also there are situations where the create_id can be raced with
    other user access, ensure that the context is only shared to
    other threads once it is fully initialized to avoid the races.
    
    [  109.088108] BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
    [  109.090315] IP: ucma_connect+0x138/0x1d0
    [  109.092595] PGD 80000001dc02d067 P4D 80000001dc02d067 PUD 1da9ef067 PMD 0
    [  109.095384] Oops: 0000 [#1] SMP KASAN PTI
    [  109.097834] CPU: 0 PID: 663 Comm: uclose Tainted: G    B 4.16.0-rc1-00062-g2975d5de6428 #45
    [  109.100816] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014
    [  109.105943] RIP: 0010:ucma_connect+0x138/0x1d0
    [  109.108850] RSP: 0018:ffff8801c8567a80 EFLAGS: 00010246
    [  109.111484] RAX: 0000000000000000 RBX: 1ffff100390acf50 RCX: ffffffff9d7812e2
    [  109.114496] RDX: 1ffffffff3f507a5 RSI: 0000000000000297 RDI: 0000000000000297
    [  109.117490] RBP: ffff8801daa15600 R08: 0000000000000000 R09: ffffed00390aceeb
    [  109.120429] R10: 0000000000000001 R11: ffffed00390aceea R12: 0000000000000000
    [  109.123318] R13: 0000000000000120 R14: ffff8801de6459c0 R15: 0000000000000118
    [  109.126221] FS:  00007fabb68d6700(0000) GS:ffff8801e5c00000(0000) knlGS:0000000000000000
    [  109.129468] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [  109.132523] CR2: 0000000000000020 CR3: 00000001d45d8003 CR4: 00000000003606b0
    [  109.135573] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [  109.138716] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [  109.142057] Call Trace:
    [  109.144160]  ? ucma_listen+0x110/0x110
    [  109.146386]  ? wake_up_q+0x59/0x90
    [  109.148853]  ? futex_wake+0x10b/0x2a0
    [  109.151297]  ? save_stack+0x89/0xb0
    [  109.153489]  ? _copy_from_user+0x5e/0x90
    [  109.155500]  ucma_write+0x174/0x1f0
    [  109.157933]  ? ucma_resolve_route+0xf0/0xf0
    [  109.160389]  ? __mod_node_page_state+0x1d/0x80
    [  109.162706]  __vfs_write+0xc4/0x350
    [  109.164911]  ? kernel_read+0xa0/0xa0
    [  109.167121]  ? path_openat+0x1b10/0x1b10
    [  109.169355]  ? fsnotify+0x899/0x8f0
    [  109.171567]  ? fsnotify_unmount_inodes+0x170/0x170
    [  109.174145]  ? __fget+0xa8/0xf0
    [  109.177110]  vfs_write+0xf7/0x280
    [  109.179532]  SyS_write+0xa1/0x120
    [  109.181885]  ? SyS_read+0x120/0x120
    [  109.184482]  ? compat_start_thread+0x60/0x60
    [  109.187124]  ? SyS_read+0x120/0x120
    [  109.189548]  do_syscall_64+0xeb/0x250
    [  109.192178]  entry_SYSCALL_64_after_hwframe+0x21/0x86
    [  109.194725] RIP: 0033:0x7fabb61ebe99
    [  109.197040] RSP: 002b:00007fabb68d5e98 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
    [  109.200294] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fabb61ebe99
    [  109.203399] RDX: 0000000000000120 RSI: 00000000200001c0 RDI: 0000000000000004
    [  109.206548] RBP: 00007fabb68d5ec0 R08: 0000000000000000 R09: 0000000000000000
    [  109.209902] R10: 0000000000000000 R11: 0000000000000202 R12: 00007fabb68d5fc0
    [  109.213327] R13: 0000000000000000 R14: 00007fff40ab2430 R15: 00007fabb68d69c0
    [  109.216613] Code: 88 44 24 2c 0f b6 84 24 6e 01 00 00 88 44 24 2d 0f
    b6 84 24 69 01 00 00 88 44 24 2e 8b 44 24 60 89 44 24 30 e8 da f6 06 ff
    31 c0 <66> 41 83 7c 24 20 1b 75 04 8b 44 24 64 48 8d 74 24 20 4c 89 e7
    [  109.223602] RIP: ucma_connect+0x138/0x1d0 RSP: ffff8801c8567a80
    [  109.226256] CR2: 0000000000000020
    
    Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
    Reported-by: <syzbot+36712f50b0552615bf59@syzkaller.appspotmail.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    [bwh: Backported to 3.2: adjust contex]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e78759ba4d27ab2f19b285f666887bf4d00b7514
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Mon Mar 19 14:20:15 2018 +0200

    RDMA/ucma: Fix use-after-free access in ucma_close
    
    commit ed65a4dc22083e73bac599ded6a262318cad7baf upstream.
    
    The error in ucma_create_id() left ctx in the list of contexts belong
    to ucma file descriptor. The attempt to close this file descriptor causes
    to use-after-free accesses while iterating over such list.
    
    Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
    Reported-by: <syzbot+dcfd344365a56fbebd0f@syzkaller.appspotmail.com>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Reviewed-by: Sean Hefty <sean.hefty@intel.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 25272b0d0d1e37d75b7481951c6a28c8c4d515c7
Author: Kirill Marinushkin <k.marinushkin@gmail.com>
Date:   Mon Mar 19 07:11:08 2018 +0100

    ALSA: usb-audio: Fix parsing descriptor of UAC2 processing unit
    
    commit a6618f4aedb2b60932d766bd82ae7ce866e842aa upstream.
    
    Currently, the offsets in the UAC2 processing unit descriptor are
    calculated incorrectly. It causes an issue when connecting the device which
    provides such a feature:
    
    ~~~~
    [84126.724420] usb 1-1.3.1: invalid Processing Unit descriptor (id 18)
    ~~~~
    
    After this patch is applied, the UAC2 processing unit inits w/o this error.
    
    Fixes: 23caaf19b11e ("ALSA: usb-mixer: Add support for Audio Class v2.0")
    Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2926594b07be714d5b9b1f307f09e7286d1203ff
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Mon Mar 19 16:33:59 2018 +0100

    libata: Make Crucial BX100 500GB LPM quirk apply to all firmware versions
    
    commit 3bf7b5d6d017c27e0d3b160aafb35a8e7cfeda1f upstream.
    
    Commit b17e5729a630 ("libata: disable LPM for Crucial BX100 SSD 500GB
    drive"), introduced a ATA_HORKAGE_NOLPM quirk for Crucial BX100 500GB SSDs
    but limited this to the MU02 firmware version, according to:
    http://www.crucial.com/usa/en/support-ssd-firmware
    
    MU02 is the last version, so there are no newer possibly fixed versions
    and if the MU02 version has broken LPM then the MU01 almost certainly
    also has broken LPM, so this commit changes the quirk to apply to all
    firmware versions.
    
    Fixes: b17e5729a630 ("libata: disable LPM for Crucial BX100 SSD 500GB...")
    Cc: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 968482dc6ea96a542661b92dc8b44074914e605e
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Mon Mar 19 16:33:58 2018 +0100

    libata: Apply NOLPM quirk to Crucial M500 480 and 960GB SSDs
    
    commit 62ac3f7305470e3f52f159de448bc1a771717e88 upstream.
    
    There have been reports of the Crucial M500 480GB model not working
    with LPM set to min_power / med_power_with_dipm level.
    
    It has not been tested with medium_power, but that typically has no
    measurable power-savings.
    
    Note the reporters Crucial_CT480M500SSD3 has a firmware version of MU03
    and there is a MU05 update available, but that update does not mention any
    LPM fixes in its changelog, so the quirk matches all firmware versions.
    
    In my experience the LPM problems with (older) Crucial SSDs seem to be
    limited to higher capacity versions of the SSDs (different firmware?),
    so this commit adds a NOLPM quirk for the 480 and 960GB versions of the
    M500, to avoid LPM causing issues with these SSDs.
    
    Reported-and-tested-by: Martin Steigerwald <martin@lichtvoll.de>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    [bwh: Backported to 3.2: Drop the TRIM quirk flags, which aren't supported]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 916446829c46be4a17a578941551428f841d2a05
Author: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Date:   Wed Mar 14 13:32:09 2018 -0700

    skbuff: Fix not waking applications when errors are enqueued
    
    commit 6e5d58fdc9bedd0255a8781b258f10bbdc63e975 upstream.
    
    When errors are enqueued to the error queue via sock_queue_err_skb()
    function, it is possible that the waiting application is not notified.
    
    Calling 'sk->sk_data_ready()' would not notify applications that
    selected only POLLERR events in poll() (for example).
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: Randy E. Witt <randy.e.witt@intel.com>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: sk_data_ready() operation takes a length parameter.
     Delete the local variable we used for that.]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0b13359cb718925be0e13eb4713d14434a681fbf
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Wed Mar 14 18:20:29 2018 -0500

    fs: Teach path_connected to handle nfs filesystems with multiple roots.
    
    commit 95dd77580ccd66a0da96e6d4696945b8cea39431 upstream.
    
    On nfsv2 and nfsv3 the nfs server can export subsets of the same
    filesystem and report the same filesystem identifier, so that the nfs
    client can know they are the same filesystem.  The subsets can be from
    disjoint directory trees.  The nfsv2 and nfsv3 filesystems provides no
    way to find the common root of all directory trees exported form the
    server with the same filesystem identifier.
    
    The practical result is that in struct super s_root for nfs s_root is
    not necessarily the root of the filesystem.  The nfs mount code sets
    s_root to the root of the first subset of the nfs filesystem that the
    kernel mounts.
    
    This effects the dcache invalidation code in generic_shutdown_super
    currently called shrunk_dcache_for_umount and that code for years
    has gone through an additional list of dentries that might be dentry
    trees that need to be freed to accomodate nfs.
    
    When I wrote path_connected I did not realize nfs was so special, and
    it's hueristic for avoiding calling is_subdir can fail.
    
    The practical case where this fails is when there is a move of a
    directory from the subtree exposed by one nfs mount to the subtree
    exposed by another nfs mount.  This move can happen either locally or
    remotely.  With the remote case requiring that the move directory be cached
    before the move and that after the move someone walks the path
    to where the move directory now exists and in so doing causes the
    already cached directory to be moved in the dcache through the magic
    of d_splice_alias.
    
    If someone whose working directory is in the move directory or a
    subdirectory and now starts calling .. from the initial mount of nfs
    (where s_root == mnt_root), then path_connected as a heuristic will
    not bother with the is_subdir check.  As s_root really is not the root
    of the nfs filesystem this heuristic is wrong, and the path may
    actually not be connected and path_connected can fail.
    
    The is_subdir function might be cheap enough that we can call it
    unconditionally.  Verifying that will take some benchmarking and
    the result may not be the same on all kernels this fix needs
    to be backported to.  So I am avoiding that for now.
    
    Filesystems with snapshots such as nilfs and btrfs do something
    similar.  But as the directory tree of the snapshots are disjoint
    from one another and from the main directory tree rename won't move
    things between them and this problem will not occur.
    
    Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
    Fixes: 397d425dc26d ("vfs: Test for and handle paths that are unreachable from their mnt_root")
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    [bwh: Backported to 3.2:
     - Add the super_block::s_iflags field
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 080c12d8adf93365bd13606074b3394042820c67
Author: Michel Dänzer <michel.daenzer@amd.com>
Date:   Wed Mar 14 18:14:04 2018 +0100

    drm/radeon: Don't turn off DP sink when disconnected
    
    commit 2681bc79eeb640562c932007bfebbbdc55bf6a7d upstream.
    
    Turning off the sink in this case causes various issues, because
    userspace expects it to stay on until it turns it off explicitly.
    
    Instead, turn the sink off and back on when a display is connected
    again. This dance seems necessary for link training to work correctly.
    
    Bugzilla: https://bugs.freedesktop.org/105308
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2201f59fee9b0f5bc6cf1dc729ab9900de423ced
Author: Bastian Stender <bst@pengutronix.de>
Date:   Thu Mar 8 15:08:11 2018 +0100

    mmc: block: fix updating ext_csd caches on ioctl call
    
    commit e74ef2194b41ba5e511fab29fe5ff00e72d2f42a upstream.
    
    PARTITION_CONFIG is cached in mmc_card->ext_csd.part_config and the
    currently active partition in mmc_blk_data->part_curr. These caches do
    not always reflect changes if the ioctl call modifies the
    PARTITION_CONFIG registers, e.g. by changing BOOT_PARTITION_ENABLE.
    
    Write the PARTITION_CONFIG value extracted from the ioctl call to the
    cache and update the currently active partition accordingly. This
    ensures that the user space cannot change the values behind the
    kernel's back. The next call to mmc_blk_part_switch() will operate on
    the data set by the ioctl and reflect the changes appropriately.
    
    Signed-off-by: Bastian Stender <bst@pengutronix.de>
    Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    [bwh: Backported to 3.2:
     - Also add the definition of MMC_EXTRACT_INDEX_FROM_ARG()
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 05a45868db488c27ff9f81e0302a35303f574032
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Tue Mar 13 11:43:23 2018 +0200

    RDMA/ucma: Fix access to non-initialized CM_ID object
    
    commit 7688f2c3bbf55e52388e37ac5d63ca471a7712e1 upstream.
    
    The attempt to join multicast group without ensuring that CMA device
    exists will lead to the following crash reported by syzkaller.
    
    [   64.076794] BUG: KASAN: null-ptr-deref in rdma_join_multicast+0x26e/0x12c0
    [   64.076797] Read of size 8 at addr 00000000000000b0 by task join/691
    [   64.076797]
    [   64.076800] CPU: 1 PID: 691 Comm: join Not tainted 4.16.0-rc1-00219-gb97853b65b93 #23
    [   64.076802] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4
    [   64.076803] Call Trace:
    [   64.076809]  dump_stack+0x5c/0x77
    [   64.076817]  kasan_report+0x163/0x380
    [   64.085859]  ? rdma_join_multicast+0x26e/0x12c0
    [   64.086634]  rdma_join_multicast+0x26e/0x12c0
    [   64.087370]  ? rdma_disconnect+0xf0/0xf0
    [   64.088579]  ? __radix_tree_replace+0xc3/0x110
    [   64.089132]  ? node_tag_clear+0x81/0xb0
    [   64.089606]  ? idr_alloc_u32+0x12e/0x1a0
    [   64.090517]  ? __fprop_inc_percpu_max+0x150/0x150
    [   64.091768]  ? tracing_record_taskinfo+0x10/0xc0
    [   64.092340]  ? idr_alloc+0x76/0xc0
    [   64.092951]  ? idr_alloc_u32+0x1a0/0x1a0
    [   64.093632]  ? ucma_process_join+0x23d/0x460
    [   64.094510]  ucma_process_join+0x23d/0x460
    [   64.095199]  ? ucma_migrate_id+0x440/0x440
    [   64.095696]  ? futex_wake+0x10b/0x2a0
    [   64.096159]  ucma_join_multicast+0x88/0xe0
    [   64.096660]  ? ucma_process_join+0x460/0x460
    [   64.097540]  ? _copy_from_user+0x5e/0x90
    [   64.098017]  ucma_write+0x174/0x1f0
    [   64.098640]  ? ucma_resolve_route+0xf0/0xf0
    [   64.099343]  ? rb_erase_cached+0x6c7/0x7f0
    [   64.099839]  __vfs_write+0xc4/0x350
    [   64.100622]  ? perf_syscall_enter+0xe4/0x5f0
    [   64.101335]  ? kernel_read+0xa0/0xa0
    [   64.103525]  ? perf_sched_cb_inc+0xc0/0xc0
    [   64.105510]  ? syscall_exit_register+0x2a0/0x2a0
    [   64.107359]  ? __switch_to+0x351/0x640
    [   64.109285]  ? fsnotify+0x899/0x8f0
    [   64.111610]  ? fsnotify_unmount_inodes+0x170/0x170
    [   64.113876]  ? __fsnotify_update_child_dentry_flags+0x30/0x30
    [   64.115813]  ? ring_buffer_record_is_on+0xd/0x20
    [   64.117824]  ? __fget+0xa8/0xf0
    [   64.119869]  vfs_write+0xf7/0x280
    [   64.122001]  SyS_write+0xa1/0x120
    [   64.124213]  ? SyS_read+0x120/0x120
    [   64.126644]  ? SyS_read+0x120/0x120
    [   64.128563]  do_syscall_64+0xeb/0x250
    [   64.130732]  entry_SYSCALL_64_after_hwframe+0x21/0x86
    [   64.132984] RIP: 0033:0x7f5c994ade99
    [   64.135699] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    [   64.138740] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99
    [   64.141056] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015
    [   64.143536] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000
    [   64.146017] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0
    [   64.148608] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0
    [   64.151060]
    [   64.153703] Disabling lock debugging due to kernel taint
    [   64.156032] BUG: unable to handle kernel NULL pointer dereference at 00000000000000b0
    [   64.159066] IP: rdma_join_multicast+0x26e/0x12c0
    [   64.161451] PGD 80000001d0298067 P4D 80000001d0298067 PUD 1dea39067 PMD 0
    [   64.164442] Oops: 0000 [#1] SMP KASAN PTI
    [   64.166817] CPU: 1 PID: 691 Comm: join Tainted: G    B 4.16.0-rc1-00219-gb97853b65b93 #23
    [   64.170004] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4
    [   64.174985] RIP: 0010:rdma_join_multicast+0x26e/0x12c0
    [   64.177246] RSP: 0018:ffff8801c8207860 EFLAGS: 00010282
    [   64.179901] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff94789522
    [   64.183344] RDX: 1ffffffff2d50fa5 RSI: 0000000000000297 RDI: 0000000000000297
    [   64.186237] RBP: ffff8801c8207a50 R08: 0000000000000000 R09: ffffed0039040ea7
    [   64.189328] R10: 0000000000000001 R11: ffffed0039040ea6 R12: 0000000000000000
    [   64.192634] R13: 0000000000000000 R14: ffff8801e2022800 R15: ffff8801d4ac2400
    [   64.196105] FS:  00007f5c99b98700(0000) GS:ffff8801e5d00000(0000) knlGS:0000000000000000
    [   64.199211] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [   64.202046] CR2: 00000000000000b0 CR3: 00000001d1c48004 CR4: 00000000003606a0
    [   64.205032] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [   64.208221] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [   64.211554] Call Trace:
    [   64.213464]  ? rdma_disconnect+0xf0/0xf0
    [   64.216124]  ? __radix_tree_replace+0xc3/0x110
    [   64.219337]  ? node_tag_clear+0x81/0xb0
    [   64.222140]  ? idr_alloc_u32+0x12e/0x1a0
    [   64.224422]  ? __fprop_inc_percpu_max+0x150/0x150
    [   64.226588]  ? tracing_record_taskinfo+0x10/0xc0
    [   64.229763]  ? idr_alloc+0x76/0xc0
    [   64.232186]  ? idr_alloc_u32+0x1a0/0x1a0
    [   64.234505]  ? ucma_process_join+0x23d/0x460
    [   64.237024]  ucma_process_join+0x23d/0x460
    [   64.240076]  ? ucma_migrate_id+0x440/0x440
    [   64.243284]  ? futex_wake+0x10b/0x2a0
    [   64.245302]  ucma_join_multicast+0x88/0xe0
    [   64.247783]  ? ucma_process_join+0x460/0x460
    [   64.250841]  ? _copy_from_user+0x5e/0x90
    [   64.253878]  ucma_write+0x174/0x1f0
    [   64.257008]  ? ucma_resolve_route+0xf0/0xf0
    [   64.259877]  ? rb_erase_cached+0x6c7/0x7f0
    [   64.262746]  __vfs_write+0xc4/0x350
    [   64.265537]  ? perf_syscall_enter+0xe4/0x5f0
    [   64.267792]  ? kernel_read+0xa0/0xa0
    [   64.270358]  ? perf_sched_cb_inc+0xc0/0xc0
    [   64.272575]  ? syscall_exit_register+0x2a0/0x2a0
    [   64.275367]  ? __switch_to+0x351/0x640
    [   64.277700]  ? fsnotify+0x899/0x8f0
    [   64.280530]  ? fsnotify_unmount_inodes+0x170/0x170
    [   64.283156]  ? __fsnotify_update_child_dentry_flags+0x30/0x30
    [   64.286182]  ? ring_buffer_record_is_on+0xd/0x20
    [   64.288749]  ? __fget+0xa8/0xf0
    [   64.291136]  vfs_write+0xf7/0x280
    [   64.292972]  SyS_write+0xa1/0x120
    [   64.294965]  ? SyS_read+0x120/0x120
    [   64.297474]  ? SyS_read+0x120/0x120
    [   64.299751]  do_syscall_64+0xeb/0x250
    [   64.301826]  entry_SYSCALL_64_after_hwframe+0x21/0x86
    [   64.304352] RIP: 0033:0x7f5c994ade99
    [   64.306711] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    [   64.309577] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99
    [   64.312334] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015
    [   64.315783] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000
    [   64.318365] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0
    [   64.320980] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0
    [   64.323515] Code: e8 e8 79 08 ff 4c 89 ff 45 0f b6 a7 b8 01 00 00 e8 68 7c 08 ff 49 8b 1f 4d 89 e5 49 c1 e4 04 48 8
    [   64.330753] RIP: rdma_join_multicast+0x26e/0x12c0 RSP: ffff8801c8207860
    [   64.332979] CR2: 00000000000000b0
    [   64.335550] ---[ end trace 0c00c17a408849c1 ]---
    
    Reported-by: <syzbot+e6aba77967bd72cbc9d6@syzkaller.appspotmail.com>
    Fixes: c8f6a362bf3e ("RDMA/cma: Add multicast communication support")
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Reviewed-by: Sean Hefty <sean.hefty@intel.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3126c14e8138c7dd32a027932af76234a9c4d3c7
Author: Florian Westphal <fw@strlen.de>
Date:   Fri Mar 9 14:27:31 2018 +0100

    netfilter: bridge: ebt_among: add more missing match size checks
    
    commit c8d70a700a5b486bfa8e5a7d33d805389f6e59f9 upstream.
    
    ebt_among is special, it has a dynamic match size and is exempt
    from the central size checks.
    
    commit c4585a2823edf ("bridge: ebt_among: add missing match size checks")
    added validation for pool size, but missed fact that the macros
    ebt_among_wh_src/dst can already return out-of-bound result because
    they do not check value of wh_src/dst_ofs (an offset) vs. the size
    of the match that userspace gave to us.
    
    v2:
    check that offset has correct alignment.
    Paolo Abeni points out that we should also check that src/dst
    wormhash arrays do not overlap, and src + length lines up with
    start of dst (or vice versa).
    v3: compact wormhash_sizes_valid() part
    
    NB: Fixes tag is intentionally wrong, this bug exists from day
    one when match was added for 2.6 kernel. Tag is there so stable
    maintainers will notice this one too.
    
    Tested with same rules from the earlier patch.
    
    Fixes: c4585a2823edf ("bridge: ebt_among: add missing match size checks")
    Reported-by: <syzbot+bdabab6f1983a03fc009@syzkaller.appspotmail.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b16f74899b271e7cc7f3897852698e28aa223dda
Author: Florian Westphal <fw@strlen.de>
Date:   Mon Feb 19 03:01:45 2018 +0100

    netfilter: bridge: ebt_among: add missing match size checks
    
    commit c4585a2823edf4d1326da44d1524ecbfda26bb37 upstream.
    
    ebt_among is special, it has a dynamic match size and is exempt
    from the central size checks.
    
    Therefore it must check that the size of the match structure
    provided from userspace is sane by making sure em->match_size
    is at least the minimum size of the expected structure.
    
    The module has such a check, but its only done after accessing
    a structure that might be out of bounds.
    
    tested with: ebtables -A INPUT ... \
    --among-dst fe:fe:fe:fe:fe:fe
    --among-dst fe:fe:fe:fe:fe:fe --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fb,fe:fe:fe:fe:fc:fd,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe
    --among-src fe:fe:fe:fe:ff:f,fe:fe:fe:fe:fe:fa,fe:fe:fe:fe:fe:fd,fe:fe:fe:fe:fe:fe,fe:fe:fe:fe:fe:fe
    
    Reported-by: <syzbot+fe0b19af568972814355@syzkaller.appspotmail.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1282010aae8a0945fcf70b2a3c8ffbd921faed04
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Mar 9 22:23:31 2018 +0100

    ALSA: seq: Clear client entry before deleting else at closing
    
    commit a2ff19f7b70118ced291a28d5313469914de451b upstream.
    
    When releasing a client, we need to clear the clienttab[] entry at
    first, then call snd_seq_queue_client_leave().  Otherwise, the
    in-flight cell in the queue might be picked up by the timer interrupt
    via snd_seq_check_queue() before calling snd_seq_queue_client_leave(),
    and it's delivered to another queue while the client is clearing
    queues.  This may eventually result in an uncleared cell remaining in
    a queue, and the later snd_seq_pool_delete() may need to wait for a
    long time until the event gets really processed.
    
    By moving the clienttab[] clearance at the beginning of release, any
    event delivery of a cell belonging to this client will fail at a later
    point, since snd_seq_client_ptr() returns NULL.  Thus the cell that
    was picked up by the timer interrupt will be returned immediately
    without further delivery, and the long stall of snd_seq_delete_pool()
    can be avoided, too.
    
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit deeaca310dc1d79b70384810c47b64b550f6bef7
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Mar 9 21:58:28 2018 +0100

    ALSA: seq: Fix possible UAF in snd_seq_check_queue()
    
    commit d0f833065221cbfcbadf19fd4102bcfa9330006a upstream.
    
    Although we've covered the races between concurrent write() and
    ioctl() in the previous patch series, there is still a possible UAF in
    the following scenario:
    
    A: user client closed           B: timer irq
      -> snd_seq_release()            -> snd_seq_timer_interrupt()
        -> snd_seq_free_client()        -> snd_seq_check_queue()
                                          -> cell = snd_seq_prioq_cell_peek()
          -> snd_seq_prioq_leave()
             .... removing all cells
          -> snd_seq_pool_done()
             .... vfree()
                                          -> snd_seq_compare_tick_time(cell)
                                             ... Oops
    
    So the problem is that a cell is peeked and accessed without any
    protection until it's retrieved from the queue again via
    snd_seq_prioq_cell_out().
    
    This patch tries to address it, also cleans up the code by a slight
    refactoring.  snd_seq_prioq_cell_out() now receives an extra pointer
    argument.  When it's non-NULL, the function checks the event timestamp
    with the given pointer.  The caller needs to pass the right reference
    either to snd_seq_tick or snd_seq_realtime depending on the event
    timestamp type.
    
    A good news is that the above change allows us to remove the
    snd_seq_prioq_cell_peek(), too, thus the patch actually reduces the
    code size.
    
    Reviewed-by: Nicolai Stange <nstange@suse.de>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    [bwh: Backported to 3.2: Deleted function had different log message]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 47e0a4def4d2e1dfcef1fcf1b78706c24584351b
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Thu Mar 8 17:17:17 2018 +0200

    xhci: Fix front USB ports on ASUS PRIME B350M-A
    
    commit 191edc5e2e515aab1075a3f0ef23599e80be5f59 upstream.
    
    When a USB device gets plugged on ASUS PRIME B350M-A's front ports, the
    xHC stops working:
    [  549.114587] xhci_hcd 0000:02:00.0: WARN: xHC CMD_RUN timeout
    [  549.114608] suspend_common(): xhci_pci_suspend+0x0/0xc0 returns -110
    [  549.114638] xhci_hcd 0000:02:00.0: can't suspend (hcd_pci_runtime_suspend returned -110)
    
    Delay before running xHC command CMD_RUN can workaround the issue.
    
    Use a new quirk to make the delay only targets to the affected xHC.
    
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b8021dfb921a69ec50ccb866178367f95c7b7878
Author: Pete Zaitcev <zaitcev@kotori.zaitcev.us>
Date:   Fri Mar 9 00:21:14 2018 -0600

    usb: usbmon: Read text within supplied buffer size
    
    commit a5f596830e27e15f7a0ecd6be55e433d776986d8 upstream.
    
    This change fixes buffer overflows and silent data corruption with the
    usbmon device driver text file read operations.
    
    Signed-off-by: Fredrik Noring <noring@nocrew.org>
    Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2326c561a9a9d8a3d50a0bfe26bd54b6c26fbb9a
Author: Julia Lawall <Julia.Lawall@lip6.fr>
Date:   Sat Dec 26 22:57:44 2015 +0100

    USB: usbmon: remove assignment from IS_ERR argument
    
    commit 46c236dc7d1212d7417e6fb0317f91c44c719322 upstream.
    
    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)
    
    // <smpl>
    @@
    expression e1,e2;
    statement S1,S2;
    @@
    
    +e1 = e2;
    if (IS_ERR(
        e1
    -   = e2
       )) S1 else S2
    // </smpl>
    
    Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit cbad884cdf3c27261eb1eebc9ba4a107dc32a35c
Author: Tony Luck <tony.luck@intel.com>
Date:   Tue Mar 6 15:21:41 2018 +0100

    x86/MCE: Save microcode revision in machine check records
    
    commit fa94d0c6e0f3431523f5701084d799c77c7d4a4f upstream.
    
    Updating microcode used to be relatively rare. Now that it has become
    more common we should save the microcode version in a machine check
    record to make sure that those people looking at the error have this
    important information bundled with the rest of the logged information.
    
    [ Borislav: Simplify a bit. ]
    
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Yazen Ghannam <yazen.ghannam@amd.com>
    Cc: linux-edac <linux-edac@vger.kernel.org>
    Link: http://lkml.kernel.org/r/20180301233449.24311-1-tony.luck@intel.com
    [bwh: Backported to 3.2:
     - Add other new fields to struct mce, to match upstream UAPI
     - Adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 496f3444b4539cb0e4a3fde7d7ab39e2bd03c027
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Wed Mar 7 18:49:16 2018 +0200

    RDMA/ucma: Check that user doesn't overflow QP state
    
    commit a5880b84430316e3e1c1f5d23aa32ec6000cc717 upstream.
    
    The QP state is limited and declared in enum ib_qp_state,
    but ucma user was able to supply any possible (u32) value.
    
    Reported-by: syzbot+0df1ab766f8924b1edba@syzkaller.appspotmail.com
    Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace")
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 225c79af589fd48a19c42e9f50cfa05a24815bda
Author: Leon Romanovsky <leonro@mellanox.com>
Date:   Wed Mar 7 14:49:09 2018 +0200

    RDMA/ucma: Limit possible option size
    
    commit 6a21dfc0d0db7b7e0acedce67ca533a6eb19283c upstream.
    
    Users of ucma are supposed to provide size of option level,
    in most paths it is supposed to be equal to u8 or u16, but
    it is not the case for the IB path record, where it can be
    multiple of struct ib_path_rec_data.
    
    This patch takes simplest possible approach and prevents providing
    values more than possible to allocate.
    
    Reported-by: syzbot+a38b0e9f694c379ca7ce@syzkaller.appspotmail.com
    Fixes: 7ce86409adcd ("RDMA/ucma: Allow user space to set service type")
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Doug Ledford <dledford@redhat.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4d2a62907278533789973df7b28f404c17b3988c
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Mar 6 07:54:53 2018 -0800

    l2tp: do not accept arbitrary sockets
    
    commit 17cfe79a65f98abe535261856c5aef14f306dff7 upstream.
    
    syzkaller found an issue caused by lack of sufficient checks
    in l2tp_tunnel_create()
    
    RAW sockets can not be considered as UDP ones for instance.
    
    In another patch, we shall replace all pr_err() by less intrusive
    pr_debug() so that syzkaller can find other bugs faster.
    Acked-by: Guillaume Nault <g.nault@alphalink.fr>
    Acked-by: James Chapman <jchapman@katalix.com>
    
    ==================================================================
    BUG: KASAN: slab-out-of-bounds in setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69
    dst_release: dst:00000000d53d0d0f refcnt:-1
    Write of size 1 at addr ffff8801d013b798 by task syz-executor3/6242
    
    CPU: 1 PID: 6242 Comm: syz-executor3 Not tainted 4.16.0-rc2+ #253
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x194/0x24d lib/dump_stack.c:53
     print_address_description+0x73/0x250 mm/kasan/report.c:256
     kasan_report_error mm/kasan/report.c:354 [inline]
     kasan_report+0x23b/0x360 mm/kasan/report.c:412
     __asan_report_store1_noabort+0x17/0x20 mm/kasan/report.c:435
     setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69
     l2tp_tunnel_create+0x1354/0x17f0 net/l2tp/l2tp_core.c:1596
     pppol2tp_connect+0x14b1/0x1dd0 net/l2tp/l2tp_ppp.c:707
     SYSC_connect+0x213/0x4a0 net/socket.c:1640
     SyS_connect+0x24/0x30 net/socket.c:1621
     do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x42/0xb7
    
    Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8dfd783824a7f5b3b23574fecc99a41aa1c1198f
Author: Danilo Krummrich <danilokrummrich@dk-develop.de>
Date:   Tue Mar 6 09:38:49 2018 +0100

    usb: quirks: add control message delay for 1b1c:1b20
    
    commit cb88a0588717ba6c756cb5972d75766b273a6817 upstream.
    
    Corsair Strafe RGB keyboard does not respond to usb control messages
    sometimes and hence generates timeouts.
    
    Commit de3af5bf259d ("usb: quirks: add delay init quirk for Corsair
    Strafe RGB keyboard") tried to fix those timeouts by adding
    USB_QUIRK_DELAY_INIT.
    
    Unfortunately, even with this quirk timeouts of usb_control_msg()
    can still be seen, but with a lower frequency (approx. 1 out of 15):
    
    [   29.103520] usb 1-8: string descriptor 0 read error: -110
    [   34.363097] usb 1-8: can't set config #1, error -110
    
    Adding further delays to different locations where usb control
    messages are issued just moves the timeouts to other locations,
    e.g.:
    
    [   35.400533] usbhid 1-8:1.0: can't add hid device: -110
    [   35.401014] usbhid: probe of 1-8:1.0 failed with error -110
    
    The only way to reliably avoid those issues is having a pause after
    each usb control message. In approx. 200 boot cycles no more timeouts
    were seen.
    
    Addionaly, keep USB_QUIRK_DELAY_INIT as it turned out to be necessary
    to have the delay in hub_port_connect() after hub_port_init().
    
    The overall boot time seems not to be influenced by these additional
    delays, even on fast machines and lightweight distributions.
    
    Fixes: de3af5bf259d ("usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard")
    Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit aa869750c78648d1ccae1a7e23239e64cc0859c9
Author: Benjamin Poirier <bpoirier@suse.com>
Date:   Tue Feb 20 15:12:00 2018 +0900

    e1000e: Fix check_for_link return value with autoneg off
    
    commit 4e7dc08e57c95673d2edaba8983c3de4dd1f65f5 upstream.
    
    When autoneg is off, the .check_for_link callback functions clear the
    get_link_status flag and systematically return a "pseudo-error". This means
    that the link is not detected as up until the next execution of the
    e1000_watchdog_task() 2 seconds later.
    
    Fixes: 19110cfbb34d ("e1000e: Separate signaling for link check/link up")
    Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
    Acked-by: Sasha Neftin <sasha.neftin@intel.com>
    Tested-by: Aaron Brown <aaron.f.brown@intel.com>
    Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
    [bwh: Backported to 3.2: adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 950c0f06dd3617fd1da39d2fb28dfc5acdc7f2ce
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Fri Mar 2 11:36:32 2018 +0100

    ahci: Add PCI-id for the Highpoint Rocketraid 644L card
    
    commit 28b2182dad43f6f8fcbd167539a26714fd12bd64 upstream.
    
    Like the Highpoint Rocketraid 642L and cards using a Marvel 88SE9235
    controller in general, this RAID card also supports AHCI mode and short
    of a custom driver, this is the only way to make it work under Linux.
    
    Note that even though the card is called to 644L, it has a product-id
    of 0x0645.
    
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1534106
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Acked-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1063c9391c430f0059780c55be0874dce91e59d2
Author: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Date:   Thu Feb 15 13:02:27 2018 +0100

    serial: sh-sci: prevent lockup on full TTY buffers
    
    commit 7842055bfce4bf0170d0f61df8b2add8399697be upstream.
    
    When the TTY buffers fill up to the configured maximum, a system lockup
    occurs:
    
    [  598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks:
    [  598.825796]  0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1
    [  598.832577]  (detected by 3, t=62517 jiffies, g=296, c=295, q=126)
    [  598.838755] Task dump for CPU 0:
    [  598.841977] swapper/0       R  running task        0     0      0 0x00000022
    [  598.849023] Call trace:
    [  598.851476]  __switch_to+0x98/0xb0
    [  598.854870]            (null)
    
    This can be prevented by doing a dummy read of the RX data register.
    
    This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0;
    reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms
    as well.
    
    Reported-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
    Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
    Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
    Tested-by: Nguyen Viet Dung <dung.nguyen.aj@renesas.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2:
     - Use sci_in()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 50bf8fc9a9a95b1c97b79278177a2378f4c7d6ad
Author: Tejun Heo <tj@kernel.org>
Date:   Tue Feb 13 07:38:08 2018 -0800

    tty: make n_tty_read() always abort if hangup is in progress
    
    commit 28b0f8a6962a24ed21737578f3b1b07424635c9e upstream.
    
    A tty is hung up by __tty_hangup() setting file->f_op to
    hung_up_tty_fops, which is skipped on ttys whose write operation isn't
    tty_write().  This means that, for example, /dev/console whose write
    op is redirected_tty_write() is never actually marked hung up.
    
    Because n_tty_read() uses the hung up status to decide whether to
    abort the waiting readers, the lack of hung-up marking can lead to the
    following scenario.
    
     1. A session contains two processes.  The leader and its child.  The
        child ignores SIGHUP.
    
     2. The leader exits and starts disassociating from the controlling
        terminal (/dev/console).
    
     3. __tty_hangup() skips setting f_op to hung_up_tty_fops.
    
     4. SIGHUP is delivered and ignored.
    
     5. tty_ldisc_hangup() is invoked.  It wakes up the waits which should
        clear the read lockers of tty->ldisc_sem.
    
     6. The reader wakes up but because tty_hung_up_p() is false, it
        doesn't abort and goes back to sleep while read-holding
        tty->ldisc_sem.
    
     7. The leader progresses to tty_ldisc_lock() in tty_ldisc_hangup()
        and is now stuck in D sleep indefinitely waiting for
        tty->ldisc_sem.
    
    The following is Alan's explanation on why some ttys aren't hung up.
    
     http://lkml.kernel.org/r/20171101170908.6ad08580@alans-desktop
    
     1. It broke the serial consoles because they would hang up and close
        down the hardware. With tty_port that *should* be fixable properly
        for any cases remaining.
    
     2. The console layer was (and still is) completely broken and doens't
        refcount properly. So if you turn on console hangups it breaks (as
        indeed does freeing consoles and half a dozen other things).
    
    As neither can be fixed quickly, this patch works around the problem
    by introducing a new flag, TTY_HUPPING, which is used solely to tell
    n_tty_read() that hang-up is in progress for the console and the
    readers should be aborted regardless of the hung-up status of the
    device.
    
    The following is a sample hung task warning caused by this issue.
    
      INFO: task agetty:2662 blocked for more than 120 seconds.
            Not tainted 4.11.3-dbg-tty-lockup-02478-gfd6c7ee-dirty #28
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
          0  2662      1 0x00000086
      Call Trace:
       __schedule+0x267/0x890
       schedule+0x36/0x80
       schedule_timeout+0x23c/0x2e0
       ldsem_down_write+0xce/0x1f6
       tty_ldisc_lock+0x16/0x30
       tty_ldisc_hangup+0xb3/0x1b0
       __tty_hangup+0x300/0x410
       disassociate_ctty+0x6c/0x290
       do_exit+0x7ef/0xb00
       do_group_exit+0x3f/0xa0
       get_signal+0x1b3/0x5d0
       do_signal+0x28/0x660
       exit_to_usermode_loop+0x46/0x86
       do_syscall_64+0x9c/0xb0
       entry_SYSCALL64_slow_path+0x25/0x25
    
    The following is the repro.  Run "$PROG /dev/console".  The parent
    process hangs in D state.
    
      #include <sys/types.h>
      #include <sys/stat.h>
      #include <sys/wait.h>
      #include <sys/ioctl.h>
      #include <fcntl.h>
      #include <unistd.h>
      #include <stdio.h>
      #include <stdlib.h>
      #include <errno.h>
      #include <signal.h>
      #include <time.h>
      #include <termios.h>
    
      int main(int argc, char **argv)
      {
              struct sigaction sact = { .sa_handler = SIG_IGN };
              struct timespec ts1s = { .tv_sec = 1 };
              pid_t pid;
              int fd;
    
              if (argc < 2) {
                      fprintf(stderr, "test-hung-tty /dev/$TTY\n");
                      return 1;
              }
    
              /* fork a child to ensure that it isn't already the session leader */
              pid = fork();
              if (pid < 0) {
                      perror("fork");
                      return 1;
              }
    
              if (pid > 0) {
                      /* top parent, wait for everyone */
                      while (waitpid(-1, NULL, 0) >= 0)
                              ;
                      if (errno != ECHILD)
                              perror("waitpid");
                      return 0;
              }
    
              /* new session, start a new session and set the controlling tty */
              if (setsid() < 0) {
                      perror("setsid");
                      return 1;
              }
    
              fd = open(argv[1], O_RDWR);
              if (fd < 0) {
                      perror("open");
                      return 1;
              }
    
              if (ioctl(fd, TIOCSCTTY, 1) < 0) {
                      perror("ioctl");
                      return 1;
              }
    
              /* fork a child, sleep a bit and exit */
              pid = fork();
              if (pid < 0) {
                      perror("fork");
                      return 1;
              }
    
              if (pid > 0) {
                      nanosleep(&ts1s, NULL);
                      printf("Session leader exiting\n");
                      exit(0);
              }
    
              /*
               * The child ignores SIGHUP and keeps reading from the controlling
               * tty.  Because SIGHUP is ignored, the child doesn't get killed on
               * parent exit and the bug in n_tty makes the read(2) block the
               * parent's control terminal hangup attempt.  The parent ends up in
               * D sleep until the child is explicitly killed.
               */
              sigaction(SIGHUP, &sact, NULL);
              printf("Child reading tty\n");
              while (1) {
                      char buf[1024];
    
                      if (read(fd, buf, sizeof(buf)) < 0) {
                              perror("read");
                              return 1;
                      }
              }
    
              return 0;
      }
    
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Cc: Alan Cox <alan@llwyncelyn.cymru>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2: TTY_HUPPING is not really a new flag; it's an old flag
     that was wrongly removed in 3.19.  Just add the test for it in n_tty_read().]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 72686d527c0d3566ec96ec6d834ce08596c10c62
Author: Jeremy Boone <jeremy.boone@nccgroup.trust>
Date:   Thu Feb 8 12:32:06 2018 -0800

    tpm_tis: fix potential buffer overruns caused by bit glitches on the bus
    
    commit 6bb320ca4a4a7b5b3db8c8d7250cc40002046878 upstream.
    
    Discrete TPMs are often connected over slow serial buses which, on
    some platforms, can have glitches causing bit flips.  In all the
    driver _recv() functions, we need to use a u32 to unmarshal the
    response size, otherwise a bit flip of the 31st bit would cause the
    expected variable to go negative, which would then try to read a huge
    amount of data.  Also sanity check that the expected amount of data is
    large enough for the TPM header.
    
    Signed-off-by: Jeremy Boone <jeremy.boone@nccgroup.trust>
    Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
    Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
    Signed-off-by: James Morris <james.morris@microsoft.com>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dbbb3062dd53e7950a18bc05cca296fb2803b10b
Author: James Chapman <jchapman@katalix.com>
Date:   Fri Feb 23 17:45:46 2018 +0000

    l2tp: fix race in pppol2tp_release with session object destroy
    
    commit d02ba2a6110c530a32926af8ad441111774d2893 upstream.
    
    pppol2tp_release uses call_rcu to put the final ref on its socket. But
    the session object doesn't hold a ref on the session socket so may be
    freed while the pppol2tp_put_sk RCU callback is scheduled. Fix this by
    having the session hold a ref on its socket until the session is
    destroyed. It is this ref that is dropped via call_rcu.
    
    Sessions are also deleted via l2tp_tunnel_closeall. This must now also put
    the final ref via call_rcu. So move the call_rcu call site into
    pppol2tp_session_close so that this happens in both destroy paths. A
    common destroy path should really be implemented, perhaps with
    l2tp_tunnel_closeall calling l2tp_session_delete like pppol2tp_release
    does, but this will be looked at later.
    
    ODEBUG: activate active (active state 1) object type: rcu_head hint:           (null)
    WARNING: CPU: 3 PID: 13407 at lib/debugobjects.c:291 debug_print_object+0x166/0x220
    Modules linked in:
    CPU: 3 PID: 13407 Comm: syzbot_19c09769 Not tainted 4.16.0-rc2+ #38
    Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
    RIP: 0010:debug_print_object+0x166/0x220
    RSP: 0018:ffff880013647a00 EFLAGS: 00010082
    RAX: dffffc0000000008 RBX: 0000000000000003 RCX: ffffffff814d3333
    RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff88001a59f6d0
    RBP: ffff880013647a40 R08: 0000000000000000 R09: 0000000000000001
    R10: ffff8800136479a8 R11: 0000000000000000 R12: 0000000000000001
    R13: ffffffff86161420 R14: ffffffff85648b60 R15: 0000000000000000
    FS:  0000000000000000(0000) GS:ffff88001a580000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000020e77000 CR3: 0000000006022000 CR4: 00000000000006e0
    Call Trace:
     debug_object_activate+0x38b/0x530
     ? debug_object_assert_init+0x3b0/0x3b0
     ? __mutex_unlock_slowpath+0x85/0x8b0
     ? pppol2tp_session_destruct+0x110/0x110
     __call_rcu.constprop.66+0x39/0x890
     ? __call_rcu.constprop.66+0x39/0x890
     call_rcu_sched+0x17/0x20
     pppol2tp_release+0x2c7/0x440
     ? fcntl_setlk+0xca0/0xca0
     ? sock_alloc_file+0x340/0x340
     sock_release+0x92/0x1e0
     sock_close+0x1b/0x20
     __fput+0x296/0x6e0
     ____fput+0x1a/0x20
     task_work_run+0x127/0x1a0
     do_exit+0x7f9/0x2ce0
     ? SYSC_connect+0x212/0x310
     ? mm_update_next_owner+0x690/0x690
     ? up_read+0x1f/0x40
     ? __do_page_fault+0x3c8/0xca0
     do_group_exit+0x10d/0x330
     ? do_group_exit+0x330/0x330
     SyS_exit_group+0x22/0x30
     do_syscall_64+0x1e0/0x730
     ? trace_hardirqs_off_thunk+0x1a/0x1c
     entry_SYSCALL_64_after_hwframe+0x42/0xb7
    RIP: 0033:0x7f362e471259
    RSP: 002b:00007ffe389abe08 EFLAGS: 00000202 ORIG_RAX: 00000000000000e7
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f362e471259
    RDX: 00007f362e471259 RSI: 000000000000002e RDI: 0000000000000000
    RBP: 00007ffe389abe30 R08: 0000000000000000 R09: 00007f362e944270
    R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000400b60
    R13: 00007ffe389abf50 R14: 0000000000000000 R15: 0000000000000000
    Code: 8d 3c dd a0 8f 64 85 48 89 fa 48 c1 ea 03 80 3c 02 00 75 7b 48 8b 14 dd a0 8f 64 85 4c 89 f6 48 c7 c7 20 85 64 85 e
    8 2a 55 14 ff <0f> 0b 83 05 ad 2a 68 04 01 48 83 c4 18 5b 41 5c 41 5d 41 5e 41
    
    Fixes: ee40fb2e1eb5b ("l2tp: protect sock pointer of struct pppol2tp_session with RCU")
    Signed-off-by: James Chapman <jchapman@katalix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 99f890a5f4de33ca43ea79b7b54241849e4bf904
Author: James Chapman <jchapman@katalix.com>
Date:   Fri Feb 23 17:45:44 2018 +0000

    l2tp: don't use inet_shutdown on ppp session destroy
    
    commit 225eb26489d05c679a4c4197ffcb81c81e9dcaf4 upstream.
    
    Previously, if a ppp session was closed, we called inet_shutdown to mark
    the socket as unconnected such that userspace would get errors and
    then close the socket. This could race with userspace closing the
    socket. Instead, leave userspace to close the socket in its own time
    (our session will be detached anyway).
    
    BUG: KASAN: use-after-free in inet_shutdown+0x5d/0x1c0
    Read of size 4 at addr ffff880010ea3ac0 by task syzbot_347bd5ac/8296
    
    CPU: 3 PID: 8296 Comm: syzbot_347bd5ac Not tainted 4.16.0-rc1+ #91
    Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
    Call Trace:
     dump_stack+0x101/0x157
     ? inet_shutdown+0x5d/0x1c0
     print_address_description+0x78/0x260
     ? inet_shutdown+0x5d/0x1c0
     kasan_report+0x240/0x360
     __asan_load4+0x78/0x80
     inet_shutdown+0x5d/0x1c0
     ? pppol2tp_show+0x80/0x80
     pppol2tp_session_close+0x68/0xb0
     l2tp_tunnel_closeall+0x199/0x210
     ? udp_v6_flush_pending_frames+0x90/0x90
     l2tp_udp_encap_destroy+0x6b/0xc0
     ? l2tp_tunnel_del_work+0x2e0/0x2e0
     udpv6_destroy_sock+0x8c/0x90
     sk_common_release+0x47/0x190
     udp_lib_close+0x15/0x20
     inet_release+0x85/0xd0
     inet6_release+0x43/0x60
     sock_release+0x53/0x100
     ? sock_alloc_file+0x260/0x260
     sock_close+0x1b/0x20
     __fput+0x19f/0x380
     ____fput+0x1a/0x20
     task_work_run+0xd2/0x110
     exit_to_usermode_loop+0x18d/0x190
     do_syscall_64+0x389/0x3b0
     entry_SYSCALL_64_after_hwframe+0x26/0x9b
    RIP: 0033:0x7fe240a45259
    RSP: 002b:00007fe241132df8 EFLAGS: 00000297 ORIG_RAX: 0000000000000003
    RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fe240a45259
    RDX: 00007fe240a45259 RSI: 0000000000000000 RDI: 00000000000000a5
    RBP: 00007fe241132e20 R08: 00007fe241133700 R09: 0000000000000000
    R10: 00007fe241133700 R11: 0000000000000297 R12: 0000000000000000
    R13: 00007ffc49aff84f R14: 0000000000000000 R15: 00007fe241141040
    
    Allocated by task 8331:
     save_stack+0x43/0xd0
     kasan_kmalloc+0xad/0xe0
     kasan_slab_alloc+0x12/0x20
     kmem_cache_alloc+0x144/0x3e0
     sock_alloc_inode+0x22/0x130
     alloc_inode+0x3d/0xf0
     new_inode_pseudo+0x1c/0x90
     sock_alloc+0x30/0x110
     __sock_create+0xaa/0x4c0
     SyS_socket+0xbe/0x130
     do_syscall_64+0x128/0x3b0
     entry_SYSCALL_64_after_hwframe+0x26/0x9b
    
    Freed by task 8314:
     save_stack+0x43/0xd0
     __kasan_slab_free+0x11a/0x170
     kasan_slab_free+0xe/0x10
     kmem_cache_free+0x88/0x2b0
     sock_destroy_inode+0x49/0x50
     destroy_inode+0x77/0xb0
     evict+0x285/0x340
     iput+0x429/0x530
     dentry_unlink_inode+0x28c/0x2c0
     __dentry_kill+0x1e3/0x2f0
     dput.part.21+0x500/0x560
     dput+0x24/0x30
     __fput+0x2aa/0x380
     ____fput+0x1a/0x20
     task_work_run+0xd2/0x110
     exit_to_usermode_loop+0x18d/0x190
     do_syscall_64+0x389/0x3b0
     entry_SYSCALL_64_after_hwframe+0x26/0x9b
    
    Fixes: fd558d186df2c ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
    Signed-off-by: James Chapman <jchapman@katalix.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: deleted code is formatted a bit differently]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 73bcecff7ee24a33241aeb60cd8de94330b45abd
Author: Matthias Schiffer <mschiffer@universe-factory.net>
Date:   Tue Jan 23 10:59:49 2018 +0100

    batman-adv: fix packet checksum in receive path
    
    commit abd6360591d3f8259f41c34e31ac4826dfe621b8 upstream.
    
    eth_type_trans() internally calls skb_pull(), which does not adjust the
    skb checksum; skb_postpull_rcsum() is necessary to avoid log spam of the
    form "bat0: hw csum failure" when packets with CHECKSUM_COMPLETE are
    received.
    
    Note that in usual setups, packets don't reach batman-adv with
    CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
    batadv's ethtype?), which is why the log messages do not occur on every
    system using batman-adv. I could reproduce this issue by stacking
    batman-adv on top of a VXLAN interface.
    
    Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
    Tested-by: Maximilian Wilhelm <max@sdn.clinic>
    Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
    Signed-off-by: Sven Eckelmann <sven@narfation.org>
    Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6acc5b4ab4c8d5a4373d733cc384a1aef17084ff
Author: Erik Veijola <erik.veijola@gmail.com>
Date:   Fri Feb 23 14:06:52 2018 +0200

    ALSA: usb-audio: Add a quirck for B&W PX headphones
    
    commit 240a8af929c7c57dcde28682725b29cf8474e8e5 upstream.
    
    The capture interface doesn't work and the playback interface only
    supports 48 kHz sampling rate even though it advertises more rates.
    
    Signed-off-by: Erik Veijola <erik.veijola@gmail.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6174a2c5957aac60dcf8f2788df428f198d4dee5
Author: Ben Crocker <bcrocker@redhat.com>
Date:   Thu Feb 22 17:52:19 2018 -0500

    drm/radeon: insist on 32-bit DMA for Cedar on PPC64/PPC64LE
    
    commit 2c83029cda55a5e7665c7c6326909427d6a01350 upstream.
    
    In radeon_device_init, set the need_dma32 flag for Cedar chips
    (e.g. FirePro 2270).  This fixes, or at least works around, a bug
    on PowerPC exposed by last year's commits
    
    8e3f1b1d8255105f31556aacf8aeb6071b00d469 (Russell Currey)
    
    and
    
    253fd51e2f533552ae35a0c661705da6c4842c1b (Alistair Popple)
    
    which enabled the 64-bit DMA iommu bypass.
    
    This caused the device to freeze, in some cases unrecoverably, and is
    the subject of several bug reports internal to Red Hat.
    
    Signed-off-by: Ben Crocker <bcrocker@redhat.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b326f1bab0cd46b62d48074b95367698965e4d14
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Feb 22 20:55:28 2018 +0100

    regulatory: add NUL to request alpha2
    
    commit 657308f73e674e86b60509a430a46e569bf02846 upstream.
    
    Similar to the ancient commit a5fe8e7695dc ("regulatory: add NUL
    to alpha2"), add another byte to alpha2 in the request struct so
    that when we use nla_put_string(), we don't overrun anything.
    
    Fixes: 73d54c9e74c4 ("cfg80211: add regulatory netlink multicast group")
    Reported-by: Kees Cook <keescook@google.com>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 53e4051f34a4fd8b56a8b98cce38610bf2257a0a
Author: David Rientjes <rientjes@google.com>
Date:   Wed Feb 21 14:45:32 2018 -0800

    kernel/relay.c: limit kmalloc size to KMALLOC_MAX_SIZE
    
    commit 88913bd8ea2a75d7e460a4bed5f75e1c32660d7e upstream.
    
    chan->n_subbufs is set by the user and relay_create_buf() does a kmalloc()
    of chan->n_subbufs * sizeof(size_t *).
    
    kmalloc_slab() will generate a warning when this fails if
    chan->subbufs * sizeof(size_t *) > KMALLOC_MAX_SIZE.
    
    Limit chan->n_subbufs to the maximum allowed kmalloc() size.
    
    Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1802061216100.122576@chino.kir.corp.google.com
    Fixes: f6302f1bcd75 ("relay: prevent integer overflow in relay_open()")
    Signed-off-by: David Rientjes <rientjes@google.com>
    Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
    Cc: Jens Axboe <axboe@kernel.dk>
    Cc: Dave Jiang <dave.jiang@intel.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3df2313052df34114c77900aa7e36ac2a870c968
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Sun Feb 18 22:17:09 2018 +0800

    libata: disable LPM for Crucial BX100 SSD 500GB drive
    
    commit b17e5729a630d8326a48ec34ef02e6b4464a6aef upstream.
    
    After Laptop Mode Tools starts to use min_power for LPM, a user found
    out Crucial BX100 SSD can't get mounted.
    
    Crucial BX100 SSD 500GB drive don't work well with min_power. This also
    happens to med_power_with_dipm.
    
    So let's disable LPM for Crucial BX100 SSD 500GB drive.
    
    BugLink: https://bugs.launchpad.net/bugs/1726930
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 67d4abc84c535bd88ace5fbc8b8752736771a33f
Author: Jan Beulich <JBeulich@suse.com>
Date:   Mon Feb 19 07:48:11 2018 -0700

    x86/mm: Fix {pmd,pud}_{set,clear}_flags()
    
    commit 842cef9113c2120f74f645111ded1e020193d84c upstream.
    
    Just like pte_{set,clear}_flags() their PMD and PUD counterparts should
    not do any address translation. This was outright wrong under Xen
    (causing a dead boot with no useful output on "suitable" systems), and
    produced needlessly more complicated code (even if just slightly) when
    paravirt was enabled.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: http://lkml.kernel.org/r/5A8AF1BB02000078001A91C3@prv-mh.provo.novell.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.2:
     - There aren't any pud_{set,clear}_flags() functions
     - There's no p4d level]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e7588cfc3445492a2020cb4a205a7258dd1d5d6a
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Feb 16 19:36:28 2018 -0800

    netfilter: IDLETIMER: be syzkaller friendly
    
    commit cfc2c740533368b96e2be5e0a4e8c3cace7d9814 upstream.
    
    We had one report from syzkaller [1]
    
    First issue is that INIT_WORK() should be done before mod_timer()
    or we risk timer being fired too soon, even with a 1 second timer.
    
    Second issue is that we need to reject too big info->timeout
    to avoid overflows in msecs_to_jiffies(info->timeout * 1000), or
    risk looping, if result after overflow is 0.
    
    [1]
    WARNING: CPU: 1 PID: 5129 at kernel/workqueue.c:1444 __queue_work+0xdf4/0x1230 kernel/workqueue.c:1444
    Kernel panic - not syncing: panic_on_warn set ...
    
    CPU: 1 PID: 5129 Comm: syzkaller159866 Not tainted 4.16.0-rc1+ #230
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     <IRQ>
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x194/0x257 lib/dump_stack.c:53
     panic+0x1e4/0x41c kernel/panic.c:183
     __warn+0x1dc/0x200 kernel/panic.c:547
     report_bug+0x211/0x2d0 lib/bug.c:184
     fixup_bug.part.11+0x37/0x80 arch/x86/kernel/traps.c:178
     fixup_bug arch/x86/kernel/traps.c:247 [inline]
     do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296
     do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315
     invalid_op+0x22/0x40 arch/x86/entry/entry_64.S:988
    RIP: 0010:__queue_work+0xdf4/0x1230 kernel/workqueue.c:1444
    RSP: 0018:ffff8801db507538 EFLAGS: 00010006
    RAX: ffff8801aeb46080 RBX: ffff8801db530200 RCX: ffffffff81481404
    RDX: 0000000000000100 RSI: ffffffff86b42640 RDI: 0000000000000082
    RBP: ffff8801db507758 R08: 1ffff1003b6a0de5 R09: 000000000000000c
    R10: ffff8801db5073f0 R11: 0000000000000020 R12: 1ffff1003b6a0eb6
    R13: ffff8801b1067ae0 R14: 00000000000001f8 R15: dffffc0000000000
     queue_work_on+0x16a/0x1c0 kernel/workqueue.c:1488
     queue_work include/linux/workqueue.h:488 [inline]
     schedule_work include/linux/workqueue.h:546 [inline]
     idletimer_tg_expired+0x44/0x60 net/netfilter/xt_IDLETIMER.c:116
     call_timer_fn+0x228/0x820 kernel/time/timer.c:1326
     expire_timers kernel/time/timer.c:1363 [inline]
     __run_timers+0x7ee/0xb70 kernel/time/timer.c:1666
     run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1692
     __do_softirq+0x2d7/0xb85 kernel/softirq.c:285
     invoke_softirq kernel/softirq.c:365 [inline]
     irq_exit+0x1cc/0x200 kernel/softirq.c:405
     exiting_irq arch/x86/include/asm/apic.h:541 [inline]
     smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
     apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:829
     </IRQ>
    RIP: 0010:arch_local_irq_restore arch/x86/include/asm/paravirt.h:777 [inline]
    RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
    RIP: 0010:_raw_spin_unlock_irqrestore+0x5e/0xba kernel/locking/spinlock.c:184
    RSP: 0018:ffff8801c20173c8 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff12
    RAX: dffffc0000000000 RBX: 0000000000000282 RCX: 0000000000000006
    RDX: 1ffffffff0d592cd RSI: 1ffff10035d68d23 RDI: 0000000000000282
    RBP: ffff8801c20173d8 R08: 1ffff10038402e47 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff8820e5c8
    R13: ffff8801b1067ad8 R14: ffff8801aea7c268 R15: ffff8801aea7c278
     __debug_object_init+0x235/0x1040 lib/debugobjects.c:378
     debug_object_init+0x17/0x20 lib/debugobjects.c:391
     __init_work+0x2b/0x60 kernel/workqueue.c:506
     idletimer_tg_create net/netfilter/xt_IDLETIMER.c:152 [inline]
     idletimer_tg_checkentry+0x691/0xb00 net/netfilter/xt_IDLETIMER.c:213
     xt_check_target+0x22c/0x7d0 net/netfilter/x_tables.c:850
     check_target net/ipv6/netfilter/ip6_tables.c:533 [inline]
     find_check_entry.isra.7+0x935/0xcf0 net/ipv6/netfilter/ip6_tables.c:575
     translate_table+0xf52/0x1690 net/ipv6/netfilter/ip6_tables.c:744
     do_replace net/ipv6/netfilter/ip6_tables.c:1160 [inline]
     do_ip6t_set_ctl+0x370/0x5f0 net/ipv6/netfilter/ip6_tables.c:1686
     nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
     nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
     ipv6_setsockopt+0x10b/0x130 net/ipv6/ipv6_sockglue.c:927
     udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
     sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2976
     SYSC_setsockopt net/socket.c:1850 [inline]
     SyS_setsockopt+0x189/0x360 net/socket.c:1829
     do_syscall_64+0x282/0x940 arch/x86/entry/common.c:287
    
    Fixes: 0902b469bd25 ("netfilter: xtables: idletimer target implementation")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzkaller <syzkaller@googlegroups.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 399ae5ba263e672bf105414f8e71adc9ff223134
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Fri Feb 16 10:48:20 2018 +0100

    libata: Apply NOLPM quirk to Crucial MX100 512GB SSDs
    
    commit 9c7be59fc519af9081c46c48f06f2b8fadf55ad8 upstream.
    
    Various people have reported the Crucial MX100 512GB model not working
    with LPM set to min_power. I've now received a report that it also does
    not work with the new med_power_with_dipm level.
    
    It does work with medium_power, but that has no measurable power-savings
    and given the amount of people being bitten by the other levels not
    working, this commit just disables LPM altogether.
    
    Note all reporters of this have either the 512GB model (max capacity), or
    are not specifying their SSD's size. So for now this quirk assumes this is
    a problem with the 512GB model only.
    
    Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=89261
    Buglink: https://github.com/linrunner/TLP/issues/84
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    [bwh: Backported to 3.2: Drop the TRIM quirk flags, which aren't supported]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 706a681ca0e882764ae549e5df26826d16cf9101
Author: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Date:   Fri Feb 16 13:20:48 2018 -0800

    nospec: Allow index argument to have const-qualified type
    
    commit b98c6a160a057d5686a8c54c79cc6c8c94a7d0c8 upstream.
    
    The last expression in a statement expression need not be a bare
    variable, quoting gcc docs
    
      The last thing in the compound statement should be an expression
      followed by a semicolon; the value of this subexpression serves as the
      value of the entire construct.
    
    and we already use that in e.g. the min/max macros which end with a
    ternary expression.
    
    This way, we can allow index to have const-qualified type, which will in
    some cases avoid the need for introducing a local copy of index of
    non-const qualified type. That, in turn, can prevent readers not
    familiar with the internals of array_index_nospec from wondering about
    the seemingly redundant extra variable, and I think that's worthwhile
    considering how confusing the whole _nospec business is.
    
    The expression _i&_mask has type unsigned long (since that is the type
    of _mask, and the BUILD_BUG_ONs guarantee that _i will get promoted to
    that), so in order not to change the type of the whole expression, add
    a cast back to typeof(_i).
    
    Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    Signed-off-by: Dan Williams <dan.j.williams@intel.com>
    Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Arjan van de Ven <arjan@linux.intel.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: David Woodhouse <dwmw2@infradead.org>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Will Deacon <will.deacon@arm.com>
    Cc: linux-arch@vger.kernel.org
    Link: http://lkml.kernel.org/r/151881604837.17395.10812767547837568328.stgit@dwillia2-desk3.amr.corp.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit a5a3182e50b5be88efd01050ba6f35e2d0aaee03
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Thu Feb 15 16:59:49 2018 +0100

    dn_getsockoptdecnet: move nf_{get/set}sockopt outside sock lock
    
    commit dfec091439bb2acf763497cfc58f2bdfc67c56b7 upstream.
    
    After commit 3f34cfae1238 ("netfilter: on sockopt() acquire sock lock
    only in the required scope"), the caller of nf_{get/set}sockopt() must
    not hold any lock, but, in such changeset, I forgot to cope with DECnet.
    
    This commit addresses the issue moving the nf call outside the lock,
    in the dn_{get,set}sockopt() with the same schema currently used by
    ipv4 and ipv6. Also moves the unhandled sockopts of the end of the main
    switch statements, to improve code readability.
    
    Reported-by: Petr Vandrovec <petr@vandrovec.name>
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198791#c2
    Fixes: 3f34cfae1238 ("netfilter: on sockopt() acquire sock lock only in the required scope")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4a6561b37ea65b4a98bd8fe16c57f231b1502302
Author: Jack Stocker <jackstocker.93@gmail.com>
Date:   Thu Feb 15 18:24:10 2018 +0000

    Add delay-init quirk for Corsair K70 RGB keyboards
    
    commit 7a1646d922577b5b48c0d222e03831141664bb59 upstream.
    
    Following on from this patch: https://lkml.org/lkml/2017/11/3/516,
    Corsair K70 RGB keyboards also require the DELAY_INIT quirk to
    start correctly at boot.
    
    Device ids found here:
    usb 3-3: New USB device found, idVendor=1b1c, idProduct=1b13
    usb 3-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 3-3: Product: Corsair K70 RGB Gaming Keyboard
    
    Signed-off-by: Jack Stocker <jackstocker.93@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 34ee743350e4b69467822c1c58df6d933893d040
Author: AMAN DEEP <aman.deep@samsung.com>
Date:   Thu Feb 8 11:55:01 2018 +0800

    usb: ohci: Proper handling of ed_rm_list to handle race condition between usb_kill_urb() and finish_unlinks()
    
    commit 46408ea558df13b110e0866b99624384a33bdeba upstream.
    
    There is a race condition between finish_unlinks->finish_urb() function
    and usb_kill_urb() in ohci controller case. The finish_urb calls
    spin_unlock(&ohci->lock) before usb_hcd_giveback_urb() function call,
    then if during this time, usb_kill_urb is called for another endpoint,
    then new ed will be added to ed_rm_list at beginning for unlink, and
    ed_rm_list will point to newly added.
    
    When finish_urb() is completed in finish_unlinks() and ed->td_list
    becomes empty as in below code (in finish_unlinks() function):
    
            if (list_empty(&ed->td_list)) {
                    *last = ed->ed_next;
                    ed->ed_next = NULL;
            } else if (ohci->rh_state == OHCI_RH_RUNNING) {
                    *last = ed->ed_next;
                    ed->ed_next = NULL;
                    ed_schedule(ohci, ed);
            }
    
    The *last = ed->ed_next will make ed_rm_list to point to ed->ed_next
    and previously added ed by usb_kill_urb will be left unreferenced by
    ed_rm_list. This causes usb_kill_urb() hang forever waiting for
    finish_unlink to remove added ed from ed_rm_list.
    
    The main reason for hang in this race condtion is addition and removal
    of ed from ed_rm_list in the beginning during usb_kill_urb and later
    last* is modified in finish_unlinks().
    
    As suggested by Alan Stern, the solution for proper handling of
    ohci->ed_rm_list is to remove ed from the ed_rm_list before finishing
    any URBs. Then at the end, we can add ed back to the list if necessary.
    
    This properly handle the updated ohci->ed_rm_list in usb_kill_urb().
    
    Fixes: 977dcfdc6031 ("USB: OHCI: don't lose track of EDs when a controller dies")
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Aman Deep <aman.deep@samsung.com>
    Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0ebead18aa59b4095e919af108e40d4375e50c5f
Author: Alan Stern <stern@rowland.harvard.edu>
Date:   Tue Jun 30 11:25:54 2015 -0400

    USB: OHCI: Fix race between ED unlink and URB submission
    
    commit 7d8021c967648accd1b78e5e1ddaad655cd2c61f upstream.
    
    This patch fixes a bug introduced by commit 977dcfdc6031 ("USB: OHCI:
    don't lose track of EDs when a controller dies").  The commit changed
    ed_state from ED_UNLINK to ED_IDLE too early, before finish_urb() had
    been called.  The user-visible consequence is that the driver
    occasionally crashes or locks up when an URB is submitted while
    another URB for the same endpoint is being unlinked.
    
    This patch moves the ED state change later, to the right place.  The
    drawback is that now we may unnecessarily execute some instructions
    multiple times when a controller dies.  Since controllers dying is an
    exceptional occurrence, a little wasted time won't matter.
    
    Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
    Reported-by: Heiko Przybyl <lil_tux@web.de>
    Tested-by: Heiko Przybyl <lil_tux@web.de>
    Fixes: 977dcfdc60311e7aa571cabf6f39c36dde13339e
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3ea5e8ca5c4f15f1e8777dc12d345bab35746841
Author: Corentin Labbe <clabbe@baylibre.com>
Date:   Wed Feb 14 12:17:47 2018 +0000

    powerpc/pseries: Add empty update_numa_cpu_lookup_table() for NUMA=n
    
    commit c1e150ceb61e4a585bad156da15c33bfe89f5858 upstream.
    
    When CONFIG_NUMA is not set, the build fails with:
    
      arch/powerpc/platforms/pseries/hotplug-cpu.c:335:4:
      error: déclaration implicite de la fonction « update_numa_cpu_lookup_table »
    
    So we have to add update_numa_cpu_lookup_table() as an empty function
    when CONFIG_NUMA is not set.
    
    Fixes: 1d9a090783be ("powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove")
    Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6eab16489865086d2891939ea069d0983b9c44dd
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Wed Feb 14 17:21:19 2018 +0100

    netfilter: nat: cope with negative port range
    
    commit db57ccf0f2f4624b4c4758379f8165277504fbd7 upstream.
    
    syzbot reported a division by 0 bug in the netfilter nat code:
    
    divide error: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
        (ftrace buffer empty)
    Modules linked in:
    CPU: 1 PID: 4168 Comm: syzkaller034710 Not tainted 4.16.0-rc1+ #309
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    RIP: 0010:nf_nat_l4proto_unique_tuple+0x291/0x530
    net/netfilter/nf_nat_proto_common.c:88
    RSP: 0018:ffff8801b2466778 EFLAGS: 00010246
    RAX: 000000000000f153 RBX: ffff8801b2466dd8 RCX: ffff8801b2466c7c
    RDX: 0000000000000000 RSI: ffff8801b2466c58 RDI: ffff8801db5293ac
    RBP: ffff8801b24667d8 R08: ffff8801b8ba6dc0 R09: ffffffff88af5900
    R10: ffff8801b24666f0 R11: 0000000000000000 R12: 000000002990f153
    R13: 0000000000000001 R14: 0000000000000000 R15: ffff8801b2466c7c
    FS:  00000000017e3880(0000) GS:ffff8801db500000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000208fdfe4 CR3: 00000001b5340002 CR4: 00000000001606e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
      dccp_unique_tuple+0x40/0x50 net/netfilter/nf_nat_proto_dccp.c:30
      get_unique_tuple+0xc28/0x1c10 net/netfilter/nf_nat_core.c:362
      nf_nat_setup_info+0x1c2/0xe00 net/netfilter/nf_nat_core.c:406
      nf_nat_redirect_ipv6+0x306/0x730 net/netfilter/nf_nat_redirect.c:124
      redirect_tg6+0x7f/0xb0 net/netfilter/xt_REDIRECT.c:34
      ip6t_do_table+0xc2a/0x1a30 net/ipv6/netfilter/ip6_tables.c:365
      ip6table_nat_do_chain+0x65/0x80 net/ipv6/netfilter/ip6table_nat.c:41
      nf_nat_ipv6_fn+0x594/0xa80 net/ipv6/netfilter/nf_nat_l3proto_ipv6.c:302
      nf_nat_ipv6_local_fn+0x33/0x5d0
    net/ipv6/netfilter/nf_nat_l3proto_ipv6.c:407
      ip6table_nat_local_fn+0x2c/0x40 net/ipv6/netfilter/ip6table_nat.c:69
      nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
      nf_hook_slow+0xba/0x1a0 net/netfilter/core.c:483
      nf_hook include/linux/netfilter.h:243 [inline]
      NF_HOOK include/linux/netfilter.h:286 [inline]
      ip6_xmit+0x10ec/0x2260 net/ipv6/ip6_output.c:277
      inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139
      dccp_transmit_skb+0x9ac/0x10f0 net/dccp/output.c:142
      dccp_connect+0x369/0x670 net/dccp/output.c:564
      dccp_v6_connect+0xe17/0x1bf0 net/dccp/ipv6.c:946
      __inet_stream_connect+0x2d4/0xf00 net/ipv4/af_inet.c:620
      inet_stream_connect+0x58/0xa0 net/ipv4/af_inet.c:684
      SYSC_connect+0x213/0x4a0 net/socket.c:1639
      SyS_connect+0x24/0x30 net/socket.c:1620
      do_syscall_64+0x282/0x940 arch/x86/entry/common.c:287
      entry_SYSCALL_64_after_hwframe+0x26/0x9b
    RIP: 0033:0x441c69
    RSP: 002b:00007ffe50cc0be8 EFLAGS: 00000217 ORIG_RAX: 000000000000002a
    RAX: ffffffffffffffda RBX: ffffffffffffffff RCX: 0000000000441c69
    RDX: 000000000000001c RSI: 00000000208fdfe4 RDI: 0000000000000003
    RBP: 00000000006cc018 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000538 R11: 0000000000000217 R12: 0000000000403590
    R13: 0000000000403620 R14: 0000000000000000 R15: 0000000000000000
    Code: 48 89 f0 83 e0 07 83 c0 01 38 d0 7c 08 84 d2 0f 85 46 02 00 00 48 8b
    45 c8 44 0f b7 20 e8 88 97 04 fd 31 d2 41 0f b7 c4 4c 89 f9 <41> f7 f6 48
    c1 e9 03 48 b8 00 00 00 00 00 fc ff df 0f b6 0c 01
    RIP: nf_nat_l4proto_unique_tuple+0x291/0x530
    net/netfilter/nf_nat_proto_common.c:88 RSP: ffff8801b2466778
    
    The problem is that currently we don't have any check on the
    configured port range. A port range == -1 triggers the bug, while
    other negative values may require a very long time to complete the
    following loop.
    
    This commit addresses the issue swapping the two ends on negative
    ranges. The check is performed in nf_nat_l4proto_unique_tuple() since
    the nft nat loads the port values from nft registers at runtime.
    
    v1 -> v2: use the correct 'Fixes' tag
    v2 -> v3: update commit message, drop unneeded READ_ONCE()
    
    Fixes: 5b1158e909ec ("[NETFILTER]: Add NAT support for nf_conntrack")
    Reported-by: syzbot+8012e198bd037f4871e5@syzkaller.appspotmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.2: adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6fc3144cafdb021a9bd1f23dec7240d857834de4
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Mon Feb 12 18:49:39 2018 +0100

    netfilter: x_tables: fix missing timer initialization in xt_LED
    
    commit 10414014bc085aac9f787a5890b33b5605fbcfc4 upstream.
    
    syzbot reported that xt_LED may try to use the ledinternal->timer
    without previously initializing it:
    
    ------------[ cut here ]------------
    kernel BUG at kernel/time/timer.c:958!
    invalid opcode: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
        (ftrace buffer empty)
    Modules linked in:
    CPU: 1 PID: 1826 Comm: kworker/1:2 Not tainted 4.15.0+ #306
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    Workqueue: ipv6_addrconf addrconf_dad_work
    RIP: 0010:__mod_timer kernel/time/timer.c:958 [inline]
    RIP: 0010:mod_timer+0x7d6/0x13c0 kernel/time/timer.c:1102
    RSP: 0018:ffff8801d24fe9f8 EFLAGS: 00010293
    RAX: ffff8801d25246c0 RBX: ffff8801aec6cb50 RCX: ffffffff816052c6
    RDX: 0000000000000000 RSI: 00000000fffbd14b RDI: ffff8801aec6cb68
    RBP: ffff8801d24fec98 R08: 0000000000000000 R09: 1ffff1003a49fd6c
    R10: ffff8801d24feb28 R11: 0000000000000005 R12: dffffc0000000000
    R13: ffff8801d24fec70 R14: 00000000fffbd14b R15: ffff8801af608f90
    FS:  0000000000000000(0000) GS:ffff8801db500000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000206d6fd0 CR3: 0000000006a22001 CR4: 00000000001606e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
      led_tg+0x1db/0x2e0 net/netfilter/xt_LED.c:75
      ip6t_do_table+0xc2a/0x1a30 net/ipv6/netfilter/ip6_tables.c:365
      ip6table_raw_hook+0x65/0x80 net/ipv6/netfilter/ip6table_raw.c:42
      nf_hook_entry_hookfn include/linux/netfilter.h:120 [inline]
      nf_hook_slow+0xba/0x1a0 net/netfilter/core.c:483
      nf_hook.constprop.27+0x3f6/0x830 include/linux/netfilter.h:243
      NF_HOOK include/linux/netfilter.h:286 [inline]
      ndisc_send_skb+0xa51/0x1370 net/ipv6/ndisc.c:491
      ndisc_send_ns+0x38a/0x870 net/ipv6/ndisc.c:633
      addrconf_dad_work+0xb9e/0x1320 net/ipv6/addrconf.c:4008
      process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2113
      worker_thread+0x223/0x1990 kernel/workqueue.c:2247
      kthread+0x33c/0x400 kernel/kthread.c:238
      ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:429
    Code: 85 2a 0b 00 00 4d 8b 3c 24 4d 85 ff 75 9f 4c 8b bd 60 fd ff ff e8 bb
    57 10 00 65 ff 0d 94 9a a1 7e e9 d9 fc ff ff e8 aa 57 10 00 <0f> 0b e8 a3
    57 10 00 e9 14 fb ff ff e8 99 57 10 00 4c 89 bd 70
    RIP: __mod_timer kernel/time/timer.c:958 [inline] RSP: ffff8801d24fe9f8
    RIP: mod_timer+0x7d6/0x13c0 kernel/time/timer.c:1102 RSP: ffff8801d24fe9f8
    ---[ end trace f661ab06f5dd8b3d ]---
    
    The ledinternal struct can be shared between several different
    xt_LED targets, but the related timer is currently initialized only
    if the first target requires it. Fix it by unconditionally
    initializing the timer struct.
    
    v1 -> v2: call del_timer_sync() unconditionally, too.
    
    Fixes: 268cb38e1802 ("netfilter: x_tables: add LED trigger target")
    Reported-by: syzbot+10c98dc5725c6c8fc7fb@syzkaller.appspotmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.2: Keep using setup_timer()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 65b073589499cd4f2e9e3e94f491b6d7b47a8255
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Thu Feb 8 13:53:52 2018 -0800

    netfilter: ipt_CLUSTERIP: fix a refcount bug in clusterip_config_find_get()
    
    commit db93a3632b0f8773a3899e04a3a3e0aa7a26eb46 upstream.
    
    In clusterip_config_find_get() we hold RCU read lock so it could
    run concurrently with clusterip_config_entry_put(), as a result,
    the refcnt could go back to 1 from 0, which leads to a double
    list_del()... Just replace refcount_inc() with
    refcount_inc_not_zero(), as for c->refcount.
    
    Fixes: d73f33b16883 ("netfilter: CLUSTERIP: RCU conversion")
    Cc: Eric Dumazet <eric.dumazet@gmail.com>
    Cc: Pablo Neira Ayuso <pablo@netfilter.org>
    Cc: Florian Westphal <fw@strlen.de>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.2: s/refcount/atomic/]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0abb05a8cfd498a24ff4d290966e22fda3ee08e5
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Thu Feb 8 12:19:00 2018 +0100

    netfilter: drop outermost socket lock in getsockopt()
    
    commit 01ea306f2ac2baff98d472da719193e738759d93 upstream.
    
    The Syzbot reported a possible deadlock in the netfilter area caused by
    rtnl lock, xt lock and socket lock being acquired with a different order
    on different code paths, leading to the following backtrace:
    Reviewed-by: Xin Long <lucien.xin@gmail.com>
    
    ======================================================
    WARNING: possible circular locking dependency detected
    4.15.0+ #301 Not tainted
    ------------------------------------------------------
    syzkaller233489/4179 is trying to acquire lock:
      (rtnl_mutex){+.+.}, at: [<0000000048e996fd>] rtnl_lock+0x17/0x20
    net/core/rtnetlink.c:74
    
    but task is already holding lock:
      (&xt[i].mutex){+.+.}, at: [<00000000328553a2>]
    xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1041
    
    which lock already depends on the new lock.
    ===
    
    Since commit 3f34cfae1230 ("netfilter: on sockopt() acquire sock lock
    only in the required scope"), we already acquire the socket lock in
    the innermost scope, where needed. In such commit I forgot to remove
    the outer-most socket lock from the getsockopt() path, this commit
    addresses the issues dropping it now.
    
    v1 -> v2: fix bad subj, added relavant 'fixes' tag
    
    Fixes: 22265a5c3c10 ("netfilter: xt_TEE: resolve oif using netdevice notifiers")
    Fixes: 202f59afd441 ("netfilter: ipt_CLUSTERIP: do not hold dev")
    Fixes: 3f34cfae1230 ("netfilter: on sockopt() acquire sock lock only in the required scope")
    Reported-by: syzbot+ddde1c7b7ff7442d7f2d@syzkaller.appspotmail.com
    Suggested-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3a7b41121346d9d95bee48bf730882c91d1af7bd
Author: Jakub Kicinski <jakub.kicinski@netronome.com>
Date:   Mon Feb 12 21:35:31 2018 -0800

    net: fix race on decreasing number of TX queues
    
    commit ac5b70198adc25c73fba28de4f78adcee8f6be0b upstream.
    
    netif_set_real_num_tx_queues() can be called when netdev is up.
    That usually happens when user requests change of number of
    channels/rings with ethtool -L.  The procedure for changing
    the number of queues involves resetting the qdiscs and setting
    dev->num_tx_queues to the new value.  When the new value is
    lower than the old one, extra care has to be taken to ensure
    ordering of accesses to the number of queues vs qdisc reset.
    
    Currently the queues are reset before new dev->num_tx_queues
    is assigned, leaving a window of time where packets can be
    enqueued onto the queues going down, leading to a likely
    crash in the drivers, since most drivers don't check if TX
    skbs are assigned to an active queue.
    
    Fixes: e6484930d7c7 ("net: allocate tx queues in register_netdevice")
    Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1101a965a700cb8bc180437deb2f078873101930
Author: Florian Westphal <fw@strlen.de>
Date:   Mon Feb 12 14:42:01 2018 +0100

    xfrm_user: uncoditionally validate esn replay attribute struct
    
    commit d97ca5d714a5334aecadadf696875da40f1fbf3e upstream.
    
    The sanity test added in ecd7918745234 can be bypassed, validation
    only occurs if XFRM_STATE_ESN flag is set, but rest of code doesn't care
    and just checks if the attribute itself is present.
    
    So always validate.  Alternative is to reject if we have the attribute
    without the flag but that would change abi.
    
    Reported-by: syzbot+0ab777c27d2bb7588f73@syzkaller.appspotmail.com
    Cc: Mathias Krause <minipli@googlemail.com>
    Fixes: ecd7918745234 ("xfrm_user: ensure user supplied esn replay window is valid")
    Fixes: d8647b79c3b7e ("xfrm: Add user interface for esn and big anti-replay windows")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3238114f6cb75bf2a2224a4e0ba3b4dbdedc2f09
Author: Eric Biggers <ebiggers@google.com>
Date:   Sat Feb 3 20:33:27 2018 -0800

    libata: remove WARN() for DMA or PIO command without data
    
    commit 9173e5e80729c8434b8d27531527c5245f4a5594 upstream.
    
    syzkaller hit a WARN() in ata_qc_issue() when writing to /dev/sg0.  This
    happened because it issued a READ_6 command with no data buffer.
    
    Just remove the WARN(), as it doesn't appear indicate a kernel bug.  The
    expected behavior is to fail the command, which the code does.
    
    Here's a reproducer that works in QEMU when /dev/sg0 refers to a disk of
    the default type ("82371SB PIIX3 IDE"):
    
        #include <fcntl.h>
        #include <unistd.h>
    
        int main()
        {
                char buf[42] = { [36] = 0x8 /* READ_6 */ };
    
                write(open("/dev/sg0", O_RDWR), buf, sizeof(buf));
        }
    
    Fixes: f92a26365a72 ("libata: change ATA_QCFLAG_DMAMAP semantics")
    Reported-by: syzbot+f7b556d1766502a69d85071d2ff08bd87be53d0f@syzkaller.appspotmail.com
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1d53252419748b4198eaed4d467dcbf60b9a7685
Author: Eric Biggers <ebiggers@google.com>
Date:   Sat Feb 3 20:30:56 2018 -0800

    libata: fix length validation of ATAPI-relayed SCSI commands
    
    commit 058f58e235cbe03e923b30ea7c49995a46a8725f upstream.
    
    syzkaller reported a crash in ata_bmdma_fill_sg() when writing to
    /dev/sg1.  The immediate cause was that the ATA command's scatterlist
    was not DMA-mapped, which causes 'pi - 1' to underflow, resulting in a
    write to 'qc->ap->bmdma_prd[0xffffffff]'.
    
    Strangely though, the flag ATA_QCFLAG_DMAMAP was set in qc->flags.  The
    root cause is that when __ata_scsi_queuecmd() is preparing to relay a
    SCSI command to an ATAPI device, it doesn't correctly validate the CDB
    length before copying it into the 16-byte buffer 'cdb' in 'struct
    ata_queued_cmd'.  Namely, it validates the fixed CDB length expected
    based on the SCSI opcode but not the actual CDB length, which can be
    larger due to the use of the SG_NEXT_CMD_LEN ioctl.  Since 'flags' is
    the next member in ata_queued_cmd, a buffer overflow corrupts it.
    
    Fix it by requiring that the actual CDB length be <= 16 (ATAPI_CDB_LEN).
    
    [Really it seems the length should be required to be <= dev->cdb_len,
    but the current behavior seems to have been intentionally introduced by
    commit 607126c2a21c ("libata-scsi: be tolerant of 12-byte ATAPI commands
    in 16-byte CDBs") to work around a userspace bug in mplayer.  Probably
    the workaround is no longer needed (mplayer was fixed in 2007), but
    continuing to allow lengths to up 16 appears harmless for now.]
    
    Here's a reproducer that works in QEMU when /dev/sg1 refers to the
    CD-ROM drive that qemu-system-x86_64 creates by default:
    
        #include <fcntl.h>
        #include <sys/ioctl.h>
        #include <unistd.h>
    
        #define SG_NEXT_CMD_LEN 0x2283
    
        int main()
        {
                char buf[53] = { [36] = 0x7e, [52] = 0x02 };
                int fd = open("/dev/sg1", O_RDWR);
                ioctl(fd, SG_NEXT_CMD_LEN, &(int){ 17 });
                write(fd, buf, sizeof(buf));
        }
    
    The crash was:
    
        BUG: unable to handle kernel paging request at ffff8cb97db37ffc
        IP: ata_bmdma_fill_sg drivers/ata/libata-sff.c:2623 [inline]
        IP: ata_bmdma_qc_prep+0xa4/0xc0 drivers/ata/libata-sff.c:2727
        PGD fb6c067 P4D fb6c067 PUD 0
        Oops: 0002 [#1] SMP
        CPU: 1 PID: 150 Comm: syz_ata_bmdma_q Not tainted 4.15.0-next-20180202 #99
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
        [...]
        Call Trace:
         ata_qc_issue+0x100/0x1d0 drivers/ata/libata-core.c:5421
         ata_scsi_translate+0xc9/0x1a0 drivers/ata/libata-scsi.c:2024
         __ata_scsi_queuecmd drivers/ata/libata-scsi.c:4326 [inline]
         ata_scsi_queuecmd+0x8c/0x210 drivers/ata/libata-scsi.c:4375
         scsi_dispatch_cmd+0xa2/0xe0 drivers/scsi/scsi_lib.c:1727
         scsi_request_fn+0x24c/0x530 drivers/scsi/scsi_lib.c:1865
         __blk_run_queue_uncond block/blk-core.c:412 [inline]
         __blk_run_queue+0x3a/0x60 block/blk-core.c:432
         blk_execute_rq_nowait+0x93/0xc0 block/blk-exec.c:78
         sg_common_write.isra.7+0x272/0x5a0 drivers/scsi/sg.c:806
         sg_write+0x1ef/0x340 drivers/scsi/sg.c:677
         __vfs_write+0x31/0x160 fs/read_write.c:480
         vfs_write+0xa7/0x160 fs/read_write.c:544
         SYSC_write fs/read_write.c:589 [inline]
         SyS_write+0x4d/0xc0 fs/read_write.c:581
         do_syscall_64+0x5e/0x110 arch/x86/entry/common.c:287
         entry_SYSCALL_64_after_hwframe+0x21/0x86
    
    Fixes: 607126c2a21c ("libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs")
    Reported-by: syzbot+1ff6f9fcc3c35f1c72a95e26528c8e7e3276e4da@syzkaller.appspotmail.com
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 72ad0a39cb3603787cca30e395f8cdb7dd911d2b
Author: Xin Long <lucien.xin@gmail.com>
Date:   Mon Feb 12 17:15:40 2018 +0800

    bridge: check brport attr show in brport_show
    
    commit 1b12580af1d0677c3c3a19e35bfe5d59b03f737f upstream.
    
    Now br_sysfs_if file flush doesn't have attr show. To read it will
    cause kernel panic after users chmod u+r this file.
    
    Xiong found this issue when running the commands:
    
      ip link add br0 type bridge
      ip link add type veth
      ip link set veth0 master br0
      chmod u+r /sys/devices/virtual/net/veth0/brport/flush
      timeout 3 cat /sys/devices/virtual/net/veth0/brport/flush
    
    kernel crashed with NULL a pointer dereference call trace.
    
    This patch is to fix it by return -EINVAL when brport_attr->show
    is null, just the same as the check for brport_attr->store in
    brport_store().
    
    Fixes: 9cf637473c85 ("bridge: add sysfs hook to flush forwarding table")
    Reported-by: Xiong Zhou <xzhou@redhat.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e05562277a05559c66476a1a32b4f43d493544a8
Author: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date:   Fri Jan 12 18:18:05 2018 -0800

    usb: dwc3: gadget: Set maxpacket size for ep0 IN
    
    commit 6180026341e852a250e1f97ebdcf71684a3c81b9 upstream.
    
    There are 2 control endpoint structures for DWC3. However, the driver
    only updates the OUT direction control endpoint structure during
    ConnectDone event. DWC3 driver needs to update the endpoint max packet
    size for control IN endpoint as well. If the max packet size is not
    properly set, then the driver will incorrectly calculate the data
    transfer size and fail to send ZLP for HS/FS 3-stage control read
    transfer.
    
    The fix is simply to update the max packet size for the ep0 IN direction
    during ConnectDone event.
    
    Fixes: 72246da40f37 ("usb: Introduce DesignWare USB3 DRD Driver")
    Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
    Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 37ecb938a4cd48d87492c16ea3e7d843a9513b38
Author: Zhang Bo <zbsdta@126.com>
Date:   Mon Feb 5 14:56:21 2018 -0800

    Input: matrix_keypad - fix race when disabling interrupts
    
    commit ea4f7bd2aca9f68470e9aac0fc9432fd180b1fe7 upstream.
    
    If matrix_keypad_stop() is executing and the keypad interrupt is triggered,
    disable_row_irqs() may be called by both matrix_keypad_interrupt() and
    matrix_keypad_stop() at the same time, causing interrupts to be disabled
    twice and the keypad being "stuck" after resuming.
    
    Take lock when setting keypad->stopped to ensure that ISR will not race
    with matrix_keypad_stop() disabling interrupts.
    
    Signed-off-by: Zhang Bo <zbsdta@126.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7aa2c8a3d19e27d8913b66e4f0e09ee86d56095e
Author: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Date:   Fri Feb 9 11:03:50 2018 +0100

    s390/qeth: fix SETIP command handling
    
    commit 1c5b2216fbb973a9410e0b06389740b5c1289171 upstream.
    
    send_control_data() applies some special handling to SETIP v4 IPA
    commands. But current code parses *all* command types for the SETIP
    command code. Limit the command code check to IPA commands.
    
    Fixes: 5b54e16f1a54 ("qeth: do not spin for SETIP ip assist command")
    Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 498f0cc811a3fb51e374c8a2d1fe18dd352d1495
Author: Greg Kurz <groug@kaod.org>
Date:   Mon Jan 22 22:02:05 2018 +0100

    9p/trans_virtio: discard zero-length reply
    
    commit 26d99834f89e76514076d9cd06f61e56e6a509b8 upstream.
    
    When a 9p request is successfully flushed, the server is expected to just
    mark it as used without sending a 9p reply (ie, without writing data into
    the buffer). In this case, virtqueue_get_buf() will return len == 0 and
    we must not report a REQ_STATUS_RCVD status to the client, otherwise the
    client will erroneously assume the request has not been flushed.
    
    Signed-off-by: Greg Kurz <groug@kaod.org>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9ecf90b305220eade0a5634e6e604cf0e4fed796
Author: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date:   Wed Mar 14 21:10:23 2018 +0100

    netlink: avoid a double skb free in genlmsg_mcast()
    
    commit 02a2385f37a7c6594c9d89b64c4a1451276f08eb upstream.
    
    nlmsg_multicast() consumes always the skb, thus the original skb must be
    freed only when this function is called with a clone.
    
    Fixes: cb9f7a9a5c96 ("netlink: ensure to loop over all netns in genlmsg_multicast_allns()")
    Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ab38ffccdf4e0b86b8e6be1ff8c7ce53df74c4ec
Author: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date:   Tue Feb 6 14:48:32 2018 +0100

    netlink: ensure to loop over all netns in genlmsg_multicast_allns()
    
    commit cb9f7a9a5c96a773bbc9c70660dc600cfff82f82 upstream.
    
    Nowadays, nlmsg_multicast() returns only 0 or -ESRCH but this was not the
    case when commit 134e63756d5f was pushed.
    However, there was no reason to stop the loop if a netns does not have
    listeners.
    Returns -ESRCH only if there was no listeners in all netns.
    
    To avoid having the same problem in the future, I didn't take the
    assumption that nlmsg_multicast() returns only 0 or -ESRCH.
    
    Fixes: 134e63756d5f ("genetlink: make netns aware")
    CC: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2: s/portid/pid/]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bbac54a340725967fc76de730f384503bfcb835e
Author: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Date:   Fri Jan 26 13:41:59 2018 -0600

    powerpc/numa: Invalidate numa_cpu_lookup_table on cpu remove
    
    commit 1d9a090783bef19fe8cdec878620d22f05191316 upstream.
    
    When DLPAR removing a CPU, the unmapping of the cpu from a node in
    unmap_cpu_from_node() should also invalidate the CPUs entry in the
    numa_cpu_lookup_table. There is not a guarantee that on a subsequent
    DLPAR add of the CPU the associativity will be the same and thus
    could be in a different node. Invalidating the entry in the
    numa_cpu_lookup_table causes the associativity to be read from the
    device tree at the time of the add.
    
    The current behavior of not invalidating the CPUs entry in the
    numa_cpu_lookup_table can result in scenarios where the the topology
    layout of CPUs in the partition does not match the device tree
    or the topology reported by the HMC.
    
    This bug looks like it was introduced in 2004 in the commit titled
    "ppc64: cpu hotplug notifier for numa", which is 6b15e4e87e32 in the
    linux-fullhist tree. Hence tag it for all stable releases.
    
    Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
    Reviewed-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    [bwh: Backported to 3.2:
     - update_numa_cpu_lookup_table() wasn't defined anywhere before
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dc6b17441d28393b827e96b735c40377a68b1111
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Mon Feb 5 14:41:45 2018 -0800

    netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert
    
    commit 7dc68e98757a8eccf8ca7a53a29b896f1eef1f76 upstream.
    
    rateest_hash is supposed to be protected by xt_rateest_mutex,
    and, as suggested by Eric, lookup and insert should be atomic,
    so we should acquire the xt_rateest_mutex once for both.
    
    So introduce a non-locking helper for internal use and keep the
    locking one for external.
    
    Reported-by: <syzbot+5cb189720978275e4c75@syzkaller.appspotmail.com>
    Fixes: 5859034d7eb8 ("[NETFILTER]: x_tables: add RATEEST target")
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Reviewed-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0846479232c94660b2f62d9390da3e8fbfc6d337
Author: Matt Redfearn <matt.redfearn@mips.com>
Date:   Mon Jan 29 11:26:45 2018 +0000

    MIPS: TXx9: use IS_BUILTIN() for CONFIG_LEDS_CLASS
    
    commit 0cde5b44a30f1daaef1c34e08191239dc63271c4 upstream.
    
    When commit b27311e1cace ("MIPS: TXx9: Add RBTX4939 board support")
    added board support for the RBTX4939, it added a call to
    led_classdev_register even if the LED class is built as a module.
    Built-in arch code cannot call module code directly like this. Commit
    b33b44073734 ("MIPS: TXX9: use IS_ENABLED() macro") subsequently
    changed the inclusion of this code to a single check that
    CONFIG_LEDS_CLASS is either builtin or a module, but the same issue
    remains.
    
    This leads to MIPS allmodconfig builds failing when CONFIG_MACH_TX49XX=y
    is set:
    
    arch/mips/txx9/rbtx4939/setup.o: In function `rbtx4939_led_probe':
    setup.c:(.init.text+0xc0): undefined reference to `of_led_classdev_register'
    make: *** [Makefile:999: vmlinux] Error 1
    
    Fix this by using the IS_BUILTIN() macro instead.
    
    Fixes: b27311e1cace ("MIPS: TXx9: Add RBTX4939 board support")
    Signed-off-by: Matt Redfearn <matt.redfearn@mips.com>
    Reviewed-by: James Hogan <jhogan@kernel.org>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18544/
    Signed-off-by: James Hogan <jhogan@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 03840a6ce87cd9a020d37b8d685f3dd89c7fd1ff
Author: Florian Fainelli <florian@openwrt.org>
Date:   Tue Jan 31 18:19:05 2012 +0100

    MIPS: TXX9: use IS_ENABLED() macro
    
    commit b33b44073734842ec0c75d376c40d0471d6113ff upstream.
    
    Signed-off-by: Florian Fainelli <florian@openwrt.org>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/3334/
    Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8d4bc4c9b764f294f639887aca19265133048f1c
Author: Jean Delvare <jdelvare@suse.de>
Date:   Sat Feb 3 11:25:20 2018 +0100

    firmware: dmi_scan: Fix handling of empty DMI strings
    
    commit a7770ae194569e96a93c48aceb304edded9cc648 upstream.
    
    The handling of empty DMI strings looks quite broken to me:
    * Strings from 1 to 7 spaces are not considered empty.
    * True empty DMI strings (string index set to 0) are not considered
      empty, and result in allocating a 0-char string.
    * Strings with invalid index also result in allocating a 0-char
      string.
    * Strings starting with 8 spaces are all considered empty, even if
      non-space characters follow (sounds like a weird thing to do, but
      I have actually seen occurrences of this in DMI tables before.)
    * Strings which are considered empty are reported as 8 spaces,
      instead of being actually empty.
    
    Some of these issues are the result of an off-by-one error in memcmp,
    the rest is incorrect by design.
    
    So let's get it square: missing strings and strings made of only
    spaces, regardless of their length, should be treated as empty and
    no memory should be allocated for them. All other strings are
    non-empty and should be allocated.
    
    Signed-off-by: Jean Delvare <jdelvare@suse.de>
    Fixes: 79da4721117f ("x86: fix DMI out of memory problems")
    Cc: Parag Warudkar <parag.warudkar@gmail.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 6f5913017efcb8f08d80bdc39edb36956c6e4ab2
Author: Jean Delvare <jdelvare@suse.de>
Date:   Wed Sep 11 14:24:09 2013 -0700

    firmware/dmi_scan: constify strings
    
    commit ffbbb96dd7570b9aafd426cd77a7ee03d224cabf upstream.
    
    Add const to all DMI string pointers where this is possible.  This fixes a
    checkpatch warning.
    
    Signed-off-by: Jean Delvare <jdelvare@suse.de>
    Cc: Joe Perches <joe@perches.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9c6a3641db87910a3e7cc0a63095a2ac1a9df41c
Author: Liu Bo <bo.li.liu@oracle.com>
Date:   Thu Jan 25 11:02:52 2018 -0700

    Btrfs: fix extent state leak from tree log
    
    commit 55237a5f2431a72435e3ed39e4306e973c0446b7 upstream.
    
    It's possible that btrfs_sync_log() bails out after one of the two
    btrfs_write_marked_extents() which convert extent state's state bit into
    EXTENT_NEED_WAIT from EXTENT_DIRTY/EXTENT_NEW, however only EXTENT_DIRTY
    and EXTENT_NEW are searched by free_log_tree() so that those extent states
    with EXTENT_NEED_WAIT lead to memory leak.
    
    Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
    Reviewed-by: Josef Bacik <jbacik@fb.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 504bc042094b80a7fcfd8d7efb2f391301f6c611
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Feb 1 10:26:57 2018 -0800

    net: igmp: add a missing rcu locking section
    
    commit e7aadb27a5415e8125834b84a74477bfbee4eff5 upstream.
    
    Newly added igmpv3_get_srcaddr() needs to be called under rcu lock.
    
    Timer callbacks do not ensure this locking.
    
    =============================
    WARNING: suspicious RCU usage
    4.15.0+ #200 Not tainted
    -----------------------------
    ./include/linux/inetdevice.h:216 suspicious rcu_dereference_check() usage!
    
    other info that might help us debug this:
    
    rcu_scheduler_active = 2, debug_locks = 1
    3 locks held by syzkaller616973/4074:
     #0:  (&mm->mmap_sem){++++}, at: [<00000000bfce669e>] __do_page_fault+0x32d/0xc90 arch/x86/mm/fault.c:1355
     #1:  ((&im->timer)){+.-.}, at: [<00000000619d2f71>] lockdep_copy_map include/linux/lockdep.h:178 [inline]
     #1:  ((&im->timer)){+.-.}, at: [<00000000619d2f71>] call_timer_fn+0x1c6/0x820 kernel/time/timer.c:1316
     #2:  (&(&im->lock)->rlock){+.-.}, at: [<000000005f833c5c>] spin_lock_bh include/linux/spinlock.h:315 [inline]
     #2:  (&(&im->lock)->rlock){+.-.}, at: [<000000005f833c5c>] igmpv3_send_report+0x98/0x5b0 net/ipv4/igmp.c:600
    
    stack backtrace:
    CPU: 0 PID: 4074 Comm: syzkaller616973 Not tainted 4.15.0+ #200
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     <IRQ>
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x194/0x257 lib/dump_stack.c:53
     lockdep_rcu_suspicious+0x123/0x170 kernel/locking/lockdep.c:4592
     __in_dev_get_rcu include/linux/inetdevice.h:216 [inline]
     igmpv3_get_srcaddr net/ipv4/igmp.c:329 [inline]
     igmpv3_newpack+0xeef/0x12e0 net/ipv4/igmp.c:389
     add_grhead.isra.27+0x235/0x300 net/ipv4/igmp.c:432
     add_grec+0xbd3/0x1170 net/ipv4/igmp.c:565
     igmpv3_send_report+0xd5/0x5b0 net/ipv4/igmp.c:605
     igmp_send_report+0xc43/0x1050 net/ipv4/igmp.c:722
     igmp_timer_expire+0x322/0x5c0 net/ipv4/igmp.c:831
     call_timer_fn+0x228/0x820 kernel/time/timer.c:1326
     expire_timers kernel/time/timer.c:1363 [inline]
     __run_timers+0x7ee/0xb70 kernel/time/timer.c:1666
     run_timer_softirq+0x4c/0x70 kernel/time/timer.c:1692
     __do_softirq+0x2d7/0xb85 kernel/softirq.c:285
     invoke_softirq kernel/softirq.c:365 [inline]
     irq_exit+0x1cc/0x200 kernel/softirq.c:405
     exiting_irq arch/x86/include/asm/apic.h:541 [inline]
     smp_apic_timer_interrupt+0x16b/0x700 arch/x86/kernel/apic/apic.c:1052
     apic_timer_interrupt+0xa9/0xb0 arch/x86/entry/entry_64.S:938
    
    Fixes: a46182b00290 ("net: igmp: Use correct source address on IGMPv3 reports")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 040c686caa16b1b7018c0d132f48d76474b0b930
Author: Mel Gorman <mgorman@techsingularity.net>
Date:   Wed Jan 31 16:19:52 2018 -0800

    mm: pin address_space before dereferencing it while isolating an LRU page
    
    commit 69d763fc6d3aee787a3e8c8c35092b4f4960fa5d upstream.
    
    Minchan Kim asked the following question -- what locks protects
    address_space destroying when race happens between inode trauncation and
    __isolate_lru_page? Jan Kara clarified by describing the race as follows
    
    CPU1                                            CPU2
    
    truncate(inode)                                 __isolate_lru_page()
      ...
      truncate_inode_page(mapping, page);
        delete_from_page_cache(page)
          spin_lock_irqsave(&mapping->tree_lock, flags);
            __delete_from_page_cache(page, NULL)
              page_cache_tree_delete(..)
                ...                                   mapping = page_mapping(page);
                page->mapping = NULL;
                ...
          spin_unlock_irqrestore(&mapping->tree_lock, flags);
          page_cache_free_page(mapping, page)
            put_page(page)
              if (put_page_testzero(page)) -> false
    - inode now has no pages and can be freed including embedded address_space
    
                                                      if (mapping && !mapping->a_ops->migratepage)
    - we've dereferenced mapping which is potentially already free.
    
    The race is theoretically possible but unlikely.  Before the
    delete_from_page_cache, truncate_cleanup_page is called so the page is
    likely to be !PageDirty or PageWriteback which gets skipped by the only
    caller that checks the mappping in __isolate_lru_page.  Even if the race
    occurs, a substantial amount of work has to happen during a tiny window
    with no preemption but it could potentially be done using a virtual
    machine to artifically slow one CPU or halt it during the critical
    window.
    
    This patch should eliminate the race with truncation by try-locking the
    page before derefencing mapping and aborting if the lock was not
    acquired.  There was a suggestion from Huang Ying to use RCU as a
    side-effect to prevent mapping being freed.  However, I do not like the
    solution as it's an unconventional means of preserving a mapping and
    it's not a context where rcu_read_lock is obviously protecting rcu data.
    
    Link: http://lkml.kernel.org/r/20180104102512.2qos3h5vqzeisrek@techsingularity.net
    Fixes: c82449352854 ("mm: compaction: make isolate_lru_page() filter-aware again")
    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Acked-by: Minchan Kim <minchan@kernel.org>
    Cc: "Huang, Ying" <ying.huang@intel.com>
    Cc: Jan Kara <jack@suse.cz>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 22204d496323e6abd5ed3ab4d251fd473543e7ff
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Tue Jan 30 19:01:40 2018 +0100

    netfilter: on sockopt() acquire sock lock only in the required scope
    
    commit 3f34cfae1238848fd53f25e5c8fd59da57901f4b upstream.
    
    Syzbot reported several deadlocks in the netfilter area caused by
    rtnl lock and socket lock being acquired with a different order on
    different code paths, leading to backtraces like the following one:
    
    ======================================================
    WARNING: possible circular locking dependency detected
    4.15.0-rc9+ #212 Not tainted
    ------------------------------------------------------
    syzkaller041579/3682 is trying to acquire lock:
      (sk_lock-AF_INET6){+.+.}, at: [<000000008775e4dd>] lock_sock
    include/net/sock.h:1463 [inline]
      (sk_lock-AF_INET6){+.+.}, at: [<000000008775e4dd>]
    do_ipv6_setsockopt.isra.8+0x3c5/0x39d0 net/ipv6/ipv6_sockglue.c:167
    
    but task is already holding lock:
      (rtnl_mutex){+.+.}, at: [<000000004342eaa9>] rtnl_lock+0x17/0x20
    net/core/rtnetlink.c:74
    
    which lock already depends on the new lock.
    
    the existing dependency chain (in reverse order) is:
    
    -> #1 (rtnl_mutex){+.+.}:
            __mutex_lock_common kernel/locking/mutex.c:756 [inline]
            __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
            mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
            rtnl_lock+0x17/0x20 net/core/rtnetlink.c:74
            register_netdevice_notifier+0xad/0x860 net/core/dev.c:1607
            tee_tg_check+0x1a0/0x280 net/netfilter/xt_TEE.c:106
            xt_check_target+0x22c/0x7d0 net/netfilter/x_tables.c:845
            check_target net/ipv6/netfilter/ip6_tables.c:538 [inline]
            find_check_entry.isra.7+0x935/0xcf0
    net/ipv6/netfilter/ip6_tables.c:580
            translate_table+0xf52/0x1690 net/ipv6/netfilter/ip6_tables.c:749
            do_replace net/ipv6/netfilter/ip6_tables.c:1165 [inline]
            do_ip6t_set_ctl+0x370/0x5f0 net/ipv6/netfilter/ip6_tables.c:1691
            nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
            nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
            ipv6_setsockopt+0x115/0x150 net/ipv6/ipv6_sockglue.c:928
            udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
            sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
            SYSC_setsockopt net/socket.c:1849 [inline]
            SyS_setsockopt+0x189/0x360 net/socket.c:1828
            entry_SYSCALL_64_fastpath+0x29/0xa0
    
    -> #0 (sk_lock-AF_INET6){+.+.}:
            lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3914
            lock_sock_nested+0xc2/0x110 net/core/sock.c:2780
            lock_sock include/net/sock.h:1463 [inline]
            do_ipv6_setsockopt.isra.8+0x3c5/0x39d0 net/ipv6/ipv6_sockglue.c:167
            ipv6_setsockopt+0xd7/0x150 net/ipv6/ipv6_sockglue.c:922
            udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
            sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
            SYSC_setsockopt net/socket.c:1849 [inline]
            SyS_setsockopt+0x189/0x360 net/socket.c:1828
            entry_SYSCALL_64_fastpath+0x29/0xa0
    
    other info that might help us debug this:
    
      Possible unsafe locking scenario:
    
            CPU0                    CPU1
            ----                    ----
       lock(rtnl_mutex);
                                    lock(sk_lock-AF_INET6);
                                    lock(rtnl_mutex);
       lock(sk_lock-AF_INET6);
    
      *** DEADLOCK ***
    
    1 lock held by syzkaller041579/3682:
      #0:  (rtnl_mutex){+.+.}, at: [<000000004342eaa9>] rtnl_lock+0x17/0x20
    net/core/rtnetlink.c:74
    
    The problem, as Florian noted, is that nf_setsockopt() is always
    called with the socket held, even if the lock itself is required only
    for very tight scopes and only for some operation.
    
    This patch addresses the issues moving the lock_sock() call only
    where really needed, namely in ipv*_getorigdst(), so that nf_setsockopt()
    does not need anymore to acquire both locks.
    
    Fixes: 22265a5c3c10 ("netfilter: xt_TEE: resolve oif using netdevice notifiers")
    Reported-by: syzbot+a4c2dc980ac1af699b36@syzkaller.appspotmail.com
    Suggested-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    [bwh: Backported to 3.2: Drop changes to ipv6_getorigdst()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3f58460c0e71b46a812dad1831b92149ee785071
Author: Dmitry Vyukov <dvyukov@google.com>
Date:   Tue Jan 30 15:21:34 2018 +0100

    netfilter: ipt_CLUSTERIP: fix out-of-bounds accesses in clusterip_tg_check()
    
    commit 1a38956cce5eabd7b74f94bab70265e4df83165e upstream.
    
    Commit 136e92bbec0a switched local_nodes from an array to a bitmask
    but did not add proper bounds checks. As the result
    clusterip_config_init_nodelist() can both over-read
    ipt_clusterip_tgt_info.local_nodes and over-write
    clusterip_config.local_nodes.
    
    Add bounds checks for both.
    
    Fixes: 136e92bbec0a ("[NETFILTER] CLUSTERIP: use a bitmap to store node responsibility data")
    Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit da6941f4cc37699b2ff3894d279ca439548f768a
Author: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
Date:   Tue Jan 23 20:11:32 2018 -0600

    scsi: ibmvfc: fix misdefined reserved field in ibmvfc_fcp_rsp_info
    
    commit c39813652700f3df552b6557530f1e5f782dbe2f upstream.
    
    The fcp_rsp_info structure as defined in the FC spec has an initial 3
    bytes reserved field. The ibmvfc driver mistakenly defined this field as
    4 bytes resulting in the rsp_code field being defined in what should be
    the start of the second reserved field and thus always being reported as
    zero by the driver.
    
    Ideally, we should wire ibmvfc up with libfc for the sake of code
    deduplication, and ease of maintaining standardized structures in a
    single place. However, for now simply fixup the definition in ibmvfc for
    backporting to distros on older kernels. Wiring up with libfc will be
    done in a followup patch.
    
    Reported-by: Hannes Reinecke <hare@suse.de>
    Signed-off-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c86fd4aa55bf7729931aa4aeafb5383e049bedd1
Author: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Date:   Wed Jan 24 06:01:57 2018 -0500

    media: cxusb, dib0700: ignore XC2028_I2C_FLUSH
    
    commit 9893b905e743ded332575ca04486bd586c0772f7 upstream.
    
    The XC2028_I2C_FLUSH only needs to be implemented on a few
    devices. Others can safely ignore it.
    
    That prevents filling the dmesg with lots of messages like:
    
            dib0700: stk7700ph_xc3028_callback: unknown command 2, arg 0
    
    Fixes: 4d37ece757a8 ("[media] tuner/xc2028: Add I2C flush callback")
    Reported-by: Enrico Mioso <mrkiko.rs@gmail.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
    [bwh: Backported to 3.2: adjust filenames]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3ab6569af58314342d8630502cd783b2d0135914
Author: Jake Daryll Obina <jake.obina@gmail.com>
Date:   Fri Sep 22 00:00:14 2017 +0800

    jffs2: Fix use-after-free bug in jffs2_iget()'s error handling path
    
    commit 5bdd0c6f89fba430e18d636493398389dadc3b17 upstream.
    
    If jffs2_iget() fails for a newly-allocated inode, jffs2_do_clear_inode()
    can get called twice in the error handling path, the first call in
    jffs2_iget() itself and the second through iget_failed(). This can result
    to a use-after-free error in the second jffs2_do_clear_inode() call, such
    as shown by the oops below wherein the second jffs2_do_clear_inode() call
    was trying to free node fragments that were already freed in the first
    jffs2_do_clear_inode() call.
    
    [   78.178860] jffs2: error: (1904) jffs2_do_read_inode_internal: CRC failed for read_inode of inode 24 at physical location 0x1fc00c
    [   78.178914] Unable to handle kernel paging request at virtual address 6b6b6b6b6b6b6b7b
    [   78.185871] pgd = ffffffc03a567000
    [   78.188794] [6b6b6b6b6b6b6b7b] *pgd=0000000000000000, *pud=0000000000000000
    [   78.194968] Internal error: Oops: 96000004 [#1] PREEMPT SMP
    ...
    [   78.513147] PC is at rb_first_postorder+0xc/0x28
    [   78.516503] LR is at jffs2_kill_fragtree+0x28/0x90 [jffs2]
    [   78.520672] pc : [<ffffff8008323d28>] lr : [<ffffff8000eb1cc8>] pstate: 60000105
    [   78.526757] sp : ffffff800cea38f0
    [   78.528753] x29: ffffff800cea38f0 x28: ffffffc01f3f8e80
    [   78.532754] x27: 0000000000000000 x26: ffffff800cea3c70
    [   78.536756] x25: 00000000dc67c8ae x24: ffffffc033d6945d
    [   78.540759] x23: ffffffc036811740 x22: ffffff800891a5b8
    [   78.544760] x21: 0000000000000000 x20: 0000000000000000
    [   78.548762] x19: ffffffc037d48910 x18: ffffff800891a588
    [   78.552764] x17: 0000000000000800 x16: 0000000000000c00
    [   78.556766] x15: 0000000000000010 x14: 6f2065646f6e695f
    [   78.560767] x13: 6461657220726f66 x12: 2064656c69616620
    [   78.564769] x11: 435243203a6c616e x10: 7265746e695f6564
    [   78.568771] x9 : 6f6e695f64616572 x8 : ffffffc037974038
    [   78.572774] x7 : bbbbbbbbbbbbbbbb x6 : 0000000000000008
    [   78.576775] x5 : 002f91d85bd44a2f x4 : 0000000000000000
    [   78.580777] x3 : 0000000000000000 x2 : 000000403755e000
    [   78.584779] x1 : 6b6b6b6b6b6b6b6b x0 : 6b6b6b6b6b6b6b6b
    ...
    [   79.038551] [<ffffff8008323d28>] rb_first_postorder+0xc/0x28
    [   79.042962] [<ffffff8000eb5578>] jffs2_do_clear_inode+0x88/0x100 [jffs2]
    [   79.048395] [<ffffff8000eb9ddc>] jffs2_evict_inode+0x3c/0x48 [jffs2]
    [   79.053443] [<ffffff8008201ca8>] evict+0xb0/0x168
    [   79.056835] [<ffffff8008202650>] iput+0x1c0/0x200
    [   79.060228] [<ffffff800820408c>] iget_failed+0x30/0x3c
    [   79.064097] [<ffffff8000eba0c0>] jffs2_iget+0x2d8/0x360 [jffs2]
    [   79.068740] [<ffffff8000eb0a60>] jffs2_lookup+0xe8/0x130 [jffs2]
    [   79.073434] [<ffffff80081f1a28>] lookup_slow+0x118/0x190
    [   79.077435] [<ffffff80081f4708>] walk_component+0xfc/0x28c
    [   79.081610] [<ffffff80081f4dd0>] path_lookupat+0x84/0x108
    [   79.085699] [<ffffff80081f5578>] filename_lookup+0x88/0x100
    [   79.089960] [<ffffff80081f572c>] user_path_at_empty+0x58/0x6c
    [   79.094396] [<ffffff80081ebe14>] vfs_statx+0xa4/0x114
    [   79.098138] [<ffffff80081ec44c>] SyS_newfstatat+0x58/0x98
    [   79.102227] [<ffffff800808354c>] __sys_trace_return+0x0/0x4
    [   79.106489] Code: d65f03c0 f9400001 b40000e1 aa0103e0 (f9400821)
    
    The jffs2_do_clear_inode() call in jffs2_iget() is unnecessary since
    iget_failed() will eventually call jffs2_do_clear_inode() if needed, so
    just remove it.
    
    Fixes: 5451f79f5f81 ("iget: stop JFFS2 from using iget() and read_inode()")
    Reviewed-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: Jake Daryll Obina <jake.obina@gmail.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9b5cc5e057e2e65c035932ff56fd796a6314307f
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Jan 25 09:48:55 2018 +0100

    USB: serial: pl2303: new device id for Chilitag
    
    commit d08dd3f3dd2ae351b793fc5b76abdbf0fd317b12 upstream.
    
    This adds a new device id for Chilitag devices to the pl2303 driver.
    
    Reported-by: "Chu.Mike [朱堅宜]" <Mike-Chu@prolific.com.tw>
    Acked-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 369813ffa51bbc02e0932fb2dd1e5f3374789dfa
Author: Matthew Wilcox <mawilcox@microsoft.com>
Date:   Fri Dec 15 12:48:32 2017 -0800

    cifs: Fix missing put_xid in cifs_file_strict_mmap
    
    commit f04a703c3d613845ae3141bfaf223489de8ab3eb upstream.
    
    If cifs_zap_mapping() returned an error, we would return without putting
    the xid that we got earlier.  Restructure cifs_file_strict_mmap() and
    cifs_file_mmap() to be more similar to each other and have a single
    point of return that always puts the xid.
    
    Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 50a44c165a67ff0b7e14d221af6cb6c1035aa90a
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Jan 10 12:39:03 2018 +0300

    HID: roccat: prevent an out of bounds read in kovaplus_profile_activated()
    
    commit 7ad81482cad67cbe1ec808490d1ddfc420c42008 upstream.
    
    We get the "new_profile_index" value from the mouse device when we're
    handling raw events.  Smatch taints it as untrusted data and complains
    that we need a bounds check.  This seems like a reasonable warning
    otherwise there is a small read beyond the end of the array.
    
    Fixes: 0e70f97f257e ("HID: roccat: Add support for Kova[+] mouse")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Acked-by: Silvan Jegen <s.jegen@gmail.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f064e3c7e09390ea48a5fbda0528e145fba432b5
Author: Eugene Syromiatnikov <esyr@redhat.com>
Date:   Mon Jan 15 20:38:17 2018 +0100

    s390: fix handling of -1 in set{,fs}[gu]id16 syscalls
    
    commit 6dd0d2d22aa363fec075cb2577ba273ac8462e94 upstream.
    
    For some reason, the implementation of some 16-bit ID system calls
    (namely, setuid16/setgid16 and setfsuid16/setfsgid16) used type cast
    instead of low2highgid/low2highuid macros for converting [GU]IDs, which
    led to incorrect handling of value of -1 (which ought to be considered
    invalid).
    
    Discovered by strace test suite.
    
    Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
    Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2957236b68e747eff5ab9176448b906042af9ff7
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu Jan 18 14:16:38 2018 +0100

    scsi: fas216: fix sense buffer initialization
    
    commit 96d5eaa9bb74d299508d811d865c2c41b38b0301 upstream.
    
    While testing with the ARM specific memset() macro removed, I ran into a
    compiler warning that shows an old bug:
    
    drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':
    drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
    
    It turns out that the definition of the scsi_cmd structure changed back
    in linux-2.6.25, so now we clear only four bytes (sizeof(pointer))
    instead of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we
    actually need to initialize the buffer here, but it's clear that if we
    do it, we should use the correct size.
    
    Fixes: de25deb18016 ("[SCSI] use dynamically allocated sense buffer")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 97aa6ff70517ec6281981ade753e6abca3fa1b7e
Author: Oliver Neukum <oneukum@suse.com>
Date:   Thu Jan 18 12:13:45 2018 +0100

    CDC-ACM: apply quirk for card reader
    
    commit df1cc78a52491f71d8170d513d0f6f114faa1bda upstream.
    
    This devices drops random bytes from messages if you talk to it
    too fast.
    
    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 629bfb9f6b0d47c4ec805ec587acca059b68e924
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Tue Jan 2 14:01:34 2018 -0500

    alpha: fix crash if pthread_create races with signal delivery
    
    commit 21ffceda1c8b3807615c40d440d7815e0c85d366 upstream.
    
    On alpha, a process will crash if it attempts to start a thread and a
    signal is delivered at the same time. The crash can be reproduced with
    this program: https://cygwin.com/ml/cygwin/2014-11/msg00473.html
    
    The reason for the crash is this:
    * we call the clone syscall
    * we go to the function copy_process
    * copy process calls copy_thread_tls, it is a wrapper around copy_thread
    * copy_thread sets the tls pointer: childti->pcb.unique = regs->r20
    * copy_thread sets regs->r20 to zero
    * we go back to copy_process
    * copy process checks "if (signal_pending(current))" and returns
      -ERESTARTNOINTR
    * the clone syscall is restarted, but this time, regs->r20 is zero, so
      the new thread is created with zero tls pointer
    * the new thread crashes in start_thread when attempting to access tls
    
    The comment in the code says that setting the register r20 is some
    compatibility with OSF/1. But OSF/1 doesn't use the CLONE_SETTLS flag, so
    we don't have to zero r20 if CLONE_SETTLS is set. This patch fixes the bug
    by zeroing regs->r20 only if CLONE_SETTLS is not set.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Matt Turner <mattst88@gmail.com>
    [bwh: Backported to 3.2:
     - Remove the settls variable, which was done upstream in commit 25906730ec01
       "alpha: reorganize copy_process(), prepare to saner fork_idle()"]
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 33d0141f9db7664a04bfb17a576867c0122f226a
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Tue Jan 2 13:59:54 2018 -0500

    alpha: fix reboot on Avanti platform
    
    commit 55fc633c41a08ce9244ff5f528f420b16b1e04d6 upstream.
    
    We need to define NEED_SRM_SAVE_RESTORE on the Avanti, otherwise we get
    machine check exception when attempting to reboot the machine.
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Matt Turner <mattst88@gmail.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b33d9e10f27273765c81fbf0b918703e30ef9537
Author: James Hogan <jhogan@kernel.org>
Date:   Tue Jan 16 21:38:24 2018 +0000

    MIPS: Fix clean of vmlinuz.{32,ecoff,bin,srec}
    
    commit 5f2483eb2423152445b39f2db59d372f523e664e upstream.
    
    Make doesn't expand shell style "vmlinuz.{32,ecoff,bin,srec}" to the 4
    separate files, so none of these files get cleaned up by make clean.
    List the files separately instead.
    
    Fixes: ec3352925b74 ("MIPS: Remove all generated vmlinuz* files on "make clean"")
    Signed-off-by: James Hogan <jhogan@kernel.org>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/18491/
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3176b3a9ebc2598e8efb31c3fc89634cc202a862
Author: Felix Kuehling <Felix.Kuehling@amd.com>
Date:   Wed Jan 17 23:52:03 2018 -0500

    drm/ttm: Don't add swapped BOs to swap-LRU list
    
    commit fd5002d6a3c602664b07668a24df4ef7a43bf078 upstream.
    
    A BO that's already swapped would be added back to the swap-LRU list
    for example if its validation failed under high memory pressure. This
    could later lead to swapping it out again and leaking previous swap
    storage.
    
    This commit adds a condition to prevent that from happening.
    
    v2: Check page_flags instead of swap_storage
    
    Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    [bwh: Backported to 3.2: We aren't checking for TTM_PAGE_FLAG_SG here as that's
     not defined]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7adc87b34aaf5df502f45e41f02089717b6f51c8
Author: Clay McClure <clay@daemons.net>
Date:   Thu Sep 21 19:01:34 2017 -0700

    ubi: Fix race condition between ubi volume creation and udev
    
    commit a51a0c8d213594bc094cb8e54aad0cb6d7f7b9a6 upstream.
    
    Similar to commit 714fb87e8bc0 ("ubi: Fix race condition between ubi
    device creation and udev"), we should make the volume active before
    registering it.
    
    Signed-off-by: Clay McClure <clay@daemons.net>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bdd119a94b74acb4cc720695eac50f01173b7496
Author: mulhern <amulhern@redhat.com>
Date:   Mon Nov 27 10:02:39 2017 -0500

    dm thin: fix documentation relative to low water mark threshold
    
    commit 9b28a1102efc75d81298198166ead87d643a29ce upstream.
    
    Fixes:
    1. The use of "exceeds" when the opposite of exceeds, falls below,
    was meant.
    2. Properly speaking, a table can not exceed a threshold.
    
    It emphasizes the important point, which is that it is the userspace
    daemon's responsibility to check for low free space when a device
    is resumed, since it won't get a special event indicating low free
    space in that situation.
    
    Signed-off-by: mulhern <amulhern@redhat.com>
    Signed-off-by: Mike Snitzer <snitzer@redhat.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 396293c0274c394da7e9d19260c632c970656b90
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Jan 14 16:09:00 2018 +0100

    USB: cdc-acm: Do not log urb submission errors on disconnect
    
    commit f0386c083c2ce85284dc0b419d7b89c8e567c09f upstream.
    
    When disconnected sometimes the cdc-acm driver logs errors like these:
    
    [20278.039417] cdc_acm 2-2:2.1: urb 9 failed submission with -19
    [20278.042924] cdc_acm 2-2:2.1: urb 10 failed submission with -19
    [20278.046449] cdc_acm 2-2:2.1: urb 11 failed submission with -19
    [20278.049920] cdc_acm 2-2:2.1: urb 12 failed submission with -19
    [20278.053442] cdc_acm 2-2:2.1: urb 13 failed submission with -19
    [20278.056915] cdc_acm 2-2:2.1: urb 14 failed submission with -19
    [20278.060418] cdc_acm 2-2:2.1: urb 15 failed submission with -19
    
    Silence these by not logging errors when the result is -ENODEV.
    
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Acked-by: Oliver Neukum <oneukum@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dcc9bd87a2825e27df2dde6425b32d9da48421b2
Author: Anna-Maria Gleixner <anna-maria@linutronix.de>
Date:   Thu Dec 21 11:41:35 2017 +0100

    hrtimer: Ensure POSIX compliance (relative CLOCK_REALTIME hrtimers)
    
    commit 48d0c9becc7f3c66874c100c126459a9da0fdced upstream.
    
    The POSIX specification defines that relative CLOCK_REALTIME timers are not
    affected by clock modifications. Those timers have to use CLOCK_MONOTONIC
    to ensure POSIX compliance.
    
    The introduction of the additional HRTIMER_MODE_PINNED mode broke this
    requirement for pinned timers.
    
    There is no user space visible impact because user space timers are not
    using pinned mode, but for consistency reasons this needs to be fixed.
    
    Check whether the mode has the HRTIMER_MODE_REL bit set instead of
    comparing with HRTIMER_MODE_ABS.
    
    Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: John Stultz <john.stultz@linaro.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: keescook@chromium.org
    Fixes: 597d0275736d ("timers: Framework for identifying pinned timers")
    Link: http://lkml.kernel.org/r/20171221104205.7269-7-anna-maria@linutronix.de
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 11043ae6a9e56a2c362ae4289f1ca77e3ff4be4f
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Mon Jan 15 11:08:38 2018 +0300

    ASoC: au1x: Fix timeout tests in au1xac97c_ac97_read()
    
    commit 123af9043e93cb6f235207d260d50f832cdb5439 upstream.
    
    The loop timeout doesn't work because it's a post op and ends with "tmo"
    set to -1.  I changed it from a post-op to a pre-op and I changed the
    initial the starting value from 5 to 6 so we still iterate 5 times.  I
    left the other as it was because it's a large number.
    
    Fixes: b3c70c9ea62a ("ASoC: Alchemy AC97C/I2SC audio support")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c7411569cbc87bad53d9811166a49eaaa3b71cc3
Author: Nicolas Pitre <nicolas.pitre@linaro.org>
Date:   Mon Jan 15 17:04:22 2018 +0100

    console/dummy: leave .con_font_get set to NULL
    
    commit 724ba8b30b044aa0d94b1cd374fc15806cdd6f18 upstream.
    
    When this method is set, the caller expects struct console_font fields
    to be properly initialized when it returns. Leave it unset otherwise
    nonsensical (leaked kernel stack) values are returned to user space.
    
    Signed-off-by: Nicolas Pitre <nico@linaro.org>
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2aa8dcc6c0fed640aac249e2edac2013b797cc1c
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Tue Aug 1 05:02:38 2017 -0500

    mn10300/misalignment: Use SIGSEGV SEGV_MAPERR to report a failed user copy
    
    commit 6ac1dc736b323011a55ecd1fc5897c24c4f77cbd upstream.
    
    Setting si_code to 0 is the same a setting si_code to SI_USER which is definitely
    not correct.  With si_code set to SI_USER si_pid and si_uid will be copied to
    userspace instead of si_addr.  Which is very wrong.
    
    So fix this by using a sensible si_code (SEGV_MAPERR) for this failure.
    
    Fixes: b920de1b77b7 ("mn10300: add the MN10300/AM33 architecture to the kernel")
    Cc: David Howells <dhowells@redhat.com>
    Cc: Masakazu Urade <urade.masakazu@jp.panasonic.com>
    Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 883f8db70b4f46532327aa08089f894193d3ed42
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Tue Aug 1 04:16:47 2017 -0500

    signal/openrisc: Fix do_unaligned_access to send the proper signal
    
    commit 500d58300571b6602341b041f97c082a461ef994 upstream.
    
    While reviewing the signal sending on openrisc the do_unaligned_access
    function stood out because it is obviously wrong.  A comment about an
    si_code set above when actually si_code is never set.  Leading to a
    random si_code being sent to userspace in the event of an unaligned
    access.
    
    Looking further SIGBUS BUS_ADRALN is the proper pair of signal and
    si_code to send for an unaligned access. That is what other
    architectures do and what is required by posix.
    
    Given that do_unaligned_access is broken in a way that no one can be
    relying on it on openrisc fix the code to just do the right thing.
    
    Fixes: 769a8a96229e ("OpenRISC: Traps")
    Cc: Jonas Bonn <jonas@southpole.se>
    Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
    Cc: Stafford Horne <shorne@gmail.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: openrisc@lists.librecores.org
    Acked-by: Stafford Horne <shorne@gmail.com>
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit ab14cc411c8ce8d07e266b0f2ac626f7e35f7f83
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Jan 3 11:16:27 2018 -0800

    crypto: hash - prevent using keyed hashes without setting key
    
    commit 9fa68f620041be04720d0cbfb1bd3ddfc6310b24 upstream.
    
    Currently, almost none of the keyed hash algorithms check whether a key
    has been set before proceeding.  Some algorithms are okay with this and
    will effectively just use a key of all 0's or some other bogus default.
    However, others will severely break, as demonstrated using
    "hmac(sha3-512-generic)", the unkeyed use of which causes a kernel crash
    via a (potentially exploitable) stack buffer overflow.
    
    A while ago, this problem was solved for AF_ALG by pairing each hash
    transform with a 'has_key' bool.  However, there are still other places
    in the kernel where userspace can specify an arbitrary hash algorithm by
    name, and the kernel uses it as unkeyed hash without checking whether it
    is really unkeyed.  Examples of this include:
    
        - KEYCTL_DH_COMPUTE, via the KDF extension
        - dm-verity
        - dm-crypt, via the ESSIV support
        - dm-integrity, via the "internal hash" mode with no key given
        - drbd (Distributed Replicated Block Device)
    
    This bug is especially bad for KEYCTL_DH_COMPUTE as that requires no
    privileges to call.
    
    Fix the bug for all users by adding a flag CRYPTO_TFM_NEED_KEY to the
    ->crt_flags of each hash transform that indicates whether the transform
    still needs to be keyed or not.  Then, make the hash init, import, and
    digest functions return -ENOKEY if the key is still needed.
    
    The new flag also replaces the 'has_key' bool which algif_hash was
    previously using, thereby simplifying the algif_hash implementation.
    
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    [bwh: Backported to 3.2:
     - In hash_accept_parent_nokey(), update initialisation of ds to use tfm
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 498a9c71955dcbac7636d0c1f33ab56852262c33
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Jan 3 11:16:26 2018 -0800

    crypto: hash - annotate algorithms taking optional key
    
    commit a208fa8f33031b9e0aba44c7d1b7e68eb0cbd29e upstream.
    
    We need to consistently enforce that keyed hashes cannot be used without
    setting the key.  To do this we need a reliable way to determine whether
    a given hash algorithm is keyed or not.  AF_ALG currently does this by
    checking for the presence of a ->setkey() method.  However, this is
    actually slightly broken because the CRC-32 algorithms implement
    ->setkey() but can also be used without a key.  (The CRC-32 "key" is not
    actually a cryptographic key but rather represents the initial state.
    If not overridden, then a default initial state is used.)
    
    Prepare to fix this by introducing a flag CRYPTO_ALG_OPTIONAL_KEY which
    indicates that the algorithm has a ->setkey() method, but it is not
    required to be called.  Then set it on all the CRC-32 algorithms.
    
    The same also applies to the Adler-32 implementation in Lustre.
    
    Also, the cryptd and mcryptd templates have to pass through the flag
    from their underlying algorithm.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    [bwh: Backported to 3.2:
     - Drop changes to nonexistent drivers
     - There's no CRYPTO_ALG_INTERNAL flag
     - Adjust filenames]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3df19924e1c70be72da9124995a336ec936cd90d
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Jan 3 11:16:23 2018 -0800

    crypto: cryptd - pass through absence of ->setkey()
    
    commit 841a3ff329713f796a63356fef6e2f72e4a3f6a3 upstream.
    
    When the cryptd template is used to wrap an unkeyed hash algorithm,
    don't install a ->setkey() method to the cryptd instance.  This change
    is necessary for cryptd to keep working with unkeyed hash algorithms
    once we start enforcing that ->setkey() is called when present.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 74ea91baca141381b1960721832ff21392f770c4
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Jan 3 11:16:22 2018 -0800

    crypto: hash - introduce crypto_hash_alg_has_setkey()
    
    commit cd6ed77ad5d223dc6299fb58f62e0f5267f7e2ba upstream.
    
    Templates that use an shash spawn can use crypto_shash_alg_has_setkey()
    to determine whether the underlying algorithm requires a key or not.
    But there was no corresponding function for ahash spawns.  Add it.
    
    Note that the new function actually has to support both shash and ahash
    algorithms, since the ahash API can be used with either.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit efe80592cd0d721b786e6b6c2b3de25bdd5f6bdf
Author: Stephan Mueller <smueller@chronox.de>
Date:   Tue Jan 2 08:55:25 2018 +0100

    crypto: af_alg - whitelist mask and type
    
    commit bb30b8848c85e18ca7e371d0a869e94b3e383bdf upstream.
    
    The user space interface allows specifying the type and mask field used
    to allocate the cipher. Only a subset of the possible flags are intended
    for user space. Therefore, white-list the allowed flags.
    
    In case the user space caller uses at least one non-allowed flag, EINVAL
    is returned.
    
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Stephan Mueller <smueller@chronox.de>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    [bwh: Backported to 3.2: The CRYPTO_ALG_KERN_DRIVER_ONLY flag is not supported,
     so set allowed to 0]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 9bbce9986d0e62506891392d6c62171f5515a96d
Author: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Date:   Thu Jan 11 13:43:33 2018 -0500

    ext4: correct documentation for grpid mount option
    
    commit 9f0372488cc9243018a812e8cfbf27de650b187b upstream.
    
    The grpid option is currently described as being the same as nogrpid.
    
    Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c98b8a3d91dfdefd23e4e804ce96051b1945c7f4
Author: Zhouyi Zhou <zhouzhouyi@gmail.com>
Date:   Wed Jan 10 00:34:19 2018 -0500

    ext4: save error to disk in __ext4_grp_locked_error()
    
    commit 06f29cc81f0350261f59643a505010531130eea0 upstream.
    
    In the function __ext4_grp_locked_error(), __save_error_info()
    is called to save error info in super block block, but does not sync
    that information to disk to info the subsequence fsck after reboot.
    
    This patch writes the error information to disk.  After this patch,
    I think there is no obvious EXT4 error handle branches which leads to
    "Remounting filesystem read-only" will leave the disk partition miss
    the subsequence fsck.
    
    Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1de5a50baa2740e190e650bf6a394af377c4d5da
Author: Colin Ian King <colin.king@canonical.com>
Date:   Fri Jan 5 15:31:06 2018 +0000

    scsi: aacraid: remove redundant setting of variable c
    
    commit 91814744646351a470f256fbcb853fb5a7229a9f upstream.
    
    A previous commit no longer stores the contents of c, so we now have a
    situation where c is being updated but the value is never read. Clean up
    the code by removing the now redundant setting of variable c.
    
    Cleans up clang warning:
    drivers/scsi/aacraid/aachba.c:943:3: warning: Value stored to 'c' is
    never read
    
    Fixes: f4e8708d3104 ("scsi: aacraid: Fix udev inquiry race condition")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Reviewed-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fd111d301264cacadc7501455ed86d590a28b9ec
Author: Jason Yan <yanaijie@huawei.com>
Date:   Thu Jan 4 21:04:32 2018 +0800

    scsi: libsas: fix error when getting phy events
    
    commit 2b23d9509fd7174b362482cf5f3b5f9a2265bc33 upstream.
    
    The intend purpose here was to goto out if smp_execute_task() returned
    error. Obviously something got screwed up. We will never get these link
    error statistics below:
    
    ~:/sys/class/sas_phy/phy-1:0:12 # cat invalid_dword_count
    0
    ~:/sys/class/sas_phy/phy-1:0:12 # cat running_disparity_error_count
    0
    ~:/sys/class/sas_phy/phy-1:0:12 # cat loss_of_dword_sync_count
    0
    ~:/sys/class/sas_phy/phy-1:0:12 # cat phy_reset_problem_count
    0
    
    Obviously we should goto error handler if smp_execute_task() returns
    non-zero.
    
    Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
    Signed-off-by: Jason Yan <yanaijie@huawei.com>
    CC: John Garry <john.garry@huawei.com>
    CC: chenqilin <chenqilin2@huawei.com>
    CC: chenxiang <chenxiang66@hisilicon.com>
    Reviewed-by: Hannes Reinecke <hare@suse.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4006b7ab6791973ec6f0718df1b17caec51dd642
Author: Eric W. Biederman <ebiederm@xmission.com>
Date:   Mon Jul 24 17:30:30 2017 -0500

    signal/sh: Ensure si_signo is initialized in do_divide_error
    
    commit 0e88bb002a9b2ee8cc3cc9478ce2dc126f849696 upstream.
    
    Set si_signo.
    
    Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
    Cc: Rich Felker <dalias@libc.org>
    Cc: Paul Mundt <lethal@linux-sh.org>
    Cc: linux-sh@vger.kernel.org
    Fixes: 0983b31849bb ("sh: Wire up division and address error exceptions on SH-2A.")
    Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a11b245f1e663d70a361599c767f1edc4f3e35c
Author: Bart Van Assche <bart.vanassche@wdc.com>
Date:   Tue Jan 2 11:39:47 2018 -0800

    pktcdvd: Fix pkt_setup_dev() error path
    
    commit 5a0ec388ef0f6e33841aeb810d7fa23f049ec4cd upstream.
    
    Commit 523e1d399ce0 ("block: make gendisk hold a reference to its queue")
    modified add_disk() and disk_release() but did not update any of the
    error paths that trigger a put_disk() call after disk->queue has been
    assigned. That introduced the following behavior in the pktcdvd driver
    if pkt_new_dev() fails:
    
    Kernel BUG at 00000000e98fd882 [verbose debug info unavailable]
    
    Since disk_release() calls blk_put_queue() anyway if disk->queue != NULL,
    fix this by removing the blk_cleanup_queue() call from the pkt_setup_dev()
    error path.
    
    Fixes: commit 523e1d399ce0 ("block: make gendisk hold a reference to its queue")
    Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit fd8893ddc97b50cf1f067a4b8248a236aae28dc7
Author: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
Date:   Tue Dec 26 20:34:22 2017 -0800

    scsi: aacraid: Fix udev inquiry race condition
    
    commit f4e8708d3104437fd7716e957f38c265b0c509ef upstream.
    
    When udev requests for a devices inquiry string, it might create multiple
    threads causing a race condition on the shared inquiry resource string.
    
    Created a buffer with the string for each thread.
    
    Fixes: 3bc8070fb75b3315 ([SCSI] aacraid: SMC vendor identification)
    Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    [bwh: Backported to 3.2:
     - s/sup_adap_info->adapter_type_text/dev->supplement_adapter_info.AdapterTypeText/
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a6bf28ca66543e1c024382a779fc57f3dc04a88
Author: Hangbin Liu <liuhangbin@gmail.com>
Date:   Fri Dec 22 15:10:17 2017 +0100

    l2tp: fix missing print session offset info
    
    commit 820da5357572715c6235ba3b3daa2d5b43a1198f upstream.
    
    Report offset parameter in L2TP_CMD_SESSION_GET command if
    it has been configured by userspace
    
    Fixes: 309795f4bec ("l2tp: Add netlink control API for L2TP")
    Reported-by: Jianlin Shi <jishi@redhat.com>
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
    Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2:
     - Use NLA_PUT_U16, consistent with the rest of the function
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5d3ecc8aa8eb3dc677d5214464a0b01e7b5e1d26
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Tue Dec 5 17:35:08 2017 +0300

    ath9k_htc: Add a sanity check in ath9k_htc_ampdu_action()
    
    commit 413fd2f5c0233d3cde391679b967c1f14cd2cb27 upstream.
    
    Smatch generates a warning here:
    
        drivers/net/wireless/ath/ath9k/htc_drv_main.c:1688 ath9k_htc_ampdu_action()
        error: buffer overflow 'ista->tid_state' 8 <= 15
    
    I don't know if it's a real bug or not but the other paths through this
    function all ensure that "tid" is less than ATH9K_HTC_MAX_TID (8) so
    checking here makes things more consistent.
    
    Fixes: fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 07599cf068b05c2e9b9a24036b43e19ff8337985
Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date:   Thu Sep 21 19:23:56 2017 -0400

    media: bt8xx: Fix err 'bt878_probe()'
    
    commit 45392ff6881dbe56d41ef0b17c2e576065f8ffa1 upstream.
    
    This is odd to call 'pci_disable_device()' in an error path before a
    coresponding successful 'pci_enable_device()'.
    
    Return directly instead.
    
    Fixes: 77e0be12100a ("V4L/DVB (4176): Bug-fix: Fix memory overflow")
    
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c2ddb5852a591e11abac56114485c04411e8386b
Author: Jia-Ju Bai <baijiaju1990@gmail.com>
Date:   Wed Dec 13 20:34:36 2017 +0800

    USB: serial: io_edgeport: fix possible sleep-in-atomic
    
    commit c7b8f77872c73f69a16528a9eb87afefcccdc18b upstream.
    
    According to drivers/usb/serial/io_edgeport.c, the driver may sleep
    under a spinlock.
    The function call path is:
    edge_bulk_in_callback (acquire the spinlock)
       process_rcvd_data
         process_rcvd_status
           change_port_settings
             send_iosp_ext_cmd
               write_cmd_usb
                 usb_kill_urb --> may sleep
    
    To fix it, the redundant usb_kill_urb() is removed from the error path
    after usb_submit_urb() fails.
    
    This possible bug is found by my static analysis tool (DSAC) and checked
    by my code review.
    
    Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 948e5ebd9b6bcec50930e39589fec706ccf745b3
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Sat Dec 9 14:52:28 2017 +0300

    ASoC: nuc900: Fix a loop timeout test
    
    commit 65a12b3aafed5fc59f4ce41b22b752b1729e6701 upstream.
    
    We should be finishing the loop with timeout set to zero but because
    this is a post-op we finish with timeout == -1.
    
    Fixes: 1082e2703a2d ("ASoC: NUC900/audio: add nuc900 audio driver support")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bb4efe4689dfdf4802bd1fd956123b2d98cc90ee
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Fri Dec 8 12:18:59 2017 +0100

    slip: sl_alloc(): remove unused parameter "dev_t line"
    
    commit 936e5d8bdfa72577e28ea671d9e2ee4fef0d6b3e upstream.
    
    The first and only parameter of sl_alloc() is unused, so remove it.
    
    Fixes: 5342b77c4123 slip: ("Clean up create and destroy")
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 8a95224d7ef3818fb367acc4a6cbdfb30229a8a7
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Thu Nov 9 16:28:14 2017 -0500

    media: cpia2: Fix a couple off by one bugs
    
    commit d5ac225c7d64c9c3ef821239edc035634e594ec9 upstream.
    
    The cam->buffers[] array has cam->num_frames elements so the > needs to
    be changed to >= to avoid going beyond the end of the array.  The
    ->buffers[] array is allocated in cpia2_allocate_buffers() if you want
    to confirm.
    
    Fixes: ab33d5071de7 ("V4L/DVB (3376): Add cpia2 camera support")
    
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 03e58a520044e3ea80a3ea43586f956e2e86c74d
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Mar 26 15:39:07 2018 -1000

    perf/hwbp: Simplify the perf-hwbp code, fix documentation
    
    commit f67b15037a7a50c57f72e69a6d59941ad90a0f0f upstream.
    
    Annoyingly, modify_user_hw_breakpoint() unnecessarily complicates the
    modification of a breakpoint - simplify it and remove the pointless
    local variables.
    
    Also update the stale Docbook while at it.
    
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 0a484bd5d67e0fc458945eeece251be35756a815
Author: K.Prasad <Prasad.Krishnan@gmail.com>
Date:   Thu Aug 2 13:46:35 2012 +0530

    perf/hwpb: Invoke __perf_event_disable() if interrupts are already disabled
    
    commit 500ad2d8b01390c98bc6dce068bccfa9534b8212 upstream.
    
    While debugging a warning message on PowerPC while using hardware
    breakpoints, it was discovered that when perf_event_disable is invoked
    through hw_breakpoint_handler function with interrupts disabled, a
    subsequent IPI in the code path would trigger a WARN_ON_ONCE message in
    smp_call_function_single function.
    
    This patch calls __perf_event_disable() when interrupts are already
    disabled, instead of perf_event_disable().
    
    Reported-by: Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com>
    Signed-off-by: K.Prasad <Prasad.Krishnan@gmail.com>
    [naveen.n.rao@linux.vnet.ibm.com: v3: Check to make sure we target current task]
    Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Link: http://lkml.kernel.org/r/20120802081635.5811.17737.stgit@localhost.localdomain
    [ Fixed build error on MIPS. ]
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 15bad6c8291a04692b928e9037844fde6f32a798
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Apr 18 12:51:31 2018 +0300

    cdrom: information leak in cdrom_ioctl_media_changed()
    
    commit 9de4ee40547fd315d4a0ed1dd15a2fa3559ad707 upstream.
    
    This cast is wrong.  "cdi->capacity" is an int and "arg" is an unsigned
    long.  The way the check is written now, if one of the high 32 bits is
    set then we could read outside the info->slots[] array.
    
    This bug is pretty old and it predates git.
    
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 5a1f747c7f58e9820ebfb6b4811934a1f48bc4fe
Author: Andy Lutomirski <luto@kernel.org>
Date:   Thu Jul 23 15:37:48 2015 -0700

    x86/entry/64: Don't use IST entry for #BP stack
    
    commit d8ba61ba58c88d5207c1ba2f7d9a2280e7d03be9 upstream.
    
    There's nothing IST-worthy about #BP/int3.  We don't allow kprobes
    in the small handful of places in the kernel that run at CPL0 with
    an invalid stack, and 32-bit kernels have used normal interrupt
    gates for #BP forever.
    
    Furthermore, we don't allow kprobes in places that have usergs while
    in kernel mode, so "paranoid" is also unnecessary.
    
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    [carnil: Backport to 3.16:
     - Adjust finename change: arch/x86/kernel/entry_64.S
     - Context changes
    ]
    [bwh: Rebase on top of "x86/traps: Enable DEBUG_STACK after cpu_init() for
     TRAP_DB/BP", and restore change in trap_init() instead of early_trap_init().
     Backport to 3.2:
     - Use zeroentry macro in entry_64.S
     - Drop changes related to breakpoint-in-NMI support
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1a2ce896855bae80c079ce45d102633546a6a87f
Author: Wang Nan <wangnan0@huawei.com>
Date:   Thu Feb 26 13:49:39 2015 +0800

    x86/traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP
    
    commit b4d8327024637cb2a1f7910dcb5d0ad7a096f473 upstream.
    
    Before this patch early_trap_init() installs DEBUG_STACK for
    X86_TRAP_BP and X86_TRAP_DB. However, DEBUG_STACK doesn't work
    correctly until cpu_init() <-- trap_init().
    
    This patch passes 0 to set_intr_gate_ist() and
    set_system_intr_gate_ist() instead of DEBUG_STACK to let it use
    same stack as kernel, and installs DEBUG_STACK for them in
    trap_init().
    
    As core runs at ring 0 between early_trap_init() and
    trap_init(), there is no chance to get a bad stack before
    trap_init().
    
    As NMI is also enabled in trap_init(), we don't need to care
    about is_debug_stack() and related things used in
    arch/x86/kernel/nmi.c.
    
    Signed-off-by: Wang Nan <wangnan0@huawei.com>
    Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
    Acked-by: Steven Rostedt <rostedt@goodmis.org>
    Cc: <dave.hansen@linux.intel.com>
    Cc: <lizefan@huawei.com>
    Cc: <luto@amacapital.net>
    Cc: <oleg@redhat.com>
    Link: http://lkml.kernel.org/r/1424929779-13174-1-git-send-email-wangnan0@huawei.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 38643d20b4d4ac378046e51b15556f0f7dc489ea
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Mon Mar 19 14:07:45 2018 +0300

    staging: ncpfs: memory corruption in ncp_read_kernel()
    
    commit 4c41aa24baa4ed338241d05494f2c595c885af8f upstream.
    
    If the server is malicious then *bytes_read could be larger than the
    size of the "target" buffer.  It would lead to memory corruption when we
    do the memcpy().
    
    Reported-by: Dr Silvio Cesare of InfoSect <Silvio Cesare <silvio.cesare@gmail.com>
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    [carnil: backport to 4.9: Files renamed from drivers/staging/ncpfs/ncplib_kernel.c
     to fs/ncpfs/ncplib_kernel.c]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 65e38566ae2600cebb885af0b58dc8732e25ee52
Author: Seunghun Han <kkamagui@gmail.com>
Date:   Tue Mar 6 15:21:43 2018 +0100

    x86/MCE: Serialize sysfs changes
    
    commit b3b7c4795ccab5be71f080774c45bbbcc75c2aaf upstream.
    
    The check_interval file in
    
      /sys/devices/system/machinecheck/machinecheck<cpu number>
    
    directory is a global timer value for MCE polling. If it is changed by one
    CPU, mce_restart() broadcasts the event to other CPUs to delete and restart
    the MCE polling timer and __mcheck_cpu_init_timer() reinitializes the
    mce_timer variable.
    
    If more than one CPU writes a specific value to the check_interval file
    concurrently, mce_timer is not protected from such concurrent accesses and
    all kinds of explosions happen. Since only root can write to those sysfs
    variables, the issue is not a big deal security-wise.
    
    However, concurrent writes to these configuration variables is void of
    reason so the proper thing to do is to serialize the access with a mutex.
    
    Boris:
    
     - Make store_int_with_restart() use device_store_ulong() to filter out
       negative intervals
     - Limit min interval to 1 second
     - Correct locking
     - Massage commit message
    
    Signed-off-by: Seunghun Han <kkamagui@gmail.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: linux-edac <linux-edac@vger.kernel.org>
    Link: http://lkml.kernel.org/r/20180302202706.9434-1-kkamagui@gmail.com
    [bwh: Backported to 3.2:
     - MCE device is a sysdev here
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2a690a408dee7a9d51b17dfe93b116bd7ab6177a
Author: Jason Yan <yanaijie@huawei.com>
Date:   Thu Jan 4 21:04:31 2018 +0800

    scsi: libsas: fix memory leak in sas_smp_get_phy_events()
    
    commit 4a491b1ab11ca0556d2fda1ff1301e862a2d44c4 upstream.
    
    We've got a memory leak with the following producer:
    
    while true;
    do cat /sys/class/sas_phy/phy-1:0:12/invalid_dword_count >/dev/null;
    done
    
    The buffer req is allocated and not freed after we return. Fix it.
    
    Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
    Signed-off-by: Jason Yan <yanaijie@huawei.com>
    CC: John Garry <john.garry@huawei.com>
    CC: chenqilin <chenqilin2@huawei.com>
    CC: chenxiang <chenxiang66@hisilicon.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Hannes Reinecke <hare@suse.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 131802b8292d35e8a407469c485565b199ed79cf
Author: Mike Kravetz <mike.kravetz@oracle.com>
Date:   Thu Mar 22 16:17:13 2018 -0700

    hugetlbfs: check for pgoff value overflow
    
    commit 63489f8e821144000e0bdca7e65a8d1cc23a7ee7 upstream.
    
    A vma with vm_pgoff large enough to overflow a loff_t type when
    converted to a byte offset can be passed via the remap_file_pages system
    call.  The hugetlbfs mmap routine uses the byte offset to calculate
    reservations and file size.
    
    A sequence such as:
    
      mmap(0x20a00000, 0x600000, 0, 0x66033, -1, 0);
      remap_file_pages(0x20a00000, 0x600000, 0, 0x20000000000000, 0);
    
    will result in the following when task exits/file closed,
    
      kernel BUG at mm/hugetlb.c:749!
      Call Trace:
        hugetlbfs_evict_inode+0x2f/0x40
        evict+0xcb/0x190
        __dentry_kill+0xcb/0x150
        __fput+0x164/0x1e0
        task_work_run+0x84/0xa0
        exit_to_usermode_loop+0x7d/0x80
        do_syscall_64+0x18b/0x190
        entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    
    The overflowed pgoff value causes hugetlbfs to try to set up a mapping
    with a negative range (end < start) that leaves invalid state which
    causes the BUG.
    
    The previous overflow fix to this code was incomplete and did not take
    the remap_file_pages system call into account.
    
    [mike.kravetz@oracle.com: v3]
      Link: http://lkml.kernel.org/r/20180309002726.7248-1-mike.kravetz@oracle.com
    [akpm@linux-foundation.org: include mmdebug.h]
    [akpm@linux-foundation.org: fix -ve left shift count on sh]
    Link: http://lkml.kernel.org/r/20180308210502.15952-1-mike.kravetz@oracle.com
    Fixes: 045c7a3f53d9 ("hugetlbfs: fix offset overflow in hugetlbfs mmap")
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Reported-by: Nic Losby <blurbdust@gmail.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Yisheng Xie <xieyisheng1@huawei.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2:
     - Use a conditional WARN() instead of VM_WARN()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 4cba2554682469496ff48536d50c399110d20043
Author: Mike Kravetz <mike.kravetz@oracle.com>
Date:   Thu Apr 13 14:56:32 2017 -0700

    hugetlbfs: fix offset overflow in hugetlbfs mmap
    
    commit 045c7a3f53d9403b62d396b6d051c4be5044cdb4 upstream.
    
    If mmap() maps a file, it can be passed an offset into the file at which
    the mapping is to start.  Offset could be a negative value when
    represented as a loff_t.  The offset plus length will be used to update
    the file size (i_size) which is also a loff_t.
    
    Validate the value of offset and offset + length to make sure they do
    not overflow and appear as negative.
    
    Found by syzcaller with commit ff8c0c53c475 ("mm/hugetlb.c: don't call
    region_abort if region_chg fails") applied.  Prior to this commit, the
    overflow would still occur but we would luckily return ENOMEM.
    
    To reproduce:
    
       mmap(0, 0x2000, 0, 0x40021, 0xffffffffffffffffULL, 0x8000000000000000ULL);
    
    Resulted in,
    
      kernel BUG at mm/hugetlb.c:742!
      Call Trace:
       hugetlbfs_evict_inode+0x80/0xa0
       evict+0x24a/0x620
       iput+0x48f/0x8c0
       dentry_unlink_inode+0x31f/0x4d0
       __dentry_kill+0x292/0x5e0
       dput+0x730/0x830
       __fput+0x438/0x720
       ____fput+0x1a/0x20
       task_work_run+0xfe/0x180
       exit_to_usermode_loop+0x133/0x150
       syscall_return_slowpath+0x184/0x1c0
       entry_SYSCALL_64_fastpath+0xab/0xad
    
    Fixes: ff8c0c53c475 ("mm/hugetlb.c: don't call region_abort if region_chg fails")
    Link: http://lkml.kernel.org/r/1491951118-30678-1-git-send-email-mike.kravetz@oracle.com
    Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
    Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 1a63d970eecf933973eae20b069f3755a7824b24
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Mar 5 22:06:09 2018 +0100

    ALSA: seq: More protection for concurrent write and ioctl races
    
    commit 7bd80091567789f1c0cb70eb4737aac8bcd2b6b9 upstream.
    
    This patch is an attempt for further hardening against races between
    the concurrent write and ioctls.  The previous fix d15d662e89fc
    ("ALSA: seq: Fix racy pool initializations") covered the race of the
    pool initialization at writer and the pool resize ioctl by the
    client->ioctl_mutex (CVE-2018-1000004).  However, basically this mutex
    should be applied more widely to the whole write operation for
    avoiding the unexpected pool operations by another thread.
    
    The only change outside snd_seq_write() is the additional mutex
    argument to helper functions, so that we can unlock / relock the given
    mutex temporarily during schedule() call for blocking write.
    
    Fixes: d15d662e89fc ("ALSA: seq: Fix racy pool initializations")
    Reported-by: 范龙飞 <long7573@126.com>
    Reported-by: Nicolai Stange <nstange@suse.de>
    Reviewed-and-tested-by: Nicolai Stange <nstange@suse.de>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit d89ffc7140e70fd8429f7147c552bdf22750a717
Author: Adam Goode <agoode@google.com>
Date:   Wed Jun 4 01:02:51 2014 -0400

    ALSA: seq: correctly detect input buffer overflow
    
    commit 21fd3e956ee8a307a06bc6e095f5767a00eb2a7e upstream.
    
    snd_seq_event_dup returns -ENOMEM in some buffer-full conditions,
    but usually returns -EAGAIN. Make -EAGAIN trigger the overflow
    condition in snd_seq_fifo_event_in so that the fifo is cleared
    and -ENOSPC is returned to userspace as stated in the alsa-lib docs.
    
    Signed-off-by: Adam Goode <agoode@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit c96a7302975ce043f565c9ce2359794e1397488c
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Mar 5 22:00:55 2018 +0100

    ALSA: seq: Don't allow resizing pool in use
    
    commit d85739367c6d56e475c281945c68fdb05ca74b4c upstream.
    
    This is a fix for a (sort of) fallout in the recent commit
    d15d662e89fc ("ALSA: seq: Fix racy pool initializations") for
    CVE-2018-1000004.
    As the pool resize deletes the existing cells, it may lead to a race
    when another thread is writing concurrently, eventually resulting a
    UAF.
    
    A simple workaround is not to allow the pool resizing when the pool is
    in use.  It's an invalid behavior in anyway.
    
    Fixes: d15d662e89fc ("ALSA: seq: Fix racy pool initializations")
    Reported-by: 范龙飞 <long7573@126.com>
    Reported-by: Nicolai Stange <nstange@suse.de>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit b5c3d49b3d5889f334d519d7a4535a3bd8632d47
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Feb 12 15:20:51 2018 +0100

    ALSA: seq: Fix racy pool initializations
    
    commit d15d662e89fc667b90cd294b0eb45694e33144da upstream.
    
    ALSA sequencer core initializes the event pool on demand by invoking
    snd_seq_pool_init() when the first write happens and the pool is
    empty.  Meanwhile user can reset the pool size manually via ioctl
    concurrently, and this may lead to UAF or out-of-bound accesses since
    the function tries to vmalloc / vfree the buffer.
    
    A simple fix is to just wrap the snd_seq_pool_init() call with the
    recently introduced client->ioctl_mutex; as the calls for
    snd_seq_pool_init() from other side are always protected with this
    mutex, we can avoid the race.
    
    Reported-by: 范龙飞 <long7573@126.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e553bcf09a6390e7f52e47132b27b4574d0ad71a
Author: Peter Malone <peter.malone@gmail.com>
Date:   Wed Mar 7 14:00:34 2018 +0100

    fbdev: Fixing arbitrary kernel leak in case FBIOGETCMAP_SPARC in sbusfb_ioctl_helper().
    
    commit 250c6c49e3b68756b14983c076183568636e2bde upstream.
    
    Fixing arbitrary kernel leak in case FBIOGETCMAP_SPARC in
    sbusfb_ioctl_helper().
    
    'index' is defined as an int in sbusfb_ioctl_helper().
    We retrieve this from the user:
    if (get_user(index, &c->index) ||
        __get_user(count, &c->count) ||
        __get_user(ured, &c->red) ||
        __get_user(ugreen, &c->green) ||
        __get_user(ublue, &c->blue))
           return -EFAULT;
    
    and then we use 'index' in the following way:
    red = cmap->red[index + i] >> 8;
    green = cmap->green[index + i] >> 8;
    blue = cmap->blue[index + i] >> 8;
    
    This is a classic information leak vulnerability. 'index' should be
    an unsigned int, given its usage above.
    
    This patch is straight-forward; it changes 'index' to unsigned int
    in two switch-cases: FBIOGETCMAP_SPARC && FBIOPUTCMAP_SPARC.
    
    This patch fixes CVE-2018-6412.
    
    Signed-off-by: Peter Malone <peter.malone@gmail.com>
    Acked-by: Mathieu Malaterre <malat@debian.org>
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    [bwh: Backported to 3.2: adjust filename]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 61079d7091f4a673a337b5d63e7e7e38ac405d37
Author: Alexey Kodanev <alexey.kodanev@oracle.com>
Date:   Fri Feb 9 17:35:23 2018 +0300

    sctp: verify size of a new chunk in _sctp_make_chunk()
    
    commit 07f2c7ab6f8d0a7e7c5764c4e6cc9c52951b9d9c upstream.
    
    When SCTP makes INIT or INIT_ACK packet the total chunk length
    can exceed SCTP_MAX_CHUNK_LEN which leads to kernel panic when
    transmitting these packets, e.g. the crash on sending INIT_ACK:
    
    [  597.804948] skbuff: skb_over_panic: text:00000000ffae06e4 len:120168
                   put:120156 head:000000007aa47635 data:00000000d991c2de
                   tail:0x1d640 end:0xfec0 dev:<NULL>
    ...
    [  597.976970] ------------[ cut here ]------------
    [  598.033408] kernel BUG at net/core/skbuff.c:104!
    [  600.314841] Call Trace:
    [  600.345829]  <IRQ>
    [  600.371639]  ? sctp_packet_transmit+0x2095/0x26d0 [sctp]
    [  600.436934]  skb_put+0x16c/0x200
    [  600.477295]  sctp_packet_transmit+0x2095/0x26d0 [sctp]
    [  600.540630]  ? sctp_packet_config+0x890/0x890 [sctp]
    [  600.601781]  ? __sctp_packet_append_chunk+0x3b4/0xd00 [sctp]
    [  600.671356]  ? sctp_cmp_addr_exact+0x3f/0x90 [sctp]
    [  600.731482]  sctp_outq_flush+0x663/0x30d0 [sctp]
    [  600.788565]  ? sctp_make_init+0xbf0/0xbf0 [sctp]
    [  600.845555]  ? sctp_check_transmitted+0x18f0/0x18f0 [sctp]
    [  600.912945]  ? sctp_outq_tail+0x631/0x9d0 [sctp]
    [  600.969936]  sctp_cmd_interpreter.isra.22+0x3be1/0x5cb0 [sctp]
    [  601.041593]  ? sctp_sf_do_5_1B_init+0x85f/0xc30 [sctp]
    [  601.104837]  ? sctp_generate_t1_cookie_event+0x20/0x20 [sctp]
    [  601.175436]  ? sctp_eat_data+0x1710/0x1710 [sctp]
    [  601.233575]  sctp_do_sm+0x182/0x560 [sctp]
    [  601.284328]  ? sctp_has_association+0x70/0x70 [sctp]
    [  601.345586]  ? sctp_rcv+0xef4/0x32f0 [sctp]
    [  601.397478]  ? sctp6_rcv+0xa/0x20 [sctp]
    ...
    
    Here the chunk size for INIT_ACK packet becomes too big, mostly
    because of the state cookie (INIT packet has large size with
    many address parameters), plus additional server parameters.
    
    Later this chunk causes the panic in skb_put_data():
    
      skb_packet_transmit()
          sctp_packet_pack()
              skb_put_data(nskb, chunk->skb->data, chunk->skb->len);
    
    'nskb' (head skb) was previously allocated with packet->size
    from u16 'chunk->chunk_hdr->length'.
    
    As suggested by Marcelo we should check the chunk's length in
    _sctp_make_chunk() before trying to allocate skb for it and
    discard a chunk if its size bigger than SCTP_MAX_CHUNK_LEN.
    
    Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leinter@gmail.com>
    Acked-by: Neil Horman <nhorman@tuxdriver.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.2:
     - Keep using WORD_ROUND() instead of SCTP_PAD4()
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 109503b8cccb3b803d875b88d21d49eab921969e
Author: Alexey Kodanev <alexey.kodanev@oracle.com>
Date:   Tue Mar 6 22:57:01 2018 +0300

    dccp: check sk for closed state in dccp_sendmsg()
    
    commit 67f93df79aeefc3add4e4b31a752600f834236e2 upstream.
    
    dccp_disconnect() sets 'dp->dccps_hc_tx_ccid' tx handler to NULL,
    therefore if DCCP socket is disconnected and dccp_sendmsg() is
    called after it, it will cause a NULL pointer dereference in
    dccp_write_xmit().
    
    This crash and the reproducer was reported by syzbot. Looks like
    it is reproduced if commit 69c64866ce07 ("dccp: CVE-2017-8824:
    use-after-free in DCCP code") is applied.
    
    Reported-by: syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com
    Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 02a37ffd681be59775c9f13686e20621f7097f7e
Author: Lukas Czerner <lczerner@redhat.com>
Date:   Tue Apr 24 11:31:44 2018 -0400

    ext4: fix bitmap position validation
    
    commit 22be37acce25d66ecf6403fc8f44df9c5ded2372 upstream.
    
    Currently in ext4_valid_block_bitmap() we expect the bitmap to be
    positioned anywhere between 0 and s_blocksize clusters, but that's
    wrong because the bitmap can be placed anywhere in the block group. This
    causes false positives when validating bitmaps on perfectly valid file
    system layouts. Fix it by checking whether the bitmap is within the group
    boundary.
    
    The problem can be reproduced using the following
    
    mkfs -t ext3 -E stride=256 /dev/vdb1
    mount /dev/vdb1 /mnt/test
    cd /mnt/test
    wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.16.3.tar.xz
    tar xf linux-4.16.3.tar.xz
    
    This will result in the warnings in the logs
    
    EXT4-fs error (device vdb1): ext4_validate_block_bitmap:399: comm tar: bg 84: block 2774529: invalid block bitmap
    
    [ Changed slightly for clarity and to not drop a overflow test -- TYT ]
    
    Signed-off-by: Lukas Czerner <lczerner@redhat.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Reported-by: Ilya Dryomov <idryomov@gmail.com>
    Fixes: 7dac4a1726a9 ("ext4: add validity checks for bitmap block numbers")
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit f278235ce148485cdb9dc990673943addafbd577
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Mon Mar 26 23:54:10 2018 -0400

    ext4: add validity checks for bitmap block numbers
    
    commit 7dac4a1726a9c64a517d595c40e95e2d0d135f6f upstream.
    
    An privileged attacker can cause a crash by mounting a crafted ext4
    image which triggers a out-of-bounds read in the function
    ext4_valid_block_bitmap() in fs/ext4/balloc.c.
    
    This issue has been assigned CVE-2018-1093.
    
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199181
    BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1560782
    Reported-by: Wen Xu <wen.xu@gatech.edu>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.2:
     - In ext4_valid_block_bitmap(), goto err_out on error
     - In ext4_read_{block,inode}_bitmap(), return NULL on error
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit eea55da54d3e425d6a5f3cfeb3f26adbb0330354
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Mon May 12 10:17:55 2014 -0400

    ext4: fix block bitmap validation when bigalloc, ^flex_bg
    
    commit e674e5cbd0942b42a12106ac0be8330f4301bef4 upstream.
    
    On a bigalloc,^flex_bg filesystem, the ext4_valid_block_bitmap
    function fails to convert from blocks to clusters when spot-checking
    the validity of the bitmap block that we've just read from disk.  This
    causes ext4 to think that the bitmap is garbage, which results in the
    block group being taken offline when it's not necessary.  Add in the
    necessary EXT4_B2C() calls to perform the conversions.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit bf7fc655f12864b4c12d902cf60ae37a708cc344
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Thu Mar 29 21:56:09 2018 -0400

    ext4: fail ext4_iget for root directory if unallocated
    
    commit 8e4b5eae5decd9dfe5a4ee369c22028f90ab4c44 upstream.
    
    If the root directory has an i_links_count of zero, then when the file
    system is mounted, then when ext4_fill_super() notices the problem and
    tries to call iput() the root directory in the error return path,
    ext4_evict_inode() will try to free the inode on disk, before all of
    the file system structures are set up, and this will result in an OOPS
    caused by a NULL pointer dereference.
    
    This issue has been assigned CVE-2018-1092.
    
    https://bugzilla.kernel.org/show_bug.cgi?id=199179
    https://bugzilla.redhat.com/show_bug.cgi?id=1560777
    
    Reported-by: Wen Xu <wen.xu@gatech.edu>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [bwh: Backported to 3.2:
     - Use EIO instead of EFSCORRUPTED
     - Adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 2609aab91aded56745a33c738f63d68ecf1b1092
Author: Florian Westphal <fw@strlen.de>
Date:   Thu Mar 8 12:54:19 2018 +0100

    netfilter: ebtables: fix erroneous reject of last rule
    
    commit 932909d9b28d27e807ff8eecb68c7748f6701628 upstream.
    
    The last rule in the blob has next_entry offset that is same as total size.
    This made "ebtables32 -A OUTPUT -d de:ad:be:ef:01:02" fail on 64 bit kernel.
    
    Fixes: b71812168571fa ("netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dccc6e2c9b486b99b6ec356e14f7de58832b3833
Author: Florian Westphal <fw@strlen.de>
Date:   Mon Feb 19 01:24:15 2018 +0100

    netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets
    
    commit b71812168571fa55e44cdd0254471331b9c4c4c6 upstream.
    
    We need to make sure the offsets are not out of range of the
    total size.
    Also check that they are in ascending order.
    
    The WARN_ON triggered by syzkaller (it sets panic_on_warn) is
    changed to also bail out, no point in continuing parsing.
    
    Briefly tested with simple ruleset of
    -A INPUT --limit 1/s' --log
    plus jump to custom chains using 32bit ebtables binary.
    
    Reported-by: <syzbot+845a53d13171abf8bf29@syzkaller.appspotmail.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit dfd9f20a2db71ca01033040ecf69d5c0e67db629
Author: alex chen <alex.chen@huawei.com>
Date:   Wed Nov 15 17:31:48 2017 -0800

    ocfs2: subsystem.su_mutex is required while accessing the item->ci_parent
    
    commit 853bc26a7ea39e354b9f8889ae7ad1492ffa28d2 upstream.
    
    The subsystem.su_mutex is required while accessing the item->ci_parent,
    otherwise, NULL pointer dereference to the item->ci_parent will be
    triggered in the following situation:
    
    add node                     delete node
    sys_write
     vfs_write
      configfs_write_file
       o2nm_node_store
        o2nm_node_local_write
                                 do_rmdir
                                  vfs_rmdir
                                   configfs_rmdir
                                    mutex_lock(&subsys->su_mutex);
                                    unlink_obj
                                     item->ci_group = NULL;
                                     item->ci_parent = NULL;
             to_o2nm_cluster_from_node
              node->nd_item.ci_parent->ci_parent
              BUG since of NULL pointer dereference to nd_item.ci_parent
    
    Moreover, the o2nm_cluster also should be protected by the
    subsystem.su_mutex.
    
    [alex.chen@huawei.com: v2]
      Link: http://lkml.kernel.org/r/59EEAA69.9080703@huawei.com
    Link: http://lkml.kernel.org/r/59E9B36A.10700@huawei.com
    Signed-off-by: Alex Chen <alex.chen@huawei.com>
    Reviewed-by: Jun Piao <piaojun@huawei.com>
    Reviewed-by: Joseph Qi <jiangqi903@gmail.com>
    Cc: Mark Fasheh <mfasheh@versity.com>
    Cc: Joel Becker <jlbec@evilplan.org>
    Cc: Junxiao Bi <junxiao.bi@oracle.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3d886ff142e713000aec6bf6f82944eb03dab28c
Author: chenjie <chenjie6@huawei.com>
Date:   Wed Nov 29 16:10:54 2017 -0800

    mm/madvise.c: fix madvise() infinite loop under special circumstances
    
    commit 6ea8d958a2c95a1d514015d4e29ba21a8c0a1a91 upstream.
    
    MADVISE_WILLNEED has always been a noop for DAX (formerly XIP) mappings.
    Unfortunately madvise_willneed() doesn't communicate this information
    properly to the generic madvise syscall implementation.  The calling
    convention is quite subtle there.  madvise_vma() is supposed to either
    return an error or update &prev otherwise the main loop will never
    advance to the next vma and it will keep looping for ever without a way
    to get out of the kernel.
    
    It seems this has been broken since introduction.  Nobody has noticed
    because nobody seems to be using MADVISE_WILLNEED on these DAX mappings.
    
    [mhocko@suse.com: rewrite changelog]
    Link: http://lkml.kernel.org/r/20171127115318.911-1-guoxuenan@huawei.com
    Fixes: fe77ba6f4f97 ("[PATCH] xip: madvice/fadvice: execute in place")
    Signed-off-by: chenjie <chenjie6@huawei.com>
    Signed-off-by: guoxuenan <guoxuenan@huawei.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: zhangyi (F) <yi.zhang@huawei.com>
    Cc: Miao Xie <miaoxie@huawei.com>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Cc: Shaohua Li <shli@fb.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Carsten Otte <cotte@de.ibm.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [bwh: Backported to 3.2: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 43da4014d8fb05379f19abe26d61af608bd680fd
Author: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Date:   Tue May 26 17:30:17 2015 -0600

    sctp: Fix mangled IPv4 addresses on a IPv6 listening socket
    
    commit 9302d7bb0c5cd46be5706859301f18c137b2439f upstream.
    
    sctp_v4_map_v6 was subtly writing and reading from members
    of a union in a way the clobbered data it needed to read before
    it read it.
    
    Zeroing the v6 flowinfo overwrites the v4 sin_addr with 0, meaning
    that every place that calls sctp_v4_map_v6 gets ::ffff:0.0.0.0 as the
    result.
    
    Reorder things to guarantee correct behaviour no matter what the
    union layout is.
    
    This impacts user space clients that open an IPv6 SCTP socket and
    receive IPv4 connections. Prior to 299ee user space would see a
    sockaddr with AF_INET and a correct address, after 299ee the sockaddr
    is AF_INET6, but the address is wrong.
    
    Fixes: 299ee123e198 (sctp: Fixup v4mapped behaviour to comply with Sock API)
    Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
    Acked-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Neil Horman <nhorman@tuxdriver.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>