commit 8d577afdee3540808302d9dc7a0a7be96c91178f
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Fri Jan 5 15:48:59 2018 +0100

    Linux 4.14.12

commit 566fb9906ee25a697f4b694dd624398712adf00b
Author: Troy Kisky <troy.kisky@boundarydevices.com>
Date:   Thu Nov 2 18:58:16 2017 -0700

    rtc: m41t80: remove unneeded checks from m41t80_sqw_set_rate
    
    commit 05a03bf260e0480bfc0db91b1fdbc2115e3f193b upstream.
    
    m41t80_sqw_set_rate will be called with the result from
    m41t80_sqw_round_rate, so might as well make
    m41t80_sqw_set_rate(n) same as
    m41t80_sqw_set_rate(m41t80_sqw_round_rate(n))
    
    As Russell King wrote[1],
    "clk_round_rate() is supposed to tell you what you end up with if you
    ask clk_set_rate() to set the exact same value you passed in - but
    clk_round_rate() won't modify the hardware."
    
    [1]
    http://lists.infradead.org/pipermail/linux-arm-kernel/2012-January/080175.html
    
    Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Christoph Fritz <chf.fritz@googlemail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7623bd95a6dccf74e30a21e437f2f789fbbe27f7
Author: Troy Kisky <troy.kisky@boundarydevices.com>
Date:   Thu Nov 2 18:58:15 2017 -0700

    rtc: m41t80: avoid i2c read in m41t80_sqw_is_prepared
    
    commit 13bb1d78f2e372ec0d9b30489ac63768240140fc upstream.
    
    This is a little more efficient and avoids the warning
    
     WARNING: possible circular locking dependency detected
     4.14.0-rc7-00010 #16 Not tainted
     ------------------------------------------------------
     kworker/2:1/70 is trying to acquire lock:
      (prepare_lock){+.+.}, at: [<c049300c>] clk_prepare_lock+0x80/0xf4
    
     but task is already holding lock:
      (i2c_register_adapter){+.+.}, at: [<c0690b04>]
                    i2c_adapter_lock_bus+0x14/0x18
    
     which lock already depends on the new lock.
    
     the existing dependency chain (in reverse order) is:
    
     -> #1 (i2c_register_adapter){+.+.}:
            rt_mutex_lock+0x44/0x5c
            i2c_adapter_lock_bus+0x14/0x18
            i2c_transfer+0xa8/0xbc
            i2c_smbus_xfer+0x20c/0x5d8
            i2c_smbus_read_byte_data+0x38/0x48
            m41t80_sqw_is_prepared+0x18/0x28
    
    Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Christoph Fritz <chf.fritz@googlemail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 11118640ae1705c57699a394d0754d4c699772c6
Author: Troy Kisky <troy.kisky@boundarydevices.com>
Date:   Thu Nov 2 18:58:14 2017 -0700

    rtc: m41t80: avoid i2c read in m41t80_sqw_recalc_rate
    
    commit 2cb90ed3de1e279dbaf23df141f54eb9fb1861e6 upstream.
    
    This is a little more efficient, and avoids the warning
    
     WARNING: possible circular locking dependency detected
     4.14.0-rc7-00007 #14 Not tainted
     ------------------------------------------------------
     alsactl/330 is trying to acquire lock:
     (prepare_lock){+.+.}, at: [<c049300c>] clk_prepare_lock+0x80/0xf4
    
     but task is already holding lock:
     (i2c_register_adapter){+.+.}, at: [<c0690ae0>]
                    i2c_adapter_lock_bus+0x14/0x18
    
     which lock already depends on the new lock.
    
     the existing dependency chain (in reverse order) is:
    
     -> #1 (i2c_register_adapter){+.+.}:
            rt_mutex_lock+0x44/0x5c
            i2c_adapter_lock_bus+0x14/0x18
            i2c_transfer+0xa8/0xbc
            i2c_smbus_xfer+0x20c/0x5d8
            i2c_smbus_read_byte_data+0x38/0x48
            m41t80_sqw_recalc_rate+0x24/0x58
    
    Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Christoph Fritz <chf.fritz@googlemail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8932255e96ecd172783c2c5a3a414066bda844cf
Author: Troy Kisky <troy.kisky@boundarydevices.com>
Date:   Thu Nov 2 18:58:13 2017 -0700

    rtc: m41t80: fix m41t80_sqw_round_rate return value
    
    commit c8384bb04261b9d32fe7402a6068ddaf38913b23 upstream.
    
    Previously it was returning the best of
    32768, 8192, 1024, 64, 2, 0
    
    Now, best of
    32768, 8192, 4096, 2048, 1024, 512, 256, 128,
    64, 32, 16, 8, 4, 2, 1, 0
    
    Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Christoph Fritz <chf.fritz@googlemail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 56073ba4e7068a737a225631b5b642a2cd105b7a
Author: Troy Kisky <troy.kisky@boundarydevices.com>
Date:   Thu Nov 2 18:58:12 2017 -0700

    rtc: m41t80: m41t80_sqw_set_rate should return 0 on success
    
    commit de6042d2fa8afe22b76e3c68fd6e9584c9415a3b upstream.
    
    Previously it was returning -EINVAL upon success.
    
    Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
    Cc: Christoph Fritz <chf.fritz@googlemail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2d01ac8cc12b973668bf898b03bf9ffb12d83b83
Author: Steffen Klassert <steffen.klassert@secunet.com>
Date:   Wed Nov 15 06:40:57 2017 +0100

    Revert "xfrm: Fix stack-out-of-bounds read in xfrm_state_find."
    
    commit 94802151894d482e82c324edf2c658f8e6b96508 upstream.
    
    This reverts commit c9f3f813d462c72dbe412cee6a5cbacf13c4ad5e.
    
    This commit breaks transport mode when the policy template
    has widlcard addresses configured, so revert it.
    
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Cc: From: Derek Robson <robsonde@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 88dff1ab04d2792492e3f7e166d039f0dc4e1a09
Author: Nick Desaulniers <ndesaulniers@google.com>
Date:   Wed Jan 3 12:39:52 2018 -0800

    x86/process: Define cpu_tss_rw in same section as declaration
    
    commit 2fd9c41aea47f4ad071accf94b94f94f2c4d31eb upstream.
    
    cpu_tss_rw is declared with DECLARE_PER_CPU_PAGE_ALIGNED
    but then defined with DEFINE_PER_CPU_SHARED_ALIGNED
    leading to section mismatch warnings.
    
    Use DEFINE_PER_CPU_PAGE_ALIGNED consistently. This is necessary because
    it's mapped to the cpu entry area and must be page aligned.
    
    [ tglx: Massaged changelog a bit ]
    
    Fixes: 1a935bc3d4ea ("x86/entry: Move SYSENTER_stack to the beginning of struct tss_struct")
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: thomas.lendacky@amd.com
    Cc: Borislav Petkov <bpetkov@suse.de>
    Cc: tklauser@distanz.ch
    Cc: minipli@googlemail.com
    Cc: me@kylehuey.com
    Cc: namit@vmware.com
    Cc: luto@kernel.org
    Cc: jpoimboe@redhat.com
    Cc: tj@kernel.org
    Cc: cl@linux.com
    Cc: bp@suse.de
    Cc: thgarnie@google.com
    Cc: kirill.shutemov@linux.intel.com
    Link: https://lkml.kernel.org/r/20180103203954.183360-1-ndesaulniers@google.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7930cb29fb5feb6d18ffc20a83a1d3e5afac7a8a
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Jan 3 19:52:04 2018 +0100

    x86/pti: Switch to kernel CR3 at early in entry_SYSCALL_compat()
    
    commit d7732ba55c4b6a2da339bb12589c515830cfac2c upstream.
    
    The preparation for PTI which added CR3 switching to the entry code
    misplaced the CR3 switch in entry_SYSCALL_compat().
    
    With PTI enabled the entry code tries to access a per cpu variable after
    switching to kernel GS. This fails because that variable is not mapped to
    user space. This results in a double fault and in the worst case a kernel
    crash.
    
    Move the switch ahead of the access and clobber RSP which has been saved
    already.
    
    Fixes: 8a09317b895f ("x86/mm/pti: Prepare the x86/entry assembly code for entry/exit CR3 switching")
    Reported-by: Lars Wendler <wendler.lars@web.de>
    Reported-by: Laura Abbott <labbott@redhat.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Borislav Betkov <bp@alien8.de>
    Cc: Andy Lutomirski <luto@kernel.org>,
    Cc: Dave Hansen <dave.hansen@linux.intel.com>,
    Cc: Peter Zijlstra <peterz@infradead.org>,
    Cc: Greg KH <gregkh@linuxfoundation.org>, ,
    Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
    Cc: Juergen Gross <jgross@suse.com>
    Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801031949200.1957@nanos
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 89c96233a9ed8ee76d6e8e6a13ea19b92971d33f
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date:   Sun Dec 31 10:18:07 2017 -0600

    x86/dumpstack: Print registers for first stack frame
    
    commit 3ffdeb1a02be3086f1411a15c5b9c481fa28e21f upstream.
    
    In the stack dump code, if the frame after the starting pt_regs is also
    a regs frame, the registers don't get printed.  Fix that.
    
    Reported-by: Andy Lutomirski <luto@amacapital.net>
    Tested-by: Alexander Tsoy <alexander@tsoy.me>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Toralf Förster <toralf.foerster@gmx.de>
    Fixes: 3b3fa11bc700 ("x86/dumpstack: Print any pt_regs found on the stack")
    Link: http://lkml.kernel.org/r/396f84491d2f0ef64eda4217a2165f5712f6a115.1514736742.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a841ba8f4d7e37acc9d46f982f418ee8e876a752
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date:   Sun Dec 31 10:18:06 2017 -0600

    x86/dumpstack: Fix partial register dumps
    
    commit a9cdbe72c4e8bf3b38781c317a79326e2e1a230d upstream.
    
    The show_regs_safe() logic is wrong.  When there's an iret stack frame,
    it prints the entire pt_regs -- most of which is random stack data --
    instead of just the five registers at the end.
    
    show_regs_safe() is also poorly named: the on_stack() checks aren't for
    safety.  Rename the function to show_regs_if_on_stack() and add a
    comment to explain why the checks are needed.
    
    These issues were introduced with the "partial register dump" feature of
    the following commit:
    
      b02fcf9ba121 ("x86/unwinder: Handle stack overflows more gracefully")
    
    That patch had gone through a few iterations of development, and the
    above issues were artifacts from a previous iteration of the patch where
    'regs' pointed directly to the iret frame rather than to the (partially
    empty) pt_regs.
    
    Tested-by: Alexander Tsoy <alexander@tsoy.me>
    Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Toralf Förster <toralf.foerster@gmx.de>
    Fixes: b02fcf9ba121 ("x86/unwinder: Handle stack overflows more gracefully")
    Link: http://lkml.kernel.org/r/5b05b8b344f59db2d3d50dbdeba92d60f2304c54.1514736742.git.jpoimboe@redhat.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 211ad3fdf63383772d492add846da4b0b2266531
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Jan 3 15:57:59 2018 +0100

    x86/pti: Make sure the user/kernel PTEs match
    
    commit 52994c256df36fda9a715697431cba9daecb6b11 upstream.
    
    Meelis reported that his K8 Athlon64 emits MCE warnings when PTI is
    enabled:
    
    [Hardware Error]: Error Addr: 0x0000ffff81e000e0
    [Hardware Error]: MC1 Error: L1 TLB multimatch.
    [Hardware Error]: cache level: L1, tx: INSN
    
    The address is in the entry area, which is mapped into kernel _AND_ user
    space. That's special because we switch CR3 while we are executing
    there.
    
    User mapping:
    0xffffffff81e00000-0xffffffff82000000           2M     ro         PSE     GLB x  pmd
    
    Kernel mapping:
    0xffffffff81000000-0xffffffff82000000          16M     ro         PSE         x  pmd
    
    So the K8 is complaining that the TLB entries differ. They differ in the
    GLB bit.
    
    Drop the GLB bit when installing the user shared mapping.
    
    Fixes: 6dc72c3cbca0 ("x86/mm/pti: Share entry text PMD")
    Reported-by: Meelis Roos <mroos@linux.ee>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Tested-by: Meelis Roos <mroos@linux.ee>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Tom Lendacky <thomas.lendacky@amd.com>
    Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801031407180.1957@nanos
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 151d7039757b71ebd9d170af0944562f51149372
Author: Tom Lendacky <thomas.lendacky@amd.com>
Date:   Tue Dec 26 23:43:54 2017 -0600

    x86/cpu, x86/pti: Do not enable PTI on AMD processors
    
    commit 694d99d40972f12e59a3696effee8a376b79d7c8 upstream.
    
    AMD processors are not subject to the types of attacks that the kernel
    page table isolation feature protects against.  The AMD microarchitecture
    does not allow memory references, including speculative references, that
    access higher privileged data when running in a lesser privileged mode
    when that access would result in a page fault.
    
    Disable page table isolation by default on AMD processors by not setting
    the X86_BUG_CPU_INSECURE feature, which controls whether X86_FEATURE_PTI
    is set.
    
    Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Reviewed-by: Borislav Petkov <bp@suse.de>
    Cc: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Andy Lutomirski <luto@kernel.org>
    Link: https://lkml.kernel.org/r/20171227054354.20369.94587.stgit@tlendack-t1.amdoffice.net
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit df4373c513b310d75aafeb8902917e7f8d0fe6a5
Author: Eric Biggers <ebiggers@google.com>
Date:   Mon Jan 1 09:28:31 2018 -0600

    capabilities: fix buffer overread on very short xattr
    
    commit dc32b5c3e6e2ef29cef76d9ce1b92d394446150e upstream.
    
    If userspace attempted to set a "security.capability" xattr shorter than
    4 bytes (e.g. 'setfattr -n security.capability -v x file'), then
    cap_convert_nscap() read past the end of the buffer containing the xattr
    value because it accessed the ->magic_etc field without verifying that
    the xattr value is long enough to contain that field.
    
    Fix it by validating the xattr value size first.
    
    This bug was found using syzkaller with KASAN.  The KASAN report was as
    follows (cleaned up slightly):
    
        BUG: KASAN: slab-out-of-bounds in cap_convert_nscap+0x514/0x630 security/commoncap.c:498
        Read of size 4 at addr ffff88002d8741c0 by task syz-executor1/2852
    
        CPU: 0 PID: 2852 Comm: syz-executor1 Not tainted 4.15.0-rc6-00200-gcc0aac99d977 #253
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014
        Call Trace:
         __dump_stack lib/dump_stack.c:17 [inline]
         dump_stack+0xe3/0x195 lib/dump_stack.c:53
         print_address_description+0x73/0x260 mm/kasan/report.c:252
         kasan_report_error mm/kasan/report.c:351 [inline]
         kasan_report+0x235/0x350 mm/kasan/report.c:409
         cap_convert_nscap+0x514/0x630 security/commoncap.c:498
         setxattr+0x2bd/0x350 fs/xattr.c:446
         path_setxattr+0x168/0x1b0 fs/xattr.c:472
         SYSC_setxattr fs/xattr.c:487 [inline]
         SyS_setxattr+0x36/0x50 fs/xattr.c:483
         entry_SYSCALL_64_fastpath+0x18/0x85
    
    Fixes: 8db6c34f1dbc ("Introduce v3 namespaced file capabilities")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Serge Hallyn <serge@hallyn.com>
    Signed-off-by: James Morris <james.l.morris@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 611583d327961acad4405063fc7c690ac2cf21c3
Author: Kees Cook <keescook@chromium.org>
Date:   Tue Jan 2 15:21:33 2018 -0800

    exec: Weaken dumpability for secureexec
    
    commit e816c201aed5232171f8eb80b5d46ae6516683b9 upstream.
    
    This is a logical revert of commit e37fdb785a5f ("exec: Use secureexec
    for setting dumpability")
    
    This weakens dumpability back to checking only for uid/gid changes in
    current (which is useless), but userspace depends on dumpability not
    being tied to secureexec.
    
      https://bugzilla.redhat.com/show_bug.cgi?id=1528633
    
    Reported-by: Tom Horsley <horsley1953@gmail.com>
    Fixes: e37fdb785a5f ("exec: Use secureexec for setting dumpability")
    Signed-off-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>