commit 2ae6c0413b4768f9d8fc6f718a732f9dae014b67
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Aug 6 16:20:52 2018 +0200

    Linux 4.14.61

commit b4653a3ea3d7e68d4118f0476c72f70288c6c7f4
Author: Tony Battersby <tonyb@cybernetics.com>
Date:   Thu Jul 12 16:30:45 2018 -0400

    scsi: sg: fix minor memory leak in error path
    
    commit c170e5a8d222537e98aa8d4fddb667ff7a2ee114 upstream.
    
    Fix a minor memory leak when there is an error opening a /dev/sg device.
    
    Fixes: cc833acbee9d ("sg: O_EXCL and other lock handling")
    Cc: <stable@vger.kernel.org>
    Reviewed-by: Ewan D. Milne <emilne@redhat.com>
    Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
    Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1a08888316d2d69d772391597fadde90d1cf1483
Author: Boris Brezillon <boris.brezillon@bootlin.com>
Date:   Tue Jul 24 15:36:01 2018 +0200

    drm/vc4: Reset ->{x, y}_scaling[1] when dealing with uniplanar formats
    
    commit a6a00918d4ad8718c3ccde38c02cec17f116b2fd upstream.
    
    This is needed to ensure ->is_unity is correct when the plane was
    previously configured to output a multi-planar format with scaling
    enabled, and is then being reconfigured to output a uniplanar format.
    
    Fixes: fc04023fafec ("drm/vc4: Add support for YUV planes.")
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Link: https://patchwork.freedesktop.org/patch/msgid/20180724133601.32114-1-boris.brezillon@bootlin.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 51ef850c78bb311e7bc5e6aada5756fbf71d6b08
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Fri Jul 13 16:12:32 2018 +0800

    crypto: padlock-aes - Fix Nano workaround data corruption
    
    commit 46d8c4b28652d35dc6cfb5adf7f54e102fc04384 upstream.
    
    This was detected by the self-test thanks to Ard's chunking patch.
    
    I finally got around to testing this out on my ancient Via box.  It
    turns out that the workaround got the assembly wrong and we end up
    doing count + initial cycles of the loop instead of just count.
    
    This obviously causes corruption, either by overwriting the source
    that is yet to be processed, or writing over the end of the buffer.
    
    On CPUs that don't require the workaround only ECB is affected.
    On Nano CPUs both ECB and CBC are affected.
    
    This patch fixes it by doing the subtraction prior to the assembly.
    
    Fixes: a76c1c23d0c3 ("crypto: padlock-aes - work around Nano CPU...")
    Cc: <stable@vger.kernel.org>
    Reported-by: Jamie Heilman <jamie@audible.transient.net>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 65be9cbe1224f1fe51591b44e3d35603b81b595c
Author: Jack Morgenstein <jackm@dev.mellanox.co.il>
Date:   Wed Jul 11 11:23:52 2018 +0300

    RDMA/uverbs: Expand primary and alt AV port checks
    
    commit addb8a6559f0f8b5a37582b7ca698358445a55bf upstream.
    
    The commit cited below checked that the port numbers provided in the
    primary and alt AVs are legal.
    
    That is sufficient to prevent a kernel panic. However, it is not
    sufficient for correct operation.
    
    In Linux, AVs (both primary and alt) must be completely self-described.
    We do not accept an AV from userspace without an embedded port number.
    (This has been the case since kernel 3.14 commit dbf727de7440
    ("IB/core: Use GID table in AH creation and dmac resolution")).
    
    For the primary AV, this embedded port number must match the port number
    specified with IB_QP_PORT.
    
    We also expect the port number embedded in the alt AV to match the
    alt_port_num value passed by the userspace driver in the modify_qp command
    base structure.
    
    Add these checks to modify_qp.
    
    Cc: <stable@vger.kernel.org> # 4.16
    Fixes: 5d4c05c3ee36 ("RDMA/uverbs: Sanitize user entered port numbers prior to access it")
    Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
    Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
    Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4aa0acf290643c8161a0b6af4b5083a000124ff1
Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Date:   Tue Jul 17 13:43:56 2018 +0300

    iwlwifi: add more card IDs for 9000 series
    
    commit 0a5257bc6d89c2ae69b9bf955679cb4f89261874 upstream.
    
    Add new device IDs for the 9000 series.
    
    Cc: stable@vger.kernel.org # 4.14
    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0eba9f5d3d4829fe5cc53abe90a73c33f47405af
Author: Mike Rapoport <rppt@linux.vnet.ibm.com>
Date:   Thu Aug 2 15:36:09 2018 -0700

    userfaultfd: remove uffd flags from vma->vm_flags if UFFD_EVENT_FORK fails
    
    commit 31e810aa1033a7db50a2746cd34a2432237f6420 upstream.
    
    The fix in commit 0cbb4b4f4c44 ("userfaultfd: clear the
    vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails") cleared the
    vma->vm_userfaultfd_ctx but kept userfaultfd flags in vma->vm_flags
    that were copied from the parent process VMA.
    
    As the result, there is an inconsistency between the values of
    vma->vm_userfaultfd_ctx.ctx and vma->vm_flags which triggers BUG_ON
    in userfaultfd_release().
    
    Clearing the uffd flags from vma->vm_flags in case of UFFD_EVENT_FORK
    failure resolves the issue.
    
    Link: http://lkml.kernel.org/r/1532931975-25473-1-git-send-email-rppt@linux.vnet.ibm.com
    Fixes: 0cbb4b4f4c44 ("userfaultfd: clear the vma->vm_userfaultfd_ctx if UFFD_EVENT_FORK fails")
    Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Reported-by: syzbot+121be635a7a35ddb7dcb@syzkaller.appspotmail.com
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Eric Biggers <ebiggers3@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a1b5bcffe4a4e6740545fe8ab4a3381da148ce89
Author: Yi Wang <wang.yi59@zte.com.cn>
Date:   Wed Jul 25 10:26:19 2018 +0800

    audit: fix potential null dereference 'context->module.name'
    
    commit b305f7ed0f4f494ad6f3ef5667501535d5a8fa31 upstream.
    
    The variable 'context->module.name' may be null pointer when
    kmalloc return null, so it's better to check it before using
    to avoid null dereference.
    Another one more thing this patch does is using kstrdup instead
    of (kmalloc + strcpy), and signal a lost record via audit_log_lost.
    
    Cc: stable@vger.kernel.org # 4.11
    Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
    Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
    Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e5a16c6a6707f7ec905dc595cd3a7e37402735a2
Author: Roman Kagan <rkagan@virtuozzo.com>
Date:   Thu Jul 19 21:59:07 2018 +0300

    kvm: x86: vmx: fix vpid leak
    
    commit 63aff65573d73eb8dda4732ad4ef222dd35e4862 upstream.
    
    VPID for the nested vcpu is allocated at vmx_create_vcpu whenever nested
    vmx is turned on with the module parameter.
    
    However, it's only freed if the L1 guest has executed VMXON which is not
    a given.
    
    As a result, on a system with nested==on every creation+deletion of an
    L1 vcpu without running an L2 guest results in leaking one vpid.  Since
    the total number of vpids is limited to 64k, they can eventually get
    exhausted, preventing L2 from starting.
    
    Delay allocation of the L2 vpid until VMXON emulation, thus matching its
    freeing.
    
    Fixes: 5c614b3583e7b6dab0c86356fa36c2bcbb8322a0
    Cc: stable@vger.kernel.org
    Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c1a29c2d00c656fcc4abfeec5f4f92762e3c7437
Author: Andy Lutomirski <luto@kernel.org>
Date:   Sun Jul 22 11:05:09 2018 -0700

    x86/entry/64: Remove %ebx handling from error_entry/exit
    
    commit b3681dd548d06deb2e1573890829dff4b15abf46 upstream.
    
    error_entry and error_exit communicate the user vs. kernel status of
    the frame using %ebx.  This is unnecessary -- the information is in
    regs->cs.  Just use regs->cs.
    
    This makes error_entry simpler and makes error_exit more robust.
    
    It also fixes a nasty bug.  Before all the Spectre nonsense, the
    xen_failsafe_callback entry point returned like this:
    
            ALLOC_PT_GPREGS_ON_STACK
            SAVE_C_REGS
            SAVE_EXTRA_REGS
            ENCODE_FRAME_POINTER
            jmp     error_exit
    
    And it did not go through error_entry.  This was bogus: RBX
    contained garbage, and error_exit expected a flag in RBX.
    
    Fortunately, it generally contained *nonzero* garbage, so the
    correct code path was used.  As part of the Spectre fixes, code was
    added to clear RBX to mitigate certain speculation attacks.  Now,
    depending on kernel configuration, RBX got zeroed and, when running
    some Wine workloads, the kernel crashes.  This was introduced by:
    
        commit 3ac6d8c787b8 ("x86/entry/64: Clear registers for exceptions/interrupts, to reduce speculation attack surface")
    
    With this patch applied, RBX is no longer needed as a flag, and the
    problem goes away.
    
    I suspect that malicious userspace could use this bug to crash the
    kernel even without the offending patch applied, though.
    
    [ Historical note: I wrote this patch as a cleanup before I was aware
      of the bug it fixed. ]
    
    [ Note to stable maintainers: this should probably get applied to all
      kernels.  If you're nervous about that, a more conservative fix to
      add xorl %ebx,%ebx; incl %ebx before the jump to error_exit should
      also fix the problem. ]
    
    Reported-and-tested-by: M. Vefa Bicakci <m.v.b@runbox.com>
    Signed-off-by: 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: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Cc: Greg KH <gregkh@linuxfoundation.org>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Cc: xen-devel@lists.xenproject.org
    Fixes: 3ac6d8c787b8 ("x86/entry/64: Clear registers for exceptions/interrupts, to reduce speculation attack surface")
    Link: http://lkml.kernel.org/r/b5010a090d3586b2d6e06c7ad3ec5542d1241c45.1532282627.git.luto@kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7cf6b325f5545ba41953e2a49267632ea3a78af8
Author: Len Brown <len.brown@intel.com>
Date:   Sat Jul 21 17:19:19 2018 -0400

    x86/apic: Future-proof the TSC_DEADLINE quirk for SKX
    
    commit d9e6dbcf28f383bf08e6a3180972f5722e514a54 upstream.
    
    All SKX with stepping higher than 4 support the TSC_DEADLINE,
    no matter the microcode version.
    
    Without this patch, upcoming SKX steppings will not be able to use
    their TSC_DEADLINE timer.
    
    Signed-off-by: Len Brown <len.brown@intel.com>
    Cc: <stable@kernel.org> # v4.14+
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 616dd5872e ("x86/apic: Update TSC_DEADLINE quirk with additional SKX stepping")
    Link: http://lkml.kernel.org/r/d0c7129e509660be9ec6b233284b8d42d90659e8.1532207856.git.len.brown@intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 34a938cd3ad45b5c6d67d83329ce1dcf239863a8
Author: Jiang Biao <jiang.biao2@zte.com.cn>
Date:   Wed Jul 18 10:29:28 2018 +0800

    virtio_balloon: fix another race between migration and ballooning
    
    commit 89da619bc18d79bca5304724c11d4ba3b67ce2c6 upstream.
    
    Kernel panic when with high memory pressure, calltrace looks like,
    
    PID: 21439 TASK: ffff881be3afedd0 CPU: 16 COMMAND: "java"
     #0 [ffff881ec7ed7630] machine_kexec at ffffffff81059beb
     #1 [ffff881ec7ed7690] __crash_kexec at ffffffff81105942
     #2 [ffff881ec7ed7760] crash_kexec at ffffffff81105a30
     #3 [ffff881ec7ed7778] oops_end at ffffffff816902c8
     #4 [ffff881ec7ed77a0] no_context at ffffffff8167ff46
     #5 [ffff881ec7ed77f0] __bad_area_nosemaphore at ffffffff8167ffdc
     #6 [ffff881ec7ed7838] __node_set at ffffffff81680300
     #7 [ffff881ec7ed7860] __do_page_fault at ffffffff8169320f
     #8 [ffff881ec7ed78c0] do_page_fault at ffffffff816932b5
     #9 [ffff881ec7ed78f0] page_fault at ffffffff8168f4c8
        [exception RIP: _raw_spin_lock_irqsave+47]
        RIP: ffffffff8168edef RSP: ffff881ec7ed79a8 RFLAGS: 00010046
        RAX: 0000000000000246 RBX: ffffea0019740d00 RCX: ffff881ec7ed7fd8
        RDX: 0000000000020000 RSI: 0000000000000016 RDI: 0000000000000008
        RBP: ffff881ec7ed79a8 R8: 0000000000000246 R9: 000000000001a098
        R10: ffff88107ffda000 R11: 0000000000000000 R12: 0000000000000000
        R13: 0000000000000008 R14: ffff881ec7ed7a80 R15: ffff881be3afedd0
        ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
    
    It happens in the pagefault and results in double pagefault
    during compacting pages when memory allocation fails.
    
    Analysed the vmcore, the page leads to second pagefault is corrupted
    with _mapcount=-256, but private=0.
    
    It's caused by the race between migration and ballooning, and lock
    missing in virtballoon_migratepage() of virtio_balloon driver.
    This patch fix the bug.
    
    Fixes: e22504296d4f64f ("virtio_balloon: introduce migration primitives to balloon pages")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jiang Biao <jiang.biao2@zte.com.cn>
    Signed-off-by: Huang Chong <huang.chong@zte.com.cn>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 45c8178cf69ea21b6d0356b3e541c8e111ba6458
Author: Jeremy Cline <jcline@redhat.com>
Date:   Fri Jul 27 22:43:01 2018 +0000

    net: socket: fix potential spectre v1 gadget in socketcall
    
    commit c8e8cd579bb4265651df8223730105341e61a2d1 upstream.
    
    'call' is a user-controlled value, so sanitize the array index after the
    bounds check to avoid speculating past the bounds of the 'nargs' array.
    
    Found with the help of Smatch:
    
    net/socket.c:2508 __do_sys_socketcall() warn: potential spectre issue
    'nargs' [r] (local cap)
    
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Jeremy Cline <jcline@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c8159f9a1ae9c9ea76b389666a37bd9263a761cd
Author: Anton Vasilyev <vasilyev@ispras.ru>
Date:   Fri Jul 27 18:50:42 2018 +0300

    can: ems_usb: Fix memory leak on ems_usb_disconnect()
    
    commit 72c05f32f4a5055c9c8fe889bb6903ec959c0aad upstream.
    
    ems_usb_probe() allocates memory for dev->tx_msg_buffer, but there
    is no its deallocation in ems_usb_disconnect().
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7de67165efe052f1a05f4afae5b7cd4dc242b34
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Thu Aug 2 08:43:35 2018 -0700

    squashfs: more metadata hardenings
    
    commit 71755ee5350b63fb1f283de8561cdb61b47f4d1d upstream.
    
    The squashfs fragment reading code doesn't actually verify that the
    fragment is inside the fragment table.  The end result _is_ verified to
    be inside the image when actually reading the fragment data, but before
    that is done, we may end up taking a page fault because the fragment
    table itself might not even exist.
    
    Another report from Anatoly and his endless squashfs image fuzzing.
    
    Reported-by: Анатолий Тросиненко <anatoly.trosinenko@gmail.com>
    Acked-by:: Phillip Lougher <phillip.lougher@gmail.com>,
    Cc: Willy Tarreau <w@1wt.eu>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 953f918d548b569d37467fadb7266d0cd93a9ff6
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Mon Jul 30 14:27:15 2018 -0700

    squashfs: more metadata hardening
    
    commit d512584780d3e6a7cacb2f482834849453d444a1 upstream.
    
    Anatoly reports another squashfs fuzzing issue, where the decompression
    parameters themselves are in a compressed block.
    
    This causes squashfs_read_data() to be called in order to read the
    decompression options before the decompression stream having been set
    up, making squashfs go sideways.
    
    Reported-by: Anatoly Trosinenko <anatoly.trosinenko@gmail.com>
    Acked-by: Phillip Lougher <phillip.lougher@gmail.com>
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a766ccbf1d29db4f3a793131c2e986287757107c
Author: Eli Cohen <eli@mellanox.com>
Date:   Mon Jul 16 11:49:27 2018 +0300

    net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager
    
    [ Upstream commit 5f5991f36dce1e69dd8bd7495763eec2e28f08e7 ]
    
    Execute mlx5_eswitch_init() only if we have MLX5_ESWITCH_MANAGER
    capabilities.
    Do the same for mlx5_eswitch_cleanup().
    
    Fixes: a9f7705ffd66 ("net/mlx5: Unify vport manager capability check")
    Signed-off-by: Eli Cohen <eli@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e0638b6a054cef5ad820f7380ff59463c6519b57
Author: YueHaibing <yuehaibing@huawei.com>
Date:   Wed Aug 1 13:27:23 2018 +0100

    rxrpc: Fix user call ID check in rxrpc_service_prealloc_one
    
    [ Upstream commit c01f6c9b3207e52fc9973a066a856ddf7a0538d8 ]
    
    There just check the user call ID isn't already in use, hence should
    compare user_call_ID with xcall->user_call_ID, which is current
    node's user_call_ID.
    
    Fixes: 540b1c48c37a ("rxrpc: Fix deadlock between call creation and sendmsg/recvmsg")
    Suggested-by: David Howells <dhowells@redhat.com>
    Signed-off-by: YueHaibing <yuehaibing@huawei.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 83a46456c983258eb0ba6cfc1ad650df9f59c9c1
Author: Jose Abreu <Jose.Abreu@synopsys.com>
Date:   Tue Jul 31 15:08:20 2018 +0100

    net: stmmac: Fix WoL for PCI-based setups
    
    [ Upstream commit b7d0f08e9129c45ed41bc0cfa8e77067881e45fd ]
    
    WoL won't work in PCI-based setups because we are not saving the PCI EP
    state before entering suspend state and not allowing D3 wake.
    
    Fix this by using a wrapper around stmmac_{suspend/resume} which
    correctly sets the PCI EP state.
    
    Signed-off-by: Jose Abreu <joabreu@synopsys.com>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Joao Pinto <jpinto@synopsys.com>
    Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
    Cc: Alexandre Torgue <alexandre.torgue@st.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1828cb3d10d9fee017fdd13dc655f708a1f39d68
Author: Jeremy Cline <jcline@redhat.com>
Date:   Tue Jul 31 21:13:16 2018 +0000

    netlink: Fix spectre v1 gadget in netlink_create()
    
    [ Upstream commit bc5b6c0b62b932626a135f516a41838c510c6eba ]
    
    'protocol' is a user-controlled value, so sanitize it after the bounds
    check to avoid using it for speculative out-of-bounds access to arrays
    indexed by it.
    
    This addresses the following accesses detected with the help of smatch:
    
    * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
      spectre issue 'nlk_cb_mutex_keys' [w]
    
    * net/netlink/af_netlink.c:654 __netlink_create() warn: potential
      spectre issue 'nlk_cb_mutex_key_strings' [w]
    
    * net/netlink/af_netlink.c:685 netlink_create() warn: potential spectre
      issue 'nl_table' [w] (local cap)
    
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: Jeremy Cline <jcline@redhat.com>
    Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcbdea1371599dab43a16dcb3649f811cf602d03
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Tue Jul 31 17:12:52 2018 -0700

    net: dsa: Do not suspend/resume closed slave_dev
    
    [ Upstream commit a94c689e6c9e72e722f28339e12dff191ee5a265 ]
    
    If a DSA slave network device was previously disabled, there is no need
    to suspend or resume it.
    
    Fixes: 2446254915a7 ("net: dsa: allow switch drivers to implement suspend/resume hooks")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8721f360894576908a32f5c2979dbe640731a97b
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Jul 30 21:50:29 2018 -0700

    ipv4: frags: handle possible skb truesize change
    
    [ Upstream commit 4672694bd4f1aebdab0ad763ae4716e89cb15221 ]
    
    ip_frag_queue() might call pskb_pull() on one skb that
    is already in the fragment queue.
    
    We need to take care of possible truesize change, or we
    might have an imbalance of the netns frags memory usage.
    
    IPv6 is immune to this bug, because RFC5722, Section 4,
    amended by Errata ID 3089 states :
    
      When reassembling an IPv6 datagram, if
      one or more its constituent fragments is determined to be an
      overlapping fragment, the entire datagram (and any constituent
      fragments) MUST be silently discarded.
    
    Fixes: 158f323b9868 ("net: adjust skb->truesize in pskb_expand_head()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc63057d5fdad14ccf94dffe746187388aad2e55
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon Jul 30 20:09:11 2018 -0700

    inet: frag: enforce memory limits earlier
    
    [ Upstream commit 56e2c94f055d328f5f6b0a5c1721cca2f2d4e0a1 ]
    
    We currently check current frags memory usage only when
    a new frag queue is created. This allows attackers to first
    consume the memory budget (default : 4 MB) creating thousands
    of frag queues, then sending tiny skbs to exceed high_thresh
    limit by 2 to 3 order of magnitude.
    
    Note that before commit 648700f76b03 ("inet: frags: use rhashtables
    for reassembly units"), work queue could be starved under DOS,
    getting no cpu cycles.
    After commit 648700f76b03, only the per frag queue timer can eventually
    remove an incomplete frag queue and its skbs.
    
    Fixes: b13d3cbfb8e8 ("inet: frag: move eviction of queues to work queue")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Jann Horn <jannh@google.com>
    Cc: Florian Westphal <fw@strlen.de>
    Cc: Peter Oskolkov <posk@google.com>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Acked-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dc8edd08cd894a87b0136c7f077b48290eef14f6
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Jul 31 06:30:54 2018 -0700

    bonding: avoid lockdep confusion in bond_get_stats()
    
    [ Upstream commit 7e2556e40026a1b0c16f37446ab398d5a5a892e4 ]
    
    syzbot found that the following sequence produces a LOCKDEP splat [1]
    
    ip link add bond10 type bond
    ip link add bond11 type bond
    ip link set bond11 master bond10
    
    To fix this, we can use the already provided nest_level.
    
    This patch also provides correct nesting for dev->addr_list_lock
    
    [1]
    WARNING: possible recursive locking detected
    4.18.0-rc6+ #167 Not tainted
    --------------------------------------------
    syz-executor751/4439 is trying to acquire lock:
    (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: spin_lock include/linux/spinlock.h:310 [inline]
    (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: bond_get_stats+0xb4/0x560 drivers/net/bonding/bond_main.c:3426
    
    but task is already holding lock:
    (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: spin_lock include/linux/spinlock.h:310 [inline]
    (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: bond_get_stats+0xb4/0x560 drivers/net/bonding/bond_main.c:3426
    
    other info that might help us debug this:
     Possible unsafe locking scenario:
    
           CPU0
           ----
      lock(&(&bond->stats_lock)->rlock);
      lock(&(&bond->stats_lock)->rlock);
    
     *** DEADLOCK ***
    
     May be due to missing lock nesting notation
    
    3 locks held by syz-executor751/4439:
     #0: (____ptrval____) (rtnl_mutex){+.+.}, at: rtnl_lock+0x17/0x20 net/core/rtnetlink.c:77
     #1: (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: spin_lock include/linux/spinlock.h:310 [inline]
     #1: (____ptrval____) (&(&bond->stats_lock)->rlock){+.+.}, at: bond_get_stats+0xb4/0x560 drivers/net/bonding/bond_main.c:3426
     #2: (____ptrval____) (rcu_read_lock){....}, at: bond_get_stats+0x0/0x560 include/linux/compiler.h:215
    
    stack backtrace:
    CPU: 0 PID: 4439 Comm: syz-executor751 Not tainted 4.18.0-rc6+ #167
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
     print_deadlock_bug kernel/locking/lockdep.c:1765 [inline]
     check_deadlock kernel/locking/lockdep.c:1809 [inline]
     validate_chain kernel/locking/lockdep.c:2405 [inline]
     __lock_acquire.cold.64+0x1fb/0x486 kernel/locking/lockdep.c:3435
     lock_acquire+0x1e4/0x540 kernel/locking/lockdep.c:3924
     __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
     _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:144
     spin_lock include/linux/spinlock.h:310 [inline]
     bond_get_stats+0xb4/0x560 drivers/net/bonding/bond_main.c:3426
     dev_get_stats+0x10f/0x470 net/core/dev.c:8316
     bond_get_stats+0x232/0x560 drivers/net/bonding/bond_main.c:3432
     dev_get_stats+0x10f/0x470 net/core/dev.c:8316
     rtnl_fill_stats+0x4d/0xac0 net/core/rtnetlink.c:1169
     rtnl_fill_ifinfo+0x1aa6/0x3fb0 net/core/rtnetlink.c:1611
     rtmsg_ifinfo_build_skb+0xc8/0x190 net/core/rtnetlink.c:3268
     rtmsg_ifinfo_event.part.30+0x45/0xe0 net/core/rtnetlink.c:3300
     rtmsg_ifinfo_event net/core/rtnetlink.c:3297 [inline]
     rtnetlink_event+0x144/0x170 net/core/rtnetlink.c:4716
     notifier_call_chain+0x180/0x390 kernel/notifier.c:93
     __raw_notifier_call_chain kernel/notifier.c:394 [inline]
     raw_notifier_call_chain+0x2d/0x40 kernel/notifier.c:401
     call_netdevice_notifiers_info+0x3f/0x90 net/core/dev.c:1735
     call_netdevice_notifiers net/core/dev.c:1753 [inline]
     netdev_features_change net/core/dev.c:1321 [inline]
     netdev_change_features+0xb3/0x110 net/core/dev.c:7759
     bond_compute_features.isra.47+0x585/0xa50 drivers/net/bonding/bond_main.c:1120
     bond_enslave+0x1b25/0x5da0 drivers/net/bonding/bond_main.c:1755
     bond_do_ioctl+0x7cb/0xae0 drivers/net/bonding/bond_main.c:3528
     dev_ifsioc+0x43c/0xb30 net/core/dev_ioctl.c:327
     dev_ioctl+0x1b5/0xcc0 net/core/dev_ioctl.c:493
     sock_do_ioctl+0x1d3/0x3e0 net/socket.c:992
     sock_ioctl+0x30d/0x680 net/socket.c:1093
     vfs_ioctl fs/ioctl.c:46 [inline]
     file_ioctl fs/ioctl.c:500 [inline]
     do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:684
     ksys_ioctl+0xa9/0xd0 fs/ioctl.c:701
     __do_sys_ioctl fs/ioctl.c:708 [inline]
     __se_sys_ioctl fs/ioctl.c:706 [inline]
     __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:706
     do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
     entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x440859
    Code: e8 2c af 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 3b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007ffc51a92878 EFLAGS: 00000213 ORIG_RAX: 0000000000000010
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000440859
    RDX: 0000000020000040 RSI: 0000000000008990 RDI: 0000000000000003
    RBP: 0000000000000000 R08: 00000000004002c8 R09: 00000000004002c8
    R10: 00000000022d5880 R11: 0000000000000213 R12: 0000000000007390
    R13: 0000000000401db0 R14: 0000000000000000 R15: 0000000000000000
    
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Jay Vosburgh <j.vosburgh@gmail.com>
    Cc: Veaceslav Falico <vfalico@gmail.com>
    Cc: Andy Gospodarek <andy@greyhouse.net>
    
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
