commit f386a1595aebe23536582c26d32b0cb409dd32ff
Author: Ben Hutchings <ben@decadent.org.uk>
Date:   Sun Jul 2 17:13:04 2017 +0100

    Linux 3.16.45

commit 24ee2a286de7ac680ad4b2423c2dcee68444e567
Author: Paolo Bonzini <pbonzini@redhat.com>
Date:   Wed Jun 7 15:13:14 2017 +0200

    KVM: x86: fix singlestepping over syscall
    
    commit c8401dda2f0a00cd25c0af6a95ed50e478d25de4 upstream.
    
    TF is handled a bit differently for syscall and sysret, compared
    to the other instructions: TF is checked after the instruction completes,
    so that the OS can disable #DB at a syscall by adding TF to FMASK.
    When the sysret is executed the #DB is taken "as if" the syscall insn
    just completed.
    
    KVM emulates syscall so that it can trap 32-bit syscall on Intel processors.
    Fix the behavior, otherwise you could get #DB on a user stack which is not
    nice.  This does not affect Linux guests, as they use an IST or task gate
    for #DB.
    
    This fixes CVE-2017-7518.
    
    Reported-by: Andy Lutomirski <luto@kernel.org>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
    [bwh: Backported to 3.16:
     - kvm_vcpu_check_singlestep() did not take an rflags parameter but
       called get_rflags() itself; delete that code
     - kvm_vcpu_check_singlestep() sets some flags differently
     - Drop changes to kvm_skip_emulated_instruction()]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit e3378be9d9cbe1f77ecfc03b4350991be58f3f82
Author: David Howells <dhowells@redhat.com>
Date:   Thu Jun 15 00:12:24 2017 +0100

    rxrpc: Fix several cases where a padded len isn't checked in ticket decode
    
    commit 5f2f97656ada8d811d3c1bef503ced266fcd53a0 upstream.
    
    This fixes CVE-2017-7482.
    
    When a kerberos 5 ticket is being decoded so that it can be loaded into an
    rxrpc-type key, there are several places in which the length of a
    variable-length field is checked to make sure that it's not going to
    overrun the available data - but the data is padded to the nearest
    four-byte boundary and the code doesn't check for this extra.  This could
    lead to the size-remaining variable wrapping and the data pointer going
    over the end of the buffer.
    
    Fix this by making the various variable-length data checks use the padded
    length.
    
    Reported-by: 石磊 <shilei-c@360.cn>
    Signed-off-by: David Howells <dhowells@redhat.com>
    Reviewed-by: Marc Dionne <marc.c.dionne@auristor.com>
    Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [bwh: Backported to 3.16: adjust filename, context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7943d19453aa1a1acf93bdb2812e0bef970ec23c
Author: Vladis Dronov <vdronov@redhat.com>
Date:   Fri Jun 2 07:42:09 2017 +0200

    drm/vmwgfx: limit the number of mip levels in vmw_gb_surface_define_ioctl()
    
    commit ee9c4e681ec4f58e42a83cb0c22a0289ade1aacf upstream.
    
    The 'req->mip_levels' parameter in vmw_gb_surface_define_ioctl() is
    a user-controlled 'uint32_t' value which is used as a loop count limit.
    This can lead to a kernel lockup and DoS. Add check for 'req->mip_levels'.
    
    References:
    https://bugzilla.redhat.com/show_bug.cgi?id=1437431
    
    Signed-off-by: Vladis Dronov <vdronov@redhat.com>
    Reviewed-by: Sinclair Yeh <syeh@vmware.com>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 702f4dd27ccf3bae7915ef1f8790db3af435d211
Author: Seung-Woo Kim <sw0312.kim@samsung.com>
Date:   Thu Dec 4 19:17:17 2014 +0900

    regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeing
    
    commit 60a2362f769cf549dc466134efe71c8bf9fbaaba upstream.
    
    After freeing pin from regulator_ena_gpio_free, loop can access
    the pin. So this patch fixes not to access pin after freeing.
    
    Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 7d8fa496d78188d6b0edaabe3f5014e41bd638a7
Author: Helge Deller <deller@gmx.de>
Date:   Mon Jun 19 17:34:05 2017 +0200

    Allow stack to grow up to address space limit
    
    commit bd726c90b6b8ce87602208701b208a208e6d5600 upstream.
    
    Fix expand_upwards() on architectures with an upward-growing stack (parisc,
    metag and partly IA-64) to allow the stack to reliably grow exactly up to
    the address space limit given by TASK_SIZE.
    
    Signed-off-by: Helge Deller <deller@gmx.de>
    Acked-by: Hugh Dickins <hughd@google.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 3c946922e7ab2b30f0568e80cc500cf52a9d2962
Author: Hugh Dickins <hughd@google.com>
Date:   Tue Jun 20 02:10:44 2017 -0700

    mm: fix new crash in unmapped_area_topdown()
    
    commit f4cb767d76cf7ee72f97dd76f6cfa6c76a5edc89 upstream.
    
    Trinity gets kernel BUG at mm/mmap.c:1963! in about 3 minutes of
    mmap testing.  That's the VM_BUG_ON(gap_end < gap_start) at the
    end of unmapped_area_topdown().  Linus points out how MAP_FIXED
    (which does not have to respect our stack guard gap intentions)
    could result in gap_end below gap_start there.  Fix that, and
    the similar case in its alternative, unmapped_area().
    
    Fixes: 1be7107fbe18 ("mm: larger stack guard gap, between vmas")
    Reported-by: Dave Jones <davej@codemonkey.org.uk>
    Debugged-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Hugh Dickins <hughd@google.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

commit 978b8aa1646d4e023edd121c7f1b8f938ccb813d
Author: Hugh Dickins <hughd@google.com>
Date:   Mon Jun 19 04:03:24 2017 -0700

    mm: larger stack guard gap, between vmas
    
    commit 1be7107fbe18eed3e319a6c3e83c78254b693acb upstream.
    
    Stack guard page is a useful feature to reduce a risk of stack smashing
    into a different mapping. We have been using a single page gap which
    is sufficient to prevent having stack adjacent to a different mapping.
    But this seems to be insufficient in the light of the stack usage in
    userspace. E.g. glibc uses as large as 64kB alloca() in many commonly
    used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX]
    which is 256kB or stack strings with MAX_ARG_STRLEN.
    
    This will become especially dangerous for suid binaries and the default
    no limit for the stack size limit because those applications can be
    tricked to consume a large portion of the stack and a single glibc call
    could jump over the guard page. These attacks are not theoretical,
    unfortunatelly.
    
    Make those attacks less probable by increasing the stack guard gap
    to 1MB (on systems with 4k pages; but make it depend on the page size
    because systems with larger base pages might cap stack allocations in
    the PAGE_SIZE units) which should cover larger alloca() and VLA stack
    allocations. It is obviously not a full fix because the problem is
    somehow inherent, but it should reduce attack space a lot.
    
    One could argue that the gap size should be configurable from userspace,
    but that can be done later when somebody finds that the new 1MB is wrong
    for some special case applications.  For now, add a kernel command line
    option (stack_guard_gap) to specify the stack gap size (in page units).
    
    Implementation wise, first delete all the old code for stack guard page:
    because although we could get away with accounting one extra page in a
    stack vma, accounting a larger gap can break userspace - case in point,
    a program run with "ulimit -S -v 20000" failed when the 1MB gap was
    counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK
    and strict non-overcommit mode.
    
    Instead of keeping gap inside the stack vma, maintain the stack guard
    gap as a gap between vmas: using vm_start_gap() in place of vm_start
    (or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few
    places which need to respect the gap - mainly arch_get_unmapped_area(),
    and and the vma tree's subtree_gap support for that.
    
    Original-patch-by: Oleg Nesterov <oleg@redhat.com>
    Original-patch-by: Michal Hocko <mhocko@suse.com>
    Signed-off-by: Hugh Dickins <hughd@google.com>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Tested-by: Helge Deller <deller@gmx.de> # parisc
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    [Hugh Dickins: Backported to 3.16]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>