commit 630b59cde7be8248b425cbe27c970c2ba8db36f2
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sat Apr 22 07:15:42 2017 +0200

    Linux 3.18.50

commit 2143e71aafc634a68d0cf15d6356501f1693c20f
Author: Linus Torvalds <torvalds@linux-foundation.org>
Date:   Thu Mar 2 12:17:22 2017 -0800

    give up on gcc ilog2() constant optimizations
    
    commit 474c90156c8dcc2fa815e6716cc9394d7930cb9c upstream.
    
    gcc-7 has an "optimization" pass that completely screws up, and
    generates the code expansion for the (impossible) case of calling
    ilog2() with a zero constant, even when the code gcc compiles does not
    actually have a zero constant.
    
    And we try to generate a compile-time error for anybody doing ilog2() on
    a constant where that doesn't make sense (be it zero or negative).  So
    now gcc7 will fail the build due to our sanity checking, because it
    created that constant-zero case that didn't actually exist in the source
    code.
    
    There's a whole long discussion on the kernel mailing about how to work
    around this gcc bug.  The gcc people themselevs have discussed their
    "feature" in
    
       https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785
    
    but it's all water under the bridge, because while it looked at one
    point like it would be solved by the time gcc7 was released, that was
    not to be.
    
    So now we have to deal with this compiler braindamage.
    
    And the only simple approach seems to be to just delete the code that
    tries to warn about bad uses of ilog2().
    
    So now "ilog2()" will just return 0 not just for the value 1, but for
    any non-positive value too.
    
    It's not like I can recall anybody having ever actually tried to use
    this function on any invalid value, but maybe the sanity check just
    meant that such code never made it out in public.
    
    Reported-by: Laura Abbott <labbott@redhat.com>
    Cc: John Stultz <john.stultz@linaro.org>,
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9e5397c79c28e5a11f8507c0e8dcc5b72a731541
Author: James Hogan <james.hogan@imgtec.com>
Date:   Tue Apr 4 08:51:34 2017 +0100

    metag/usercopy: Add missing fixups
    
    commit b884a190afcecdbef34ca508ea5ee88bb7c77861 upstream.
    
    The rapf copy loops in the Meta usercopy code is missing some extable
    entries for HTP cores with unaligned access checking enabled, where
    faults occur on the instruction immediately after the faulting access.
    
    Add the fixup labels and extable entries for these cases so that corner
    case user copy failures don't cause kernel crashes.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4740da3f61dd0cd688a4bc1fe03e6941929ad8f6
Author: James Hogan <james.hogan@imgtec.com>
Date:   Mon Apr 3 17:41:40 2017 +0100

    metag/usercopy: Fix src fixup in from user rapf loops
    
    commit 2c0b1df88b987a12d95ea1d6beaf01894f3cc725 upstream.
    
    The fixup code to rewind the source pointer in
    __asm_copy_from_user_{32,64}bit_rapf_loop() always rewound the source by
    a single unit (4 or 8 bytes), however this is insufficient if the fault
    didn't occur on the first load in the loop, as the source pointer will
    have been incremented but nothing will have been stored until all 4
    register [pairs] are loaded.
    
    Read the LSM_STEP field of TXSTATUS (which is already loaded into a
    register), a bit like the copy_to_user versions, to determine how many
    iterations of MGET[DL] have taken place, all of which need rewinding.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5620eb311c4a716e5761c1a8b37a683af3660287
Author: James Hogan <james.hogan@imgtec.com>
Date:   Tue Apr 4 11:43:26 2017 +0100

    metag/usercopy: Set flags before ADDZ
    
    commit fd40eee1290ad7add7aa665e3ce6b0f9fe9734b4 upstream.
    
    The fixup code for the copy_to_user rapf loops reads TXStatus.LSM_STEP
    to decide how far to rewind the source pointer. There is a special case
    for the last execution of an MGETL/MGETD, since it leaves LSM_STEP=0
    even though the number of MGETLs/MGETDs attempted was 4. This uses ADDZ
    which is conditional upon the Z condition flag, but the AND instruction
    which masked the TXStatus.LSM_STEP field didn't set the condition flags
    based on the result.
    
    Fix that now by using ANDS which does set the flags, and also marking
    the condition codes as clobbered by the inline assembly.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c02ee85c98fb1aa7af8c5d3d8b74fc3b182e0cd9
Author: James Hogan <james.hogan@imgtec.com>
Date:   Fri Mar 31 11:14:02 2017 +0100

    metag/usercopy: Zero rest of buffer from copy_from_user
    
    commit 563ddc1076109f2b3f88e6d355eab7b6fd4662cb upstream.
    
    Currently we try to zero the destination for a failed read from userland
    in fixup code in the usercopy.c macros. The rest of the destination
    buffer is then zeroed from __copy_user_zeroing(), which is used for both
    copy_from_user() and __copy_from_user().
    
    Unfortunately we fail to zero in the fixup code as D1Ar1 is set to 0
    before the fixup code entry labels, and __copy_from_user() shouldn't even
    be zeroing the rest of the buffer.
    
    Move the zeroing out into copy_from_user() and rename
    __copy_user_zeroing() to raw_copy_from_user() since it no longer does
    any zeroing. This also conveniently matches the name needed for
    RAW_COPY_USER support in a later patch.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Reported-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 753c05dc2f0842711677f616fd740230b8959a69
Author: James Hogan <james.hogan@imgtec.com>
Date:   Fri Mar 31 13:35:01 2017 +0100

    metag/usercopy: Add early abort to copy_to_user
    
    commit fb8ea062a8f2e85256e13f55696c5c5f0dfdcc8b upstream.
    
    When copying to userland on Meta, if any faults are encountered
    immediately abort the copy instead of continuing on and repeatedly
    faulting, and worse potentially copying further bytes successfully to
    subsequent valid pages.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Reported-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 63916ca6f09540e0166136f0ef407c60acf21541
Author: James Hogan <james.hogan@imgtec.com>
Date:   Fri Mar 31 11:23:18 2017 +0100

    metag/usercopy: Fix alignment error checking
    
    commit 2257211942bbbf6c798ab70b487d7e62f7835a1a upstream.
    
    Fix the error checking of the alignment adjustment code in
    raw_copy_from_user(), which mistakenly considers it safe to skip the
    error check when aligning the source buffer on a 2 or 4 byte boundary.
    
    If the destination buffer was unaligned it may have started to copy
    using byte or word accesses, which could well be at the start of a new
    (valid) source page. This would result in it appearing to have copied 1
    or 2 bytes at the end of the first (invalid) page rather than none at
    all.
    
    Fixes: 373cd784d0fc ("metag: Memory handling")
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f80e032430314aa07274df0b89af512a0dbaa392
Author: James Hogan <james.hogan@imgtec.com>
Date:   Fri Mar 31 10:37:44 2017 +0100

    metag/usercopy: Drop unused macros
    
    commit ef62a2d81f73d9cddef14bc3d9097a57010d551c upstream.
    
    Metag's lib/usercopy.c has a bunch of copy_from_user macros for larger
    copies between 5 and 16 bytes which are completely unused. Before fixing
    zeroing lets drop these macros so there is less to fix.
    
    Signed-off-by: James Hogan <james.hogan@imgtec.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Cc: linux-metag@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 814051bdd74d00cfe02c12526f493823812e4e4b
Author: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Date:   Fri Jun 17 17:33:59 2016 +0000

    ring-buffer: Fix return value check in test_ringbuffer()
    
    commit 62277de758b155dc04b78f195a1cb5208c37b2df upstream.
    
    In case of error, the function kthread_run() returns ERR_PTR()
    and never returns NULL. The NULL test in the return value check
    should be replaced with IS_ERR().
    
    Link: http://lkml.kernel.org/r/1466184839-14927-1-git-send-email-weiyj_lk@163.com
    
    Fixes: 6c43e554a ("ring-buffer: Add ring buffer startup selftest")
    Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c01cf9586df930e721f608578329496081c9624a
Author: Chris Salls <salls@cs.ucsb.edu>
Date:   Fri Apr 7 23:48:11 2017 -0700

    mm/mempolicy.c: fix error handling in set_mempolicy and mbind.
    
    commit cf01fb9985e8deb25ccf0ea54d916b8871ae0e62 upstream.
    
    In the case that compat_get_bitmap fails we do not want to copy the
    bitmap to the user as it will contain uninitialized stack data and leak
    sensitive data.
    
    Signed-off-by: Chris Salls <salls@cs.ucsb.edu>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6a9a73e7e766e5198e3a12f65a98b82f9836459
Author: Rafał Miłecki <rafal@milecki.pl>
Date:   Sun Nov 20 16:09:30 2016 +0100

    mtd: bcm47xxpart: fix parsing first block after aligned TRX
    
    commit bd5d21310133921021d78995ad6346f908483124 upstream.
    
    After parsing TRX we should skip to the first block placed behind it.
    Our code was working only with TRX with length not aligned to the
    blocksize. In other cases (length aligned) it was missing the block
    places right after TRX.
    
    This fixes calculation and simplifies the comment.
    
    Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
    Signed-off-by: Brian Norris <computersforpeace@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4f6625fa5fdd63bccc08d324e765fc3e58117c6c
Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date:   Fri Mar 31 15:11:55 2017 -0700

    mm, hugetlb: use pte_present() instead of pmd_present() in follow_huge_pmd()
    
    commit c9d398fa237882ea07167e23bcfc5e6847066518 upstream.
    
    I found the race condition which triggers the following bug when
    move_pages() and soft offline are called on a single hugetlb page
    concurrently.
    
        Soft offlining page 0x119400 at 0x700000000000
        BUG: unable to handle kernel paging request at ffffea0011943820
        IP: follow_huge_pmd+0x143/0x190
        PGD 7ffd2067
        PUD 7ffd1067
        PMD 0
            [61163.582052] Oops: 0000 [#1] SMP
        Modules linked in: binfmt_misc ppdev virtio_balloon parport_pc pcspkr i2c_piix4 parport i2c_core acpi_cpufreq ip_tables xfs libcrc32c ata_generic pata_acpi virtio_blk 8139too crc32c_intel ata_piix serio_raw libata virtio_pci 8139cp virtio_ring virtio mii floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: cap_check]
        CPU: 0 PID: 22573 Comm: iterate_numa_mo Tainted: P           OE   4.11.0-rc2-mm1+ #2
        Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
        RIP: 0010:follow_huge_pmd+0x143/0x190
        RSP: 0018:ffffc90004bdbcd0 EFLAGS: 00010202
        RAX: 0000000465003e80 RBX: ffffea0004e34d30 RCX: 00003ffffffff000
        RDX: 0000000011943800 RSI: 0000000000080001 RDI: 0000000465003e80
        RBP: ffffc90004bdbd18 R08: 0000000000000000 R09: ffff880138d34000
        R10: ffffea0004650000 R11: 0000000000c363b0 R12: ffffea0011943800
        R13: ffff8801b8d34000 R14: ffffea0000000000 R15: 000077ff80000000
        FS:  00007fc977710740(0000) GS:ffff88007dc00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: ffffea0011943820 CR3: 000000007a746000 CR4: 00000000001406f0
        Call Trace:
         follow_page_mask+0x270/0x550
         SYSC_move_pages+0x4ea/0x8f0
         SyS_move_pages+0xe/0x10
         do_syscall_64+0x67/0x180
         entry_SYSCALL64_slow_path+0x25/0x25
        RIP: 0033:0x7fc976e03949
        RSP: 002b:00007ffe72221d88 EFLAGS: 00000246 ORIG_RAX: 0000000000000117
        RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fc976e03949
        RDX: 0000000000c22390 RSI: 0000000000001400 RDI: 0000000000005827
        RBP: 00007ffe72221e00 R08: 0000000000c2c3a0 R09: 0000000000000004
        R10: 0000000000c363b0 R11: 0000000000000246 R12: 0000000000400650
        R13: 00007ffe72221ee0 R14: 0000000000000000 R15: 0000000000000000
        Code: 81 e4 ff ff 1f 00 48 21 c2 49 c1 ec 0c 48 c1 ea 0c 4c 01 e2 49 bc 00 00 00 00 00 ea ff ff 48 c1 e2 06 49 01 d4 f6 45 bc 04 74 90 <49> 8b 7c 24 20 40 f6 c7 01 75 2b 4c 89 e7 8b 47 1c 85 c0 7e 2a
        RIP: follow_huge_pmd+0x143/0x190 RSP: ffffc90004bdbcd0
        CR2: ffffea0011943820
        ---[ end trace e4f81353a2d23232 ]---
        Kernel panic - not syncing: Fatal exception
        Kernel Offset: disabled
    
    This bug is triggered when pmd_present() returns true for non-present
    hugetlb, so fixing the present check in follow_huge_pmd() prevents it.
    Using pmd_present() to determine present/non-present for hugetlb is not
    correct, because pmd_present() checks multiple bits (not only
    _PAGE_PRESENT) for historical reason and it can misjudge hugetlb state.
    
    Fixes: e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()")
    Link: http://lkml.kernel.org/r/1490149898-20231-1-git-send-email-n-horiguchi@ah.jp.nec.com
    Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Acked-by: Hillf Danton <hillf.zj@alibaba-inc.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Christian Borntraeger <borntraeger@de.ibm.com>
    Cc: Gerald Schaefer <gerald.schaefer@de.ibm.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 08b1ade02e584ac5eb8d9c075debf202bed9d085
Author: Bjorn Andersson <bjorn.andersson@linaro.org>
Date:   Tue Mar 14 08:23:26 2017 -0700

    pinctrl: qcom: Don't clear status bit on irq_unmask
    
    commit a6566710adaa4a7dd5e0d99820ff9c9c30ee5951 upstream.
    
    Clearing the status bit on irq_unmask will discard any pending interrupt
    that did arrive after the irq_ack, i.e. while the IRQ handler function
    was executing.
    
    Fixes: f365be092572 ("pinctrl: Add Qualcomm TLMM driver")
    Cc: Stephen Boyd <sboyd@codeaurora.org>
    Reported-by: Timur Tabi <timur@codeaurora.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bcfe0f5b4a2bd6602cfd046ad52ffdfca59e4e82
Author: Ladi Prosek <lprosek@redhat.com>
Date:   Thu Mar 23 08:04:18 2017 +0100

    virtio_balloon: init 1st buffer in stats vq
    
    commit fc8653228c8588a120f6b5dad6983b7b61ff669e upstream.
    
    When init_vqs runs, virtio_balloon.stats is either uninitialized or
    contains stale values. The host updates its state with garbage data
    because it has no way of knowing that this is just a marker buffer
    used for signaling.
    
    This patch updates the stats before pushing the initial buffer.
    
    Alternative fixes:
    * Push an empty buffer in init_vqs. Not easily done with the current
      virtio implementation and violates the spec "Driver MUST supply the
      same subset of statistics in all buffers submitted to the statsq".
    * Push a buffer with invalid tags in init_vqs. Violates the same
      spec clause, plus "invalid tag" is not really defined.
    
    Note: the spec says:
            When using the legacy interface, the device SHOULD ignore all values in
            the first buffer in the statsq supplied by the driver after device
            initialization. Note: Historically, drivers supplied an uninitialized
            buffer in the first buffer.
    
    Unfortunately QEMU does not seem to implement the recommendation
    even for the legacy interface.
    
    Signed-off-by: Ladi Prosek <lprosek@redhat.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f142c511242fb15eb50c848e1723d86ddb274d49
Author: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
Date:   Thu Dec 15 11:48:18 2016 -0600

    block: allow WRITE_SAME commands with the SG_IO ioctl
    
    commit 25cdb64510644f3e854d502d69c73f21c6df88a9 upstream.
    
    The WRITE_SAME commands are not present in the blk_default_cmd_filter
    write_ok list, and thus are failed with -EPERM when the SG_IO ioctl()
    is executed without CAP_SYS_RAWIO capability (e.g., unprivileged users).
    [ sg_io() -> blk_fill_sghdr_rq() > blk_verify_command() -> -EPERM ]
    
    The problem can be reproduced with the sg_write_same command
    
      # sg_write_same --num 1 --xferlen 512 /dev/sda
      #
    
      # capsh --drop=cap_sys_rawio -- -c \
        'sg_write_same --num 1 --xferlen 512 /dev/sda'
        Write same: pass through os error: Operation not permitted
      #
    
    For comparison, the WRITE_VERIFY command does not observe this problem,
    since it is in that list:
    
      # capsh --drop=cap_sys_rawio -- -c \
        'sg_write_verify --num 1 --ilen 512 --lba 0 /dev/sda'
      #
    
    So, this patch adds the WRITE_SAME commands to the list, in order
    for the SG_IO ioctl to finish successfully:
    
      # capsh --drop=cap_sys_rawio -- -c \
        'sg_write_same --num 1 --xferlen 512 /dev/sda'
      #
    
    That case happens to be exercised by QEMU KVM guests with 'scsi-block' devices
    (qemu "-device scsi-block" [1], libvirt "<disk type='block' device='lun'>" [2]),
    which employs the SG_IO ioctl() and runs as an unprivileged user (libvirt-qemu).
    
    In that scenario, when a filesystem (e.g., ext4) performs its zero-out calls,
    which are translated to write-same calls in the guest kernel, and then into
    SG_IO ioctls to the host kernel, SCSI I/O errors may be observed in the guest:
    
      [...] sd 0:0:0:0: [sda] tag#0 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
      [...] sd 0:0:0:0: [sda] tag#0 Sense Key : Aborted Command [current]
      [...] sd 0:0:0:0: [sda] tag#0 Add. Sense: I/O process terminated
      [...] sd 0:0:0:0: [sda] tag#0 CDB: Write Same(10) 41 00 01 04 e0 78 00 00 08 00
      [...] blk_update_request: I/O error, dev sda, sector 17096824
    
    Links:
    [1] http://git.qemu.org/?p=qemu.git;a=commit;h=336a6915bc7089fb20fea4ba99972ad9a97c5f52
    [2] https://libvirt.org/formatdomain.html#elementsDisks (see 'disk' -> 'device')
    
    Signed-off-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
    Signed-off-by: Brahadambal Srinivasan <latha@linux.vnet.ibm.com>
    Reported-by: Manjunatha H R <manjuhr1@in.ibm.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Jens Axboe <axboe@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 68fc744fb343f8124813bd33ba4101eb43e97ef0
Author: Henrik Ingo <henrik.ingo@avoinelama.fi>
Date:   Sun May 29 17:58:00 2016 -0300

    uvcvideo: uvc_scan_fallback() for webcams with broken chain
    
    commit e950267ab802c8558f1100eafd4087fd039ad634 upstream.
    
    Some devices have invalid baSourceID references, causing uvc_scan_chain()
    to fail, but if we just take the entities we can find and put them
    together in the most sensible chain we can think of, turns out they do
    work anyway. Note: This heuristic assumes there is a single chain.
    
    At the time of writing, devices known to have such a broken chain are
      - Acer Integrated Camera (5986:055a)
      - Realtek rtl157a7 (0bda:57a7)
    
    Signed-off-by: Henrik Ingo <henrik.ingo@avoinelama.fi>
    Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c7293aedb4990eef20cdf74c5b51b6f351ddf025
Author: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Date:   Mon Nov 28 19:34:42 2016 -0200

    serial: 8250_pci: Detach low-level driver during PCI error recovery
    
    commit f209fa03fc9d131b3108c2e4936181eabab87416 upstream.
    
    During a PCI error recovery, like the ones provoked by EEH in the ppc64
    platform, all IO to the device must be blocked while the recovery is
    completed.  Current 8250_pci implementation only suspends the port
    instead of detaching it, which doesn't prevent incoming accesses like
    TIOCMGET and TIOCMSET calls from reaching the device.  Those end up
    racing with the EEH recovery, crashing it.  Similar races were also
    observed when opening the device and when shutting it down during
    recovery.
    
    This patch implements a more robust IO blockage for the 8250_pci
    recovery by unregistering the port at the beginning of the procedure and
    re-adding it afterwards.  Since the port is detached from the uart
    layer, we can be sure that no request will make through to the device
    during recovery.  This is similar to the solution used by the JSM serial
    driver.
    
    I thank Peter Hurley <peter@hurleysoftware.com> for valuable input on
    this one over one year ago.
    
    Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d233e2efc6d76dd4c28042ff5f06eefa0e833503
Author: Joerg Roedel <jroedel@suse.de>
Date:   Wed Mar 22 18:33:25 2017 +0100

    ACPI: Do not create a platform_device for IOAPIC/IOxAPIC
    
    commit 08f63d97749185fab942a3a47ed80f5bd89b8b7d upstream.
    
    No platform-device is required for IO(x)APICs, so don't even
    create them.
    
    [ rjw: This fixes a problem with leaking platform device objects
      after IOAPIC/IOxAPIC hot-removal events.]
    
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2ed2f05e2e75a9279995ce366d6a5ea44d73593d
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date:   Thu Mar 16 08:56:28 2017 -0500

    ACPI: Fix incompatibility with mcount-based function graph tracing
    
    commit 61b79e16c68d703dde58c25d3935d67210b7d71b upstream.
    
    Paul Menzel reported a warning:
    
      WARNING: CPU: 0 PID: 774 at /build/linux-ROBWaj/linux-4.9.13/kernel/trace/trace_functions_graph.c:233 ftrace_return_to_handler+0x1aa/0x1e0
      Bad frame pointer: expected f6919d98, received f6919db0
        from func acpi_pm_device_sleep_wake return to c43b6f9d
    
    The warning means that function graph tracing is broken for the
    acpi_pm_device_sleep_wake() function.  That's because the ACPI Makefile
    unconditionally sets the '-Os' gcc flag to optimize for size.  That's an
    issue because mcount-based function graph tracing is incompatible with
    '-Os' on x86, thanks to the following gcc bug:
    
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109
    
    I have another patch pending which will ensure that mcount-based
    function graph tracing is never used with CONFIG_CC_OPTIMIZE_FOR_SIZE on
    x86.
    
    But this patch is needed in addition to that one because the ACPI
    Makefile overrides that config option for no apparent reason.  It has
    had this flag since the beginning of git history, and there's no related
    comment, so I don't know why it's there.  As far as I can tell, there's
    no reason for it to be there.  The appropriate behavior is for it to
    honor CONFIG_CC_OPTIMIZE_FOR_{SIZE,PERFORMANCE} like the rest of the
    kernel.
    
    Reported-by: Paul Menzel <pmenzel@molgen.mpg.de>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 51d70cc797a3e0fb6a913c05106ffe6a58a2f07c
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Wed Jan 25 20:24:57 2017 -0800

    xfs: clear _XBF_PAGES from buffers when readahead page
    
    commit 2aa6ba7b5ad3189cc27f14540aa2f57f0ed8df4b upstream.
    
    If we try to allocate memory pages to back an xfs_buf that we're trying
    to read, it's possible that we'll be so short on memory that the page
    allocation fails.  For a blocking read we'll just wait, but for
    readahead we simply dump all the pages we've collected so far.
    
    Unfortunately, after dumping the pages we neglect to clear the
    _XBF_PAGES state, which means that the subsequent call to xfs_buf_free
    thinks that b_pages still points to pages we own.  It then double-frees
    the b_pages pages.
    
    This results in screaming about negative page refcounts from the memory
    manager, which xfs oughtn't be triggering.  To reproduce this case,
    mount a filesystem where the size of the inodes far outweighs the
    availalble memory (a ~500M inode filesystem on a VM with 300MB memory
    did the trick here) and run bulkstat in parallel with other memory
    eating processes to put a huge load on the system.  The "check summary"
    phase of xfs_scrub also works for this purpose.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Eric Sandeen <sandeen@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 20022ad6d87e1b42885195dabe935b2cd9ff3160
Author: Eric Sandeen <sandeen@sandeen.net>
Date:   Tue Nov 8 12:55:18 2016 +1100

    xfs: fix up xfs_swap_extent_forks inline extent handling
    
    commit 4dfce57db6354603641132fac3c887614e3ebe81 upstream.
    
    There have been several reports over the years of NULL pointer
    dereferences in xfs_trans_log_inode during xfs_fsr processes,
    when the process is doing an fput and tearing down extents
    on the temporary inode, something like:
    
    BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
    PID: 29439  TASK: ffff880550584fa0  CPU: 6   COMMAND: "xfs_fsr"
        [exception RIP: xfs_trans_log_inode+0x10]
     #9 [ffff8800a57bbbe0] xfs_bunmapi at ffffffffa037398e [xfs]
    #10 [ffff8800a57bbce8] xfs_itruncate_extents at ffffffffa0391b29 [xfs]
    #11 [ffff8800a57bbd88] xfs_inactive_truncate at ffffffffa0391d0c [xfs]
    #12 [ffff8800a57bbdb8] xfs_inactive at ffffffffa0392508 [xfs]
    #13 [ffff8800a57bbdd8] xfs_fs_evict_inode at ffffffffa035907e [xfs]
    #14 [ffff8800a57bbe00] evict at ffffffff811e1b67
    #15 [ffff8800a57bbe28] iput at ffffffff811e23a5
    #16 [ffff8800a57bbe58] dentry_kill at ffffffff811dcfc8
    #17 [ffff8800a57bbe88] dput at ffffffff811dd06c
    #18 [ffff8800a57bbea8] __fput at ffffffff811c823b
    #19 [ffff8800a57bbef0] ____fput at ffffffff811c846e
    #20 [ffff8800a57bbf00] task_work_run at ffffffff81093b27
    #21 [ffff8800a57bbf30] do_notify_resume at ffffffff81013b0c
    #22 [ffff8800a57bbf50] int_signal at ffffffff8161405d
    
    As it turns out, this is because the i_itemp pointer, along
    with the d_ops pointer, has been overwritten with zeros
    when we tear down the extents during truncate.  When the in-core
    inode fork on the temporary inode used by xfs_fsr was originally
    set up during the extent swap, we mistakenly looked at di_nextents
    to determine whether all extents fit inline, but this misses extents
    generated by speculative preallocation; we should be using if_bytes
    instead.
    
    This mistake corrupts the in-memory inode, and code in
    xfs_iext_remove_inline eventually gets bad inputs, causing
    it to memmove and memset incorrect ranges; this became apparent
    because the two values in ifp->if_u2.if_inline_ext[1] contained
    what should have been in d_ops and i_itemp; they were memmoved due
    to incorrect array indexing and then the original locations
    were zeroed with memset, again due to an array overrun.
    
    Fix this by properly using i_df.if_bytes to determine the number
    of extents, not di_nextents.
    
    Thanks to dchinner for looking at this with me and spotting the
    root cause.
    
    [nborisov: backported to 4.4]
    
    Signed-off-by: Eric Sandeen <sandeen@redhat.com>
    Reviewed-by: Brian Foster <bfoster@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Nikolay Borisov <nborisov@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0f27d9dcfe8fde07cb39b81eacf7f733c7b1df47
Author: Darrick J. Wong <darrick.wong@oracle.com>
Date:   Mon Dec 5 12:38:38 2016 +1100

    xfs: don't allow di_size with high bit set
    
    commit ef388e2054feedaeb05399ed654bdb06f385d294 upstream.
    
    The on-disk field di_size is used to set i_size, which is a signed
    integer of loff_t.  If the high bit of di_size is set, we'll end up with
    a negative i_size, which will cause all sorts of problems.  Since the
    VFS won't let us create a file with such length, we should catch them
    here in the verifier too.
    
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: Dave Chinner <dchinner@redhat.com>
    Signed-off-by: Dave Chinner <david@fromorbit.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 230a372ff7316c9a22619257c1ad8974cb96daa5
Author: Todd Fujinaka <todd.fujinaka@intel.com>
Date:   Mon Nov 28 09:09:57 2016 -0800

    igb: add i211 to i210 PHY workaround
    
    commit 5bc8c230e2a993b49244f9457499f17283da9ec7 upstream.
    
    i210 and i211 share the same PHY but have different PCI IDs. Don't
    forget i211 for any i210 workarounds.
    
    Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
    Tested-by: Aaron Brown <aaron.f.brown@intel.com>
    Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6446e0ba431baccb80f844de751121344e8fb934
Author: Chris J Arges <christopherarges@gmail.com>
Date:   Wed Nov 2 09:13:42 2016 -0500

    igb: Workaround for igb i210 firmware issue
    
    commit 4e684f59d760a2c7c716bb60190783546e2d08a1 upstream.
    
    Sometimes firmware may not properly initialize I347AT4_PAGE_SELECT causing
    the probe of an igb i210 NIC to fail. This patch adds an addition zeroing
    of this register during igb_get_phy_id to workaround this issue.
    
    Thanks for Jochen Henneberg for the idea and original patch.
    
    Signed-off-by: Chris J Arges <christopherarges@gmail.com>
    Tested-by: Aaron Brown <aaron.f.brown@intel.com>
    Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d1fad8235fe72f5d39dfe130f5b8d36311bac4d9
Author: Koos Vriezen <koos.vriezen@gmail.com>
Date:   Wed Mar 1 21:02:50 2017 +0100

    iommu/vt-d: Fix NULL pointer dereference in device_to_iommu
    
    commit 5003ae1e735e6bfe4679d9bed6846274f322e77e upstream.
    
    The function device_to_iommu() in the Intel VT-d driver
    lacks a NULL-ptr check, resulting in this oops at boot on
    some platforms:
    
     BUG: unable to handle kernel NULL pointer dereference at 00000000000007ab
     IP: [<ffffffff8132234a>] device_to_iommu+0x11a/0x1a0
     PGD 0
    
     [...]
    
     Call Trace:
       ? find_or_alloc_domain.constprop.29+0x1a/0x300
       ? dw_dma_probe+0x561/0x580 [dw_dmac_core]
       ? __get_valid_domain_for_dev+0x39/0x120
       ? __intel_map_single+0x138/0x180
       ? intel_alloc_coherent+0xb6/0x120
       ? sst_hsw_dsp_init+0x173/0x420 [snd_soc_sst_haswell_pcm]
       ? mutex_lock+0x9/0x30
       ? kernfs_add_one+0xdb/0x130
       ? devres_add+0x19/0x60
       ? hsw_pcm_dev_probe+0x46/0xd0 [snd_soc_sst_haswell_pcm]
       ? platform_drv_probe+0x30/0x90
       ? driver_probe_device+0x1ed/0x2b0
       ? __driver_attach+0x8f/0xa0
       ? driver_probe_device+0x2b0/0x2b0
       ? bus_for_each_dev+0x55/0x90
       ? bus_add_driver+0x110/0x210
       ? 0xffffffffa11ea000
       ? driver_register+0x52/0xc0
       ? 0xffffffffa11ea000
       ? do_one_initcall+0x32/0x130
       ? free_vmap_area_noflush+0x37/0x70
       ? kmem_cache_alloc+0x88/0xd0
       ? do_init_module+0x51/0x1c4
       ? load_module+0x1ee9/0x2430
       ? show_taint+0x20/0x20
       ? kernel_read_file+0xfd/0x190
       ? SyS_finit_module+0xa3/0xb0
       ? do_syscall_64+0x4a/0xb0
       ? entry_SYSCALL64_slow_path+0x25/0x25
     Code: 78 ff ff ff 4d 85 c0 74 ee 49 8b 5a 10 0f b6 9b e0 00 00 00 41 38 98 e0 00 00 00 77 da 0f b6 eb 49 39 a8 88 00 00 00 72 ce eb 8f <41> f6 82 ab 07 00 00 04 0f 85 76 ff ff ff 0f b6 4d 08 88 0e 49
     RIP  [<ffffffff8132234a>] device_to_iommu+0x11a/0x1a0
      RSP <ffffc90001457a78>
     CR2: 00000000000007ab
     ---[ end trace 16f974b6d58d0aad ]---
    
    Add the missing pointer check.
    
    Fixes: 1c387188c60f53b338c20eee32db055dfe022a9b ("iommu/vt-d: Fix IOMMU lookup for SR-IOV Virtual Functions")
    Signed-off-by: Koos Vriezen <koos.vriezen@gmail.com>
    Signed-off-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc09e721aeb8bca1713136d09c054e4ad193f8f4
Author: Adrian Hunter <adrian.hunter@intel.com>
Date:   Mon Mar 20 19:50:29 2017 +0200

    mmc: sdhci: Do not disable interrupts while waiting for clock
    
    commit e2ebfb2142acefecc2496e71360f50d25726040b upstream.
    
    Disabling interrupts for even a millisecond can cause problems for some
    devices. That can happen when sdhci changes clock frequency because it
    waits for the clock to become stable under a spin lock.
    
    The spin lock is not necessary here. Anything that is racing with changes
    to the I/O state is already broken. The mmc core already provides
    synchronization via "claiming" the host.
    
    Although the spin lock probably should be removed from the code paths that
    lead to this point, such a patch would touch too much code to be suitable
    for stable trees. Consequently, for this patch, just drop the spin lock
    while waiting.
    
    Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Tested-by: Ludovic Desroches <ludovic.desroches@microchip.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d4925dd3275e8fbebe5626d404358ac799eeae52
Author: Eric Biggers <ebiggers@google.com>
Date:   Wed Mar 15 14:52:02 2017 -0400

    ext4: mark inode dirty after converting inline directory
    
    commit b9cf625d6ecde0d372e23ae022feead72b4228a6 upstream.
    
    If ext4_convert_inline_data() was called on a directory with inline
    data, the filesystem was left in an inconsistent state (as considered by
    e2fsck) because the file size was not increased to cover the new block.
    This happened because the inode was not marked dirty after i_disksize
    was updated.  Fix this by marking the inode dirty at the end of
    ext4_finish_convert_inline_dir().
    
    This bug was probably not noticed before because most users mark the
    inode dirty afterwards for other reasons.  But if userspace executed
    FS_IOC_SET_ENCRYPTION_POLICY with invalid parameters, as exercised by
    'kvm-xfstests -c adv generic/396', then the inode was never marked dirty
    after updating i_disksize.
    
    Fixes: 3c47d54170b6a678875566b1b8d6dcf57904e49b
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 75a06cc203a19e442ab35aab1cdd8940a8336193
Author: Michael Engl <michael.engl@wjw-solutions.com>
Date:   Tue Oct 3 13:57:00 2017 +0100

    iio: adc: ti_am335x_adc: fix fifo overrun recovery
    
    commit e83bb3e6f3efa21f4a9d883a25d0ecd9dfb431e1 upstream.
    
    The tiadc_irq_h(int irq, void *private) function is handling FIFO
    overruns by clearing flags, disabling and enabling the ADC to
    recover.
    
    If the ADC is running in continuous mode a FIFO overrun happens
    regularly. If the disabling of the ADC happens concurrently with
    a new conversion. It might happen that the enabling of the ADC
    is ignored by the hardware. This stops the ADC permanently. No
    more interrupts are triggered.
    
    According to the AM335x Reference Manual (SPRUH73H October 2011 -
    Revised April 2013 - Chapter 12.4 and 12.5) it is necessary to
    check the ADC FSM bits in REG_ADCFSM before enabling the ADC
    again. Because the disabling of the ADC is done right after the
    current conversion has been finished.
    
    To trigger this bug it is necessary to run the ADC in continuous
    mode. The ADC values of all channels need to be read in an endless
    loop. The bug appears within the first 6 hours (~5.4 million
    handled FIFO overruns). The user space application will hang on
    reading new values from the character device.
    
    Fixes: ca9a563805f7a ("iio: ti_am335x_adc: Add continuous sampling
    support")
    Signed-off-by: Michael Engl <michael.engl@wjw-solutions.com>
    Signed-off-by: Jonathan Cameron <jic23@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7c83fd79a5478df4819b0753547d508209a3d21d
Author: Johan Hovold <johan@kernel.org>
Date:   Tue Mar 14 17:55:45 2017 +0100

    USB: usbtmc: add missing endpoint sanity check
    
    commit 687e0687f71ec00e0132a21fef802dee88c2f1ad upstream.
    
    USBTMC devices are required to have a bulk-in and a bulk-out endpoint,
    but the driver failed to verify this, something which could lead to the
    endpoint addresses being taken from uninitialised memory.
    
    Make sure to zero all private data as part of allocation, and add the
    missing endpoint sanity check.
    
    Note that this also addresses a more recently introduced issue, where
    the interrupt-in-presence flag would also be uninitialised whenever the
    optional interrupt-in endpoint is not present. This in turn could lead
    to an interrupt urb being allocated, initialised and submitted based on
    uninitialised values.
    
    Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.")
    Fixes: 5b775f672cc9 ("USB: add USB test and measurement class driver")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    [ johan: backport to v4.4 ]
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2410dd8ae02d799d6bc7130c2e336be93c77413
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Mar 13 13:47:53 2017 +0100

    uwb: i1480-dfu: fix NULL-deref at probe
    
    commit 4ce362711d78a4999011add3115b8f4b0bc25e8c upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Note that the dereference happens in the cmd and wait_init_done
    callbacks which are called during probe.
    
    Fixes: 1ba47da52712 ("uwb: add the i1480 DFU driver")
    Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
    Cc: David Vrabel <david.vrabel@csr.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 14d75cdaa93ecf7a59159ea52e543b6c9882ad4e
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Mar 13 13:47:52 2017 +0100

    uwb: hwa-rc: fix NULL-deref at probe
    
    commit daf229b15907fbfdb6ee183aac8ca428cb57e361 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Note that the dereference happens in the start callback which is called
    during probe.
    
    Fixes: de520b8bd552 ("uwb: add HWA radio controller driver")
    Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
    Cc: David Vrabel <david.vrabel@csr.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 87ddf66099922594f6a08410b238ae59630d3666
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Mar 13 13:40:22 2017 +0100

    mmc: ushc: fix NULL-deref at probe
    
    commit 181302dc7239add8ab1449c23ecab193f52ee6ab upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Fixes: 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver")
    Cc: David Vrabel <david.vrabel@csr.com>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29d30b77aa1ef5579150bc059f9f525e81cb533d
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Mar 22 08:10:21 2017 -0700

    tcp: initialize icsk_ack.lrcvtime at session start time
    
    commit 15bb7745e94a665caf42bfaabf0ce062845b533b upstream.
    
    icsk_ack.lrcvtime has a 0 value at socket creation time.
    
    tcpi_last_data_recv can have bogus value if no payload is ever received.
    
    This patch initializes icsk_ack.lrcvtime for active sessions
    in tcp_finish_connect(), and for passive sessions in
    tcp_create_openreq_child()
    
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Acked-by: Neal Cardwell <ncardwell@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2a5b25a89346b4b300059d807cdca076ff4b016b
Author: Daniel Borkmann <daniel@iogearbox.net>
Date:   Wed Mar 22 13:08:08 2017 +0100

    socket, bpf: fix sk_filter use after free in sk_clone_lock
    
    commit 95aa915c2f04c27bb3935c8b9446435f40f17f9d upstream.
    
    In sk_clone_lock(), we create a new socket and inherit most of the
    parent's members via sock_copy() which memcpy()'s various sections.
    Now, in case the parent socket had a BPF socket filter attached,
    then newsk->sk_filter points to the same instance as the original
    sk->sk_filter.
    
    sk_filter_charge() is then called on the newsk->sk_filter to take a
    reference and should that fail due to hitting max optmem, we bail
    out and release the newsk instance.
    
    The issue is that commit 278571baca2a ("net: filter: simplify socket
    charging") wrongly combined the dismantle path with the failure path
    of xfrm_sk_clone_policy(). This means, even when charging failed, we
    call sk_free_unlock_clone() on the newsk, which then still points to
    the same sk_filter as the original sk.
    
    Thus, sk_free_unlock_clone() calls into __sk_destruct() eventually
    where it tests for present sk_filter and calls sk_filter_uncharge()
    on it, which potentially lets sk_omem_alloc wrap around and releases
    the eBPF prog and sk_filter structure from the (still intact) parent.
    
    Fix it by making sure that when sk_filter_charge() failed, we reset
    newsk->sk_filter back to NULL before passing to sk_free_unlock_clone(),
    so that we don't mess with the parents sk_filter.
    
    Only if xfrm_sk_clone_policy() fails, we did reach the point where
    either the parent's filter was NULL and as a result newsk's as well
    or where we previously had a successful sk_filter_charge(), thus for
    that case, we do need sk_filter_uncharge() to release the prior taken
    reference on sk_filter.
    
    Fixes: 278571baca2a ("net: filter: simplify socket charging")
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit af60665c918d708e28f40caf42f7d884f8883cc6
Author: Andrey Ulanov <andreyu@google.com>
Date:   Tue Mar 14 20:16:42 2017 -0700

    net: unix: properly re-increment inflight counter of GC discarded candidates
    
    commit 7df9c24625b9981779afb8fcdbe2bb4765e61147 upstream.
    
    Dmitry has reported that a BUG_ON() condition in unix_notinflight()
    may be triggered by a simple code that forwards unix socket in an
    SCM_RIGHTS message.
    That is caused by incorrect unix socket GC implementation in unix_gc().
    
    The GC first collects list of candidates, then (a) decrements their
    "children's" inflight counter, (b) checks which inflight counters are
    now 0, and then (c) increments all inflight counters back.
    (a) and (c) are done by calling scan_children() with inc_inflight or
    dec_inflight as the second argument.
    
    Commit 6209344f5a37 ("net: unix: fix inflight counting bug in garbage
    collector") changed scan_children() such that it no longer considers
    sockets that do not have UNIX_GC_CANDIDATE flag. It also added a block
    of code that that unsets this flag _before_ invoking
    scan_children(, dec_iflight, ). This may lead to incorrect inflight
    counters for some sockets.
    
    This change fixes this bug by changing order of operations:
    UNIX_GC_CANDIDATE is now unset only after all inflight counters are
    restored to the original state.
    
      kernel BUG at net/unix/garbage.c:149!
      RIP: 0010:[<ffffffff8717ebf4>]  [<ffffffff8717ebf4>]
      unix_notinflight+0x3b4/0x490 net/unix/garbage.c:149
      Call Trace:
       [<ffffffff8716cfbf>] unix_detach_fds.isra.19+0xff/0x170 net/unix/af_unix.c:1487
       [<ffffffff8716f6a9>] unix_destruct_scm+0xf9/0x210 net/unix/af_unix.c:1496
       [<ffffffff86a90a01>] skb_release_head_state+0x101/0x200 net/core/skbuff.c:655
       [<ffffffff86a9808a>] skb_release_all+0x1a/0x60 net/core/skbuff.c:668
       [<ffffffff86a980ea>] __kfree_skb+0x1a/0x30 net/core/skbuff.c:684
       [<ffffffff86a98284>] kfree_skb+0x184/0x570 net/core/skbuff.c:705
       [<ffffffff871789d5>] unix_release_sock+0x5b5/0xbd0 net/unix/af_unix.c:559
       [<ffffffff87179039>] unix_release+0x49/0x90 net/unix/af_unix.c:836
       [<ffffffff86a694b2>] sock_release+0x92/0x1f0 net/socket.c:570
       [<ffffffff86a6962b>] sock_close+0x1b/0x20 net/socket.c:1017
       [<ffffffff81a76b8e>] __fput+0x34e/0x910 fs/file_table.c:208
       [<ffffffff81a771da>] ____fput+0x1a/0x20 fs/file_table.c:244
       [<ffffffff81483ab0>] task_work_run+0x1a0/0x280 kernel/task_work.c:116
       [<     inline     >] exit_task_work include/linux/task_work.h:21
       [<ffffffff8141287a>] do_exit+0x183a/0x2640 kernel/exit.c:828
       [<ffffffff8141383e>] do_group_exit+0x14e/0x420 kernel/exit.c:931
       [<ffffffff814429d3>] get_signal+0x663/0x1880 kernel/signal.c:2307
       [<ffffffff81239b45>] do_signal+0xc5/0x2190 arch/x86/kernel/signal.c:807
       [<ffffffff8100666a>] exit_to_usermode_loop+0x1ea/0x2d0
      arch/x86/entry/common.c:156
       [<     inline     >] prepare_exit_to_usermode arch/x86/entry/common.c:190
       [<ffffffff81009693>] syscall_return_slowpath+0x4d3/0x570
      arch/x86/entry/common.c:259
       [<ffffffff881478e6>] entry_SYSCALL_64_fastpath+0xc4/0xc6
    
    Link: https://lkml.org/lkml/2017/3/6/252
    Signed-off-by: Andrey Ulanov <andreyu@google.com>
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Fixes: 6209344 ("net: unix: fix inflight counting bug in garbage collector")
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 38ab6ca2b73ee6a040ed0e2ac57c9fdbe186401a
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Mar 15 13:21:28 2017 -0700

    net: properly release sk_frag.page
    
    commit 22a0e18eac7a9e986fec76c60fa4a2926d1291e2 upstream.
    
    I mistakenly added the code to release sk->sk_frag in
    sk_common_release() instead of sk_destruct()
    
    TCP sockets using sk->sk_allocation == GFP_ATOMIC do no call
    sk_common_release() at close time, thus leaking one (order-3) page.
    
    iSCSI is using such sockets.
    
    Fixes: 5640f7685831 ("net: use a per task frag allocator")
    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 a8cc8ec83eb3b94e9db9396c0acd8e9ef60c2b18
Author: Florian Fainelli <f.fainelli@gmail.com>
Date:   Wed Mar 15 12:57:21 2017 -0700

    net: bcmgenet: Do not suspend PHY if Wake-on-LAN is enabled
    
    commit 5371bbf4b295eea334ed453efa286afa2c3ccff3 upstream.
    
    Suspending the PHY would be putting it in a low power state where it
    may no longer allow us to do Wake-on-LAN.
    
    Fixes: cc013fb48898 ("net: bcmgenet: correctly suspend and resume PHY device")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a6ec5610d3d756c41a58c014283a2d246adb0c4f
Author: Maor Gottlieb <maorg@mellanox.com>
Date:   Tue Mar 21 15:59:17 2017 +0200

    net/mlx5: Increase number of max QPs in default profile
    
    commit 5f40b4ed975c26016cf41953b7510fe90718e21c upstream.
    
    With ConnectX-4 sharing SRQs from the same space as QPs, we hit a
    limit preventing some applications to allocate needed QPs amount.
    Double the size to 256K.
    
    Fixes: e126ba97dba9e ('mlx5: Add driver for Mellanox Connect-IB adapters')
    Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
    Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 13cabfaac036f05562e09b57e1598d88dc6e2eed
Author: Oliver Neukum <oneukum@suse.com>
Date:   Tue Mar 14 12:09:56 2017 +0100

    ACM gadget: fix endianness in notifications
    
    commit cdd7928df0d2efaa3270d711963773a08a4cc8ab upstream.
    
    The gadget code exports the bitfield for serial status changes
    over the wire in its internal endianness. The fix is to convert
    to little endian before sending it over the wire.
    
    Signed-off-by: Oliver Neukum <oneukum@suse.com>
    Tested-by: 家瑋 <momo1208@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 14a4020705916435c3f850627e3eb8ee97a063be
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:43:09 2017 -0700

    Input: sur40 - validate number of endpoints before using them
    
    commit 92461f5d723037530c1f36cce93640770037812c upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer or accessing memory that lie beyond the end of the endpoint
    array should a malicious device lack the expected endpoints.
    
    Fixes: bdb5c57f209c ("Input: add sur40 driver for Samsung SUR40... ")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c201e0b44896488c1b02515f08ece02bc106cb8d
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:41:55 2017 -0700

    Input: kbtab - validate number of endpoints before using them
    
    commit cb1b494663e037253337623bf1ef2df727883cb7 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d1f5902b6bf1dff1efa02ca799a89917b8237f07
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:35:12 2017 -0700

    Input: cm109 - validate number of endpoints before using them
    
    commit ac2ee9ba953afe88f7a673e1c0c839227b1d7891 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Fixes: c04148f915e5 ("Input: add driver for USB VoIP phones with CM109...")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6139f43c4fec7f969c23958e713b301f2e49497e
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:37:01 2017 -0700

    Input: yealink - validate number of endpoints before using them
    
    commit 5cc4a1a9f5c179795c8a1f2b0f4361829d6a070e upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Fixes: aca951a22a1d ("[PATCH] input-driver-yealink-P1K-usb-phone")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1a215bc8af3f9090238e9f6f85d5d5deddf88fb6
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:39:29 2017 -0700

    Input: hanwang - validate number of endpoints before using them
    
    commit ba340d7b83703768ce566f53f857543359aa1b98 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Fixes: bba5394ad3bd ("Input: add support for Hanwang tablets")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0c0454a88f398f70d9621d568a0f8040baf5469b
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:36:13 2017 -0700

    Input: ims-pcu - validate number of endpoints before using them
    
    commit 1916d319271664241b7aa0cd2b05e32bdb310ce9 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack control-interface endpoints.
    
    Fixes: 628329d52474 ("Input: add IMS Passenger Control Unit driver")
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9232fb802953b00f8d0b0812e6de551e76d3866e
Author: Johan Hovold <johan@kernel.org>
Date:   Thu Mar 16 11:34:02 2017 -0700

    Input: iforce - validate number of endpoints before using them
    
    commit 59cf8bed44a79ec42303151dd014fdb6434254bb upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer or accessing memory that lie beyond the end of the endpoint
    array should a malicious device lack the expected endpoints.
    
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4ccfd76775aafc2ce3edf799f892d94e6d2963c1
Author: Kai-Heng Feng <kai.heng.feng@canonical.com>
Date:   Tue Mar 7 09:31:29 2017 -0800

    Input: i8042 - add noloop quirk for Dell Embedded Box PC 3000
    
    commit 45838660e34d90db8d4f7cbc8fd66e8aff79f4fe upstream.
    
    The aux port does not get detected without noloop quirk, so external PS/2
    mouse cannot work as result.
    
    The PS/2 mouse can work with this quirk.
    
    BugLink: https://bugs.launchpad.net/bugs/1591053
    Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
    Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 102f190c4b1edbb3a377c2e90074a3b09529c6b3
Author: Eric Dumazet <edumazet@google.com>
Date:   Tue Mar 21 19:22:28 2017 -0700

    ipv4: provide stronger user input validation in nl_fib_input()
    
    commit c64c0b3cac4c5b8cb093727d2c19743ea3965c0b upstream.
    
    Alexander reported a KMSAN splat caused by reads of uninitialized
    field (tb_id_in) from user provided struct fib_result_nl
    
    It turns out nl_fib_input() sanity tests on user input is a bit
    wrong :
    
    User can pretend nlh->nlmsg_len is big enough, but provide
    at sendmsg() time a too small buffer.
    
    Reported-by: Alexander Potapenko <glider@google.com>
    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 3f01e667e6f5efcd7e89adc3aaf0d74492786fb8
Author: Tahsin Erdogan <tahsin@google.com>
Date:   Sat Feb 25 13:00:19 2017 -0800

    percpu: acquire pcpu_lock when updating pcpu_nr_empty_pop_pages
    
    commit 320661b08dd6f1746d5c7ab4eb435ec64b97cd45 upstream.
    
    Update to pcpu_nr_empty_pop_pages in pcpu_alloc() is currently done
    without holding pcpu_lock. This can lead to bad updates to the variable.
    Add missing lock calls.
    
    Fixes: b539b87fed37 ("percpu: implmeent pcpu_nr_empty_pop_pages and chunk->nr_populated")
    Signed-off-by: Tahsin Erdogan <tahsin@google.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 824b5f14a5796671b63265f340bb18c2d61e1e63
Author: Johan Hovold <johan@kernel.org>
Date:   Mon Mar 13 13:39:01 2017 +0100

    isdn/gigaset: fix NULL-deref at probe
    
    commit 68c32f9c2a36d410aa242e661506e5b2c2764179 upstream.
    
    Make sure to check the number of endpoints to avoid dereferencing a
    NULL-pointer should a malicious device lack endpoints.
    
    Fixes: cf7776dc05b8 ("[PATCH] isdn4linux: Siemens Gigaset drivers -
    direct USB connection")
    Cc: Hansjoerg Lipp <hjlipp@web.de>
    Signed-off-by: Johan Hovold <johan@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4426d53ac9f00cb0fc9eb8f6fe9e66268b190117
Author: Max Lohrmann <post@wickenrode.com>
Date:   Tue Mar 7 22:09:56 2017 -0800

    target: Fix VERIFY_16 handling in sbc_parse_cdb
    
    commit 13603685c1f12c67a7a2427f00b63f39a2b6f7c9 upstream.
    
    As reported by Max, the Windows 2008 R2 chkdsk utility expects
    VERIFY_16 to be supported, and does not handle the returned
    CHECK_CONDITION properly, resulting in an infinite loop.
    
    The kernel will log huge amounts of this error:
    
    kernel: TARGET_CORE[iSCSI]: Unsupported SCSI Opcode 0x8f, sending
    CHECK_CONDITION.
    
    Signed-off-by: Max Lohrmann <post@wickenrode.com>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4cf189eee2dd17d60c9141b7f7fe0f277ff74740
Author: Shaohua Li <shli@fb.com>
Date:   Tue Feb 28 13:00:20 2017 -0800

    md/raid1/10: fix potential deadlock
    
    commit 61eb2b43b99ebdc9bc6bc83d9792257b243e7cb3 upstream.
    
    Neil Brown pointed out a potential deadlock in raid 10 code with
    bio_split/chain. The raid1 code could have the same issue, but recent
    barrier rework makes it less likely to happen. The deadlock happens in
    below sequence:
    
    1. generic_make_request(bio), this will set current->bio_list
    2. raid10_make_request will split bio to bio1 and bio2
    3. __make_request(bio1), wait_barrer, add underlayer disk bio to
    current->bio_list
    4. __make_request(bio2), wait_barrer
    
    If raise_barrier happens between 3 & 4, since wait_barrier runs at 3,
    raise_barrier waits for IO completion from 3. And since raise_barrier
    sets barrier, 4 waits for raise_barrier. But IO from 3 can't be
    dispatched because raid10_make_request() doesn't finished yet.
    
    The solution is to adjust the IO ordering. Quotes from Neil:
    "
    It is much safer to:
    
        if (need to split) {
            split = bio_split(bio, ...)
            bio_chain(...)
            make_request_fn(split);
            generic_make_request(bio);
       } else
            make_request_fn(mddev, bio);
    
    This way we first process the initial section of the bio (in 'split')
    which will queue some requests to the underlying devices.  These
    requests will be queued in generic_make_request.
    Then we queue the remainder of the bio, which will be added to the end
    of the generic_make_request queue.
    Then we return.
    generic_make_request() will pop the lower-level device requests off the
    queue and handle them first.  Then it will process the remainder
    of the original bio once the first section has been fully processed.
    "
    
    Note, this only happens in read path. In write path, the bio is flushed to
    underlaying disks either by blk flush (from schedule) or offladed to raid1/10d.
    It's queued in current->bio_list.
    
    Cc: Coly Li <colyli@suse.de>
    Suggested-by: NeilBrown <neilb@suse.com>
    Reviewed-by: Jack Wang <jinpu.wang@profitbricks.com>
    Signed-off-by: Shaohua Li <shli@fb.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56f5f521cb3c9a90ea40bc6053eb3961d4bbbb0d
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Thu Mar 16 13:47:49 2017 +0100

    perf/core: Fix event inheritance on fork()
    
    commit e7cc4865f0f31698ef2f7aac01a50e78968985b7 upstream.
    
    While hunting for clues to a use-after-free, Oleg spotted that
    perf_event_init_context() can loose an error value with the result
    that fork() can succeed even though we did not fully inherit the perf
    event context.
    
    Spotted-by: Oleg Nesterov <oleg@redhat.com>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Vince Weaver <vincent.weaver@maine.edu>
    Cc: oleg@redhat.com
    Fixes: 889ff0150661 ("perf/core: Split context's event group list into pinned and non-pinned lists")
    Link: http://lkml.kernel.org/r/20170316125823.190342547@infradead.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 883bc09b140752f699610f6582ffe08fd26ee71e
Author: Marc Zyngier <marc.zyngier@arm.com>
Date:   Thu Mar 16 18:20:50 2017 +0000

    arm/arm64: KVM: Take mmap_sem in kvm_arch_prepare_memory_region
    
    commit 72f310481a08db821b614e7b5d00febcc9064b36 upstream.
    
    We don't hold the mmap_sem while searching for VMAs (via find_vma), in
    kvm_arch_prepare_memory_region, which can end up in expected failures.
    
    Fixes: commit 8eef91239e57 ("arm/arm64: KVM: map MMIO regions at creation time")
    Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: Eric Auger <eric.auger@rehat.com>
    Reviewed-by: Christoffer Dall <cdall@linaro.org>
    [ Handle dirty page logging failure case ]
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07882feab469f30e8e67b6aa02e2913004dac1da
Author: David Hildenbrand <david@redhat.com>
Date:   Thu Mar 23 18:24:19 2017 +0100

    KVM: kvm_io_bus_unregister_dev() should never fail
    
    commit 90db10434b163e46da413d34db8d0e77404cc645 upstream.
    
    No caller currently checks the return value of
    kvm_io_bus_unregister_dev(). This is evil, as all callers silently go on
    freeing their device. A stale reference will remain in the io_bus,
    getting at least used again, when the iobus gets teared down on
    kvm_destroy_vm() - leading to use after free errors.
    
    There is nothing the callers could do, except retrying over and over
    again.
    
    So let's simply remove the bus altogether, print an error and make
    sure no one can access this broken bus again (returning -ENOMEM on any
    attempt to access it).
    
    Fixes: e93f8a0f821e ("KVM: convert io_bus to SRCU")
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
    Signed-off-by: David Hildenbrand <david@redhat.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c6216a0f1e3da39f37aba3d43257c8cda172b414
Author: Peter Xu <peterx@redhat.com>
Date:   Wed Mar 15 16:01:17 2017 +0800

    KVM: x86: clear bus pointer when destroyed
    
    commit df630b8c1e851b5e265dc2ca9c87222e342c093b upstream.
    
    When releasing the bus, let's clear the bus pointers to mark it out. If
    any further device unregister happens on this bus, we know that we're
    done if we found the bus being released already.
    
    Signed-off-by: Peter Xu <peterx@redhat.com>
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 750e339d74c92cdd83007cb8f29febd6017d1472
Author: Thomas Huth <thuth@redhat.com>
Date:   Wed May 18 21:01:20 2016 +0200

    KVM: PPC: Book3S PR: Fix illegal opcode emulation
    
    commit 708e75a3ee750dce1072134e630d66c4e6eaf63c upstream.
    
    If kvmppc_handle_exit_pr() calls kvmppc_emulate_instruction() to emulate
    one instruction (in the BOOK3S_INTERRUPT_H_EMUL_ASSIST case), it calls
    kvmppc_core_queue_program() afterwards if kvmppc_emulate_instruction()
    returned EMULATE_FAIL, so the guest gets an program interrupt for the
    illegal opcode.
    However, the kvmppc_emulate_instruction() also tried to inject a
    program exception for this already, so the program interrupt gets
    injected twice and the return address in srr0 gets destroyed.
    All other callers of kvmppc_emulate_instruction() are also injecting
    a program interrupt, and since the callers have the right knowledge
    about the srr1 flags that should be used, it is the function
    kvmppc_emulate_instruction() that should _not_ inject program
    interrupts, so remove the kvmppc_core_queue_program() here.
    
    This fixes the issue discovered by Laurent Vivier with kvm-unit-tests
    where the logs are filled with these messages when the test tries
    to execute an illegal instruction:
    
         Couldn't emulate instruction 0x00000000 (op 0 xop 0)
         kvmppc_handle_exit_pr: emulation at 700 failed (00000000)
    
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    Reviewed-by: Alexander Graf <agraf@suse.de>
    Tested-by: Laurent Vivier <lvivier@redhat.com>
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1280bf203e26550d0a6784ec54f6caf8744caf8f
Author: Roman Mashak <mrv@mojatatu.com>
Date:   Fri Feb 24 11:00:32 2017 -0500

    net sched actions: decrement module reference count after table flush.
    
    commit edb9d1bff4bbe19b8ae0e71b1f38732591a9eeb2 upstream.
    
    When tc actions are loaded as a module and no actions have been installed,
    flushing them would result in actions removed from the memory, but modules
    reference count not being decremented, so that the modules would not be
    unloaded.
    
    Following is example with GACT action:
    
    % sudo modprobe act_gact
    % lsmod
    Module                  Size  Used by
    act_gact               16384  0
    %
    % sudo tc actions ls action gact
    %
    % sudo tc actions flush action gact
    % lsmod
    Module                  Size  Used by
    act_gact               16384  1
    % sudo tc actions flush action gact
    % lsmod
    Module                  Size  Used by
    act_gact               16384  2
    % sudo rmmod act_gact
    rmmod: ERROR: Module act_gact is in use
    ....
    
    After the fix:
    % lsmod
    Module                  Size  Used by
    act_gact               16384  0
    %
    % sudo tc actions add action pass index 1
    % sudo tc actions add action pass index 2
    % sudo tc actions add action pass index 3
    % lsmod
    Module                  Size  Used by
    act_gact               16384  3
    %
    % sudo tc actions flush action gact
    % lsmod
    Module                  Size  Used by
    act_gact               16384  0
    %
    % sudo tc actions flush action gact
    % lsmod
    Module                  Size  Used by
    act_gact               16384  0
    % sudo rmmod act_gact
    % lsmod
    Module                  Size  Used by
    %
    
    Fixes: f97017cdefef ("net-sched: Fix actions flushing")
    Signed-off-by: Roman Mashak <mrv@mojatatu.com>
    Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02415182a92ccd72b60c22e723a56a74a566d2e7
Author: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Date:   Thu Feb 23 09:31:18 2017 -0300

    sctp: deny peeloff operation on asocs with threads sleeping on it
    
    commit dfcb9f4f99f1e9a49e43398a7bfbf56927544af1 upstream.
    
    commit 2dcab5984841 ("sctp: avoid BUG_ON on sctp_wait_for_sndbuf")
    attempted to avoid a BUG_ON call when the association being used for a
    sendmsg() is blocked waiting for more sndbuf and another thread did a
    peeloff operation on such asoc, moving it to another socket.
    
    As Ben Hutchings noticed, then in such case it would return without
    locking back the socket and would cause two unlocks in a row.
    
    Further analysis also revealed that it could allow a double free if the
    application managed to peeloff the asoc that is created during the
    sendmsg call, because then sctp_sendmsg() would try to free the asoc
    that was created only for that call.
    
    This patch takes another approach. It will deny the peeloff operation
    if there is a thread sleeping on the asoc, so this situation doesn't
    exist anymore. This avoids the issues described above and also honors
    the syscalls that are already being handled (it can be multiple sendmsg
    calls).
    
    Joint work with Xin Long.
    
    Fixes: 2dcab5984841 ("sctp: avoid BUG_ON on sctp_wait_for_sndbuf")
    Cc: Alexander Popov <alex.popov@linux.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 245939276ea26a21b78826f19e295eea30f75383
Author: Mantas M <grawity@gmail.com>
Date:   Fri Dec 16 10:30:59 2016 +0200

    net: ipv6: check route protocol when deleting routes
    
    commit c2ed1880fd61a998e3ce40254a99a2ad000f1a7d upstream.
    
    The protocol field is checked when deleting IPv4 routes, but ignored for
    IPv6, which causes problems with routing daemons accidentally deleting
    externally set routes (observed by multiple bird6 users).
    
    This can be verified using `ip -6 route del <prefix> proto something`.
    
    Signed-off-by: Mantas MikulÄ—nas <grawity@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 02197940d0643fea707254f0bab9d63caf42a577
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Feb 4 16:57:04 2017 +0000

    catc: Use heap buffer for memory size test
    
    commit 2d6a0e9de03ee658a9adc3bfb2f0ca55dff1e478 upstream.
    
    Allocating USB buffers on the stack is not portable, and no longer
    works on x86_64 (with VMAP_STACK enabled as per default).
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 424d97047c81c130753517b2d88f25975dd7d84c
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Feb 4 16:56:56 2017 +0000

    catc: Combine failure cleanup code in catc_probe()
    
    commit d41149145f98fe26dcd0bfd1d6cc095e6e041418 upstream.
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 86da423abff5709d07960c9d3ff3f1def1dd2fe6
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Feb 4 16:56:32 2017 +0000

    rtl8150: Use heap buffers for all register access
    
    commit 7926aff5c57b577ab0f43364ff0c59d968f6a414 upstream.
    
    Allocating USB buffers on the stack is not portable, and no longer
    works on x86_64 (with VMAP_STACK enabled as per default).
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 90388dcb8fafea093c373b1509b724df24c2a6e2
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sat Feb 4 16:56:03 2017 +0000

    pegasus: Use heap buffers for all register access
    
    commit 5593523f968bc86d42a035c6df47d5e0979b5ace upstream.
    
    Allocating USB buffers on the stack is not portable, and no longer
    works on x86_64 (with VMAP_STACK enabled as per default).
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    References: https://bugs.debian.org/852556
    Reported-by: Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
    Tested-by: Lisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ae98f9de71a35fbc0e7164f76cf45c30716749d6
Author: Omar Sandoval <osandov@fb.com>
Date:   Wed Feb 1 00:02:27 2017 -0800

    virtio-console: avoid DMA from stack
    
    commit c4baad50297d84bde1a7ad45e50c73adae4a2192 upstream.
    
    put_chars() stuffs the buffer it gets into an sg, but that buffer may be
    on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it
    manifested as printks getting turned into NUL bytes).
    
    Signed-off-by: Omar Sandoval <osandov@fb.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Reviewed-by: Amit Shah <amit.shah@redhat.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6485381c3b3dcc7b068d4f0c376a002e57d42383
Author: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Date:   Sun Feb 12 13:02:13 2017 -0200

    dvb-usb-firmware: don't do DMA on stack
    
    commit 67b0503db9c29b04eadfeede6bebbfe5ddad94ef upstream.
    
    The buffer allocation for the firmware data was changed in
    commit 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
    but the same applies for the reset value.
    
    Fixes: 43fab9793c1f ("[media] dvb-usb: don't use stack for firmware load")
    Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab9ea4dcd5e99497066041d0ff8b2126e314053c
Author: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Date:   Tue Jan 24 08:13:11 2017 -0200

    dvb-usb: don't use stack for firmware load
    
    commit 43fab9793c1f44e665b4f98035a14942edf03ddc upstream.
    
    As reported by Marc Duponcheel <marc@offline.be>, firmware load on
    dvb-usb is using the stack, with is not allowed anymore on default
    Kernel configurations:
    
    [ 1025.958836] dvb-usb: found a 'WideView WT-220U PenType Receiver (based on ZL353)' in cold state, will try to load a firmware
    [ 1025.958853] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw'
    [ 1025.958855] dvb-usb: could not stop the USB controller CPU.
    [ 1025.958856] dvb-usb: error while transferring firmware (transferred size: -11, block size: 3)
    [ 1025.958856] dvb-usb: firmware download failed at 8 with -22
    [ 1025.958867] usbcore: registered new interface driver dvb_usb_dtt200u
    
    [    2.789902] dvb-usb: downloading firmware from file 'dvb-usb-wt220u-zl0353-01.fw'
    [    2.789905] ------------[ cut here ]------------
    [    2.789911] WARNING: CPU: 3 PID: 2196 at drivers/usb/core/hcd.c:1584 usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore]
    [    2.789912] transfer buffer not dma capable
    [    2.789912] Modules linked in: btusb dvb_usb_dtt200u(+) dvb_usb_af9035(+) btrtl btbcm dvb_usb dvb_usb_v2 btintel dvb_core bluetooth rc_core rfkill x86_pkg_temp_thermal intel_powerclamp coretemp crc32_pclmul aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd drm_kms_helper syscopyarea sysfillrect pcspkr i2c_i801 sysimgblt fb_sys_fops drm i2c_smbus i2c_core r8169 lpc_ich mfd_core mii thermal fan rtc_cmos video button acpi_cpufreq processor snd_hda_codec_realtek snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hwdep snd_hda_core snd_pcm snd_timer snd crc32c_intel ahci libahci libata xhci_pci ehci_pci xhci_hcd ehci_hcd usbcore usb_common dm_mirror dm_region_hash dm_log dm_mod
    [    2.789936] CPU: 3 PID: 2196 Comm: systemd-udevd Not tainted 4.9.0-gentoo #1
    [    2.789937] Hardware name: ASUS All Series/H81I-PLUS, BIOS 0401 07/23/2013
    [    2.789938]  ffffc9000339b690 ffffffff812bd397 ffffc9000339b6e0 0000000000000000
    [    2.789939]  ffffc9000339b6d0 ffffffff81055c86 000006300339b6a0 ffff880116c0c000
    [    2.789941]  0000000000000000 0000000000000000 0000000000000001 ffff880116c08000
    [    2.789942] Call Trace:
    [    2.789945]  [<ffffffff812bd397>] dump_stack+0x4d/0x66
    [    2.789947]  [<ffffffff81055c86>] __warn+0xc6/0xe0
    [    2.789948]  [<ffffffff81055cea>] warn_slowpath_fmt+0x4a/0x50
    [    2.789952]  [<ffffffffa006d460>] usb_hcd_map_urb_for_dma+0x430/0x560 [usbcore]
    [    2.789954]  [<ffffffff814ed5a8>] ? io_schedule_timeout+0xd8/0x110
    [    2.789956]  [<ffffffffa006e09c>] usb_hcd_submit_urb+0x9c/0x980 [usbcore]
    [    2.789958]  [<ffffffff812d0ebf>] ? copy_page_to_iter+0x14f/0x2b0
    [    2.789960]  [<ffffffff81126818>] ? pagecache_get_page+0x28/0x240
    [    2.789962]  [<ffffffff8118c2a0>] ? touch_atime+0x20/0xa0
    [    2.789964]  [<ffffffffa006f7c4>] usb_submit_urb+0x2c4/0x520 [usbcore]
    [    2.789967]  [<ffffffffa006feca>] usb_start_wait_urb+0x5a/0xe0 [usbcore]
    [    2.789969]  [<ffffffffa007000c>] usb_control_msg+0xbc/0xf0 [usbcore]
    [    2.789970]  [<ffffffffa067903d>] usb_cypress_writemem+0x3d/0x40 [dvb_usb]
    [    2.789972]  [<ffffffffa06791cf>] usb_cypress_load_firmware+0x4f/0x130 [dvb_usb]
    [    2.789973]  [<ffffffff8109dbbe>] ? console_unlock+0x2fe/0x5d0
    [    2.789974]  [<ffffffff8109e10c>] ? vprintk_emit+0x27c/0x410
    [    2.789975]  [<ffffffff8109e40a>] ? vprintk_default+0x1a/0x20
    [    2.789976]  [<ffffffff81124d76>] ? printk+0x43/0x4b
    [    2.789977]  [<ffffffffa0679310>] dvb_usb_download_firmware+0x60/0xd0 [dvb_usb]
    [    2.789979]  [<ffffffffa0679898>] dvb_usb_device_init+0x3d8/0x610 [dvb_usb]
    [    2.789981]  [<ffffffffa069e302>] dtt200u_usb_probe+0x92/0xd0 [dvb_usb_dtt200u]
    [    2.789984]  [<ffffffffa007420c>] usb_probe_interface+0xfc/0x270 [usbcore]
    [    2.789985]  [<ffffffff8138bf95>] driver_probe_device+0x215/0x2d0
    [    2.789986]  [<ffffffff8138c0e6>] __driver_attach+0x96/0xa0
    [    2.789987]  [<ffffffff8138c050>] ? driver_probe_device+0x2d0/0x2d0
    [    2.789988]  [<ffffffff81389ffb>] bus_for_each_dev+0x5b/0x90
    [    2.789989]  [<ffffffff8138b7b9>] driver_attach+0x19/0x20
    [    2.789990]  [<ffffffff8138b33c>] bus_add_driver+0x11c/0x220
    [    2.789991]  [<ffffffff8138c91b>] driver_register+0x5b/0xd0
    [    2.789994]  [<ffffffffa0072f6c>] usb_register_driver+0x7c/0x130 [usbcore]
    [    2.789994]  [<ffffffffa06a5000>] ? 0xffffffffa06a5000
    [    2.789996]  [<ffffffffa06a501e>] dtt200u_usb_driver_init+0x1e/0x20 [dvb_usb_dtt200u]
    [    2.789997]  [<ffffffff81000408>] do_one_initcall+0x38/0x140
    [    2.789998]  [<ffffffff8116001c>] ? __vunmap+0x7c/0xc0
    [    2.789999]  [<ffffffff81124fb0>] ? do_init_module+0x22/0x1d2
    [    2.790000]  [<ffffffff81124fe8>] do_init_module+0x5a/0x1d2
    [    2.790002]  [<ffffffff810c96b1>] load_module+0x1e11/0x2580
    [    2.790003]  [<ffffffff810c68b0>] ? show_taint+0x30/0x30
    [    2.790004]  [<ffffffff81177250>] ? kernel_read_file+0x100/0x190
    [    2.790005]  [<ffffffff810c9ffa>] SyS_finit_module+0xba/0xc0
    [    2.790007]  [<ffffffff814f13e0>] entry_SYSCALL_64_fastpath+0x13/0x94
    [    2.790008] ---[ end trace c78a74e78baec6fc ]---
    
    So, allocate the structure dynamically.
    
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    [bwh: Backported to 4.9: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit be63d158bba15c468d474808b60e6ac2417a933b
Author: Kees Cook <keescook@chromium.org>
Date:   Wed Apr 5 09:39:08 2017 -0700

    mm: Tighten x86 /dev/mem with zeroing reads
    
    commit a4866aa812518ed1a37d8ea0c881dc946409de94 upstream.
    
    Under CONFIG_STRICT_DEVMEM, reading System RAM through /dev/mem is
    disallowed. However, on x86, the first 1MB was always allowed for BIOS
    and similar things, regardless of it actually being System RAM. It was
    possible for heap to end up getting allocated in low 1MB RAM, and then
    read by things like x86info or dd, which would trip hardened usercopy:
    
    usercopy: kernel memory exposure attempt detected from ffff880000090000 (dma-kmalloc-256) (4096 bytes)
    
    This changes the x86 exception for the low 1MB by reading back zeros for
    System RAM areas instead of blindly allowing them. More work is needed to
    extend this to mmap, but currently mmap doesn't go through usercopy, so
    hardened usercopy won't Oops the kernel.
    
    Reported-by: Tommi Rantala <tommi.t.rantala@nokia.com>
    Tested-by: Tommi Rantala <tommi.t.rantala@nokia.com>
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Cc: Brad Spengler <spender@grsecurity.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fc7935ac7a6f3bcd5aa945e74005accf0939e6c5
Author: Thierry Reding <treding@nvidia.com>
Date:   Thu Jan 12 17:07:43 2017 +0100

    rtc: tegra: Implement clock handling
    
    commit 5fa4086987506b2ab8c92f8f99f2295db9918856 upstream.
    
    Accessing the registers of the RTC block on Tegra requires the module
    clock to be enabled. This only works because the RTC module clock will
    be enabled by default during early boot. However, because the clock is
    unused, the CCF will disable it at late_init time. This causes the RTC
    to become unusable afterwards. This can easily be reproduced by trying
    to use the RTC:
    
            $ hwclock --rtc /dev/rtc1
    
    This will hang the system. I ran into this by following up on a report
    by Martin Michlmayr that reboot wasn't working on Tegra210 systems. It
    turns out that the rtc-tegra driver's ->shutdown() implementation will
    hang the CPU, because of the disabled clock, before the system can be
    rebooted.
    
    What confused me for a while is that the same driver is used on prior
    Tegra generations where the hang can not be observed. However, as Peter
    De Schrijver pointed out, this is because on 32-bit Tegra chips the RTC
    clock is enabled by the tegra20_timer.c clocksource driver, which uses
    the RTC to provide a persistent clock. This code is never enabled on
    64-bit Tegra because the persistent clock infrastructure does not exist
    on 64-bit ARM.
    
    The proper fix for this is to add proper clock handling to the RTC
    driver in order to ensure that the clock is enabled when the driver
    requires it. All device trees contain the clock already, therefore
    no additional changes are required.
    
    Reported-by: Martin Michlmayr <tbm@cyrius.com>
    Acked-By Peter De Schrijver <pdeschrijver@nvidia.com>
    Signed-off-by: Thierry Reding <treding@nvidia.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    [bwh: Backported to 4.9: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4291affef60f80a35ebb1452154b117838f78f53
Author: Lee, Chun-Yi <joeyli.kernel@gmail.com>
Date:   Thu Nov 3 08:18:52 2016 +0800

    platform/x86: acer-wmi: setup accelerometer when machine has appropriate notify event
    
    commit 98d610c3739ac354319a6590b915f4624d9151e6 upstream.
    
    The accelerometer event relies on the ACERWMID_EVENT_GUID notify.
    So, this patch changes the codes to setup accelerometer input device
    when detected ACERWMID_EVENT_GUID. It avoids that the accel input
    device created on every Acer machines.
    
    In addition, patch adds a clearly parsing logic of accelerometer hid
    to acer_wmi_get_handle_cb callback function. It is positive matching
    the "SENR" name with "BST0001" device to avoid non-supported hardware.
    
    Reported-by: Bjørn Mork <bjorn@mork.no>
    Cc: Darren Hart <dvhart@infradead.org>
    Signed-off-by: Lee, Chun-Yi <jlee@suse.com>
    [andy: slightly massage commit message]
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c59f266fa87e8413db93040348db33f1995bb2b4
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu Feb 2 12:36:01 2017 -0200

    dvb-usb-v2: avoid use-after-free
    
    commit 005145378c9ad7575a01b6ce1ba118fb427f583a upstream.
    
    I ran into a stack frame size warning because of the on-stack copy of
    the USB device structure:
    
    drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_disconnect':
    drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:1029:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
    
    Copying a device structure like this is wrong for a number of other reasons
    too aside from the possible stack overflow. One of them is that the
    dev_info() call will print the name of the device later, but AFAICT
    we have only copied a pointer to the name earlier and the actual name
    has been freed by the time it gets printed.
    
    This removes the on-stack copy of the device and instead copies the
    device name using kstrdup(). I'm ignoring the possible failure here
    as both printk() and kfree() are able to deal with NULL pointers.
    
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c2798145e731005fa1e6ee2a489940c1dd8f03e4
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Mon Apr 10 17:27:57 2017 +0800

    crypto: ahash - Fix EINPROGRESS notification callback
    
    commit ef0579b64e93188710d48667cb5e014926af9f1b upstream.
    
    The ahash API modifies the request's callback function in order
    to clean up after itself in some corner cases (unaligned final
    and missing finup).
    
    When the request is complete ahash will restore the original
    callback and everything is fine.  However, when the request gets
    an EBUSY on a full queue, an EINPROGRESS callback is made while
    the request is still ongoing.
    
    In this case the ahash API will incorrectly call its own callback.
    
    This patch fixes the problem by creating a temporary request
    object on the stack which is used to relay EINPROGRESS back to
    the original completion function.
    
    This patch also adds code to preserve the original flags value.
    
    Fixes: ab6bf4e5e5e4 ("crypto: hash - Fix the pointer voodoo in...")
    Reported-by: Sabrina Dubroca <sd@queasysnail.net>
    Tested-by: Sabrina Dubroca <sd@queasysnail.net>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fb844ee3497f09fb68f5ab2a54f3f6da1fd1c5b1
Author: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date:   Mon Mar 20 17:49:03 2017 +1100

    powerpc: Disable HFSCR[TM] if TM is not supported
    
    commit 7ed23e1bae8bf7e37fd555066550a00b95a3a98b upstream.
    
    On Power8 & Power9 the early CPU inititialisation in __init_HFSCR()
    turns on HFSCR[TM] (Hypervisor Facility Status and Control Register
    [Transactional Memory]), but that doesn't take into account that TM
    might be disabled by CPU features, or disabled by the kernel being built
    with CONFIG_PPC_TRANSACTIONAL_MEM=n.
    
    So later in boot, when we have setup the CPU features, clear HSCR[TM] if
    the TM CPU feature has been disabled. We use CPU_FTR_TM_COMP to account
    for the CONFIG_PPC_TRANSACTIONAL_MEM=n case.
    
    Without this a KVM guest might try use TM, even if told not to, and
    cause an oops in the host kernel. Typically the oops is seen in
    __kvmppc_vcore_entry() and may or may not be fatal to the host, but is
    always bad news.
    
    In practice all shipping CPU revisions do support TM, and all host
    kernels we are aware of build with TM support enabled, so no one should
    actually be able to hit this in the wild.
    
    Fixes: 2a3563b023e5 ("powerpc: Setup in HFSCR for POWER8")
    Cc: stable@vger.kernel.org # v3.10+
    Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
    Tested-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
    [mpe: Rewrite change log with input from Sam, add Fixes/stable]
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    [sb: Backported to linux-4.4.y: adjusted context]
    Signed-off-by: Sam Bobroff <sam.bobroff@au1.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5fda39e3e36c35a79b22a1210074d05d9f286d88
Author: Minchan Kim <minchan@kernel.org>
Date:   Thu Apr 13 14:56:37 2017 -0700

    zram: do not use copy_page with non-page aligned address
    
    commit d72e9a7a93e4f8e9e52491921d99e0c8aa89eb4e upstream.
    
    The copy_page is optimized memcpy for page-alinged address.  If it is
    used with non-page aligned address, it can corrupt memory which means
    system corruption.  With zram, it can happen with
    
    1. 64K architecture
    2. partial IO
    3. slub debug
    
    Partial IO need to allocate a page and zram allocates it via kmalloc.
    With slub debug, kmalloc(PAGE_SIZE) doesn't return page-size aligned
    address.  And finally, copy_page(mem, cmem) corrupts memory.
    
    So, this patch changes it to memcpy.
    
    Actuaully, we don't need to change zram_bvec_write part because zsmalloc
    returns page-aligned address in case of PAGE_SIZE class but it's not
    good to rely on the internal of zsmalloc.
    
    Note:
     When this patch is merged to stable, clear_page should be fixed, too.
     Unfortunately, recent zram removes it by "same page merge" feature so
     it's hard to backport this patch to -stable tree.
    
    I will handle it when I receive the mail from stable tree maintainer to
    merge this patch to backport.
    
    Fixes: 42e99bd ("zram: optimize memory operations with clear_page()/copy_page()")
    Link: http://lkml.kernel.org/r/1492042622-12074-2-git-send-email-minchan@kernel.org
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.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 de3596d3a3ea0cbb9ddd85a7491e766582b1dacc
Author: Richard Genoud <richard.genoud@gmail.com>
Date:   Mon Mar 20 11:52:41 2017 +0100

    tty/serial: atmel: fix race condition (TX+DMA)
    
    commit 31ca2c63fdc0aee725cbd4f207c1256f5deaabde upstream.
    
    If uart_flush_buffer() is called between atmel_tx_dma() and
    atmel_complete_tx_dma(), the circular buffer has been cleared, but not
    atmel_port->tx_len.
    That leads to a circular buffer overflow (dumping (UART_XMIT_SIZE -
    atmel_port->tx_len) bytes).
    
    Tested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
    Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dfcf2be2ae5aa49f454c53c932783aeb18723573
Author: Horia Geantă <horia.geanta@nxp.com>
Date:   Wed Apr 5 11:41:03 2017 +0300

    crypto: caam - fix RNG deinstantiation error checking
    
    commit 40c98cb57cdbc377456116ad4582c89e329721b0 upstream.
    
    RNG instantiation was previously fixed by
    commit 62743a4145bb9 ("crypto: caam - fix RNG init descriptor ret. code checking")
    while deinstantiation was not addressed.
    
    Since the descriptors used are similar, in the sense that they both end
    with a JUMP HALT command, checking for errors should be similar too,
    i.e. status code 7000_0000h should be considered successful.
    
    Fixes: 1005bccd7a4a6 ("crypto: caam - enable instantiation of all RNG4 state handles")
    Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7ece5889c4a405e5320c426ee18afcff7b7150eb
Author: Ankur Arora <ankur.a.arora@oracle.com>
Date:   Tue Mar 21 15:43:38 2017 -0700

    xen/acpi: upload PM state from init-domain to Xen
    
    commit 1914f0cd203c941bba72f9452c8290324f1ef3dc upstream.
    
    This was broken in commit cd979883b9ed ("xen/acpi-processor:
    fix enabling interrupts on syscore_resume"). do_suspend (from
    xen/manage.c) and thus xen_resume_notifier never get called on
    the initial-domain at resume (it is if running as guest.)
    
    The rationale for the breaking change was that upload_pm_data()
    potentially does blocking work in syscore_resume(). This patch
    addresses the original issue by scheduling upload_pm_data() to
    execute in workqueue context.
    
    Cc: Stanislaw Gruszka <sgruszka@redhat.com>
    Based-on-patch-by: Konrad Wilk <konrad.wilk@oracle.com>
    Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
    Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
    Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4d80ec7c8ebb109103d6f85b819f5906d7967b8d
Author: John Garry <john.garry@huawei.com>
Date:   Thu Mar 16 23:07:28 2017 +0800

    scsi: libsas: fix ata xfer length
    
    commit 9702c67c6066f583b629cf037d2056245bb7a8e6 upstream.
    
    The total ata xfer length may not be calculated properly, in that we do
    not use the proper method to get an sg element dma length.
    
    According to the code comment, sg_dma_len() should be used after
    dma_map_sg() is called.
    
    This issue was found by turning on the SMMUv3 in front of the hisi_sas
    controller in hip07. Multiple sg elements were being combined into a
    single element, but the original first element length was being use as
    the total xfer length.
    
    Fixes: ff2aeb1eb64c8a4770a6 ("libata: convert to chained sg")
    Signed-off-by: John Garry <john.garry@huawei.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a3bc27d43f5b5e8cac993b447eeb2f2efb1493af
Author: peter chang <dpf@google.com>
Date:   Wed Feb 15 14:11:54 2017 -0800

    scsi: sg: check length passed to SG_NEXT_CMD_LEN
    
    commit bf33f87dd04c371ea33feb821b60d63d754e3124 upstream.
    
    The user can control the size of the next command passed along, but the
    value passed to the ioctl isn't checked against the usable max command
    size.
    
    Signed-off-by: Peter Chang <dpf@google.com>
    Acked-by: Douglas Gilbert <dgilbert@interlog.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4ce86a74378b0ed41a76ae123bc1bdd1b0461ccc
Author: Chris Leech <cleech@redhat.com>
Date:   Mon Feb 27 16:58:36 2017 -0800

    scsi: libiscsi: add lock around task lists to fix list corruption regression
    
    commit 6f8830f5bbab16e54f261de187f3df4644a5b977 upstream.
    
    There's a rather long standing regression from the commit "libiscsi:
    Reduce locking contention in fast path"
    
    Depending on iSCSI target behavior, it's possible to hit the case in
    iscsi_complete_task where the task is still on a pending list
    (!list_empty(&task->running)).  When that happens the task is removed
    from the list while holding the session back_lock, but other task list
    modification occur under the frwd_lock.  That leads to linked list
    corruption and eventually a panicked system.
    
    Rather than back out the session lock split entirely, in order to try
    and keep some of the performance gains this patch adds another lock to
    maintain the task lists integrity.
    
    Major enterprise supported kernels have been backing out the lock split
    for while now, thanks to the efforts at IBM where a lab setup has the
    most reliable reproducer I've seen on this issue.  This patch has been
    tested there successfully.
    
    Signed-off-by: Chris Leech <cleech@redhat.com>
    Fixes: 659743b02c41 ("[SCSI] libiscsi: Reduce locking contention in fast path")
    Reported-by: Prashantha Subbarao <psubbara@us.ibm.com>
    Reviewed-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 484a5b69dd960a77d3f1b551e45b38c5339ae87e
Author: Anton Blanchard <anton@samba.org>
Date:   Mon Feb 13 08:49:20 2017 +1100

    scsi: lpfc: Add shutdown method for kexec
    
    commit 85e8a23936ab3442de0c42da97d53b29f004ece1 upstream.
    
    We see lpfc devices regularly fail during kexec. Fix this by adding a
    shutdown method which mirrors the remove method.
    
    Signed-off-by: Anton Blanchard <anton@samba.org>
    Reviewed-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
    Tested-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b6a45bb19a450a5cc8344952338bdd090168cf08
Author: Nicholas Bellinger <nab@linux-iscsi.org>
Date:   Thu Nov 3 23:06:53 2016 -0700

    target/pscsi: Fix TYPE_TAPE + TYPE_MEDIMUM_CHANGER export
    
    commit a04e54f2c35823ca32d56afcd5cea5b783e2f51a upstream.
    
    The following fixes a divide by zero OOPs with TYPE_TAPE
    due to pscsi_tape_read_blocksize() failing causing a zero
    sd->sector_size being propigated up via dev_attrib.hw_block_size.
    
    It also fixes another long-standing bug where TYPE_TAPE and
    TYPE_MEDIMUM_CHANGER where using pscsi_create_type_other(),
    which does not call scsi_device_get() to take the device
    reference.  Instead, rename pscsi_create_type_rom() to
    pscsi_create_type_nondisk() and use it for all cases.
    
    Finally, also drop a dump_stack() in pscsi_get_blocks() for
    non TYPE_DISK, which in modern target-core can get invoked
    via target_sense_desc_format() during CHECK_CONDITION.
    
    Reported-by: Malcolm Haak <insanemal@gmail.com>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2a139e1ef3a550e328d9136e20c571b337fe2e21
Author: Michael Ellerman <mpe@ellerman.id.au>
Date:   Tue Mar 7 16:14:49 2017 +1100

    powerpc/boot: Fix zImage TOC alignment
    
    commit 97ee351b50a49717543533cfb85b4bf9d88c9680 upstream.
    
    Recent toolchains force the TOC to be 256 byte aligned. We need to
    enforce this alignment in the zImage linker script, otherwise pointers
    to our TOC variables (__toc_start) could be incorrect. If the actual
    start of the TOC and __toc_start don't have the same value we crash
    early in the zImage wrapper.
    
    Suggested-by: Alan Modra <amodra@gmail.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cafb47d587fd98dc4de5dc1e52fdbe7307e3a4ff
Author: Paul Mackerras <paulus@ozlabs.org>
Date:   Tue Apr 4 14:56:05 2017 +1000

    powerpc: Don't try to fix up misaligned load-with-reservation instructions
    
    commit 48fe9e9488743eec9b7c1addd3c93f12f2123d54 upstream.
    
    In the past, there was only one load-with-reservation instruction,
    lwarx, and if a program attempted a lwarx on a misaligned address, it
    would take an alignment interrupt and the kernel handler would emulate
    it as though it was lwzx, which was not really correct, but benign since
    it is loading the right amount of data, and the lwarx should be paired
    with a stwcx. to the same address, which would also cause an alignment
    interrupt which would result in a SIGBUS being delivered to the process.
    
    We now have 5 different sizes of load-with-reservation instruction. Of
    those, lharx and ldarx cause an immediate SIGBUS by luck since their
    entries in aligninfo[] overlap instructions which were not fixed up, but
    lqarx overlaps with lhz and will be emulated as such. lbarx can never
    generate an alignment interrupt since it only operates on 1 byte.
    
    To straighten this out and fix the lqarx case, this adds code to detect
    the l[hwdq]arx instructions and return without fixing them up, resulting
    in a SIGBUS being delivered to the process.
    
    Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 695bf042560301c210b51512def57c9dae8f6d3e
Author: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Date:   Wed Mar 29 19:19:42 2017 +0200

    powerpc/mm: Add missing global TLB invalidate if cxl is active
    
    commit 88b1bf7268f56887ca88eb09c6fb0f4fc970121a upstream.
    
    Commit 4c6d9acce1f4 ("powerpc/mm: Add hooks for cxl") converted local
    TLB invalidates to global if the cxl driver is active. This is necessary
    because the CAPP snoops invalidations to forward them to the PSL on the
    cxl adapter. However one path was forgotten. native_flush_hash_range()
    still does local TLB invalidates, as found out the hard way recently.
    
    This patch fixes it by following the same logic as previously: if the
    cxl driver is active, the local TLB invalidates are 'upgraded' to
    global.
    
    Fixes: 4c6d9acce1f4 ("powerpc/mm: Add hooks for cxl")
    Signed-off-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
    Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9ebfed203c0d93449a074c5c2fd5bb3e58518f0d
Author: Takashi Iwai <tiwai@suse.de>
Date:   Fri Mar 24 17:07:57 2017 +0100

    ALSA: seq: Fix race during FIFO resize
    
    commit 2d7d54002e396c180db0c800c1046f0a3c471597 upstream.
    
    When a new event is queued while processing to resize the FIFO in
    snd_seq_fifo_clear(), it may lead to a use-after-free, as the old pool
    that is being queued gets removed.  For avoiding this race, we need to
    close the pool to be deleted and sync its usage before actually
    deleting it.
    
    The issue was spotted by syzkaller.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 13878b67fae6d5310ec94378c1f30b1a12322f0d
Author: Takashi Iwai <tiwai@suse.de>
Date:   Tue Mar 21 13:56:04 2017 +0100

    ALSA: seq: Fix racy cell insertions during snd_seq_pool_done()
    
    commit c520ff3d03f0b5db7146d9beed6373ad5d2a5e0e upstream.
    
    When snd_seq_pool_done() is called, it marks the closing flag to
    refuse the further cell insertions.  But snd_seq_pool_done() itself
    doesn't clear the cells but just waits until all cells are cleared by
    the caller side.  That is, it's racy, and this leads to the endless
    stall as syzkaller spotted.
    
    This patch addresses the racy by splitting the setup of pool->closing
    flag out of snd_seq_pool_done(), and calling it properly before
    snd_seq_pool_done().
    
    BugLink: http://lkml.kernel.org/r/CACT4Y+aqqy8bZA1fFieifNxR2fAfFQQABcBHj801+u5ePV0URw@mail.gmail.com
    Reported-and-tested-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 571c66ea070d09a5b385461f0ac1b8b8bdf74d70
Author: Uwe Kleine-König <uwe@kleine-koenig.org>
Date:   Sat Jul 2 17:28:10 2016 +0200

    rtc: s35390a: improve irq handling
    
    commit 3bd32722c827d00eafe8e6d5b83e9f3148ea7c7e upstream.
    
    On some QNAP NAS devices the rtc can wake the machine. Several people
    noticed that once the machine was woken this way it fails to shut down.
    That's because the driver fails to acknowledge the interrupt and so it
    keeps active and restarts the machine immediatly after shutdown. See
    https://bugs.debian.org/794266 for a bug report.
    
    Doing this correctly requires to interpret the INT2 flag of the first read
    of the STATUS1 register because this bit is cleared by read.
    
    Note this is not maximally robust though because a pending irq isn't
    detected when the STATUS1 register was already read (and so INT2 is not
    set) but the irq was not disabled. But that is a hardware imposed problem
    that cannot easily be fixed by software.
    
    Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit da5284394a085084d343dbcb9a4c8f70c80f617a
Author: Uwe Kleine-König <uwe@kleine-koenig.org>
Date:   Sat Jul 2 17:28:09 2016 +0200

    rtc: s35390a: implement reset routine as suggested by the reference
    
    commit 8e6583f1b5d1f5f129b873f1428b7e414263d847 upstream.
    
    There were two deviations from the reference manual: you have to wait
    half a second when POC is active and you might have to repeat
    initialization when POC or BLD are still set after the sequence.
    
    Note however that as POC and BLD are cleared by read the driver might
    not be able to detect that a reset is necessary. I don't have a good
    idea how to fix this.
    
    Additionally report the value read from STATUS1 to the caller. This
    prepares the next patch.
    
    Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ae3e89ca207152832d6425546d1ebc2eefad616b
Author: Uwe Kleine-König <uwe@kleine-koenig.org>
Date:   Mon Apr 3 23:32:38 2017 +0200

    rtc: s35390a: make sure all members in the output are set
    
    commit fdd4bc9313e59a1757cfc8ac5836cff55ec03eeb in 4.4-stable.
    
    The rtc core calls the .read_alarm with all fields initialized to 0. As
    the s35390a driver doesn't touch some fields the returned date is
    interpreted as a date in January 1900. So make sure all fields are set
    to -1; some of them are then overwritten with the right data depending
    on the hardware state.
    
    In mainline this is done by commit d68778b80dd7 ("rtc: initialize output
    parameter for read alarm to "uninitialized"") in the core. This is
    considered to dangerous for stable as it might have side effects for
    other rtc drivers that might for example rely on alarm->time.tm_sec
    being initialized to 0.
    
    Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ead8dee1ef171ce2b12ad1c357ae429e2b4ca42e
Author: Uwe Kleine-König <uwe@kleine-koenig.org>
Date:   Sat Jul 2 17:28:08 2016 +0200

    rtc: s35390a: fix reading out alarm
    
    commit f87e904ddd8f0ef120e46045b0addeb1cc88354e upstream.
    
    There are several issues fixed in this patch:
    
     - When alarm isn't enabled, set .enabled to zero instead of returning
       -EINVAL.
     - Ignore how IRQ1 is configured when determining if IRQ2 is on.
     - The three alarm registers have an enable flag which must be
       evaluated.
     - The chip always triggers when the seconds register gets 0.
    
    Note that the rtc framework however doesn't handle the result correctly
    because it doesn't check wday being initialized and so interprets an
    alarm being set for 10:00 AM in three days as 10:00 AM tomorrow (or
    today if that's not over yet).
    
    Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 74f44ced501029b6d77c44b792f2b2fc78558634
Author: Vitaly Kuznetsov <vkuznets@redhat.com>
Date:   Sat Apr 30 19:21:35 2016 -0700

    Drivers: hv: balloon: don't crash when memory is added in non-sorted order
    
    commit 77c0c9735bc0ba5898e637a3a20d6bcb50e3f67d upstream.
    
    When we iterate through all HA regions in handle_pg_range() we have an
    assumption that all these regions are sorted in the list and the
    'start_pfn >= has->end_pfn' check is enough to find the proper region.
    Unfortunately it's not the case with WS2016 where host can hot-add regions
    in a different order. We end up modifying the wrong HA region and crashing
    later on pages online. Modify the check to make sure we found the region
    we were searching for while iterating. Fix the same check in pfn_covered()
    as well.
    
    Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
    Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3d8525dbe0554adb2c91c96ce7af4201b7ce590c
Author: bsegall@google.com <bsegall@google.com>
Date:   Fri Apr 7 16:04:51 2017 -0700

    ptrace: fix PTRACE_LISTEN race corrupting task->state
    
    commit 5402e97af667e35e54177af8f6575518bf251d51 upstream.
    
    In PT_SEIZED + LISTEN mode STOP/CONT signals cause a wakeup against
    __TASK_TRACED.  If this races with the ptrace_unfreeze_traced at the end
    of a PTRACE_LISTEN, this can wake the task /after/ the check against
    __TASK_TRACED, but before the reset of state to TASK_TRACED.  This
    causes it to instead clobber TASK_WAKING, allowing a subsequent wakeup
    against TRACED while the task is still on the rq wake_list, corrupting
    it.
    
    Oleg said:
     "The kernel can crash or this can lead to other hard-to-debug problems.
      In short, "task->state = TASK_TRACED" in ptrace_unfreeze_traced()
      assumes that nobody else can wake it up, but PTRACE_LISTEN breaks the
      contract. Obviusly it is very wrong to manipulate task->state if this
      task is already running, or WAKING, or it sleeps again"
    
    [akpm@linux-foundation.org: coding-style fixes]
    Fixes: 9899d11f ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL")
    Link: http://lkml.kernel.org/r/xm26y3vfhmkp.fsf_-_@bsegall-linux.mtv.corp.google.com
    Signed-off-by: Ben Segall <bsegall@google.com>
    Acked-by: Oleg Nesterov <oleg@redhat.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 fcf401dfd1d19ff818332074e3c993e0e6a4abc5
Author: Jan-Marek Glogowski <glogow@fbihome.de>
Date:   Mon Feb 20 12:25:58 2017 +0100

    Reset TreeId to zero on SMB2 TREE_CONNECT
    
    commit 806a28efe9b78ffae5e2757e1ee924b8e50c08ab upstream.
    
    Currently the cifs module breaks the CIFS specs on reconnect as
    described in http://msdn.microsoft.com/en-us/library/cc246529.aspx:
    
    "TreeId (4 bytes): Uniquely identifies the tree connect for the
    command. This MUST be 0 for the SMB2 TREE_CONNECT Request."
    
    Signed-off-by: Jan-Marek Glogowski <glogow@fbihome.de>
    Reviewed-by: Aurelien Aptel <aaptel@suse.com>
    Tested-by: Aurelien Aptel <aaptel@suse.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 166232772045663f5aeaae2af77cb99bee874477
Author: Heiko Carstens <heiko.carstens@de.ibm.com>
Date:   Mon Mar 27 09:48:04 2017 +0200

    s390/uaccess: get_user() should zero on failure (again)
    
    commit d09c5373e8e4eaaa09233552cbf75dc4c4f21203 upstream.
    
    Commit fd2d2b191fe7 ("s390: get_user() should zero on failure")
    intended to fix s390's get_user() implementation which did not zero
    the target operand if the read from user space faulted. Unfortunately
    the patch has no effect: the corresponding inline assembly specifies
    that the operand is only written to ("=") and the previous value is
    discarded.
    
    Therefore the compiler is free to and actually does omit the zero
    initialization.
    
    To fix this simply change the contraint modifier to "+", so the
    compiler cannot omit the initialization anymore.
    
    Fixes: c9ca78415ac1 ("s390/uaccess: provide inline variants of get_user/put_user")
    Fixes: fd2d2b191fe7 ("s390: get_user() should zero on failure")
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5f61b67fa0a725f9c6f0c0151ce144969d8e573d
Author: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Date:   Mon Mar 13 12:14:58 2017 -0300

    s390/decompressor: fix initrd corruption caused by bss clear
    
    commit d82c0d12c92705ef468683c9b7a8298dd61ed191 upstream.
    
    Reorder the operations in decompress_kernel() to ensure initrd is moved
    to a safe location before the bss section is zeroed.
    
    During decompression bss can overlap with the initrd and this can
    corrupt the initrd contents depending on the size of the compressed
    kernel (which affects where the initrd is placed by the bootloader) and
    the size of the bss section of the decompressor.
    
    Also use the correct initrd size when checking for overlaps with
    parmblock.
    
    Fixes: 06c0dd72aea3 ([S390] fix boot failures with compressed kernels)
    Reviewed-by: Joy Latten <joy.latten@canonical.com>
    Reviewed-by: Vineetha HariPai <vineetha.hari.pai@canonical.com>
    Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
    Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 93aa01c2525b9fbee03bd453746ad9ab8dc0dd69
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:57 2017 +0100

    metag/ptrace: Reject partial NT_METAG_RPIPE writes
    
    commit 7195ee3120d878259e8d94a5d9f808116f34d5ea upstream.
    
    It's not clear what behaviour is sensible when doing partial write of
    NT_METAG_RPIPE, so just don't bother.
    
    This patch assumes that userspace will never rely on a partial SETREGSET
    in this case, since it's not clear what should happen anyway.
    
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Acked-by: James Hogan <james.hogan@imgtec.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 07d4114f80f2bc5bd44ad11d8060267b0f747d06
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:56 2017 +0100

    metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
    
    commit 5fe81fe98123ce41265c65e95d34418d30d005d1 upstream.
    
    Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
    to fill TXSTATUS, a well-defined default value is used, based on the
    task's current value.
    
    Suggested-by: James Hogan <james.hogan@imgtec.com>
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 80ca91fddf1c129c444ca51e08f444107350f853
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:55 2017 +0100

    metag/ptrace: Preserve previous registers for short regset write
    
    commit a78ce80d2c9178351b34d78fec805140c29c193e upstream.
    
    Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
    to fill all the registers, the thread's old registers are preserved.
    
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Acked-by: James Hogan <james.hogan@imgtec.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 82cf1d4c68b359cfac59bc19b94c761a5aadcf81
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:59 2017 +0100

    sparc/ptrace: Preserve previous registers for short regset write
    
    commit d3805c546b275c8cc7d40f759d029ae92c7175f2 upstream.
    
    Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
    to fill all the registers, the thread's old registers are preserved.
    
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Acked-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 54893ad83f6f1e5b9374f50f619ebd7be75952bf
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:58 2017 +0100

    mips/ptrace: Preserve previous registers for short regset write
    
    commit d614fd58a2834cfe4efa472c33c8f3ce2338b09b upstream.
    
    Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET
    to fill all the registers, the thread's old registers are preserved.
    
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit fede0737c92d370f0cc20819824ba142dbaa1e2a
Author: Dave Martin <Dave.Martin@arm.com>
Date:   Mon Mar 27 15:10:53 2017 +0100

    c6x/ptrace: Remove useless PTRACE_SETREGSET implementation
    
    commit fb411b837b587a32046dc4f369acb93a10b1def8 upstream.
    
    gpr_set won't work correctly and can never have been tested, and the
    correct behaviour is not clear due to the endianness-dependent task
    layout.
    
    So, just remove it.  The core code will now return -EOPNOTSUPPORT when
    trying to set NT_PRSTATUS on this architecture until/unless a correct
    implementation is supplied.
    
    Signed-off-by: Dave Martin <Dave.Martin@arm.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2e29dce3fd6c31f5d0e623e5a929c06d5436ee60
Author: Li Qiang <liq3ea@gmail.com>
Date:   Mon Mar 27 20:10:53 2017 -0700

    drm/vmwgfx: fix integer overflow in vmw_surface_define_ioctl()
    
    commit e7e11f99564222d82f0ce84bd521e57d78a6b678 upstream.
    
    In vmw_surface_define_ioctl(), the 'num_sizes' is the sum of the
    'req->mip_levels' array. This array can be assigned any value from
    the user space. As both the 'num_sizes' and the array is uint32_t,
    it is easy to make 'num_sizes' overflow. The later 'mip_levels' is
    used as the loop count. This can lead an oob write. Add the check of
    'req->mip_levels' to avoid this.
    
    Signed-off-by: Li Qiang <liqiang6-s@360.cn>
    Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 45a8b039a684a61d8e564cf143f430d8854f0e12
Author: Thomas Hellstrom <thellstrom@vmware.com>
Date:   Mon Mar 27 13:06:05 2017 +0200

    drm/vmwgfx: Remove getparam error message
    
    commit 53e16798b0864464c5444a204e1bb93ae246c429 upstream.
    
    The mesa winsys sometimes uses unimplemented parameter requests to
    check for features. Remove the error message to avoid bloating the
    kernel log.
    
    Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
    Reviewed-by: Brian Paul <brianp@vmware.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f2815ee3e60e528ac245ced1925ad53fd89329f6
Author: Thomas Hellstrom <thellstrom@vmware.com>
Date:   Mon Mar 27 11:21:25 2017 +0200

    drm/ttm, drm/vmwgfx: Relax permission checking when opening surfaces
    
    commit fe25deb7737ce6c0879ccf79c99fa1221d428bf2 upstream.
    
    Previously, when a surface was opened using a legacy (non prime) handle,
    it was verified to have been created by a client in the same master realm.
    Relax this so that opening is also allowed recursively if the client
    already has the surface open.
    
    This works around a regression in svga mesa where opening of a shared
    surface is used recursively to obtain surface information.
    
    Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cc4856f61469c7f46de1d9360a2e1076b7e4d1d5
Author: Murray McAllister <murray.mcallister@insomniasec.com>
Date:   Mon Mar 27 11:15:12 2017 +0200

    drm/vmwgfx: avoid calling vzalloc with a 0 size in vmw_get_cap_3d_ioctl()
    
    commit 63774069d9527a1aeaa4aa20e929ef5e8e9ecc38 upstream.
    
    In vmw_get_cap_3d_ioctl(), a user can supply 0 for a size that is
    used in vzalloc(). This eventually calls dump_stack() (in warn_alloc()),
    which can leak useful addresses to dmesg.
    
    Add check to avoid a size of 0.
    
    Signed-off-by: Murray McAllister <murray.mcallister@insomniasec.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e7f776a49aabe3c734f9d94ba2522961a91c6b7
Author: Murray McAllister <murray.mcallister@insomniasec.com>
Date:   Mon Mar 27 11:12:53 2017 +0200

    drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl()
    
    commit 36274ab8c596f1240c606bb514da329add2a1bcd upstream.
    
    Before memory allocations vmw_surface_define_ioctl() checks the
    upper-bounds of a user-supplied size, but does not check if the
    supplied size is 0.
    
    Add check to avoid NULL pointer dereferences.
    
    Signed-off-by: Murray McAllister <murray.mcallister@insomniasec.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6409cadab04a83cb3403cf37bcc06c7e1e807667
Author: Thomas Hellstrom <thellstrom@vmware.com>
Date:   Mon Mar 27 11:09:08 2017 +0200

    drm/vmwgfx: Type-check lookups of fence objects
    
    commit f7652afa8eadb416b23eb57dec6f158529942041 upstream.
    
    A malicious caller could otherwise hand over handles to other objects
    causing all sorts of interesting problems.
    
    Testing done: Ran a Fedora 25 desktop using both Xorg and
    gnome-shell/Wayland.
    
    Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit aa5b35bad59a2691db0ea739fb79be82aff5cbb8
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Tue Jan 24 11:56:21 2017 +0100

    kvm: fix page struct leak in handle_vmon
    
    commit 06ce521af9558814b8606c0476c54497cf83a653 upstream.
    
    handle_vmon gets a reference on VMXON region page,
    but does not release it. Release the reference.
    
    Found by syzkaller; based on a patch by Dmitry.
    
    Reported-by: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    [bwh: Backported to 3.16: use skip_emulated_instruction()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3405698af0b3597da73e2476a2d37cb7f19081b9
Author: Amit Pundir <amit.pundir@linaro.org>
Date:   Thu Apr 6 11:37:14 2017 +0530

    Revert "ARM: 8457/1: psci-smp is built only for SMP"
    
    This reverts commit dbcfee724255ae171af51aaa56d8c5b78342adc9 which is
    commit be95485a0b8288a93402705730d3ea32f9f812b9 upstream.
    
    Upstream commit be95485 (ARM: 8457/1: psci-smp is built only for SMP)
    was intended to fix the build error for configs with CONFIG_SMP=n and
    CONFIG_ARM_PSCI=y, but it end up introducing a build error when
    cherry-picked on 3.18.y.
    
    This patch resulted in redefinition of psci_init() and broke the
    build for every build config in 3.18.y with CONFIG_SMP=n and
    CONFIG_ARM_PSCI=y.
    
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0806093a3d63ddd7c4e3227d4e1d30ac1c85a8dd
Author: Max Bires <jbires@google.com>
Date:   Tue Jan 3 08:18:07 2017 -0800

    char: lack of bool string made CONFIG_DEVPORT always on
    
    commit f2cfa58b136e4b06a9b9db7af5ef62fbb5992f62 upstream.
    
    Without a bool string present, using "# CONFIG_DEVPORT is not set" in
    defconfig files would not actually unset devport. This esnured that
    /dev/port was always on, but there are reasons a user may wish to
    disable it (smaller kernel, attack surface reduction) if it's not being
    used. Adding a message here in order to make this user visible.
    
    Signed-off-by: Max Bires <jbires@google.com>
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 03444b0eb9ca68d737d4fe8989997ae18fbc7b2b
Author: Geert Uytterhoeven <geert@linux-m68k.org>
Date:   Mon Apr 11 10:40:55 2016 +0200

    char: Drop bogus dependency of DEVPORT on !M68K
    
    commit 309124e2648d668a0c23539c5078815660a4a850 upstream.
    
    According to full-history-linux commit d3794f4fa7c3edc3 ("[PATCH] M68k
    update (part 25)"), port operations are allowed on m68k if CONFIG_ISA is
    defined.
    
    However, commit 153dcc54df826d2f ("[PATCH] mem driver: fix conditional
    on isa i/o support") accidentally changed an "||" into an "&&",
    disabling it completely on m68k. This logic was retained when
    introducing the DEVPORT symbol in commit 4f911d64e04a44c4 ("Make
    /dev/port conditional on config symbol").
    
    Drop the bogus dependency on !M68K to fix this.
    
    Fixes: 153dcc54df826d2f ("[PATCH] mem driver: fix conditional on isa i/o support")
    Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Tested-by: Al Stone <ahs3@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1f9b31fde36beb9905e9f7584a095880808cb669
Author: Steven Rostedt (VMware) <rostedt@goodmis.org>
Date:   Fri Apr 14 17:45:45 2017 -0400

    ftrace: Fix removing of second function probe
    
    commit 82cc4fc2e70ec5baeff8f776f2773abc8b2cc0ae upstream.
    
    When two function probes are added to set_ftrace_filter, and then one of
    them is removed, the update to the function locations is not performed, and
    the record keeping of the function states are corrupted, and causes an
    ftrace_bug() to occur.
    
    This is easily reproducable by adding two probes, removing one, and then
    adding it back again.
    
     # cd /sys/kernel/debug/tracing
     # echo schedule:traceoff > set_ftrace_filter
     # echo do_IRQ:traceoff > set_ftrace_filter
     # echo \!do_IRQ:traceoff > /debug/tracing/set_ftrace_filter
     # echo do_IRQ:traceoff > set_ftrace_filter
    
    Causes:
     ------------[ cut here ]------------
     WARNING: CPU: 2 PID: 1098 at kernel/trace/ftrace.c:2369 ftrace_get_addr_curr+0x143/0x220
     Modules linked in: [...]
     CPU: 2 PID: 1098 Comm: bash Not tainted 4.10.0-test+ #405
     Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v02.05 05/07/2012
     Call Trace:
      dump_stack+0x68/0x9f
      __warn+0x111/0x130
      ? trace_irq_work_interrupt+0xa0/0xa0
      warn_slowpath_null+0x1d/0x20
      ftrace_get_addr_curr+0x143/0x220
      ? __fentry__+0x10/0x10
      ftrace_replace_code+0xe3/0x4f0
      ? ftrace_int3_handler+0x90/0x90
      ? printk+0x99/0xb5
      ? 0xffffffff81000000
      ftrace_modify_all_code+0x97/0x110
      arch_ftrace_update_code+0x10/0x20
      ftrace_run_update_code+0x1c/0x60
      ftrace_run_modify_code.isra.48.constprop.62+0x8e/0xd0
      register_ftrace_function_probe+0x4b6/0x590
      ? ftrace_startup+0x310/0x310
      ? debug_lockdep_rcu_enabled.part.4+0x1a/0x30
      ? update_stack_state+0x88/0x110
      ? ftrace_regex_write.isra.43.part.44+0x1d3/0x320
      ? preempt_count_sub+0x18/0xd0
      ? mutex_lock_nested+0x104/0x800
      ? ftrace_regex_write.isra.43.part.44+0x1d3/0x320
      ? __unwind_start+0x1c0/0x1c0
      ? _mutex_lock_nest_lock+0x800/0x800
      ftrace_trace_probe_callback.isra.3+0xc0/0x130
      ? func_set_flag+0xe0/0xe0
      ? __lock_acquire+0x642/0x1790
      ? __might_fault+0x1e/0x20
      ? trace_get_user+0x398/0x470
      ? strcmp+0x35/0x60
      ftrace_trace_onoff_callback+0x48/0x70
      ftrace_regex_write.isra.43.part.44+0x251/0x320
      ? match_records+0x420/0x420
      ftrace_filter_write+0x2b/0x30
      __vfs_write+0xd7/0x330
      ? do_loop_readv_writev+0x120/0x120
      ? locks_remove_posix+0x90/0x2f0
      ? do_lock_file_wait+0x160/0x160
      ? __lock_is_held+0x93/0x100
      ? rcu_read_lock_sched_held+0x5c/0xb0
      ? preempt_count_sub+0x18/0xd0
      ? __sb_start_write+0x10a/0x230
      ? vfs_write+0x222/0x240
      vfs_write+0xef/0x240
      SyS_write+0xab/0x130
      ? SyS_read+0x130/0x130
      ? trace_hardirqs_on_caller+0x182/0x280
      ? trace_hardirqs_on_thunk+0x1a/0x1c
      entry_SYSCALL_64_fastpath+0x18/0xad
     RIP: 0033:0x7fe61c157c30
     RSP: 002b:00007ffe87890258 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
     RAX: ffffffffffffffda RBX: ffffffff8114a410 RCX: 00007fe61c157c30
     RDX: 0000000000000010 RSI: 000055814798f5e0 RDI: 0000000000000001
     RBP: ffff8800c9027f98 R08: 00007fe61c422740 R09: 00007fe61ca53700
     R10: 0000000000000073 R11: 0000000000000246 R12: 0000558147a36400
     R13: 00007ffe8788f160 R14: 0000000000000024 R15: 00007ffe8788f15c
      ? trace_hardirqs_off_caller+0xc0/0x110
     ---[ end trace 99fa09b3d9869c2c ]---
     Bad trampoline accounting at: ffffffff81cc3b00 (do_IRQ+0x0/0x150)
    
    Fixes: 59df055f1991 ("ftrace: trace different functions with a different tracer")
    Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit de584f83548a1045e4f5ce6bcbde428c52e5a0b3
Author: Juergen Gross <jgross@suse.com>
Date:   Fri Apr 7 17:28:23 2017 +0200

    xen, fbfront: fix connecting to backend
    
    commit 9121b15b5628b38b4695282dc18c553440e0f79b upstream.
    
    Connecting to the backend isn't working reliably in xen-fbfront: in
    case XenbusStateInitWait of the backend has been missed the backend
    transition to XenbusStateConnected will trigger the connected state
    only without doing the actions required when the backend has
    connected.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1038f1f4fc69146e7af4ef43beb5e8bb75520ecd
Author: Martin K. Petersen <martin.petersen@oracle.com>
Date:   Tue Apr 4 10:42:30 2017 -0400

    scsi: sd: Fix capacity calculation with 32-bit sector_t
    
    commit 7c856152cb92f8eee2df29ef325a1b1f43161aff upstream.
    
    We previously made sure that the reported disk capacity was less than
    0xffffffff blocks when the kernel was not compiled with large sector_t
    support (CONFIG_LBDAF). However, this check assumed that the capacity
    was reported in units of 512 bytes.
    
    Add a sanity check function to ensure that we only enable disks if the
    entire reported capacity can be expressed in terms of sector_t.
    
    Reported-by: Steve Magnani <steve.magnani@digidescorp.com>
    Cc: Bart Van Assche <Bart.VanAssche@sandisk.com>
    Reviewed-by: Bart Van Assche <Bart.VanAssche@sandisk.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 167d5febc93eda34633984718c42d15e89053c56
Author: Martin K. Petersen <martin.petersen@oracle.com>
Date:   Fri Mar 17 08:47:14 2017 -0400

    scsi: sr: Sanity check returned mode data
    
    commit a00a7862513089f17209b732f230922f1942e0b9 upstream.
    
    Kefeng Wang discovered that old versions of the QEMU CD driver would
    return mangled mode data causing us to walk off the end of the buffer in
    an attempt to parse it. Sanity check the returned mode sense data.
    
    Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
    Tested-by: Kefeng Wang <wangkefeng.wang@huawei.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e204051d186017d0a715b2872a867de2fb54832c
Author: Nicholas Bellinger <nab@linux-iscsi.org>
Date:   Sun Apr 2 13:36:44 2017 -0700

    iscsi-target: Drop work-around for legacy GlobalSAN initiator
    
    commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46 upstream.
    
    Once upon a time back in 2009, a work-around was added to support
    the GlobalSAN iSCSI initiator v3.3 for MacOSX, which during login
    did not propose nor respond to MaxBurstLength, FirstBurstLength,
    DefaultTime2Wait and DefaultTime2Retain keys.
    
    The work-around in iscsi_check_proposer_for_optional_reply()
    allowed the missing keys to be proposed, but did not require
    waiting for a response before moving to full feature phase
    operation.  This allowed GlobalSAN v3.3 to work out-of-the
    box, and for many years we didn't run into login interopt
    issues with any other initiators..
    
    Until recently, when Martin tried a QLogic 57840S iSCSI Offload
    HBA on Windows 2016 which completed login, but subsequently
    failed with:
    
        Got unknown iSCSI OpCode: 0x43
    
    The issue was QLogic MSFT side did not propose DefaultTime2Wait +
    DefaultTime2Retain, so LIO proposes them itself, and immediately
    transitions to full feature phase because of the GlobalSAN hack.
    However, the QLogic MSFT side still attempts to respond to
    DefaultTime2Retain + DefaultTime2Wait, even though LIO has set
    ISCSI_FLAG_LOGIN_NEXT_STAGE3 + ISCSI_FLAG_LOGIN_TRANSIT
    in last login response.
    
    So while the QLogic MSFT side should have been proposing these
    two keys to start, it was doing the correct thing per RFC-3720
    attempting to respond to proposed keys before transitioning to
    full feature phase.
    
    All that said, recent versions of GlobalSAN iSCSI (v5.3.0.541)
    does correctly propose the four keys during login, making the
    original work-around moot.
    
    So in order to allow QLogic MSFT to run unmodified as-is, go
    ahead and drop this long standing work-around.
    
    Reported-by: Martin Svec <martin.svec@zoner.cz>
    Cc: Martin Svec <martin.svec@zoner.cz>
    Cc: Himanshu Madhani <Himanshu.Madhani@cavium.com>
    Cc: Arun Easi <arun.easi@cavium.com>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 808430c496059b98b321b80ed45286c0bebcdc9d
Author: Nicholas Bellinger <nab@linux-iscsi.org>
Date:   Thu Mar 23 17:19:24 2017 -0700

    iscsi-target: Fix TMR reference leak during session shutdown
    
    commit efb2ea770bb3b0f40007530bc8b0c22f36e1c5eb upstream.
    
    This patch fixes a iscsi-target specific TMR reference leak
    during session shutdown, that could occur when a TMR was
    quiesced before the hand-off back to iscsi-target code
    via transport_cmd_check_stop_to_fabric().
    
    The reference leak happens because iscsit_free_cmd() was
    incorrectly skipping the final target_put_sess_cmd() for
    TMRs when transport_generic_free_cmd() returned zero because
    the se_cmd->cmd_kref did not reach zero, due to the missing
    se_cmd assignment in original code.
    
    The result was iscsi_cmd and it's associated se_cmd memory
    would be freed once se_sess->sess_cmd_map where released,
    but the associated se_tmr_req was leaked and remained part
    of se_device->dev_tmr_list.
    
    This bug would manfiest itself as kernel paging request
    OOPsen in core_tmr_lun_reset(), when a left-over se_tmr_req
    attempted to dereference it's se_cmd pointer that had
    already been released during normal session shutdown.
    
    To address this bug, go ahead and treat ISCSI_OP_SCSI_CMD
    and ISCSI_OP_SCSI_TMFUNC the same when there is an extra
    se_cmd->cmd_kref to drop in iscsit_free_cmd(), and use
    op_scsi to signal __iscsit_free_cmd() when the former
    needs to clear any further iscsi related I/O state.
    
    Reported-by: Rob Millner <rlm@daterainc.com>
    Cc: Rob Millner <rlm@daterainc.com>
    Reported-by: Chu Yuan Lin <cyl@datera.io>
    Cc: Chu Yuan Lin <cyl@datera.io>
    Tested-by: Chu Yuan Lin <cyl@datera.io>
    Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ced7ce3d7440482f960f506718cb2e500a35b088
Author: Mathias Krause <minipli@googlemail.com>
Date:   Mon Apr 10 17:14:27 2017 +0200

    x86/vdso: Ensure vdso32_enabled gets set to valid values only
    
    commit c06989da39cdb10604d572c8c7ea8c8c97f3c483 upstream.
    
    vdso_enabled can be set to arbitrary integer values via the kernel command
    line 'vdso32=' parameter or via 'sysctl abi.vsyscall32'.
    
    load_vdso32() only maps VDSO if vdso_enabled == 1, but ARCH_DLINFO_IA32
    merily checks for vdso_enabled != 0. As a consequence the AT_SYSINFO_EHDR
    auxiliary vector for the VDSO_ENTRY is emitted with a NULL pointer which
    causes a segfault when the application tries to use the VDSO.
    
    Restrict the valid arguments on the command line and the sysctl to 0 and 1.
    
    Fixes: b0b49f2673f0 ("x86, vdso: Remove compat vdso support")
    Signed-off-by: Mathias Krause <minipli@googlemail.com>
    Acked-by: Andy Lutomirski <luto@amacapital.net>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Roland McGrath <roland@redhat.com>
    Link: http://lkml.kernel.org/r/1491424561-7187-1-git-send-email-minipli@googlemail.com
    Link: http://lkml.kernel.org/r/20170410151723.518412863@linutronix.de
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3255c1b5ef16098a658a2ddb9194813f0323fc80
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Mon Apr 10 17:14:28 2017 +0200

    x86/vdso: Plug race between mapping and ELF header setup
    
    commit 6fdc6dd90272ce7e75d744f71535cfbd8d77da81 upstream.
    
    The vsyscall32 sysctl can racy against a concurrent fork when it switches
    from disabled to enabled:
    
        arch_setup_additional_pages()
            if (vdso32_enabled)
               --> No mapping
                                            sysctl.vsysscall32()
                                              --> vdso32_enabled = true
        create_elf_tables()
          ARCH_DLINFO_IA32
            if (vdso32_enabled) {
               --> Add VDSO entry with NULL pointer
    
    Make ARCH_DLINFO_IA32 check whether the VDSO mapping has been set up for
    the newly forked process or not.
    
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Andy Lutomirski <luto@amacapital.net>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Mathias Krause <minipli@googlemail.com>
    Link: http://lkml.kernel.org/r/20170410151723.602367196@linutronix.de
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f9e23df467fef4c19847cb7331d6a3309d5144c3
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Tue Apr 11 10:10:28 2017 +0200

    perf/x86: Avoid exposing wrong/stale data in intel_pmu_lbr_read_32()
    
    commit f2200ac311302fcdca6556fd0c5127eab6c65a3e upstream.
    
    When the perf_branch_entry::{in_tx,abort,cycles} fields were added,
    intel_pmu_lbr_read_32() wasn't updated to initialize them.
    
    Signed-off-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>
    Cc: linux-kernel@vger.kernel.org
    Fixes: 135c5612c460 ("perf/x86/intel: Support Haswell/v4 LBR format")
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9146e634c4f01e1bbe6b8366d979a9997a4630ed
Author: Cameron Gutman <aicommander@gmail.com>
Date:   Mon Apr 10 20:44:25 2017 -0700

    Input: xpad - add support for Razer Wildcat gamepad
    
    commit 5376366886251e2f8f248704adb620a4bc4c0937 upstream.
    
    Signed-off-by: Cameron Gutman <aicommander@gmail.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ca57d3aea1114bb99b76690282d05e8efb34ba04
Author: Germano Percossi <germano.percossi@citrix.com>
Date:   Fri Apr 7 12:29:38 2017 +0100

    CIFS: store results of cifs_reopen_file to avoid infinite wait
    
    commit 1fa839b4986d648b907d117275869a0e46c324b9 upstream.
    
    This fixes Continuous Availability when errors during
    file reopen are encountered.
    
    cifs_user_readv and cifs_user_writev would wait for ever if
    results of cifs_reopen_file are not stored and for later inspection.
    
    In fact, results are checked and, in case of errors, a chain
    of function calls leading to reads and writes to be scheduled in
    a separate thread is skipped.
    These threads will wake up the corresponding waiters once reads
    and writes are done.
    
    However, given the return value is not stored, when rc is checked
    for errors a previous one (always zero) is inspected instead.
    This leads to pending reads/writes added to the list, making
    cifs_user_readv and cifs_user_writev wait for ever.
    
    Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>