commit e0e7ae96b72318d3d8797de0befbe6c6f001f663
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Thu Aug 24 17:15:18 2017 -0700

    Linux 4.12.9

commit 3f40666fff9678bb549dbd4653484538a8aa7d9d
Author: Hector Martin <marcan@marcan.st>
Date:   Wed Aug 2 00:45:44 2017 +0900

    usb: qmi_wwan: add D-Link DWM-222 device ID
    
    commit bed9ff165960921303a100228585f2d1691b42eb upstream.
    
    Signed-off-by: Hector Martin <marcan@marcan.st>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2322bcce28862537c4c31684a3eeaf5a3e27c20
Author: Mathias Nyman <mathias.nyman@linux.intel.com>
Date:   Fri Jun 2 16:36:26 2017 +0300

    usb: optimize acpi companion search for usb port devices
    
    commit ed18c5fa945768a9bec994e786edbbbc7695acf6 upstream.
    
    This optimization significantly reduces xhci driver load time.
    
    In ACPI tables the acpi companion port devices are children of
    the hub device. The port devices are identified by their port number
    returned by the ACPI _ADR method.
    _ADR 0 is reserved for the root hub device.
    
    The current implementation to find a acpi companion port device
    loops through all acpi port devices under that parent hub, evaluating
    their _ADR method each time a new port device is added.
    
    for a xHC controller with 25 ports under its roothub it
    will end up invoking ACPI bytecode 625 times before all ports
    are ready, making it really slow.
    
    The _ADR values are already read and cached earler. So instead of
    running the bytecode again we can check the cached _ADR value first,
    and then fall back to the old way.
    
    As one of the more significant changes, the xhci load time on
    Intel kabylake reduced by 70%, (28ms) from
    initcall xhci_pci_init+0x0/0x49 returned 0 after 39537 usecs
    to
    initcall xhci_pci_init+0x0/0x49 returned 0 after 11270 usecs
    
    Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6632ae821b59916c1a6e38e5a35f80df26faf90c
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date:   Sat Jul 15 00:10:58 2017 -0500

    debug: Fix WARN_ON_ONCE() for modules
    
    commit 325cdacd03c12629aa5f9ee2ace49b1f3dc184a8 upstream.
    
    Mike Galbraith reported a situation where a WARN_ON_ONCE() call in DRM
    code turned into an oops.  As it turns out, WARN_ON_ONCE() seems to be
    completely broken when called from a module.
    
    The bug was introduced with the following commit:
    
      19d436268dde ("debug: Add _ONCE() logic to report_bug()")
    
    That commit changed WARN_ON_ONCE() to move its 'once' logic into the bug
    trap handler.  It requires a writable bug table so that the BUGFLAG_DONE
    bit can be written to the flags to indicate the first warning has
    occurred.
    
    The bug table was made writable for vmlinux, which relies on
    vmlinux.lds.S and vmlinux.lds.h for laying out the sections.  However,
    it wasn't made writable for modules, which rely on the ELF section
    header flags.
    
    Reported-by: Mike Galbraith <efault@gmx.de>
    Tested-by: Masami Hiramatsu <mhiramat@kernel.org>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 19d436268dde ("debug: Add _ONCE() logic to report_bug()")
    Link: http://lkml.kernel.org/r/a53b04235a65478dd9afc51f5b329fdc65c84364.1500095401.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Changbin Du <changbin.du@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c170b7930db3ab6de2a81b76e7f9bd3444c8ca32
Author: Oleg Nesterov <oleg@redhat.com>
Date:   Mon Aug 21 17:35:02 2017 +0200

    pids: make task_tgid_nr_ns() safe
    
    commit dd1c1f2f2028a7b851f701fc6a8ebe39dcb95e7c upstream.
    
    This was reported many times, and this was even mentioned in commit
    52ee2dfdd4f5 ("pids: refactor vnr/nr_ns helpers to make them safe") but
    somehow nobody bothered to fix the obvious problem: task_tgid_nr_ns() is
    not safe because task->group_leader points to nowhere after the exiting
    task passes exit_notify(), rcu_read_lock() can not help.
    
    We really need to change __unhash_process() to nullify group_leader,
    parent, and real_parent, but this needs some cleanups.  Until then we
    can turn task_tgid_nr_ns() into another user of __task_pid_nr_ns() and
    fix the problem.
    
    Reported-by: Troy Kensinger <tkensinger@google.com>
    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e950adf8983f18cf210145af0cda1fe7e6aa8c11
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Sun Aug 20 13:26:27 2017 -0700

    Sanitize 'move_pages()' permission checks
    
    commit 197e7e521384a23b9e585178f3f11c9fa08274b9 upstream.
    
    The 'move_paghes()' system call was introduced long long ago with the
    same permission checks as for sending a signal (except using
    CAP_SYS_NICE instead of CAP_SYS_KILL for the overriding capability).
    
    That turns out to not be a great choice - while the system call really
    only moves physical page allocations around (and you need other
    capabilities to do a lot of it), you can check the return value to map
    out some the virtual address choices and defeat ASLR of a binary that
    still shares your uid.
    
    So change the access checks to the more common 'ptrace_may_access()'
    model instead.
    
    This tightens the access checks for the uid, and also effectively
    changes the CAP_SYS_NICE check to CAP_SYS_PTRACE, but it's unlikely that
    anybody really _uses_ this legacy system call any more (we hav ebetter
    NUMA placement models these days), so I expect nobody to notice.
    
    Famous last words.
    
    Reported-by: Otto Ebeling <otto.ebeling@iki.fi>
    Acked-by: Eric W. Biederman <ebiederm@xmission.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 7cbc3a8aaaa37eaacbf33c60356677bce837428a
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Aug 15 09:50:13 2017 +0200

    kernel/watchdog: Prevent false positives with turbo modes
    
    commit 7edaeb6841dfb27e362288ab8466ebdc4972e867 upstream.
    
    The hardlockup detector on x86 uses a performance counter based on unhalted
    CPU cycles and a periodic hrtimer. The hrtimer period is about 2/5 of the
    performance counter period, so the hrtimer should fire 2-3 times before the
    performance counter NMI fires. The NMI code checks whether the hrtimer
    fired since the last invocation. If not, it assumess a hard lockup.
    
    The calculation of those periods is based on the nominal CPU
    frequency. Turbo modes increase the CPU clock frequency and therefore
    shorten the period of the perf/NMI watchdog. With extreme Turbo-modes (3x
    nominal frequency) the perf/NMI period is shorter than the hrtimer period
    which leads to false positives.
    
    A simple fix would be to shorten the hrtimer period, but that comes with
    the side effect of more frequent hrtimer and softlockup thread wakeups,
    which is not desired.
    
    Implement a low pass filter, which checks the perf/NMI period against
    kernel time. If the perf/NMI fires before 4/5 of the watchdog period has
    elapsed then the event is ignored and postponed to the next perf/NMI.
    
    That solves the problem and avoids the overhead of shorter hrtimer periods
    and more frequent softlockup thread wakeups.
    
    Fixes: 58687acba592 ("lockup_detector: Combine nmi_watchdog and softlockup detector")
    Reported-and-tested-by: Kan Liang <Kan.liang@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: dzickus@redhat.com
    Cc: prarit@redhat.com
    Cc: ak@linux.intel.com
    Cc: babu.moger@oracle.com
    Cc: peterz@infradead.org
    Cc: eranian@google.com
    Cc: acme@redhat.com
    Cc: atomlin@redhat.com
    Cc: akpm@linux-foundation.org
    Cc: torvalds@linux-foundation.org
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1708150931310.1886@nanos
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ee7025fef78c8c9a8ad476829025a25cdd5d590d
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Sat Aug 19 12:57:51 2017 +0300

    genirq/ipi: Fixup checks against nr_cpu_ids
    
    commit 8fbbe2d7cc478d1544f41f2271787c993c23a4f6 upstream.
    
    Valid CPU ids are [0, nr_cpu_ids-1] inclusive.
    
    Fixes: 3b8e29a82dd1 ("genirq: Implement ipi_send_mask/single()")
    Fixes: f9bce791ae2a ("genirq: Add a new function to get IPI reverse mapping")
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/20170819095751.GB27864@avx2
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8eee5da54afe3de15af67a41ff2b6125af62a590
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Fri Aug 18 10:53:45 2017 +0100

    genirq: Restore trigger settings in irq_modify_status()
    
    commit e8f241893dfbbebe2813c01eac54f263e6a5e59c upstream.
    
    irq_modify_status starts by clearing the trigger settings from
    irq_data before applying the new settings, but doesn't restore them,
    leaving them to IRQ_TYPE_NONE.
    
    That's pretty confusing to the potential request_irq() that could
    follow. Instead, snapshot the settings before clearing them, and restore
    them if the irq_modify_status() invocation was not changing the trigger.
    
    Fixes: 1e2a7d78499e ("irqdomain: Don't set type when mapping an IRQ")
    Reported-and-tested-by: jeffy <jeffy.chen@rock-chips.com>
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Jon Hunter <jonathanh@nvidia.com>
    Link: http://lkml.kernel.org/r/20170818095345.12378-1-marc.zyngier@arm.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 399193e8ef2d41a123831ce67561fb5419c85324
Author: Boris Brezillon <boris.brezillon@free-electrons.com>
Date:   Tue Jul 4 11:10:40 2017 +0200

    irqchip/atmel-aic: Fix unbalanced refcount in aic_common_rtc_irq_fixup()
    
    commit 277867ade8262583f4280cadbe90e0031a3706a7 upstream.
    
    of_find_compatible_node() is calling of_node_put() on its first argument
    thus leading to an unbalanced of_node_get/put() issue if the node has not
    been retained before that.
    
    Instead of passing the root node, pass NULL, which does exactly the same:
    iterate over all DT nodes, starting from the root node.
    
    Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
    Reported-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Fixes: 3d61467f9bab ("irqchip: atmel-aic: Implement RTC irq fixup")
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2eceab663b9d04abb10ada7050ac7406b7b40c19
Author: Boris Brezillon <boris.brezillon@free-electrons.com>
Date:   Tue Jul 4 11:10:39 2017 +0200

    irqchip/atmel-aic: Fix unbalanced of_node_put() in aic_common_irq_fixup()
    
    commit 469bcef53c546bb792aa66303933272991b7831d upstream.
    
    aic_common_irq_fixup() is calling twice of_node_put() on the same node
    thus leading to an unbalanced refcount on the root node.
    
    Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
    Reported-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Fixes: b2f579b58e93 ("irqchip: atmel-aic: Add irq fixup infrastructure")
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c4ab73ef2cfc3898c839513db9032d07c88f0f11
Author: Oleg Nesterov <oleg@redhat.com>
Date:   Tue Aug 15 17:40:11 2017 +0200

    x86/elf: Remove the unnecessary ADDR_NO_RANDOMIZE checks
    
    commit 01578e36163cdd0e4fd61d9976de15f13364e26d upstream.
    
    The ADDR_NO_RANDOMIZE checks in stack_maxrandom_size() and
    randomize_stack_top() are not required.
    
    PF_RANDOMIZE is set by load_elf_binary() only if ADDR_NO_RANDOMIZE is not
    set, no need to re-check after that.
    
    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Link: http://lkml.kernel.org/r/20170815154011.GB1076@redhat.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 932769e10de9f8b46707af8ee95ae507cba58b2e
Author: Oleg Nesterov <oleg@redhat.com>
Date:   Tue Aug 15 17:39:52 2017 +0200

    x86: Fix norandmaps/ADDR_NO_RANDOMIZE
    
    commit 47ac5484fd961420e5ec0bb5b972fde381f57365 upstream.
    
    Documentation/admin-guide/kernel-parameters.txt says:
    
        norandmaps  Don't use address space randomization. Equivalent
                    to echo 0 > /proc/sys/kernel/randomize_va_space
    
    but it doesn't work because arch_rnd() which is used to randomize
    mm->mmap_base returns a random value unconditionally. And as Kirill
    pointed out, ADDR_NO_RANDOMIZE is broken by the same reason.
    
    Just shift the PF_RANDOMIZE check from arch_mmap_rnd() to arch_rnd().
    
    Fixes: 1b028f784e8c ("x86/mm: Introduce mmap_compat_base() for 32-bit mmap()")
    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
    Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20170815153952.GA1076@redhat.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c588e0cb269da19162eb896d397dc7ea54388cbf
Author: Andy Lutomirski <luto@kernel.org>
Date:   Mon Aug 7 19:43:13 2017 -0700

    x86/asm/64: Clear AC on NMI entries
    
    commit e93c17301ac55321fc18e0f8316e924e58a83c8c upstream.
    
    This closes a hole in our SMAP implementation.
    
    This patch comes from grsecurity. Good catch!
    
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    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>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/314cc9f294e8f14ed85485727556ad4f15bb1659.1502159503.git.luto@kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 44e9d5afcec38098a4f7056116a486e110c55b49
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Wed Aug 2 19:39:30 2017 +0200

    perf/x86: Fix RDPMC vs. mm_struct tracking
    
    commit bfe334924ccd9f4a53f30240c03cf2f43f5b2df1 upstream.
    
    Vince reported the following rdpmc() testcase failure:
    
     > Failing test case:
     >
     >      fd=perf_event_open();
     >      addr=mmap(fd);
     >      exec()  // without closing or unmapping the event
     >      fd=perf_event_open();
     >      addr=mmap(fd);
     >      rdpmc() // GPFs due to rdpmc being disabled
    
    The problem is of course that exec() plays tricks with what is
    current->mm, only destroying the old mappings after having
    installed the new mm.
    
    Fix this confusion by passing along vma->vm_mm instead of relying on
    current->mm.
    
    Reported-by: Vince Weaver <vincent.weaver@maine.edu>
    Tested-by: Vince Weaver <vincent.weaver@maine.edu>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Reviewed-by: Andy Lutomirski <luto@kernel.org>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@gmail.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Fixes: 1e0fb9ec679c ("perf: Add pmu callbacks to track event mapping and unmapping")
    Link: http://lkml.kernel.org/r/20170802173930.cstykcqefmqt7jau@hirez.programming.kicks-ass.net
    [ Minor cleanups. ]
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 33f1d0c79b044ac8d721d24ea0adb4146824d3bf
Author: Munehisa Kamata <kamatam@amazon.com>
Date:   Wed Aug 9 15:31:40 2017 -0700

    xen-blkfront: use a right index when checking requests
    
    commit b15bd8cb37598afb2963f7eb9e2de468d2d60a2f upstream.
    
    Since commit d05d7f40791c ("Merge branch 'for-4.8/core' of
    git://git.kernel.dk/linux-block") and 3fc9d690936f ("Merge branch
    'for-4.8/drivers' of git://git.kernel.dk/linux-block"), blkfront_resume()
    has been using an index for iterating ring_info to check request when
    iterating blk_shadow in an inner loop. This seems to have been
    accidentally introduced during the massive rewrite of the block layer
    macros in the commits.
    
    This may cause crash like this:
    
    [11798.057074] BUG: unable to handle kernel NULL pointer dereference at 0000000000000048
    [11798.058832] IP: [<ffffffff814411fa>] blkfront_resume+0x10a/0x610
    ....
    [11798.061063] Call Trace:
    [11798.061063]  [<ffffffff8139ce93>] xenbus_dev_resume+0x53/0x140
    [11798.061063]  [<ffffffff8139ce40>] ? xenbus_dev_probe+0x150/0x150
    [11798.061063]  [<ffffffff813f359e>] dpm_run_callback+0x3e/0x110
    [11798.061063]  [<ffffffff813f3a08>] device_resume+0x88/0x190
    [11798.061063]  [<ffffffff813f4cc0>] dpm_resume+0x100/0x2d0
    [11798.061063]  [<ffffffff813f5221>] dpm_resume_end+0x11/0x20
    [11798.061063]  [<ffffffff813950a8>] do_suspend+0xe8/0x1a0
    [11798.061063]  [<ffffffff813954bd>] shutdown_handler+0xfd/0x130
    [11798.061063]  [<ffffffff8139aba0>] ? split+0x110/0x110
    [11798.061063]  [<ffffffff8139ac26>] xenwatch_thread+0x86/0x120
    [11798.061063]  [<ffffffff810b4570>] ? prepare_to_wait_event+0x110/0x110
    [11798.061063]  [<ffffffff8108fe57>] kthread+0xd7/0xf0
    [11798.061063]  [<ffffffff811da811>] ? kfree+0x121/0x170
    [11798.061063]  [<ffffffff8108fd80>] ? kthread_park+0x60/0x60
    [11798.061063]  [<ffffffff810863b0>] ?  call_usermodehelper_exec_work+0xb0/0xb0
    [11798.061063]  [<ffffffff810864ea>] ?  call_usermodehelper_exec_async+0x13a/0x140
    [11798.061063]  [<ffffffff81534a45>] ret_from_fork+0x25/0x30
    
    Use the right index in the inner loop.
    
    Fixes: d05d7f40791c ("Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block")
    Fixes: 3fc9d690936f ("Merge branch 'for-4.8/drivers' of git://git.kernel.dk/linux-block")
    Signed-off-by: Munehisa Kamata <kamatam@amazon.com>
    Reviewed-by: Thomas Friebel <friebelt@amazon.de>
    Reviewed-by: Eduardo Valentin <eduval@amazon.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Reviewed-by: Roger Pau Monne <roger.pau@citrix.com>
    Cc: xen-devel@lists.xenproject.org
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bd876f33dbebc1d0dc70386f28323b918dabe1f3
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Wed Aug 16 16:01:14 2017 +1000

    powerpc: Fix VSX enabling/flushing to also test MSR_FP and MSR_VEC
    
    commit 5a69aec945d27e78abac9fd032533d3aaebf7c1e upstream.
    
    VSX uses a combination of the old vector registers, the old FP
    registers and new "second halves" of the FP registers.
    
    Thus when we need to see the VSX state in the thread struct
    (flush_vsx_to_thread()) or when we'll use the VSX in the kernel
    (enable_kernel_vsx()) we need to ensure they are all flushed into
    the thread struct if either of them is individually enabled.
    
    Unfortunately we only tested if the whole VSX was enabled, not if they
    were individually enabled.
    
    Fixes: 72cd7b44bc99 ("powerpc: Uncomment and make enable_kernel_vsx() routine available")
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a77b5b81ad592f4afe4418241cdd521a265f90f0
Author: Christoph Hellwig <hch@lst.de>
Date:   Thu Aug 17 12:24:47 2017 +0200

    blk-mq-pci: add a fallback when pci_irq_get_affinity returns NULL
    
    commit c005390374957baacbc38eef96ea360559510aa7 upstream.
    
    While pci_irq_get_affinity should never fail for SMP kernel that
    implement the affinity mapping, it will always return NULL in the
    UP case, so provide a fallback mapping of all queues to CPU 0 in
    that case.
    
    Signed-off-by: Christoph Hellwig <hch@lst.de>
    Reviewed-by: Omar Sandoval <osandov@fb.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e88bdec3ff7c9752d895c1e49f41319dea21ab76
Author: Gary Bisson <gary.bisson@boundarydevices.com>
Date:   Thu Aug 17 15:50:10 2017 +0200

    ARM: dts: imx6qdl-nitrogen6_som2: fix PCIe reset
    
    commit c40bc54fdf2d52a80f66b365f1eac9d43b32e107 upstream.
    
    Previous value was a bad copy of nitrogen6_max device tree.
    
    Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
    Fixes: 3faa1bb2e89c ("ARM: dts: imx: add Boundary Devices Nitrogen6_SOM2 support")
    Signed-off-by: Shawn Guo <shawnguo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c1cee6062ac9c375cda25bd2d334d54af4bd4c26
Author: Roger Pau Monne <roger.pau@citrix.com>
Date:   Tue Jul 18 15:01:00 2017 +0100

    xen: fix bio vec merging
    
    commit 462cdace790ac2ed6aad1b19c9c0af0143b6aab0 upstream.
    
    The current test for bio vec merging is not fully accurate and can be
    tricked into merging bios when certain grant combinations are used.
    The result of these malicious bio merges is a bio that extends past
    the memory page used by any of the originating bios.
    
    Take into account the following scenario, where a guest creates two
    grant references that point to the same mfn, ie: grant 1 -> mfn A,
    grant 2 -> mfn A.
    
    These references are then used in a PV block request, and mapped by
    the backend domain, thus obtaining two different pfns that point to
    the same mfn, pfn B -> mfn A, pfn C -> mfn A.
    
    If those grants happen to be used in two consecutive sectors of a disk
    IO operation becoming two different bios in the backend domain, the
    checks in xen_biovec_phys_mergeable will succeed, because bfn1 == bfn2
    (they both point to the same mfn). However due to the bio merging,
    the backend domain will end up with a bio that expands past mfn A into
    mfn A + 1.
    
    Fix this by making sure the check in xen_biovec_phys_mergeable takes
    into account the offset and the length of the bio, this basically
    replicates whats done in __BIOVEC_PHYS_MERGEABLE using mfns (bus
    addresses). While there also remove the usage of
    __BIOVEC_PHYS_MERGEABLE, since that's already checked by the callers
    of xen_biovec_phys_mergeable.
    
    Reported-by: "Jan H. Schönherr" <jschoenh@amazon.de>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aab425db4279aeb83b7911693f0cccbd3644c9fd
Author: Kees Cook <keescook@chromium.org>
Date:   Fri Aug 18 15:16:31 2017 -0700

    mm: revert x86_64 and arm64 ELF_ET_DYN_BASE base changes
    
    commit c715b72c1ba406f133217b509044c38d8e714a37 upstream.
    
    Moving the x86_64 and arm64 PIE base from 0x555555554000 to 0x000100000000
    broke AddressSanitizer.  This is a partial revert of:
    
      eab09532d400 ("binfmt_elf: use ELF_ET_DYN_BASE only for PIE")
      02445990a96e ("arm64: move ELF_ET_DYN_BASE to 4GB / 4MB")
    
    The AddressSanitizer tool has hard-coded expectations about where
    executable mappings are loaded.
    
    The motivation for changing the PIE base in the above commits was to
    avoid the Stack-Clash CVEs that allowed executable mappings to get too
    close to heap and stack.  This was mainly a problem on 32-bit, but the
    64-bit bases were moved too, in an effort to proactively protect those
    systems (proofs of concept do exist that show 64-bit collisions, but
    other recent changes to fix stack accounting and setuid behaviors will
    minimize the impact).
    
    The new 32-bit PIE base is fine for ASan (since it matches the ET_EXEC
    base), so only the 64-bit PIE base needs to be reverted to let x86 and
    arm64 ASan binaries run again.  Future changes to the 64-bit PIE base on
    these architectures can be made optional once a more dynamic method for
    dealing with AddressSanitizer is found.  (e.g.  always loading PIE into
    the mmap region for marked binaries.)
    
    Link: http://lkml.kernel.org/r/20170807201542.GA21271@beast
    Fixes: eab09532d400 ("binfmt_elf: use ELF_ET_DYN_BASE only for PIE")
    Fixes: 02445990a96e ("arm64: move ELF_ET_DYN_BASE to 4GB / 4MB")
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Reported-by: Kostya Serebryany <kcc@google.com>
    Acked-by: Will Deacon <will.deacon@arm.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: "H. Peter Anvin" <hpa@zytor.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    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 8ac8e1d2a2547607b164e3b5e58c5084906ad05e
Author: Laura Abbott <labbott@redhat.com>
Date:   Fri Aug 18 15:16:27 2017 -0700

    mm/vmalloc.c: don't unconditonally use __GFP_HIGHMEM
    
    commit 704b862f9efd6d4c87a8d0a344dda19bda9c6b69 upstream.
    
    Commit 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly") added
    use of __GFP_HIGHMEM for allocations.  vmalloc_32 may use
    GFP_DMA/GFP_DMA32 which does not play nice with __GFP_HIGHMEM and will
    trigger a BUG in gfp_zone.
    
    Only add __GFP_HIGHMEM if we aren't using GFP_DMA/GFP_DMA32.
    
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1482249
    Link: http://lkml.kernel.org/r/20170816220705.31374-1-labbott@redhat.com
    Fixes: 19809c2da28a ("mm, vmalloc: use __GFP_HIGHMEM implicitly")
    Signed-off-by: Laura Abbott <labbott@redhat.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    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 6b2676ed32bad395689998bea6ce2d64aeda02a6
Author: zhong jiang <zhongjiang@huawei.com>
Date:   Fri Aug 18 15:16:24 2017 -0700

    mm/mempolicy: fix use after free when calling get_mempolicy
    
    commit 73223e4e2e3867ebf033a5a8eb2e5df0158ccc99 upstream.
    
    I hit a use after free issue when executing trinity and repoduced it
    with KASAN enabled.  The related call trace is as follows.
    
      BUG: KASan: use after free in SyS_get_mempolicy+0x3c8/0x960 at addr ffff8801f582d766
      Read of size 2 by task syz-executor1/798
    
      INFO: Allocated in mpol_new.part.2+0x74/0x160 age=3 cpu=1 pid=799
         __slab_alloc+0x768/0x970
         kmem_cache_alloc+0x2e7/0x450
         mpol_new.part.2+0x74/0x160
         mpol_new+0x66/0x80
         SyS_mbind+0x267/0x9f0
         system_call_fastpath+0x16/0x1b
      INFO: Freed in __mpol_put+0x2b/0x40 age=4 cpu=1 pid=799
         __slab_free+0x495/0x8e0
         kmem_cache_free+0x2f3/0x4c0
         __mpol_put+0x2b/0x40
         SyS_mbind+0x383/0x9f0
         system_call_fastpath+0x16/0x1b
      INFO: Slab 0xffffea0009cb8dc0 objects=23 used=8 fp=0xffff8801f582de40 flags=0x200000000004080
      INFO: Object 0xffff8801f582d760 @offset=5984 fp=0xffff8801f582d600
    
      Bytes b4 ffff8801f582d750: ae 01 ff ff 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a  ........ZZZZZZZZ
      Object ffff8801f582d760: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
      Object ffff8801f582d770: 6b 6b 6b 6b 6b 6b 6b a5                          kkkkkkk.
      Redzone ffff8801f582d778: bb bb bb bb bb bb bb bb                          ........
      Padding ffff8801f582d8b8: 5a 5a 5a 5a 5a 5a 5a 5a                          ZZZZZZZZ
      Memory state around the buggy address:
      ffff8801f582d600: fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc fc
      ffff8801f582d680: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff8801f582d700: fc fc fc fc fc fc fc fc fc fc fc fc fb fb fb fc
    
    !shared memory policy is not protected against parallel removal by other
    thread which is normally protected by the mmap_sem.  do_get_mempolicy,
    however, drops the lock midway while we can still access it later.
    
    Early premature up_read is a historical artifact from times when
    put_user was called in this path see https://lwn.net/Articles/124754/
    but that is gone since 8bccd85ffbaf ("[PATCH] Implement sys_* do_*
    layering in the memory policy layer.").  but when we have the the
    current mempolicy ref count model.  The issue was introduced
    accordingly.
    
    Fix the issue by removing the premature release.
    
    Link: http://lkml.kernel.org/r/1502950924-27521-1-git-send-email-zhongjiang@huawei.com
    Signed-off-by: zhong jiang <zhongjiang@huawei.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    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 8b53b7560a8b33216ebb2b4522668b70b3bbba41
Author: Prakash Gupta <guptap@codeaurora.org>
Date:   Fri Aug 18 15:16:21 2017 -0700

    mm/cma_debug.c: fix stack corruption due to sprintf usage
    
    commit da094e42848e3c36feaa3b5271e53983fd45424f upstream.
    
    name[] in cma_debugfs_add_one() can only accommodate 16 chars including
    NULL to store sprintf output.  It's common for cma device name to be
    larger than 15 chars.  This can cause stack corrpution.  If the gcc
    stack protector is turned on, this can cause a panic due to stack
    corruption.
    
    Below is one example trace:
    
      Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in:
      ffffff8e69a75730
      Call trace:
         dump_backtrace+0x0/0x2c4
         show_stack+0x20/0x28
         dump_stack+0xb8/0xf4
         panic+0x154/0x2b0
         print_tainted+0x0/0xc0
         cma_debugfs_init+0x274/0x290
         do_one_initcall+0x5c/0x168
         kernel_init_freeable+0x1c8/0x280
    
    Fix the short sprintf buffer in cma_debugfs_add_one() by using
    scnprintf() instead of sprintf().
    
    Link: http://lkml.kernel.org/r/1502446217-21840-1-git-send-email-guptap@codeaurora.org
    Fixes: f318dd083c81 ("cma: Store a name in the cma structure")
    Signed-off-by: Prakash Gupta <guptap@codeaurora.org>
    Acked-by: Laura Abbott <labbott@redhat.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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 76e8fe02bf5064143de5815a8762d73492689f9d
Author: Michal Hocko <mhocko@suse.com>
Date:   Fri Aug 18 15:16:12 2017 -0700

    mm: fix double mmap_sem unlock on MMF_UNSTABLE enforced SIGBUS
    
    commit 5b53a6ea886700a128b697a6fe8375340dea2c30 upstream.
    
    Tetsuo Handa has noticed that MMF_UNSTABLE SIGBUS path in
    handle_mm_fault causes a lockdep splat
    
      Out of memory: Kill process 1056 (a.out) score 603 or sacrifice child
      Killed process 1056 (a.out) total-vm:4268108kB, anon-rss:2246048kB, file-rss:0kB, shmem-rss:0kB
      a.out (1169) used greatest stack depth: 11664 bytes left
      DEBUG_LOCKS_WARN_ON(depth <= 0)
      ------------[ cut here ]------------
      WARNING: CPU: 6 PID: 1339 at kernel/locking/lockdep.c:3617 lock_release+0x172/0x1e0
      CPU: 6 PID: 1339 Comm: a.out Not tainted 4.13.0-rc3-next-20170803+ #142
      Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/02/2015
      RIP: 0010:lock_release+0x172/0x1e0
      Call Trace:
         up_read+0x1a/0x40
         __do_page_fault+0x28e/0x4c0
         do_page_fault+0x30/0x80
         page_fault+0x28/0x30
    
    The reason is that the page fault path might have dropped the mmap_sem
    and returned with VM_FAULT_RETRY.  MMF_UNSTABLE check however rewrites
    the error path to VM_FAULT_SIGBUS and we always expect mmap_sem taken in
    that path.  Fix this by taking mmap_sem when VM_FAULT_RETRY is held in
    the MMF_UNSTABLE path.
    
    We cannot simply add VM_FAULT_SIGBUS to the existing error code because
    all arch specific page fault handlers and g-u-p would have to learn a
    new error code combination.
    
    Link: http://lkml.kernel.org/r/20170807113839.16695-2-mhocko@kernel.org
    Fixes: 3f70dc38cec2 ("mm: make sure that kthreads will not refault oom reaped memory")
    Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Acked-by: David Rientjes <rientjes@google.com>
    Cc: Andrea Argangeli <andrea@kernel.org>
    Cc: "Kirill A. Shutemov" <kirill@shutemov.name>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Wenwei Tao <wenwei.tww@alibaba-inc.com>
    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 889a17078f255307d591c875d0412e54d9ac9492
Author: Vladimir Davydov <vdavydov.dev@gmail.com>
Date:   Fri Aug 18 15:16:08 2017 -0700

    slub: fix per memcg cache leak on css offline
    
    commit f6ba488073fe8159851fe398cc3c5ee383bb4c7a upstream.
    
    To avoid a possible deadlock, sysfs_slab_remove() schedules an
    asynchronous work to delete sysfs entries corresponding to the kmem
    cache.  To ensure the cache isn't freed before the work function is
    called, it takes a reference to the cache kobject.  The reference is
    supposed to be released by the work function.
    
    However, the work function (sysfs_slab_remove_workfn()) does nothing in
    case the cache sysfs entry has already been deleted, leaking the kobject
    and the corresponding cache.
    
    This may happen on a per memcg cache destruction, because sysfs entries
    of a per memcg cache are deleted on memcg offline if the cache is empty
    (see __kmemcg_cache_deactivate()).
    
    The kmemleak report looks like this:
    
      unreferenced object 0xffff9f798a79f540 (size 32):
        comm "kworker/1:4", pid 15416, jiffies 4307432429 (age 28687.554s)
        hex dump (first 32 bytes):
          6b 6d 61 6c 6c 6f 63 2d 31 36 28 31 35 39 39 3a  kmalloc-16(1599:
          6e 65 77 72 6f 6f 74 29 00 23 6b c0 ff ff ff ff  newroot).#k.....
        backtrace:
           kmemleak_alloc+0x4a/0xa0
           __kmalloc_track_caller+0x148/0x2c0
           kvasprintf+0x66/0xd0
           kasprintf+0x49/0x70
           memcg_create_kmem_cache+0xe6/0x160
           memcg_kmem_cache_create_func+0x20/0x110
           process_one_work+0x205/0x5d0
           worker_thread+0x4e/0x3a0
           kthread+0x109/0x140
           ret_from_fork+0x2a/0x40
      unreferenced object 0xffff9f79b6136840 (size 416):
        comm "kworker/1:4", pid 15416, jiffies 4307432429 (age 28687.573s)
        hex dump (first 32 bytes):
          40 fb 80 c2 3e 33 00 00 00 00 00 40 00 00 00 00  @...>3.....@....
          00 00 00 00 00 00 00 00 10 00 00 00 10 00 00 00  ................
        backtrace:
           kmemleak_alloc+0x4a/0xa0
           kmem_cache_alloc+0x128/0x280
           create_cache+0x3b/0x1e0
           memcg_create_kmem_cache+0x118/0x160
           memcg_kmem_cache_create_func+0x20/0x110
           process_one_work+0x205/0x5d0
           worker_thread+0x4e/0x3a0
           kthread+0x109/0x140
           ret_from_fork+0x2a/0x40
    
    Fix the leak by adding the missing call to kobject_put() to
    sysfs_slab_remove_workfn().
    
    Link: http://lkml.kernel.org/r/20170812181134.25027-1-vdavydov.dev@gmail.com
    Fixes: 3b7b314053d02 ("slub: make sysfs file removal asynchronous")
    Signed-off-by: Vladimir Davydov <vdavydov.dev@gmail.com>
    Reported-by: Andrei Vagin <avagin@gmail.com>
    Tested-by: Andrei Vagin <avagin@gmail.com>
    Acked-by: Tejun Heo <tj@kernel.org>
    Acked-by: David Rientjes <rientjes@google.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Pekka Enberg <penberg@kernel.org>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    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 4d45f00b927cfa66c39cb8828ca8b30f5c8323c4
Author: Pavel Tatashin <pasha.tatashin@oracle.com>
Date:   Fri Aug 18 15:16:05 2017 -0700

    mm: discard memblock data later
    
    commit 3010f876500f9ba921afaeccec30c45ca6584dc8 upstream.
    
    There is existing use after free bug when deferred struct pages are
    enabled:
    
    The memblock_add() allocates memory for the memory array if more than
    128 entries are needed.  See comment in e820__memblock_setup():
    
      * The bootstrap memblock region count maximum is 128 entries
      * (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries
      * than that - so allow memblock resizing.
    
    This memblock memory is freed here:
            free_low_memory_core_early()
    
    We access the freed memblock.memory later in boot when deferred pages
    are initialized in this path:
    
            deferred_init_memmap()
                    for_each_mem_pfn_range()
                      __next_mem_pfn_range()
                        type = &memblock.memory;
    
    One possible explanation for why this use-after-free hasn't been hit
    before is that the limit of INIT_MEMBLOCK_REGIONS has never been
    exceeded at least on systems where deferred struct pages were enabled.
    
    Tested by reducing INIT_MEMBLOCK_REGIONS down to 4 from the current 128,
    and verifying in qemu that this code is getting excuted and that the
    freed pages are sane.
    
    Link: http://lkml.kernel.org/r/1502485554-318703-2-git-send-email-pasha.tatashin@oracle.com
    Fixes: 7e18adb4f80b ("mm: meminit: initialise remaining struct pages in parallel with kswapd")
    Signed-off-by: Pavel Tatashin <pasha.tatashin@oracle.com>
    Reviewed-by: Steven Sistare <steven.sistare@oracle.com>
    Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
    Reviewed-by: Bob Picco <bob.picco@oracle.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    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 c24138794d14ed8167ace6f7ece1c0226a0a5f07
Author: Jussi Laako <jussi@sonarnerd.net>
Date:   Fri Aug 18 10:42:14 2017 +0300

    ALSA: usb-audio: add DSD support for new Amanero PID
    
    commit ed993c6fdfa7734881a4516852d95ae2d3b604d3 upstream.
    
    Add DSD support for new Amanero Combo384 firmware version with a new
    PID. This firmware uses DSD_U32_BE.
    
    Fixes: 3eff682d765b ("ALSA: usb-audio: Support both DSD LE/BE Amanero firmware versions")
    Signed-off-by: Jussi Laako <jussi@sonarnerd.net>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c482b084491bd38e3e57457f871fcf06342346ab
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Aug 16 14:18:37 2017 +0200

    ALSA: usb-audio: Add mute TLV for playback volumes on C-Media devices
    
    commit 0f174b3525a43bd51f9397394763925e0ebe7bc7 upstream.
    
    C-Media devices (at least some models) mute the playback stream when
    volumes are set to the minimum value.  But this isn't informed via TLV
    and the user-space, typically PulseAudio, gets confused as if it's
    still played in a low volume.
    
    This patch adds the new flag, min_mute, to struct usb_mixer_elem_info
    for indicating that the mixer element is with the minimum-mute volume.
    This flag is set for known C-Media devices in
    snd_usb_mixer_fu_apply_quirk() in turn.
    
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196669
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b33fcbb01b3af0586a377f16d32cd6252ed8da31
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Aug 14 14:35:50 2017 +0200

    ALSA: usb-audio: Apply sample rate quirk to Sennheiser headset
    
    commit a8e800fe0f68bc28ce309914f47e432742b865ed upstream.
    
    A Senheisser headset requires the typical sample-rate quirk for
    avoiding spurious errors from inquiring the current sample rate like:
     usb 1-1: 2:1: cannot get freq at ep 0x4
     usb 1-1: 3:1: cannot get freq at ep 0x83
    
    The USB ID 1395:740a has to be added to the entries in
    snd_usb_get_sample_rate_quirk().
    
    Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1052580
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8f05296965d80c55f5c8048aebec7eb308429cbb
Author: Daniel Mentz <danielmentz@google.com>
Date:   Mon Aug 14 14:46:01 2017 -0700

    ALSA: seq: 2nd attempt at fixing race creating a queue
    
    commit 7e1d90f60a0d501c8503e636942ca704a454d910 upstream.
    
    commit 4842e98f26dd80be3623c4714a244ba52ea096a8 ("ALSA: seq: Fix race at
    creating a queue") attempted to fix a race reported by syzkaller. That
    fix has been described as follows:
    
    "
    When a sequencer queue is created in snd_seq_queue_alloc(),it adds the
    new queue element to the public list before referencing it.  Thus the
    queue might be deleted before the call of snd_seq_queue_use(), and it
    results in the use-after-free error, as spotted by syzkaller.
    
    The fix is to reference the queue object at the right time.
    "
    
    Even with that fix in place, syzkaller reported a use-after-free error.
    It specifically pointed to the last instruction "return q->queue" in
    snd_seq_queue_alloc(). The pointer q is being used after kfree() has
    been called on it.
    
    It turned out that there is still a small window where a race can
    happen. The window opens at
    snd_seq_ioctl_create_queue()->snd_seq_queue_alloc()->queue_list_add()
    and closes at
    snd_seq_ioctl_create_queue()->queueptr()->snd_use_lock_use(). Between
    these two calls, a different thread could delete the queue and possibly
    re-create a different queue in the same location in queue_list.
    
    This change prevents this situation by calling snd_use_lock_use() from
    snd_seq_queue_alloc() prior to calling queue_list_add(). It is then the
    caller's responsibility to call snd_use_lock_free(&q->use_lock).
    
    Fixes: 4842e98f26dd ("ALSA: seq: Fix race at creating a queue")
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Daniel Mentz <danielmentz@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6a280cd12306c86b3c23ebb8df941fae2d6a5707
Author: Shaohua Li <shli@fb.com>
Date:   Fri Aug 11 20:34:45 2017 -0700

    MD: not clear ->safemode for external metadata array
    
    commit afc1f55ca44e257f69da8f43e0714a76686ae8d1 upstream.
    
    ->safemode should be triggered by mdadm for external metadaa array, otherwise
    array's state confuses mdadm.
    
    Fixes: 33182d15c6bf(md: always clear ->safemode when md_check_recovery gets the mddev lock.)
    Cc: NeilBrown <neilb@suse.com>
    Signed-off-by: Shaohua Li <shli@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7987c4066cbb4c178bb7807bfd3441f9e65e8c38
Author: NeilBrown <neilb@suse.com>
Date:   Tue Aug 8 16:56:36 2017 +1000

    md: always clear ->safemode when md_check_recovery gets the mddev lock.
    
    commit 33182d15c6bf182f7ae32a66ea4a547d979cd6d7 upstream.
    
    If ->safemode == 1, md_check_recovery() will try to get the mddev lock
    and perform various other checks.
    If mddev->in_sync is zero, it will call set_in_sync, and clear
    ->safemode.  However if mddev->in_sync is not zero, ->safemode will not
    be cleared.
    
    When md_check_recovery() drops the mddev lock, the thread is woken
    up again.  Normally it would just check if there was anything else to
    do, find nothing, and go to sleep.  However as ->safemode was not
    cleared, it will take the mddev lock again, then wake itself up
    when unlocking.
    
    This results in an infinite loop, repeatedly calling
    md_check_recovery(), which RCU or the soft-lockup detector
    will eventually complain about.
    
    Prior to commit 4ad23a976413 ("MD: use per-cpu counter for
    writes_pending"), safemode would only be set to one when the
    writes_pending counter reached zero, and would be cleared again
    when writes_pending is incremented.  Since that patch, safemode
    is set more freely, but is not reliably cleared.
    
    So in md_check_recovery() clear ->safemode before checking ->in_sync.
    
    Fixes: 4ad23a976413 ("MD: use per-cpu counter for writes_pending")
    Reported-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reported-by: David R <david@unsolicited.net>
    Signed-off-by: NeilBrown <neilb@suse.com>
    Signed-off-by: Shaohua Li <shli@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit febaf83252f2e5c94e396619d904047f1c13d4a1
Author: NeilBrown <neilb@suse.com>
Date:   Tue Aug 8 16:56:36 2017 +1000

    md: fix test in md_write_start()
    
    commit 81fe48e9aa00bdd509bd3c37a76d1132da6b9f09 upstream.
    
    md_write_start() needs to clear the in_sync flag is it is set, or if
    there might be a race with set_in_sync() such that the later will
    set it very soon.  In the later case it is sufficient to take the
    spinlock to synchronize with set_in_sync(), and then set the flag
    if needed.
    
    The current test is incorrect.
    It should be:
      if "flag is set" or "race is possible"
    
    "flag is set" is trivially "mddev->in_sync".
    "race is possible" should be tested by "mddev->sync_checkers".
    
    If sync_checkers is 0, then there can be no race.  set_in_sync() will
    wait in percpu_ref_switch_to_atomic_sync() for an RCU grace period,
    and as md_write_start() holds the rcu_read_lock(), set_in_sync() will
    be sure ot see the update to writes_pending.
    
    If sync_checkers is > 0, there could be race.  If md_write_start()
    happened entirely between
                    if (!mddev->in_sync &&
                        percpu_ref_is_zero(&mddev->writes_pending)) {
    and
                            mddev->in_sync = 1;
    in set_in_sync(), then it would not see that is_sync had been set,
    and set_in_sync() would not see that writes_pending had been
    incremented.
    
    This bug means that in_sync is sometimes not set when it should be.
    Consequently there is a small chance that the array will be marked as
    "clean" when in fact it is inconsistent.
    
    Fixes: 4ad23a976413 ("MD: use per-cpu counter for writes_pending")
    Signed-off-by: NeilBrown <neilb@suse.com>
    Signed-off-by: Shaohua Li <shli@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5f46f337bdeb3e461d14b8119d12d0d109ab42f4
Author: KT Liao <kt.liao@emc.com.tw>
Date:   Mon Aug 14 20:11:59 2017 -0700

    Input: elan_i2c - Add antoher Lenovo ACPI ID for upcoming Lenovo NB
    
    commit 76988690402dde2880bfe06ecccf381d48ba8e1c upstream.
    
    Add 2 new IDs (ELAN0609 and ELAN060B) to the list of ACPI IDs that should
    be handled by the driver.
    
    Signed-off-by: KT Liao <kt.liao@emc.com.tw>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 04d0645d62a5b220d4920813ae32ce61a8712fbd
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Mon Aug 14 20:11:26 2017 -0700

    Input: elan_i2c - add ELAN0608 to the ACPI table
    
    commit 1874064eed0502bd9bef7be8023757b0c4f26883 upstream.
    
    Similar to commit 722c5ac708b4f ("Input: elan_i2c - add ELAN0605 to the
    ACPI table"), ELAN0608 should be handled by elan_i2c.
    
    This touchpad can be found in Lenovo ideapad 320-14IKB.
    
    BugLink: https://bugs.launchpad.net/bugs/1708852
    
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b5e042f90f1f9b33f9788c4e18981c2b1ccddafa
Author: Chunming Zhou <David1.Zhou@amd.com>
Date:   Fri Aug 11 09:34:33 2017 +0800

    drm/amdgpu: save list length when fence is signaled
    
    commit 7a7c286d07f9c704e8fd11dd960bf421cc67b66b upstream.
    
    update the list first to avoid redundant checks.
    
    Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2149506faff17258aef239703b97f908291e8c13
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Tue Aug 8 14:19:04 2017 +0100

    drm/i915: Perform an invalidate prior to executing golden renderstate
    
    commit a0125a932e917cb507b682cb66645efdca1f8cab upstream.
    
    As we may have just bound the renderstate into the GGTT for execution, we
    need to ensure that the GTT TLB are also flushed.
    
    On snb-gt2, this would cause a random GPU hang at the start of a new
    context (e.g. boot) and on snb-gt1, it was causing the renderstate batch
    to take ~10s. It was the GPU hang that revealed the truth, as the CS
    gleefully executed beyond the end of the golden renderstate batch, a good
    indicator for a GTT TLB miss.
    
    Fixes: 20fe17aa52dc ("drm/i915: Remove redundant TLB invalidate on switching contexts")
    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20170808131904.1385-1-chris@chris-wilson.co.uk
    Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
    Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.12-rc1+
    (cherry picked from commit 802673d66f8a6ded5d2689d597853c7bb3a70163)
    Signed-off-by: Jani Nikula <jani.nikula@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aac1a12cc70022e56c95d50485a578f717a2edd9
Author: megha.dey@linux.intel.com <megha.dey@linux.intel.com>
Date:   Wed Aug 2 13:49:09 2017 -0700

    crypto: x86/sha1 - Fix reads beyond the number of blocks passed
    
    commit 8861249c740fc4af9ddc5aee321eafefb960d7c6 upstream.
    
    It was reported that the sha1 AVX2 function(sha1_transform_avx2) is
    reading ahead beyond its intended data, and causing a crash if the next
    block is beyond page boundary:
    http://marc.info/?l=linux-crypto-vger&m=149373371023377
    
    This patch makes sure that there is no overflow for any buffer length.
    
    It passes the tests written by Jan Stancek that revealed this problem:
    https://github.com/jstancek/sha1-avx2-crash
    
    I have re-enabled sha1-avx2 by reverting commit
    b82ce24426a4071da9529d726057e4e642948667
    
    Fixes: b82ce24426a4 ("crypto: sha1-ssse3 - Disable avx2")
    Originally-by: Ilya Albrekht <ilya.albrekht@intel.com>
    Tested-by: Jan Stancek <jstancek@redhat.com>
    Signed-off-by: Megha Dey <megha.dey@linux.intel.com>
    Reported-by: Jan Stancek <jstancek@redhat.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f1615538cd1c9d3effeb52751b71a9bc0ede8ecd
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Wed Aug 2 16:40:47 2017 +0800

    crypto: ixp4xx - Fix error handling path in 'aead_perform()'
    
    commit 28389575a8cf933a5f3c378556b9f4d3cce0efd2 upstream.
    
    In commit 0f987e25cb8a, the source processing has been moved in front of
    the destination processing, but the error handling path has not been
    modified accordingly.
    Free resources in the correct order to avoid some leaks.
    
    Fixes: 0f987e25cb8a ("crypto: ixp4xx - Fix false lastlen uninitialised warning")
    Reported-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Reviewed-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0a76684da5c25c9b5a7bde5c44b386fd31995f9d
Author: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Date:   Sat Aug 12 23:36:47 2017 +0200

    parisc: pci memory bar assignment fails with 64bit kernels on dino/cujo
    
    commit 4098116039911e8870d84c975e2ec22dab65a909 upstream.
    
    For 64bit kernels the lmmio_space_offset of the host bridge window
    isn't set correctly on systems with dino/cujo PCI host bridges.
    This leads to not assigned memory bars and failing drivers, which
    need to use these bars.
    
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Acked-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dfaf892df1056d82e2f060a0df0017a7908ba9ab
Author: Jan Kara <jack@suse.cz>
Date:   Tue Aug 15 13:00:36 2017 +0200

    audit: Fix use after free in audit_remove_watch_rule()
    
    commit d76036ab47eafa6ce52b69482e91ca3ba337d6d6 upstream.
    
    audit_remove_watch_rule() drops watch's reference to parent but then
    continues to work with it. That is not safe as parent can get freed once
    we drop our reference. The following is a trivial reproducer:
    
    mount -o loop image /mnt
    touch /mnt/file
    auditctl -w /mnt/file -p wax
    umount /mnt
    auditctl -D
    <crash in fsnotify_destroy_mark()>
    
    Grab our own reference in audit_remove_watch_rule() earlier to make sure
    mark does not get freed under us.
    
    Reported-by: Tony Jones <tonyj@suse.de>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Tested-by: Tony Jones <tonyj@suse.de>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>