commit 49fe90b853dfb1087d0a734cd7f4af1aa00c8e53
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Jan 31 12:06:14 2018 +0100

    Linux 4.4.114

commit 3f84339bd344b2cf0afe64b78d3964bb6422d0f3
Author: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date:   Mon Jan 22 20:11:06 2018 +0000

    nfsd: auth: Fix gid sorting when rootsquash enabled
    
    commit 1995266727fa8143897e89b55f5d3c79aa828420 upstream.
    
    Commit bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility
    group_info allocators") appears to break nfsd rootsquash in a pretty
    major way.
    
    It adds a call to groups_sort() inside the loop that copies/squashes
    gids, which means the valid gids are sorted along with the following
    garbage.  The net result is that the highest numbered valid gids are
    replaced with any lower-valued garbage gids, possibly including 0.
    
    We should sort only once, after filling in all the gids.
    
    Fixes: bdcf0a423ea1 ("kernel: make groups_sort calling a responsibility ...")
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Acked-by: J. Bruce Fields <bfields@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Wolfgang Walter <linux@stwm.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit edaafa805e0f9d09560a4892790b8e19cab8bf09
Author: Dan Streetman <ddstreet@ieee.org>
Date:   Thu Jan 18 16:14:26 2018 -0500

    net: tcp: close sock if net namespace is exiting
    
    
    [ Upstream commit 4ee806d51176ba7b8ff1efd81f271d7252e03a1d ]
    
    When a tcp socket is closed, if it detects that its net namespace is
    exiting, close immediately and do not wait for FIN sequence.
    
    For normal sockets, a reference is taken to their net namespace, so it will
    never exit while the socket is open.  However, kernel sockets do not take a
    reference to their net namespace, so it may begin exiting while the kernel
    socket is still open.  In this case if the kernel socket is a tcp socket,
    it will stay open trying to complete its close sequence.  The sock's dst(s)
    hold a reference to their interface, which are all transferred to the
    namespace's loopback interface when the real interfaces are taken down.
    When the namespace tries to take down its loopback interface, it hangs
    waiting for all references to the loopback interface to release, which
    results in messages like:
    
    unregister_netdevice: waiting for lo to become free. Usage count = 1
    
    These messages continue until the socket finally times out and closes.
    Since the net namespace cleanup holds the net_mutex while calling its
    registered pernet callbacks, any new net namespace initialization is
    blocked until the current net namespace finishes exiting.
    
    After this change, the tcp socket notices the exiting net namespace, and
    closes immediately, releasing its dst(s) and their reference to the
    loopback interface, which lets the net namespace continue exiting.
    
    Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1711407
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=97811
    Signed-off-by: Dan Streetman <ddstreet@canonical.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d35cd5e279881ec36ff8cd82a2d9caebc0cce3fc
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Jan 17 14:21:13 2018 -0800

    flow_dissector: properly cap thoff field
    
    
    [ Upstream commit d0c081b49137cd3200f2023c0875723be66e7ce5 ]
    
    syzbot reported yet another crash [1] that is caused by
    insufficient validation of DODGY packets.
    
    Two bugs are happening here to trigger the crash.
    
    1) Flow dissection leaves with incorrect thoff field.
    
    2) skb_probe_transport_header() sets transport header to this invalid
    thoff, even if pointing after skb valid data.
    
    3) qdisc_pkt_len_init() reads out-of-bound data because it
    trusts tcp_hdrlen(skb)
    
    Possible fixes :
    
    - Full flow dissector validation before injecting bad DODGY packets in
    the stack.
     This approach was attempted here : https://patchwork.ozlabs.org/patch/
    861874/
    
    - Have more robust functions in the core.
      This might be needed anyway for stable versions.
    
    This patch fixes the flow dissection issue.
    
    [1]
    CPU: 1 PID: 3144 Comm: syzkaller271204 Not tainted 4.15.0-rc4-mm1+ #49
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x194/0x257 lib/dump_stack.c:53
     print_address_description+0x73/0x250 mm/kasan/report.c:256
     kasan_report_error mm/kasan/report.c:355 [inline]
     kasan_report+0x23b/0x360 mm/kasan/report.c:413
     __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:432
     __tcp_hdrlen include/linux/tcp.h:35 [inline]
     tcp_hdrlen include/linux/tcp.h:40 [inline]
     qdisc_pkt_len_init net/core/dev.c:3160 [inline]
     __dev_queue_xmit+0x20d3/0x2200 net/core/dev.c:3465
     dev_queue_xmit+0x17/0x20 net/core/dev.c:3554
     packet_snd net/packet/af_packet.c:2943 [inline]
     packet_sendmsg+0x3ad5/0x60a0 net/packet/af_packet.c:2968
     sock_sendmsg_nosec net/socket.c:628 [inline]
     sock_sendmsg+0xca/0x110 net/socket.c:638
     sock_write_iter+0x31a/0x5d0 net/socket.c:907
     call_write_iter include/linux/fs.h:1776 [inline]
     new_sync_write fs/read_write.c:469 [inline]
     __vfs_write+0x684/0x970 fs/read_write.c:482
     vfs_write+0x189/0x510 fs/read_write.c:544
     SYSC_write fs/read_write.c:589 [inline]
     SyS_write+0xef/0x220 fs/read_write.c:581
     entry_SYSCALL_64_fastpath+0x1f/0x96
    
    Fixes: 34fad54c2537 ("net: __skb_flow_dissect() must cap its return value")
    Fixes: a6e544b0a88b ("flow_dissector: Jump to exit code in __skb_flow_dissect")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Willem de Bruijn <willemb@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cab8451486a6fd9ba4ce798d41352f45abb44fae
Author: Jim Westfall <jwestfall@surrealistic.net>
Date:   Sun Jan 14 04:18:51 2018 -0800

    ipv4: Make neigh lookup keys for loopback/point-to-point devices be INADDR_ANY
    
    
    [ Upstream commit cd9ff4de0107c65d69d02253bb25d6db93c3dbc1 ]
    
    Map all lookup neigh keys to INADDR_ANY for loopback/point-to-point devices
    to avoid making an entry for every remote ip the device needs to talk to.
    
    This used the be the old behavior but became broken in a263b3093641f
    (ipv4: Make neigh lookups directly in output packet path) and later removed
    in 0bb4087cbec0 (ipv4: Fix neigh lookup keying over loopback/point-to-point
    devices) because it was broken.
    
    Signed-off-by: Jim Westfall <jwestfall@surrealistic.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29837a4a8764c1b73674eb78c99717cbc73aa9f3
Author: Jim Westfall <jwestfall@surrealistic.net>
Date:   Sun Jan 14 04:18:50 2018 -0800

    net: Allow neigh contructor functions ability to modify the primary_key
    
    
    [ Upstream commit 096b9854c04df86f03b38a97d40b6506e5730919 ]
    
    Use n->primary_key instead of pkey to account for the possibility that a neigh
    constructor function may have modified the primary_key value.
    
    Signed-off-by: Jim Westfall <jwestfall@surrealistic.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0d9bcadb2226150776c5bf84ef6eb5df03e32b03
Author: Neil Horman <nhorman@tuxdriver.com>
Date:   Mon Jan 22 16:06:37 2018 -0500

    vmxnet3: repair memory leak
    
    
    [ Upstream commit 848b159835ddef99cc4193083f7e786c3992f580 ]
    
    with the introduction of commit
    b0eb57cb97e7837ebb746404c2c58c6f536f23fa, it appears that rq->buf_info
    is improperly handled.  While it is heap allocated when an rx queue is
    setup, and freed when torn down, an old line of code in
    vmxnet3_rq_destroy was not properly removed, leading to rq->buf_info[0]
    being set to NULL prior to its being freed, causing a memory leak, which
    eventually exhausts the system on repeated create/destroy operations
    (for example, when  the mtu of a vmxnet3 interface is changed
    frequently.
    
    Fix is pretty straight forward, just move the NULL set to after the
    free.
    
    Tested by myself with successful results
    
    Applies to net, and should likely be queued for stable, please
    
    Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
    Reported-By: boyang@redhat.com
    CC: boyang@redhat.com
    CC: Shrikrishna Khare <skhare@vmware.com>
    CC: "VMware, Inc." <pv-drivers@vmware.com>
    CC: David S. Miller <davem@davemloft.net>
    Acked-by: Shrikrishna Khare <skhare@vmware.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 50194c3f48de2c2374731d4b6b7f3fbb89250094
Author: Xin Long <lucien.xin@gmail.com>
Date:   Mon Jan 15 17:01:36 2018 +0800

    sctp: return error if the asoc has been peeled off in sctp_wait_for_sndbuf
    
    
    [ Upstream commit a0ff660058b88d12625a783ce9e5c1371c87951f ]
    
    After commit cea0cc80a677 ("sctp: use the right sk after waking up from
    wait_buf sleep"), it may change to lock another sk if the asoc has been
    peeled off in sctp_wait_for_sndbuf.
    
    However, the asoc's new sk could be already closed elsewhere, as it's in
    the sendmsg context of the old sk that can't avoid the new sk's closing.
    If the sk's last one refcnt is held by this asoc, later on after putting
    this asoc, the new sk will be freed, while under it's own lock.
    
    This patch is to revert that commit, but fix the old issue by returning
    error under the old sk's lock.
    
    Fixes: cea0cc80a677 ("sctp: use the right sk after waking up from wait_buf sleep")
    Reported-by: syzbot+ac6ea7baa4432811eb50@syzkaller.appspotmail.com
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Neil Horman <nhorman@tuxdriver.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 23f521bc70b935156e13897db2873312b18b0437
Author: Xin Long <lucien.xin@gmail.com>
Date:   Mon Jan 15 17:02:00 2018 +0800

    sctp: do not allow the v4 socket to bind a v4mapped v6 address
    
    
    [ Upstream commit c5006b8aa74599ce19104b31d322d2ea9ff887cc ]
    
    The check in sctp_sockaddr_af is not robust enough to forbid binding a
    v4mapped v6 addr on a v4 socket.
    
    The worse thing is that v4 socket's bind_verify would not convert this
    v4mapped v6 addr to a v4 addr. syzbot even reported a crash as the v4
    socket bound a v6 addr.
    
    This patch is to fix it by doing the common sa.sa_family check first,
    then AF_INET check for v4mapped v6 addrs.
    
    Fixes: 7dab83de50c7 ("sctp: Support ipv6only AF_INET6 sockets.")
    Reported-by: syzbot+7b7b518b1228d2743963@syzkaller.appspotmail.com
    Acked-by: Neil Horman <nhorman@tuxdriver.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d6611191f5a18d03314ab4a1b621d1892116af79
Author: Francois Romieu <romieu@fr.zoreil.com>
Date:   Fri Jan 26 01:53:26 2018 +0100

    r8169: fix memory corruption on retrieval of hardware statistics.
    
    
    [ Upstream commit a78e93661c5fd30b9e1dee464b2f62f966883ef7 ]
    
    Hardware statistics retrieval hurts in tight invocation loops.
    
    Avoid extraneous write and enforce strict ordering of writes targeted to
    the tally counters dump area address registers.
    
    Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
    Tested-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a49558ebc2c4ce129a381d7cf39c4f01ea02c78b
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Mon Jan 22 18:06:37 2018 +0100

    pppoe: take ->needed_headroom of lower device into account on xmit
    
    
    [ Upstream commit 02612bb05e51df8489db5e94d0cf8d1c81f87b0c ]
    
    In pppoe_sendmsg(), reserving dev->hard_header_len bytes of headroom
    was probably fine before the introduction of ->needed_headroom in
    commit f5184d267c1a ("net: Allow netdevices to specify needed head/tailroom").
    
    But now, virtual devices typically advertise the size of their overhead
    in dev->needed_headroom, so we must also take it into account in
    skb_reserve().
    Allocation size of skb is also updated to take dev->needed_tailroom
    into account and replace the arbitrary 32 bytes with the real size of
    a PPPoE header.
    
    This issue was discovered by syzbot, who connected a pppoe socket to a
    gre device which had dev->header_ops->create == ipgre_header and
    dev->hard_header_len == 0. Therefore, PPPoE didn't reserve any
    headroom, and dev_hard_header() crashed when ipgre_header() tried to
    prepend its header to skb->data.
    
    skbuff: skb_under_panic: text:000000001d390b3a len:31 put:24
    head:00000000d8ed776f data:000000008150e823 tail:0x7 end:0xc0 dev:gre0
    ------------[ cut here ]------------
    kernel BUG at net/core/skbuff.c:104!
    invalid opcode: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
        (ftrace buffer empty)
    Modules linked in:
    CPU: 1 PID: 3670 Comm: syzkaller801466 Not tainted
    4.15.0-rc7-next-20180115+ #97
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    RIP: 0010:skb_panic+0x162/0x1f0 net/core/skbuff.c:100
    RSP: 0018:ffff8801d9bd7840 EFLAGS: 00010282
    RAX: 0000000000000083 RBX: ffff8801d4f083c0 RCX: 0000000000000000
    RDX: 0000000000000083 RSI: 1ffff1003b37ae92 RDI: ffffed003b37aefc
    RBP: ffff8801d9bd78a8 R08: 1ffff1003b37ae8a R09: 0000000000000000
    R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff86200de0
    R13: ffffffff84a981ad R14: 0000000000000018 R15: ffff8801d2d34180
    FS:  00000000019c4880(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000208bc000 CR3: 00000001d9111001 CR4: 00000000001606e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
      skb_under_panic net/core/skbuff.c:114 [inline]
      skb_push+0xce/0xf0 net/core/skbuff.c:1714
      ipgre_header+0x6d/0x4e0 net/ipv4/ip_gre.c:879
      dev_hard_header include/linux/netdevice.h:2723 [inline]
      pppoe_sendmsg+0x58e/0x8b0 drivers/net/ppp/pppoe.c:890
      sock_sendmsg_nosec net/socket.c:630 [inline]
      sock_sendmsg+0xca/0x110 net/socket.c:640
      sock_write_iter+0x31a/0x5d0 net/socket.c:909
      call_write_iter include/linux/fs.h:1775 [inline]
      do_iter_readv_writev+0x525/0x7f0 fs/read_write.c:653
      do_iter_write+0x154/0x540 fs/read_write.c:932
      vfs_writev+0x18a/0x340 fs/read_write.c:977
      do_writev+0xfc/0x2a0 fs/read_write.c:1012
      SYSC_writev fs/read_write.c:1085 [inline]
      SyS_writev+0x27/0x30 fs/read_write.c:1082
      entry_SYSCALL_64_fastpath+0x29/0xa0
    
    Admittedly PPPoE shouldn't be allowed to run on non Ethernet-like
    interfaces, but reserving space for ->needed_headroom is a more
    fundamental issue that needs to be addressed first.
    
    Same problem exists for __pppoe_xmit(), which also needs to take
    dev->needed_headroom into account in skb_cow_head().
    
    Fixes: f5184d267c1a ("net: Allow netdevices to specify needed head/tailroom")
    Reported-by: syzbot+ed0838d0fa4c4f2b528e20286e6dc63effc7c14d@syzkaller.appspotmail.com
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Reviewed-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 f50fc5f4f3e5f0d2b55cd09c01f3a09d0ddeb9dc
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Jan 18 19:59:19 2018 -0800

    net: qdisc_pkt_len_init() should be more robust
    
    
    [ Upstream commit 7c68d1a6b4db9012790af7ac0f0fdc0d2083422a ]
    
    Without proper validation of DODGY packets, we might very well
    feed qdisc_pkt_len_init() with invalid GSO packets.
    
    tcp_hdrlen() might access out-of-bound data, so let's use
    skb_header_pointer() and proper checks.
    
    Whole story is described in commit d0c081b49137 ("flow_dissector:
    properly cap thoff field")
    
    We have the goal of validating DODGY packets earlier in the stack,
    so we might very well revert this fix in the future.
    
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Cc: Willem de Bruijn <willemb@google.com>
    Cc: Jason Wang <jasowang@redhat.com>
    Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bed42ef5ebbfc046e0440f7e0f941cc07f8ca1e8
Author: Craig Gallek <kraig@google.com>
Date:   Wed Feb 10 11:50:37 2016 -0500

    tcp: __tcp_hdrlen() helper
    
    commit d9b3fca27385eafe61c3ca6feab6cb1e7dc77482 upstream.
    
    tcp_hdrlen is wasteful if you already have a pointer to struct tcphdr.
    This splits the size calculation into a helper function that can be
    used if a struct tcphdr is already available.
    
    Signed-off-by: Craig Gallek <kraig@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6c489ab43ccacb9f26620ded90374c582c466344
Author: Felix Fietkau <nbd@nbd.name>
Date:   Fri Jan 19 11:50:46 2018 +0100

    net: igmp: fix source address check for IGMPv3 reports
    
    
    [ Upstream commit ad23b750933ea7bf962678972a286c78a8fa36aa ]
    
    Commit "net: igmp: Use correct source address on IGMPv3 reports"
    introduced a check to validate the source address of locally generated
    IGMPv3 packets.
    Instead of checking the local interface address directly, it uses
    inet_ifa_match(fl4->saddr, ifa), which checks if the address is on the
    local subnet (or equal to the point-to-point address if used).
    
    This breaks for point-to-point interfaces, so check against
    ifa->ifa_local directly.
    
    Cc: Kevin Cernekee <cernekee@chromium.org>
    Fixes: a46182b00290 ("net: igmp: Use correct source address on IGMPv3 reports")
    Reported-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Tested-by: Florian Wolters <florian@florian-wolters.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1202fc020465b67297f84dfc7127b83805082c69
Author: Yuiko Oshino <yuiko.oshino@microchip.com>
Date:   Mon Jan 15 13:24:28 2018 -0500

    lan78xx: Fix failure in USB Full Speed
    
    
    [ Upstream commit a5b1379afbfabf91e3a689e82ac619a7157336b3 ]
    
    Fix initialize the uninitialized tx_qlen to an appropriate value when USB
    Full Speed is used.
    
    Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")
    Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f64568e420e6b9b523611ef564941b83c7527614
Author: Eric Dumazet <edumazet@google.com>
Date:   Thu Jan 11 22:31:18 2018 -0800

    ipv6: ip6_make_skb() needs to clear cork.base.dst
    
    
    [ Upstream commit 95ef498d977bf44ac094778fd448b98af158a3e6 ]
    
    In my last patch, I missed fact that cork.base.dst was not initialized
    in ip6_make_skb() :
    
    If ip6_setup_cork() returns an error, we might attempt a dst_release()
    on some random pointer.
    
    Fixes: 862c03ee1deb ("ipv6: fix possible mem leaks in ipv6_make_skb()")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c867a05df5d1baefbb2040474356b5e02ca5fcaf
Author: Mike Maloney <maloney@google.com>
Date:   Wed Jan 10 12:45:10 2018 -0500

    ipv6: fix udpv6 sendmsg crash caused by too small MTU
    
    
    [ Upstream commit 749439bfac6e1a2932c582e2699f91d329658196 ]
    
    The logic in __ip6_append_data() assumes that the MTU is at least large
    enough for the headers.  A device's MTU may be adjusted after being
    added while sendmsg() is processing data, resulting in
    __ip6_append_data() seeing any MTU.  For an mtu smaller than the size of
    the fragmentation header, the math results in a negative 'maxfraglen',
    which causes problems when refragmenting any previous skb in the
    skb_write_queue, leaving it possibly malformed.
    
    Instead sendmsg returns EINVAL when the mtu is calculated to be less
    than IPV6_MIN_MTU.
    
    Found by syzkaller:
    kernel BUG at ./include/linux/skbuff.h:2064!
    invalid opcode: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
       (ftrace buffer empty)
    Modules linked in:
    CPU: 1 PID: 14216 Comm: syz-executor5 Not tainted 4.13.0-rc4+ #2
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    task: ffff8801d0b68580 task.stack: ffff8801ac6b8000
    RIP: 0010:__skb_pull include/linux/skbuff.h:2064 [inline]
    RIP: 0010:__ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617
    RSP: 0018:ffff8801ac6bf570 EFLAGS: 00010216
    RAX: 0000000000010000 RBX: 0000000000000028 RCX: ffffc90003cce000
    RDX: 00000000000001b8 RSI: ffffffff839df06f RDI: ffff8801d9478ca0
    RBP: ffff8801ac6bf780 R08: ffff8801cc3f1dbc R09: 0000000000000000
    R10: ffff8801ac6bf7a0 R11: 43cb4b7b1948a9e7 R12: ffff8801cc3f1dc8
    R13: ffff8801cc3f1d40 R14: 0000000000001036 R15: dffffc0000000000
    FS:  00007f43d740c700(0000) GS:ffff8801dc100000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007f7834984000 CR3: 00000001d79b9000 CR4: 00000000001406e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     ip6_finish_skb include/net/ipv6.h:911 [inline]
     udp_v6_push_pending_frames+0x255/0x390 net/ipv6/udp.c:1093
     udpv6_sendmsg+0x280d/0x31a0 net/ipv6/udp.c:1363
     inet_sendmsg+0x11f/0x5e0 net/ipv4/af_inet.c:762
     sock_sendmsg_nosec net/socket.c:633 [inline]
     sock_sendmsg+0xca/0x110 net/socket.c:643
     SYSC_sendto+0x352/0x5a0 net/socket.c:1750
     SyS_sendto+0x40/0x50 net/socket.c:1718
     entry_SYSCALL_64_fastpath+0x1f/0xbe
    RIP: 0033:0x4512e9
    RSP: 002b:00007f43d740bc08 EFLAGS: 00000216 ORIG_RAX: 000000000000002c
    RAX: ffffffffffffffda RBX: 00000000007180a8 RCX: 00000000004512e9
    RDX: 000000000000002e RSI: 0000000020d08000 RDI: 0000000000000005
    RBP: 0000000000000086 R08: 00000000209c1000 R09: 000000000000001c
    R10: 0000000000040800 R11: 0000000000000216 R12: 00000000004b9c69
    R13: 00000000ffffffff R14: 0000000000000005 R15: 00000000202c2000
    Code: 9e 01 fe e9 c5 e8 ff ff e8 7f 9e 01 fe e9 4a ea ff ff 48 89 f7 e8 52 9e 01 fe e9 aa eb ff ff e8 a8 b6 cf fd 0f 0b e8 a1 b6 cf fd <0f> 0b 49 8d 45 78 4d 8d 45 7c 48 89 85 78 fe ff ff 49 8d 85 ba
    RIP: __skb_pull include/linux/skbuff.h:2064 [inline] RSP: ffff8801ac6bf570
    RIP: __ip6_make_skb+0x18cf/0x1f70 net/ipv6/ip6_output.c:1617 RSP: ffff8801ac6bf570
    
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Signed-off-by: Mike Maloney <maloney@google.com>
    Reviewed-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 c5371a321a4a3c1f181f4482b3b3ceae06b72879
Author: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date:   Mon Jan 22 20:06:42 2018 +0000

    ipv6: Fix getsockopt() for sockets with default IPV6_AUTOFLOWLABEL
    
    
    [ Upstream commit e9191ffb65d8e159680ce0ad2224e1acbde6985c ]
    
    Commit 513674b5a2c9 ("net: reevalulate autoflowlabel setting after
    sysctl setting") removed the initialisation of
    ipv6_pinfo::autoflowlabel and added a second flag to indicate
    whether this field or the net namespace default should be used.
    
    The getsockopt() handling for this case was not updated, so it
    currently returns 0 for all sockets for which IPV6_AUTOFLOWLABEL is
    not explicitly enabled.  Fix it to return the effective value, whether
    that has been set at the socket or net namespace level.
    
    Fixes: 513674b5a2c9 ("net: reevalulate autoflowlabel setting after sysctl ...")
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e91e5b700fb6f887d4df4a18de0d8865df43d77d
Author: Alexey Kodanev <alexey.kodanev@oracle.com>
Date:   Fri Jan 26 15:14:16 2018 +0300

    dccp: don't restart ccid2_hc_tx_rto_expire() if sk in closed state
    
    
    [ Upstream commit dd5684ecae3bd8e44b644f50e2c12c7e57fdfef5 ]
    
    ccid2_hc_tx_rto_expire() timer callback always restarts the timer
    again and can run indefinitely (unless it is stopped outside), and after
    commit 120e9dabaf55 ("dccp: defer ccid_hc_tx_delete() at dismantle time"),
    which moved ccid_hc_tx_delete() (also includes sk_stop_timer()) from
    dccp_destroy_sock() to sk_destruct(), this started to happen quite often.
    The timer prevents releasing the socket, as a result, sk_destruct() won't
    be called.
    
    Found with LTP/dccp_ipsec tests running on the bonding device,
    which later couldn't be unloaded after the tests were completed:
    
      unregister_netdevice: waiting for bond0 to become free. Usage count = 148
    
    Fixes: 2a91aa396739 ("[DCCP] CCID2: Initial CCID2 (TCP-Like) implementation")
    Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
    Reviewed-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 360496cab53af2f1dd77dbe353b7b665bcfdc1e3
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Fri Jan 26 14:54:32 2018 +0100

    hrtimer: Reset hrtimer cpu base proper on CPU hotplug
    
    commit d5421ea43d30701e03cadc56a38854c36a8b4433 upstream.
    
    The hrtimer interrupt code contains a hang detection and mitigation
    mechanism, which prevents that a long delayed hrtimer interrupt causes a
    continous retriggering of interrupts which prevent the system from making
    progress. If a hang is detected then the timer hardware is programmed with
    a certain delay into the future and a flag is set in the hrtimer cpu base
    which prevents newly enqueued timers from reprogramming the timer hardware
    prior to the chosen delay. The subsequent hrtimer interrupt after the delay
    clears the flag and resumes normal operation.
    
    If such a hang happens in the last hrtimer interrupt before a CPU is
    unplugged then the hang_detected flag is set and stays that way when the
    CPU is plugged in again. At that point the timer hardware is not armed and
    it cannot be armed because the hang_detected flag is still active, so
    nothing clears that flag. As a consequence the CPU does not receive hrtimer
    interrupts and no timers expire on that CPU which results in RCU stalls and
    other malfunctions.
    
    Clear the flag along with some other less critical members of the hrtimer
    cpu base to ensure starting from a clean state when a CPU is plugged in.
    
    Thanks to Paul, Sebastian and Anna-Maria for their help to get down to the
    root cause of that hard to reproduce heisenbug. Once understood it's
    trivial and certainly justifies a brown paperbag.
    
    Fixes: 41d2e4949377 ("hrtimer: Tune hrtimer_interrupt hang logic")
    Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Sebastian Sewior <bigeasy@linutronix.de>
    Cc: Anna-Maria Gleixner <anna-maria@linutronix.de>
    Link: https://lkml.kernel.org/r/alpine.DEB.2.20.1801261447590.2067@nanos
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 20c0a04284496b262b172707b7dd122cdd8fe9a1
Author: Jia Zhang <zhang.jia@linux.alibaba.com>
Date:   Tue Jan 23 11:41:32 2018 +0100

    x86/microcode/intel: Extend BDW late-loading further with LLC size check
    
    commit 7e702d17ed138cf4ae7c00e8c00681ed464587c7 upstream.
    
    Commit b94b73733171 ("x86/microcode/intel: Extend BDW late-loading with a
    revision check") reduced the impact of erratum BDF90 for Broadwell model
    79.
    
    The impact can be reduced further by checking the size of the last level
    cache portion per core.
    
    Tony: "The erratum says the problem only occurs on the large-cache SKUs.
    So we only need to avoid the update if we are on a big cache SKU that is
    also running old microcode."
    
    For more details, see erratum BDF90 in document #334165 (Intel Xeon
    Processor E7-8800/4800 v4 Product Family Specification Update) from
    September 2017.
    
    Fixes: b94b73733171 ("x86/microcode/intel: Extend BDW late-loading with a revision check")
    Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Tony Luck <tony.luck@intel.com>
    Link: https://lkml.kernel.org/r/1516321542-31161-1-git-send-email-zhang.jia@linux.alibaba.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 506ff217e470bdaa78477406a051c0570403307d
Author: Greg KH <gregkh@linuxfoundation.org>
Date:   Wed Mar 8 19:03:44 2017 +0100

    eventpoll.h: add missing epoll event masks
    
    commit 7e040726850a106587485c21bdacc0bfc8a0cbed upstream.
    
    [resend due to me forgetting to cc: linux-api the first time around I
    posted these back on Feb 23]
    
    From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    
    For some reason these values are not in the uapi header file, so any
    libc has to define it themselves.  To prevent them from needing to do
    this, just have the kernel provide the correct values.
    
    Reported-by: Elliott Hughes <enh@google.com>
    Signed-off-by: Greg Hackmann <ghackmann@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ed73df0b7f23c95b3243a0f4bfc40f962e61d349
Author: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date:   Fri Jan 26 16:23:02 2018 +0000

    vsyscall: Fix permissions for emulate mode with KAISER/PTI
    
    The backport of KAISER to 4.4 turned vsyscall emulate mode into native
    mode.  Add a vsyscall_pgprot variable to hold the correct page
    protections, like Borislav and Hugh did for 3.2 and 3.18.
    
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Hugh Dickins <hughd@google.com>
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e1e457a49544718928282c56b69af082e1ebe405
Author: Thomas Meyer <thomas@m3y3r.de>
Date:   Sun Aug 20 13:26:04 2017 +0200

    um: link vmlinux with -no-pie
    
    commit 883354afbc109c57f925ccc19840055193da0cc0 upstream.
    
    Debian's gcc defaults to pie. The global Makefile already defines the -fno-pie option.
    Link UML dynamic kernel image also with -no-pie to fix the build.
    
    Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
    Signed-off-by: Richard Weinberger <richard@nod.at>
    Cc: Bernie Innocenti <codewiz@google.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 04e7c734e33c53ca2f2b8d027d9f7251f12bb206
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Fri Dec 15 10:50:09 2017 -0700

    usbip: prevent leaking socket pointer address in messages
    
    commit 90120d15f4c397272aaf41077960a157fc4212bf upstream.
    
    usbip driver is leaking socket pointer address in messages. Remove
    the messages that aren't useful and print sockfd in the ones that
    are useful for debugging.
    
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b6f826ba10dce86f74efd3c0953cb9982a3c51e2
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Thu Dec 7 14:16:48 2017 -0700

    usbip: fix stub_rx: harden CMD_SUBMIT path to handle malicious input
    
    commit c6688ef9f29762e65bce325ef4acd6c675806366 upstream.
    
    Harden CMD_SUBMIT path to handle malicious input that could trigger
    large memory allocations. Add checks to validate transfer_buffer_length
    and number_of_packets to protect against bad input requesting for
    unbounded memory allocations. Validate early in get_pipe() and return
    failure.
    
    Reported-by: Secunia Research <vuln@secunia.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 80e733a9b37fb6b40351bf1924d5a90d89c375ae
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Thu Dec 7 14:16:47 2017 -0700

    usbip: fix stub_rx: get_pipe() to validate endpoint number
    
    commit 635f545a7e8be7596b9b2b6a43cab6bbd5a88e43 upstream.
    
    get_pipe() routine doesn't validate the input endpoint number
    and uses to reference ep_in and ep_out arrays. Invalid endpoint
    number can trigger BUG(). Range check the epnum and returning
    error instead of calling BUG().
    
    Change caller stub_recv_cmd_submit() to handle the get_pipe()
    error return.
    
    Reported-by: Secunia Research <vuln@secunia.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18e905a839ed54b135b00e9d9c9dee2ed6908a08
Author: Andrew Goodbody <andrew.goodbody@cambrionix.com>
Date:   Tue Feb 2 17:36:39 2016 +0000

    usb: usbip: Fix possible deadlocks reported by lockdep
    
    commit 21619792d1eca7e772ca190ba68588e57f29595b upstream.
    
    Change spin_lock calls to spin_lock_irqsave to prevent
    attmpted recursive lock taking in interrupt context.
    
    This patch fixes Bug 109351
      https://bugzilla.kernel.org/show_bug.cgi?id=109351
    
    Signed-off-by: Andrew Goodbody <andrew.goodbody@cambrionix.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 9af75003499c7a441e5a483220f5d2cf65861e73
Author: Aaron Ma <aaron.ma@canonical.com>
Date:   Fri Jan 19 09:43:39 2018 -0800

    Input: trackpoint - force 3 buttons if 0 button is reported
    
    commit f5d07b9e98022d50720e38aa936fc11c67868ece upstream.
    
    Lenovo introduced trackpoint compatible sticks with minimum PS/2 commands.
    They supposed to reply with 0x02, 0x03, or 0x04 in response to the
    "Read Extended ID" command, so we would know not to try certain extended
    commands. Unfortunately even some trackpoints reporting the original IBM
    version (0x01 firmware 0x0e) now respond with incorrect data to the "Get
    Extended Buttons" command:
    
     thinkpad_acpi: ThinkPad BIOS R0DET87W (1.87 ), EC unknown
     thinkpad_acpi: Lenovo ThinkPad E470, model 20H1004SGE
    
     psmouse serio2: trackpoint: IBM TrackPoint firmware: 0x0e, buttons: 0/0
    
    Since there are no trackpoints without buttons, let's assume the trackpoint
    has 3 buttons when we get 0 response to the extended buttons query.
    
    Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
    Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=196253
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5f1dc06152e1683a9277a2836517d6574757dd1f
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Wed Jan 24 15:28:17 2018 +0100

    Revert "module: Add retpoline tag to VERMAGIC"
    
    commit 5132ede0fe8092b043dae09a7cc32b8ae7272baa upstream.
    
    This reverts commit 6cfb521ac0d5b97470883ff9b7facae264b7ab12.
    
    Turns out distros do not want to make retpoline as part of their "ABI",
    so this patch should not have been merged.  Sorry Andi, this was my
    fault, I suggested it when your original patch was the "correct" way of
    doing this instead.
    
    Reported-by: Jiri Kosina <jikos@kernel.org>
    Fixes: 6cfb521ac0d5 ("module: Add retpoline tag to VERMAGIC")
    Acked-by: Andi Kleen <ak@linux.intel.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: David Woodhouse <dwmw@amazon.co.uk>
    Cc: rusty@rustcorp.com.au
    Cc: arjan.van.de.ven@intel.com
    Cc: jeyu@kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 509ed20926aa67aa9933b13f96002dc86b71ca60
Author: Johannes Thumshirn <jthumshirn@suse.de>
Date:   Mon Oct 9 13:33:19 2017 +0200

    scsi: libiscsi: fix shifting of DID_REQUEUE host byte
    
    commit eef9ffdf9cd39b2986367bc8395e2772bc1284ba upstream.
    
    The SCSI host byte should be shifted left by 16 in order to have
    scsi_decide_disposition() do the right thing (.i.e. requeue the
    command).
    
    Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
    Fixes: 661134ad3765 ("[SCSI] libiscsi, bnx2i: make bound ep check common")
    Cc: Lee Duncan <lduncan@suse.com>
    Cc: Hannes Reinecke <hare@suse.de>
    Cc: Bart Van Assche <Bart.VanAssche@sandisk.com>
    Cc: Chris Leech <cleech@redhat.com>
    Acked-by: Lee Duncan <lduncan@suse.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ad941c49a40237b77c543469e9e8daee0482a851
Author: Jiri Slaby <jslaby@suse.cz>
Date:   Tue Jun 13 13:35:51 2017 +0200

    fs/fcntl: f_setown, avoid undefined behaviour
    
    commit fc3dc67471461c0efcb1ed22fb7595121d65fad9 upstream.
    
    fcntl(0, F_SETOWN, 0x80000000) triggers:
    UBSAN: Undefined behaviour in fs/fcntl.c:118:7
    negation of -2147483648 cannot be represented in type 'int':
    CPU: 1 PID: 18261 Comm: syz-executor Not tainted 4.8.1-0-syzkaller #1
    ...
    Call Trace:
    ...
     [<ffffffffad8f0868>] ? f_setown+0x1d8/0x200
     [<ffffffffad8f19a9>] ? SyS_fcntl+0x999/0xf30
     [<ffffffffaed1fb00>] ? entry_SYSCALL_64_fastpath+0x23/0xc1
    
    Fix that by checking the arg parameter properly (against INT_MAX) before
    "who = -who". And return immediatelly with -EINVAL in case it is wrong.
    Note that according to POSIX we can return EINVAL:
        http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
    
        [EINVAL]
            The cmd argument is F_SETOWN and the value of the argument
            is not valid as a process or process group identifier.
    
    [v2] returns an error, v1 used to fail silently
    [v3] implement proper check for the bad value INT_MIN
    
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Cc: Jeff Layton <jlayton@poochiereds.net>
    Cc: "J. Bruce Fields" <bfields@fieldses.org>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: linux-fsdevel@vger.kernel.org
    Signed-off-by: Jeff Layton <jlayton@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e22c8378505e1354b4346c7ecccb446b7c505deb
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jun 22 09:32:49 2017 +0200

    reiserfs: Don't clear SGID when inheriting ACLs
    
    commit 6883cd7f68245e43e91e5ee583b7550abf14523f upstream.
    
    When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit
    set, DIR1 is expected to have SGID bit set (and owning group equal to
    the owning group of 'DIR0'). However when 'DIR0' also has some default
    ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on
    'DIR1' to get cleared if user is not member of the owning group.
    
    Fix the problem by moving posix_acl_update_mode() out of
    __reiserfs_set_acl() into reiserfs_set_acl(). That way the function will
    not be called when inheriting ACLs which is what we want as it prevents
    SGID bit clearing and the mode has been properly set by
    posix_acl_create() anyway.
    
    Fixes: 073931017b49d9458aa351605b43a7e34598caef
    CC: reiserfs-devel@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 512e3b18531eb9526a1e695c19043f78e3a0abb1
Author: Jeff Mahoney <jeffm@suse.com>
Date:   Thu Jun 22 16:35:04 2017 -0400

    reiserfs: don't preallocate blocks for extended attributes
    
    commit 54930dfeb46e978b447af0fb8ab4e181c1bf9d7a upstream.
    
    Most extended attributes will fit in a single block.  More importantly,
    we drop the reference to the inode while holding the transaction open
    so the preallocated blocks aren't released.  As a result, the inode
    may be evicted before it's removed from the transaction's prealloc list
    which can cause memory corruption.
    
    Signed-off-by: Jeff Mahoney <jeffm@suse.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ac125d89f8e980f100f63634a81b84fed7e997cf
Author: Jeff Mahoney <jeffm@suse.com>
Date:   Thu Jun 22 16:47:34 2017 -0400

    reiserfs: fix race in prealloc discard
    
    commit 08db141b5313ac2f64b844fb5725b8d81744b417 upstream.
    
    The main loop in __discard_prealloc is protected by the reiserfs write lock
    which is dropped across schedules like the BKL it replaced.  The problem is
    that it checks the value, calls a routine that schedules, and then adjusts
    the state.  As a result, two threads that are calling
    reiserfs_prealloc_discard at the same time can race when one calls
    reiserfs_free_prealloc_block, the lock is dropped, and the other calls
    reiserfs_free_prealloc_block with the same block number.  In the right
    circumstances, it can cause the prealloc count to go negative.
    
    Signed-off-by: Jeff Mahoney <jeffm@suse.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8e8224de0e1848a5905ebda018969e2ce72258ca
Author: Jan Kara <jack@suse.cz>
Date:   Wed Jun 21 14:34:15 2017 +0200

    ext2: Don't clear SGID when inheriting ACLs
    
    commit a992f2d38e4ce17b8c7d1f7f67b2de0eebdea069 upstream.
    
    When new directory 'DIR1' is created in a directory 'DIR0' with SGID bit
    set, DIR1 is expected to have SGID bit set (and owning group equal to
    the owning group of 'DIR0'). However when 'DIR0' also has some default
    ACLs that 'DIR1' inherits, setting these ACLs will result in SGID bit on
    'DIR1' to get cleared if user is not member of the owning group.
    
    Fix the problem by creating __ext2_set_acl() function that does not call
    posix_acl_update_mode() and use it when inheriting ACLs. That prevents
    SGID bit clearing and the mode has been properly set by
    posix_acl_create() anyway.
    
    Fixes: 073931017b49d9458aa351605b43a7e34598caef
    CC: stable@vger.kernel.org
    CC: linux-ext4@vger.kernel.org
    Signed-off-by: Jan Kara <jack@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d01ceb4722cd8d64176272434fe332b596750d9c
Author: Kevin Cernekee <cernekee@chromium.org>
Date:   Tue Dec 5 15:42:41 2017 -0800

    netfilter: xt_osf: Add missing permission checks
    
    commit 916a27901de01446bcf57ecca4783f6cff493309 upstream.
    
    The capability check in nfnetlink_rcv() verifies that the caller
    has CAP_NET_ADMIN in the namespace that "owns" the netlink socket.
    However, xt_osf_fingers is shared by all net namespaces on the
    system.  An unprivileged user can create user and net namespaces
    in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable()
    check:
    
        vpnns -- nfnl_osf -f /tmp/pf.os
    
        vpnns -- nfnl_osf -f /tmp/pf.os -d
    
    These non-root operations successfully modify the systemwide OS
    fingerprint list.  Add new capable() checks so that they can't.
    
    Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a359a437fbc6bb08aa9cc8e25ef4ac3b77ca727b
Author: Kevin Cernekee <cernekee@chromium.org>
Date:   Sun Dec 3 12:12:45 2017 -0800

    netfilter: nfnetlink_cthelper: Add missing permission checks
    
    commit 4b380c42f7d00a395feede754f0bc2292eebe6e5 upstream.
    
    The capability check in nfnetlink_rcv() verifies that the caller
    has CAP_NET_ADMIN in the namespace that "owns" the netlink socket.
    However, nfnl_cthelper_list is shared by all net namespaces on the
    system.  An unprivileged user can create user and net namespaces
    in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable()
    check:
    
        $ nfct helper list
        nfct v1.4.4: netlink error: Operation not permitted
        $ vpnns -- nfct helper list
        {
                .name = ftp,
                .queuenum = 0,
                .l3protonum = 2,
                .l4protonum = 6,
                .priv_data_len = 24,
                .status = enabled,
        };
    
    Add capable() checks in nfnetlink_cthelper, as this is cleaner than
    trying to generalize the solution.
    
    Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 936b21419e7c5be2f81e6dea02fc3d8852f3fb83
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Fri Apr 29 10:39:34 2016 +0200

    netfilter: fix IS_ERR_VALUE usage
    
    commit 92b4423e3a0bc5d43ecde4bcad871f8b5ba04efd upstream.
    
    This is a forward-port of the original patch from Andrzej Hajda,
    he said:
    
    "IS_ERR_VALUE should be used only with unsigned long type.
    Otherwise it can work incorrectly. To achieve this function
    xt_percpu_counter_alloc is modified to return unsigned long,
    and its result is assigned to temporary variable to perform
    error checking, before assigning to .pcnt field.
    
    The patch follows conclusion from discussion on LKML [1][2].
    
    [1]: http://permalink.gmane.org/gmane.linux.kernel/2120927
    [2]: http://permalink.gmane.org/gmane.linux.kernel/2150581"
    
    Original patch from Andrzej is here:
    
    http://patchwork.ozlabs.org/patch/582970/
    
    This patch has clashed with input validation fixes for x_tables.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>

commit f4ca7cba8ffa94c43913ed322c7d35ab3d6d1e38
Author: Pau Espin Pedrol <pau.espin@tessares.net>
Date:   Fri Jan 6 20:33:27 2017 +0100

    netfilter: use fwmark_reflect in nf_send_reset
    
    commit cc31d43b4154ad5a7d8aa5543255a93b7e89edc2 upstream.
    
    Otherwise, RST packets generated by ipt_REJECT always have mark 0 when
    the routing is checked later in the same code path.
    
    Fixes: e110861f8609 ("net: add a sysctl to reflect the fwmark on replies")
    Cc: Lorenzo Colitti <lorenzo@google.com>
    Signed-off-by: Pau Espin Pedrol <pau.espin@tessares.net>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 80291566d8f324563f2d889ef5a470e223d44f5c
Author: Ulrich Weber <ulrich.weber@riverbed.com>
Date:   Mon Oct 24 18:07:23 2016 +0200

    netfilter: nf_conntrack_sip: extend request line validation
    
    commit 444f901742d054a4cd5ff045871eac5131646cfb upstream.
    
    on SIP requests, so a fragmented TCP SIP packet from an allow header starting with
     INVITE,NOTIFY,OPTIONS,REFER,REGISTER,UPDATE,SUBSCRIBE
     Content-Length: 0
    
    will not bet interpreted as an INVITE request. Also Request-URI must start with an alphabetic character.
    
    Confirm with RFC 3261
     Request-Line   =  Method SP Request-URI SP SIP-Version CRLF
    
    Fixes: 30f33e6dee80 ("[NETFILTER]: nf_conntrack_sip: support method specific request/response handling")
    Signed-off-by: Ulrich Weber <ulrich.weber@riverbed.com>
    Acked-by: Marco Angaroni <marcoangaroni@gmail.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2cf26badef7bde1f9ecb9fbdea2079ce366f3013
Author: Florian Westphal <fw@strlen.de>
Date:   Thu Aug 25 15:33:29 2016 +0200

    netfilter: restart search if moved to other chain
    
    commit 95a8d19f28e6b29377a880c6264391a62e07fccc upstream.
    
    In case nf_conntrack_tuple_taken did not find a conflicting entry
    check that all entries in this hash slot were tested and restart
    in case an entry was moved to another chain.
    
    Reported-by: Eric Dumazet <edumazet@google.com>
    Fixes: ea781f197d6a ("netfilter: nf_conntrack: use SLAB_DESTROY_BY_RCU and get rid of call_rcu()")
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Acked-by: Eric Dumazet <edumazet@google.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2adda392d28baa25ca7803002fdafcaa95b7b1fb
Author: Liping Zhang <liping.zhang@spreadtrum.com>
Date:   Mon Aug 8 22:07:27 2016 +0800

    netfilter: nfnetlink_queue: reject verdict request from different portid
    
    commit 00a3101f561816e58de054a470484996f78eb5eb upstream.
    
    Like NFQNL_MSG_VERDICT_BATCH do, we should also reject the verdict
    request when the portid is not same with the initial portid(maybe
    from another process).
    
    Fixes: 97d32cf9440d ("netfilter: nfnetlink_queue: batch verdict support")
    Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
    Reviewed-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d8f5cce0a8bce0decd125ef430ee6196692ff8da
Author: Liping Zhang <liping.zhang@spreadtrum.com>
Date:   Mon Aug 8 21:57:58 2016 +0800

    netfilter: nf_ct_expect: remove the redundant slash when policy name is empty
    
    commit b173a28f62cf929324a8a6adcc45adadce311d16 upstream.
    
    The 'name' filed in struct nf_conntrack_expect_policy{} is not a
    pointer, so check it is NULL or not will always return true. Even if the
    name is empty, slash will always be displayed like follows:
      # cat /proc/net/nf_conntrack_expect
      297 l3proto = 2 proto=6 src=1.1.1.1 dst=2.2.2.2 sport=1 dport=1025 ftp/
                                                                            ^
    
    Fixes: 3a8fc53a45c4 ("netfilter: nf_ct_helper: allocate 16 bytes for the helper and policy names")
    Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit da00455d38a73c9412dd3f99285b48753ff1b61a
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Thu May 26 19:08:10 2016 +0200

    netfilter: nf_dup_ipv6: set again FLOWI_FLAG_KNOWN_NH at flowi6_flags
    
    commit 83170f3beccccd7ceb4f9a0ac0c4dc736afde90c upstream.
    
    With the commit 48e8aa6e3137 ("ipv6: Set FLOWI_FLAG_KNOWN_NH at
    flowi6_flags") ip6_pol_route() callers were asked to to set the
    FLOWI_FLAG_KNOWN_NH properly and xt_TEE was updated accordingly,
    but with the later refactor in commit bbde9fc1824a ("netfilter:
    factor out packet duplication for IPv4/IPv6") the flowi6_flags
    update was lost.
    This commit re-add it just before the routing decision.
    
    Fixes: bbde9fc1824a ("netfilter: factor out packet duplication for IPv4/IPv6")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a84338dad3c9501a5301db27ee665cda663219fc
Author: Hongxu Jia <hongxu.jia@windriver.com>
Date:   Tue Nov 29 21:56:26 2016 -0500

    netfilter: arp_tables: fix invoking 32bit "iptable -P INPUT ACCEPT" failed in 64bit kernel
    
    commit 17a49cd549d9dc8707dc9262210166455c612dde upstream.
    
    Since 09d9686047db ("netfilter: x_tables: do compat validation via
    translate_table"), it used compatr structure to assign newinfo
    structure.  In translate_compat_table of ip_tables.c and ip6_tables.c,
    it used compatr->hook_entry to replace info->hook_entry and
    compatr->underflow to replace info->underflow, but not do the same
    replacement in arp_tables.c.
    
    It caused invoking 32-bit "arptbale -P INPUT ACCEPT" failed in 64bit
    kernel.
    --------------------------------------
    root@qemux86-64:~# arptables -P INPUT ACCEPT
    root@qemux86-64:~# arptables -P INPUT ACCEPT
    ERROR: Policy for `INPUT' offset 448 != underflow 0
    arptables: Incompatible with this kernel
    --------------------------------------
    
    Fixes: 09d9686047db ("netfilter: x_tables: do compat validation via translate_table")
    Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
    Acked-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 45cf54e13c70ce0ec4875220103916978ce3ed07
Author: Florian Westphal <fw@strlen.de>
Date:   Thu Jul 14 17:51:26 2016 +0200

    netfilter: x_tables: speed up jump target validation
    
    commit f4dc77713f8016d2e8a3295e1c9c53a21f296def upstream.
    
    The dummy ruleset I used to test the original validation change was broken,
    most rules were unreachable and were not tested by mark_source_chains().
    
    In some cases rulesets that used to load in a few seconds now require
    several minutes.
    
    sample ruleset that shows the behaviour:
    
    echo "*filter"
    for i in $(seq 0 100000);do
            printf ":chain_%06x - [0:0]\n" $i
    done
    for i in $(seq 0 100000);do
       printf -- "-A INPUT -j chain_%06x\n" $i
       printf -- "-A INPUT -j chain_%06x\n" $i
       printf -- "-A INPUT -j chain_%06x\n" $i
    done
    echo COMMIT
    
    [ pipe result into iptables-restore ]
    
    This ruleset will be about 74mbyte in size, with ~500k searches
    though all 500k[1] rule entries. iptables-restore will take forever
    (gave up after 10 minutes)
    
    Instead of always searching the entire blob for a match, fill an
    array with the start offsets of every single ipt_entry struct,
    then do a binary search to check if the jump target is present or not.
    
    After this change ruleset restore times get again close to what one
    gets when reverting 36472341017529e (~3 seconds on my workstation).
    
    [1] every user-defined rule gets an implicit RETURN, so we get
    300k jumps + 100k userchains + 100k returns -> 500k rule entries
    
    Fixes: 36472341017529e ("netfilter: x_tables: validate targets of jumps")
    Reported-by: Jeff Wu <wujiafu@gmail.com>
    Tested-by: Jeff Wu <wujiafu@gmail.com>
    Signed-off-by: Florian Westphal <fw@strlen.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Acked-by: Michal Kubecek <mkubecek@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4c19b00e5588828f0d3198b926efade766dcf2c8
Author: Seunghun Han <kkamagui@gmail.com>
Date:   Wed Apr 26 16:18:08 2017 +0800

    ACPICA: Namespace: fix operand cache leak
    
    commit 3b2d69114fefa474fca542e51119036dceb4aa6f upstream.
    
    ACPICA commit a23325b2e583556eae88ed3f764e457786bf4df6
    
    I found some ACPI operand cache leaks in ACPI early abort cases.
    
    Boot log of ACPI operand cache leak is as follows:
    >[    0.174332] ACPI: Added _OSI(Module Device)
    >[    0.175504] ACPI: Added _OSI(Processor Device)
    >[    0.176010] ACPI: Added _OSI(3.0 _SCP Extensions)
    >[    0.177032] ACPI: Added _OSI(Processor Aggregator Device)
    >[    0.178284] ACPI: SCI (IRQ16705) allocation failed
    >[    0.179352] ACPI Exception: AE_NOT_ACQUIRED, Unable to install
    System Control Interrupt handler (20160930/evevent-131)
    >[    0.180008] ACPI: Unable to start the ACPI Interpreter
    >[    0.181125] ACPI Error: Could not remove SCI handler
    (20160930/evmisc-281)
    >[    0.184068] kmem_cache_destroy Acpi-Operand: Slab cache still has
    objects
    >[    0.185358] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.10.0-rc3 #2
    >[    0.186820] Hardware name: innotek gmb_h virtual_box/virtual_box, BIOS
    virtual_box 12/01/2006
    >[    0.188000] Call Trace:
    >[    0.188000]  ? dump_stack+0x5c/0x7d
    >[    0.188000]  ? kmem_cache_destroy+0x224/0x230
    >[    0.188000]  ? acpi_sleep_proc_init+0x22/0x22
    >[    0.188000]  ? acpi_os_delete_cache+0xa/0xd
    >[    0.188000]  ? acpi_ut_delete_caches+0x3f/0x7b
    >[    0.188000]  ? acpi_terminate+0x5/0xf
    >[    0.188000]  ? acpi_init+0x288/0x32e
    >[    0.188000]  ? __class_create+0x4c/0x80
    >[    0.188000]  ? video_setup+0x7a/0x7a
    >[    0.188000]  ? do_one_initcall+0x4e/0x1b0
    >[    0.188000]  ? kernel_init_freeable+0x194/0x21a
    >[    0.188000]  ? rest_init+0x80/0x80
    >[    0.188000]  ? kernel_init+0xa/0x100
    >[    0.188000]  ? ret_from_fork+0x25/0x30
    
    When early abort is occurred due to invalid ACPI information, Linux kernel
    terminates ACPI by calling acpi_terminate() function. The function calls
    acpi_ns_terminate() function to delete namespace data and ACPI operand cache
    (acpi_gbl_module_code_list).
    
    But the deletion code in acpi_ns_terminate() function is wrapped in
    ACPI_EXEC_APP definition, therefore the code is only executed when the
    definition exists. If the define doesn't exist, ACPI operand cache
    (acpi_gbl_module_code_list) is leaked, and stack dump is shown in kernel log.
    
    This causes a security threat because the old kernel (<= 4.9) shows memory
    locations of kernel functions in stack dump, therefore kernel ASLR can be
    neutralized.
    
    To fix ACPI operand leak for enhancing security, I made a patch which
    removes the ACPI_EXEC_APP define in acpi_ns_terminate() function for
    executing the deletion code unconditionally.
    
    Link: https://github.com/acpica/acpica/commit/a23325b2
    Signed-off-by: Seunghun Han <kkamagui@gmail.com>
    Signed-off-by: Lv Zheng <lv.zheng@intel.com>
    Signed-off-by: Bob Moore <robert.moore@intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Lee, Chun-Yi <jlee@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1fe277d48f998bd928f1b6ddcbe72f2a34b6f5ad
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Dec 30 02:27:31 2016 +0100

    ACPI / scan: Prefer devices without _HID/_CID for _ADR matching
    
    commit c2a6bbaf0c5f90463a7011a295bbdb7e33c80b51 upstream.
    
    The way acpi_find_child_device() works currently is that, if there
    are two (or more) devices with the same _ADR value in the same
    namespace scope (which is not specifically allowed by the spec and
    the OS behavior in that case is not defined), the first one of them
    found to be present (with the help of _STA) will be returned.
    
    This covers the majority of cases, but is not sufficient if some of
    the devices in question have a _HID (or _CID) returning some valid
    ACPI/PNP device IDs (which is disallowed by the spec) and the
    ASL writers' expectation appears to be that the OS will match
    devices without a valid ACPI/PNP device ID against a given bus
    address first.
    
    To cover this special case as well, modify find_child_checks()
    to prefer devices without ACPI/PNP device IDs over devices that
    have them.
    
    Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Tested-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4d48ba75ec7877939e9f69ef66894f7f9ce4cf38
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Thu Jun 2 01:57:50 2016 +0200

    ACPI / processor: Avoid reserving IO regions too early
    
    commit 86314751c7945fa0c67f459beeda2e7c610ca429 upstream.
    
    Roland Dreier reports that one of his systems cannot boot because of
    the changes made by commit ac212b6980d8 (ACPI / processor: Use common
    hotplug infrastructure).
    
    The problematic part of it is the request_region() call in
    acpi_processor_get_info() that used to run at module init time before
    the above commit and now it runs much earlier.  Unfortunately, the
    region(s) reserved by it fall into a range the PCI subsystem attempts
    to reserve for AHCI IO BARs.  As a result, the PCI reservation fails
    and AHCI doesn't work, while previously the PCI reservation would
    be made before acpi_processor_get_info() and it would succeed.
    
    That request_region() call, however, was overlooked by commit
    ac212b6980d8, as it is not necessary for the enumeration of the
    processors.  It only is needed when the ACPI processor driver
    actually attempts to handle them which doesn't happen before
    loading the ACPI processor driver module.  Therefore that call
    should have been moved from acpi_processor_get_info() into that
    module.
    
    Address the problem by moving the request_region() call in question
    out of acpi_processor_get_info() and use the observation that the
    region reserved by it is only needed if the FADT-based CPU
    throttling method is going to be used, which means that it should
    be sufficient to invoke it from acpi_processor_get_throttling_fadt().
    
    Fixes: ac212b6980d8 (ACPI / processor: Use common hotplug infrastructure)
    Reported-by: Roland Dreier <roland@purestorage.com>
    Tested-by: Roland Dreier <roland@purestorage.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 699a6cc7dd321113c99e06c6c997e8d15557439c
Author: Rui Wang <rui.y.wang@intel.com>
Date:   Wed Jun 8 14:59:52 2016 +0800

    x86/ioapic: Fix incorrect pointers in ioapic_setup_resources()
    
    commit 9d98bcec731756b8688b59ec998707924d716d7b upstream.
    
    On a 4-socket Brickland system, hot-removing one ioapic is fine.
    Hot-removing the 2nd one causes panic in mp_unregister_ioapic()
    while calling release_resource().
    
    It is because the iomem_res pointer has already been released
    when removing the first ioapic.
    
    To explain the use of &res[num] here: res is assigned to ioapic_resources,
    and later in ioapic_insert_resources() we do:
    
            struct resource *r = ioapic_resources;
    
            for_each_ioapic(i) {
                    insert_resource(&iomem_resource, r);
                    r++;
            }
    
    Here 'r' is treated as an arry of 'struct resource', and the r++ ensures
    that each element of the array is inserted separately. Thus we should call
    release_resouce() on each element at &res[num].
    
    Fix it by assigning the correct pointers to ioapics[i].iomem_res in
    ioapic_setup_resources().
    
    Signed-off-by: Rui Wang <rui.y.wang@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: tony.luck@intel.com
    Cc: linux-pci@vger.kernel.org
    Cc: rjw@rjwysocki.net
    Cc: linux-acpi@vger.kernel.org
    Cc: bhelgaas@google.com
    Link: http://lkml.kernel.org/r/1465369193-4816-3-git-send-email-rui.y.wang@intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Acked-by: Joerg Roedel <jroedel@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bab93a6196224c862c679a1b1e97be8ceef926a5
Author: Jiri Slaby <jslaby@suse.cz>
Date:   Wed Dec 14 15:06:07 2016 -0800

    ipc: msg, make msgrcv work with LONG_MIN
    
    commit 999898355e08ae3b92dfd0a08db706e0c6703d30 upstream.
    
    When LONG_MIN is passed to msgrcv, one would expect to recieve any
    message.  But convert_mode does *msgtyp = -*msgtyp and -LONG_MIN is
    undefined.  In particular, with my gcc -LONG_MIN produces -LONG_MIN
    again.
    
    So handle this case properly by assigning LONG_MAX to *msgtyp if
    LONG_MIN was specified as msgtyp to msgrcv.
    
    This code:
      long msg[] = { 100, 200 };
      int m = msgget(IPC_PRIVATE, IPC_CREAT | 0644);
      msgsnd(m, &msg, sizeof(msg), 0);
      msgrcv(m, &msg, sizeof(msg), LONG_MIN, 0);
    
    produces currently nothing:
    
      msgget(IPC_PRIVATE, IPC_CREAT|0644)     = 65538
      msgsnd(65538, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, 0) = 0
      msgrcv(65538, ...
    
    Except a UBSAN warning:
    
      UBSAN: Undefined behaviour in ipc/msg.c:745:13
      negation of -9223372036854775808 cannot be represented in type 'long int':
    
    With the patch, I see what I expect:
    
      msgget(IPC_PRIVATE, IPC_CREAT|0644)     = 0
      msgsnd(0, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, 0) = 0
      msgrcv(0, {100, "\310\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16, -9223372036854775808, 0) = 16
    
    Link: http://lkml.kernel.org/r/20161024082633.10148-1-jslaby@suse.cz
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Manfred Spraul <manfred@colorfullife.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 90ca50c56bfba6c670c4b32cc062aa4c2b850938
Author: Vlastimil Babka <vbabka@suse.cz>
Date:   Wed Nov 15 17:38:30 2017 -0800

    mm, page_alloc: fix potential false positive in __zone_watermark_ok
    
    commit b050e3769c6b4013bb937e879fc43bf1847ee819 upstream.
    
    Since commit 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for
    order-0 allocations"), __zone_watermark_ok() check for high-order
    allocations will shortcut per-migratetype free list checks for
    ALLOC_HARDER allocations, and return true as long as there's free page
    of any migratetype.  The intention is that ALLOC_HARDER can allocate
    from MIGRATE_HIGHATOMIC free lists, while normal allocations can't.
    
    However, as a side effect, the watermark check will then also return
    true when there are pages only on the MIGRATE_ISOLATE list, or (prior to
    CMA conversion to ZONE_MOVABLE) on the MIGRATE_CMA list.  Since the
    allocation cannot actually obtain isolated pages, and might not be able
    to obtain CMA pages, this can result in a false positive.
    
    The condition should be rare and perhaps the outcome is not a fatal one.
    Still, it's better if the watermark check is correct.  There also
    shouldn't be a performance tradeoff here.
    
    Link: http://lkml.kernel.org/r/20171102125001.23708-1-vbabka@suse.cz
    Fixes: 97a16fc82a7c ("mm, page_alloc: only enforce watermarks for order-0 allocations")
    Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
    Acked-by: Mel Gorman <mgorman@techsingularity.net>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1ab0bb9834766841e0119d472c78077c459654ac
Author: Doug Berger <opendmb@gmail.com>
Date:   Mon Jul 10 15:49:44 2017 -0700

    cma: fix calculation of aligned offset
    
    commit e048cb32f69038aa1c8f11e5c1b331be4181659d upstream.
    
    The align_offset parameter is used by bitmap_find_next_zero_area_off()
    to represent the offset of map's base from the previous alignment
    boundary; the function ensures that the returned index, plus the
    align_offset, honors the specified align_mask.
    
    The logic introduced by commit b5be83e308f7 ("mm: cma: align to physical
    address, not CMA region position") has the cma driver calculate the
    offset to the *next* alignment boundary.  In most cases, the base
    alignment is greater than that specified when making allocations,
    resulting in a zero offset whether we align up or down.  In the example
    given with the commit, the base alignment (8MB) was half the requested
    alignment (16MB) so the math also happened to work since the offset is
    8MB in both directions.  However, when requesting allocations with an
    alignment greater than twice that of the base, the returned index would
    not be correctly aligned.
    
    Also, the align_order arguments of cma_bitmap_aligned_mask() and
    cma_bitmap_aligned_offset() should not be negative so the argument type
    was made unsigned.
    
    Fixes: b5be83e308f7 ("mm: cma: align to physical address, not CMA region position")
    Link: http://lkml.kernel.org/r/20170628170742.2895-1-opendmb@gmail.com
    Signed-off-by: Angus Clark <angus@angusclark.org>
    Signed-off-by: Doug Berger <opendmb@gmail.com>
    Acked-by: Gregory Fong <gregory.0xf0@gmail.com>
    Cc: Doug Berger <opendmb@gmail.com>
    Cc: Angus Clark <angus@angusclark.org>
    Cc: Laura Abbott <labbott@redhat.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Lucas Stach <l.stach@pengutronix.de>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Shiraz Hashim <shashim@codeaurora.org>
    Cc: Jaewon Kim <jaewon31.kim@samsung.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 361376a53481a7e042a1dd320b6bdbde8dc1ba48
Author: Michal Hocko <mhocko@suse.com>
Date:   Fri May 12 15:46:26 2017 -0700

    hwpoison, memcg: forcibly uncharge LRU pages
    
    commit 18365225f0440d09708ad9daade2ec11275c3df9 upstream.
    
    Laurent Dufour has noticed that hwpoinsoned pages are kept charged.  In
    his particular case he has hit a bad_page("page still charged to
    cgroup") when onlining a hwpoison page.  While this looks like something
    that shouldn't happen in the first place because onlining hwpages and
    returning them to the page allocator makes only little sense it shows a
    real problem.
    
    hwpoison pages do not get freed usually so we do not uncharge them (at
    least not since commit 0a31bc97c80c ("mm: memcontrol: rewrite uncharge
    API")).  Each charge pins memcg (since e8ea14cc6ead ("mm: memcontrol:
    take a css reference for each charged page")) as well and so the
    mem_cgroup and the associated state will never go away.  Fix this leak
    by forcibly uncharging a LRU hwpoisoned page in delete_from_lru_cache().
    We also have to tweak uncharge_list because it cannot rely on zero ref
    count for these pages.
    
    [akpm@linux-foundation.org: coding-style fixes]
    Fixes: 0a31bc97c80c ("mm: memcontrol: rewrite uncharge API")
    Link: http://lkml.kernel.org/r/20170502185507.GB19165@dhcp22.suse.cz
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Reported-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
    Tested-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
    Reviewed-by: Balbir Singh <bsingharora@gmail.com>
    Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.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 7175e56fa7076ea176ffa6dd41ddad288294ddb5
Author: Michal Hocko <mhocko@suse.com>
Date:   Mon Jul 10 15:49:51 2017 -0700

    mm/mmap.c: do not blow on PROT_NONE MAP_FIXED holes in the stack
    
    commit 561b5e0709e4a248c67d024d4d94b6e31e3edf2f upstream.
    
    Commit 1be7107fbe18 ("mm: larger stack guard gap, between vmas") has
    introduced a regression in some rust and Java environments which are
    trying to implement their own stack guard page.  They are punching a new
    MAP_FIXED mapping inside the existing stack Vma.
    
    This will confuse expand_{downwards,upwards} into thinking that the
    stack expansion would in fact get us too close to an existing non-stack
    vma which is a correct behavior wrt safety.  It is a real regression on
    the other hand.
    
    Let's work around the problem by considering PROT_NONE mapping as a part
    of the stack.  This is a gros hack but overflowing to such a mapping
    would trap anyway an we only can hope that usespace knows what it is
    doing and handle it propely.
    
    Fixes: 1be7107fbe18 ("mm: larger stack guard gap, between vmas")
    Link: http://lkml.kernel.org/r/20170705182849.GA18027@dhcp22.suse.cz
    Signed-off-by: Michal Hocko <mhocko@suse.com>
    Debugged-by: Vlastimil Babka <vbabka@suse.cz>
    Cc: Ben Hutchings <ben@decadent.org.uk>
    Cc: Willy Tarreau <w@1wt.eu>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Hugh Dickins <hughd@google.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 13757fc50433b6b6f68c21bd88a094d56514cb5b
Author: Vlastimil Babka <vbabka@suse.cz>
Date:   Tue Oct 11 13:51:14 2016 -0700

    fs/select: add vmalloc fallback for select(2)
    
    commit 2d19309cf86883f634a4f8ec55a54bda87db19bf upstream.
    
    The select(2) syscall performs a kmalloc(size, GFP_KERNEL) where size grows
    with the number of fds passed. We had a customer report page allocation
    failures of order-4 for this allocation. This is a costly order, so it might
    easily fail, as the VM expects such allocation to have a lower-order fallback.
    
    Such trivial fallback is vmalloc(), as the memory doesn't have to be physically
    contiguous and the allocation is temporary for the duration of the syscall
    only. There were some concerns, whether this would have negative impact on the
    system by exposing vmalloc() to userspace. Although an excessive use of vmalloc
    can cause some system wide performance issues - TLB flushes etc. - a large
    order allocation is not for free either and an excessive reclaim/compaction can
    have a similar effect. Also note that the size is effectively limited by
    RLIMIT_NOFILE which defaults to 1024 on the systems I checked. That means the
    bitmaps will fit well within single page and thus the vmalloc() fallback could
    be only excercised for processes where root allows a higher limit.
    
    Note that the poll(2) syscall seems to use a linked list of order-0 pages, so
    it doesn't need this kind of fallback.
    
    [eric.dumazet@gmail.com: fix failure path logic]
    [akpm@linux-foundation.org: use proper type for size]
    Link: http://lkml.kernel.org/r/20160927084536.5923-1-vbabka@suse.cz
    Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Cc: Alexander Viro <viro@zeniv.linux.org.uk>
    Cc: Eric Dumazet <eric.dumazet@gmail.com>
    Cc: David Laight <David.Laight@ACULAB.COM>
    Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
    Cc: Nicholas Piggin <npiggin@gmail.com>
    Cc: Jason Baron <jbaron@akamai.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 0fd49331f9c1fee00ad9ef125faea9d14d7c6a59
Author: yangbo lu <yangbo.lu@freescale.com>
Date:   Wed Nov 25 10:05:37 2015 +0800

    mmc: sdhci-of-esdhc: add/remove some quirks according to vendor version
    
    commit 1ef5e49e46b919052474d9b54a15debc79ff0133 upstream.
    
    A previous patch had removed esdhc_of_platform_init() by mistake.
    static void esdhc_of_platform_init(struct sdhci_host *host)
    {
            u32 vvn;
    
            vvn = in_be32(host->ioaddr + SDHCI_SLOT_INT_STATUS);
            vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
            if (vvn == VENDOR_V_22)
                    host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
    
            if (vvn > VENDOR_V_22)
                    host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
    }
    
    This patch is used to fix it by add/remove some quirks according to
    verdor version in probe.
    
    Signed-off-by: Yangbo Lu <yangbo.lu@freescale.com>
    Fixes: f4932cfd22f1 ("mmc: sdhci-of-esdhc: support both BE and LE host controller")
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Signed-off-by: Matthias Brugger <mbrugger@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5ee8fef15d0affce9ff482dd99ff33a0578c2368
Author: Minghuan Lian <Minghuan.Lian@nxp.com>
Date:   Mon Feb 29 17:24:15 2016 -0600

    PCI: layerscape: Fix MSG TLP drop setting
    
    commit 1195c103f6c98d9ff381cac3a8760d4f8a133627 upstream.
    
    Some kinds of Layerscape PCIe controllers will forward the received message
    TLPs to system application address space, which could corrupt system memory
    or lead to a system hang.  Enable MSG_DROP to fix this issue.
    
    Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Matthias Brugger <mbrugger@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 12de6baf0637e2b0067bf5d71c3a7af1ec5b4ff1
Author: Yang Shi <yang.shi@linaro.org>
Date:   Wed Jan 27 09:32:05 2016 -0800

    PCI: layerscape: Add "fsl,ls2085a-pcie" compatible ID
    
    commit dbae40b76abef2f8a7e7bf1701f77df9e73def48 upstream.
    
    The Layerscape PCI host driver must recognize ls2085a compatible when using
    firmware with ls2085a compatible property, otherwise the PCI bus won't be
    detected even though ls2085a compatible is included by the dts.
    
    Signed-off-by: Yang Shi <yang.shi@linaro.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Matthias Brugger <mbrugger@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a91cdfa754905b702a5841b8d2b895599d8fad72
Author: Sudeep Holla <sudeep.holla@arm.com>
Date:   Fri Oct 28 09:45:29 2016 +0100

    drivers: base: cacheinfo: fix boot error message when acpi is enabled
    
    commit 55877ef45fbd7f975d078426866b7d1a2435dcc3 upstream.
    
    ARM64 enables both CONFIG_OF and CONFIG_ACPI and the firmware can pass
    both ACPI tables and the device tree. Based on the kernel parameter, one
    of the two will be chosen. If acpi is enabled, then device tree is not
    unflattened.
    
    Currently ARM64 platforms report:
    "
            Failed to find cpu0 device node
            Unable to detect cache hierarchy from DT for CPU 0
    "
    which is incorrect when booting with ACPI. Also latest ACPI v6.1 has no
    support for cache properties/hierarchy.
    
    This patch adds check for unflattened device tree and also returns as
    "not supported" if ACPI is runtime enabled.
    
    It also removes the reference to DT from the error message as the cache
    hierarchy can be detected from the firmware(OF/DT/ACPI)
    
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f31a8450c09327339939fe195707749c1d67016d
Author: Sudeep Holla <sudeep.holla@arm.com>
Date:   Fri Oct 28 09:45:28 2016 +0100

    drivers: base: cacheinfo: fix x86 with CONFIG_OF enabled
    
    commit fac51482577d5e05bbb0efa8d602a3c2111098bf upstream.
    
    With CONFIG_OF enabled on x86, we get the following error on boot:
    "
            Failed to find cpu0 device node
            Unable to detect cache hierarchy from DT for CPU 0
    "
    and the cacheinfo fails to get populated in the corresponding sysfs
    entries. This is because cache_setup_of_node looks for of_node for
    setting up the shared cpu_map without checking that it's already
    populated in the architecture specific callback.
    
    In order to indicate that the shared cpu_map is already populated, this
    patch introduces a boolean `cpu_map_populated` in struct cpu_cacheinfo
    that can be used by the generic code to skip cache_shared_cpu_map_setup.
    
    This patch also sets that boolean for x86.
    
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
    Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 29b73cace1b1cc2daf2556b3285d4e79f19bcb3b
Author: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
Date:   Tue Apr 25 16:44:03 2017 -0500

    Prevent timer value 0 for MWAITX
    
    commit 88d879d29f9cc0de2d930b584285638cdada6625 upstream.
    
    Newer hardware has uncovered a bug in the software implementation of
    using MWAITX for the delay function. A value of 0 for the timer is meant
    to indicate that a timeout will not be used to exit MWAITX. On newer
    hardware this can result in MWAITX never returning, resulting in NMI
    soft lockup messages being printed. On older hardware, some of the other
    conditions under which MWAITX can exit masked this issue. The AMD APM
    does not currently document this and will be updated.
    
    Please refer to http://marc.info/?l=kvm&m=148950623231140 for
    information regarding NMI soft lockup messages on an AMD Ryzen 1800X.
    This has been root-caused as a 0 passed to MWAITX causing it to wait
    indefinitely.
    
    This change has the added benefit of avoiding the unnecessary setup of
    MONITORX/MWAITX when the delay value is zero.
    
    Signed-off-by: Janakarajan Natarajan <Janakarajan.Natarajan@amd.com>
    Link: http://lkml.kernel.org/r/1493156643-29366-1-git-send-email-Janakarajan.Natarajan@amd.com
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 839003061aa9362f23866614862b49b57bfdd6ce
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Mon Oct 24 11:41:56 2016 +0200

    timers: Plug locking race vs. timer migration
    
    commit b831275a3553c32091222ac619cfddd73a5553fb upstream.
    
    Linus noticed that lock_timer_base() lacks a READ_ONCE() for accessing the
    timer flags. As a consequence the compiler is allowed to reload the flags
    between the initial check for TIMER_MIGRATION and the following timer base
    computation and the spin lock of the base.
    
    While this has not been observed (yet), we need to make sure that it never
    happens.
    
    Fixes: 0eeda71bc30d ("timer: Replace timer base by a cpu index")
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1610241711220.4983@nanos
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 08b1cf4964d526cf3c2ea9e36ffd752752543ef3
Author: Vegard Nossum <vegard.nossum@oracle.com>
Date:   Sat Aug 13 01:37:04 2016 +0200

    time: Avoid undefined behaviour in ktime_add_safe()
    
    commit 979515c5645830465739254abc1b1648ada41518 upstream.
    
    I ran into this:
    
        ================================================================================
        UBSAN: Undefined behaviour in kernel/time/hrtimer.c:310:16
        signed integer overflow:
        9223372036854775807 + 50000 cannot be represented in type 'long long int'
        CPU: 2 PID: 4798 Comm: trinity-c2 Not tainted 4.8.0-rc1+ #91
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
         0000000000000000 ffff88010ce6fb88 ffffffff82344740 0000000041b58ab3
         ffffffff84f97a20 ffffffff82344694 ffff88010ce6fbb0 ffff88010ce6fb60
         000000000000c350 ffff88010ce6f968 dffffc0000000000 ffffffff857bc320
        Call Trace:
         [<ffffffff82344740>] dump_stack+0xac/0xfc
         [<ffffffff82344694>] ? _atomic_dec_and_lock+0xc4/0xc4
         [<ffffffff8242df78>] ubsan_epilogue+0xd/0x8a
         [<ffffffff8242e6b4>] handle_overflow+0x202/0x23d
         [<ffffffff8242e4b2>] ? val_to_string.constprop.6+0x11e/0x11e
         [<ffffffff8236df71>] ? timerqueue_add+0x151/0x410
         [<ffffffff81485c48>] ? hrtimer_start_range_ns+0x3b8/0x1380
         [<ffffffff81795631>] ? memset+0x31/0x40
         [<ffffffff8242e6fd>] __ubsan_handle_add_overflow+0xe/0x10
         [<ffffffff81488ac9>] hrtimer_nanosleep+0x5d9/0x790
         [<ffffffff814884f0>] ? hrtimer_init_sleeper+0x80/0x80
         [<ffffffff813a9ffb>] ? __might_sleep+0x5b/0x260
         [<ffffffff8148be10>] common_nsleep+0x20/0x30
         [<ffffffff814906c7>] SyS_clock_nanosleep+0x197/0x210
         [<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
         [<ffffffff823c7113>] ? __this_cpu_preempt_check+0x13/0x20
         [<ffffffff8162ef60>] ? __context_tracking_exit.part.3+0x30/0x1b0
         [<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
         [<ffffffff81007bd3>] do_syscall_64+0x1b3/0x4b0
         [<ffffffff845f85aa>] entry_SYSCALL64_slow_path+0x25/0x25
        ================================================================================
    
    Add a new ktime_add_unsafe() helper which doesn't check for overflow, but
    doesn't throw a UBSAN warning when it does overflow either.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Richard Cochran <richardcochran@gmail.com>
    Cc: Prarit Bhargava <prarit@redhat.com>
    Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
    Signed-off-by: John Stultz <john.stultz@linaro.org>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0cb5ae4db47abc3985016aac6326ef98c533fe4d
Author: Eric Biggers <ebiggers3@gmail.com>
Date:   Sun Jan 24 20:08:52 2016 -0600

    PM / sleep: declare __tracedata symbols as char[] rather than char
    
    commit f97238373b8662a6d580e204df2e7bcbfa43e27a upstream.
    
    Accessing more than one byte from a symbol declared simply 'char' is undefined
    behavior, as reported by UBSAN:
    
            UBSAN: Undefined behaviour in drivers/base/power/trace.c:178:18
            load of address ffffffff8203fc78 with insufficient space
            for an object of type 'char'
    
    Avoid this by declaring the symbols as arrays.
    
    Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 08f39b7bcccb532a6b96fdeaf91ed08e4af7dda4
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Tue Jan 16 19:30:14 2018 +0100

    can: af_can: canfd_rcv(): replace WARN_ONCE by pr_warn_once
    
    commit d4689846881d160a4d12a514e991a740bcb5d65a upstream.
    
    If an invalid CANFD frame is received, from a driver or from a tun
    interface, a Kernel warning is generated.
    
    This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a
    kernel, bootet with panic_on_warn, does not panic. A printk seems to be
    more appropriate here.
    
    Reported-by: syzbot+e3b775f40babeff6e68b@syzkaller.appspotmail.com
    Suggested-by: Dmitry Vyukov <dvyukov@google.com>
    Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Cc: linux-stable <stable@vger.kernel.org>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e7514af60542830a37cd8f2fc0419fc5e320d70c
Author: Marc Kleine-Budde <mkl@pengutronix.de>
Date:   Tue Jan 16 19:30:14 2018 +0100

    can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once
    
    commit 8cb68751c115d176ec851ca56ecfbb411568c9e8 upstream.
    
    If an invalid CAN frame is received, from a driver or from a tun
    interface, a Kernel warning is generated.
    
    This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a
    kernel, bootet with panic_on_warn, does not panic. A printk seems to be
    more appropriate here.
    
    Reported-by: syzbot+4386709c0c1284dca827@syzkaller.appspotmail.com
    Suggested-by: Dmitry Vyukov <dvyukov@google.com>
    Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1d00e3d9b7ed8fbf6729b7c5a8aae9f2711d2655
Author: Daniel Bristot de Oliveira <bristot@redhat.com>
Date:   Mon May 29 16:24:03 2017 +0200

    sched/deadline: Use the revised wakeup rule for suspending constrained dl tasks
    
    commit 3effcb4247e74a51f5d8b775a1ee4abf87cc089a upstream.
    
    We have been facing some problems with self-suspending constrained
    deadline tasks. The main reason is that the original CBS was not
    designed for such sort of tasks.
    
    One problem reported by Xunlei Pang takes place when a task
    suspends, and then is awakened before the deadline, but so close
    to the deadline that its remaining runtime can cause the task
    to have an absolute density higher than allowed. In such situation,
    the original CBS assumes that the task is facing an early activation,
    and so it replenishes the task and set another deadline, one deadline
    in the future. This rule works fine for implicit deadline tasks.
    Moreover, it allows the system to adapt the period of a task in which
    the external event source suffered from a clock drift.
    
    However, this opens the window for bandwidth leakage for constrained
    deadline tasks. For instance, a task with the following parameters:
    
      runtime   = 5 ms
      deadline  = 7 ms
      [density] = 5 / 7 = 0.71
      period    = 1000 ms
    
    If the task runs for 1 ms, and then suspends for another 1ms,
    it will be awakened with the following parameters:
    
      remaining runtime = 4
      laxity = 5
    
    presenting a absolute density of 4 / 5 = 0.80.
    
    In this case, the original CBS would assume the task had an early
    wakeup. Then, CBS will reset the runtime, and the absolute deadline will
    be postponed by one relative deadline, allowing the task to run.
    
    The problem is that, if the task runs this pattern forever, it will keep
    receiving bandwidth, being able to run 1ms every 2ms. Following this
    behavior, the task would be able to run 500 ms in 1 sec. Thus running
    more than the 5 ms / 1 sec the admission control allowed it to run.
    
    Trying to address the self-suspending case, Luca Abeni, Giuseppe
    Lipari, and Juri Lelli [1] revisited the CBS in order to deal with
    self-suspending tasks. In the new approach, rather than
    replenishing/postponing the absolute deadline, the revised wakeup rule
    adjusts the remaining runtime, reducing it to fit into the allowed
    density.
    
    A revised version of the idea is:
    
    At a given time t, the maximum absolute density of a task cannot be
    higher than its relative density, that is:
    
      runtime / (deadline - t) <= dl_runtime / dl_deadline
    
    Knowing the laxity of a task (deadline - t), it is possible to move
    it to the other side of the equality, thus enabling to define max
    remaining runtime a task can use within the absolute deadline, without
    over-running the allowed density:
    
      runtime = (dl_runtime / dl_deadline) * (deadline - t)
    
    For instance, in our previous example, the task could still run:
    
      runtime = ( 5 / 7 ) * 5
      runtime = 3.57 ms
    
    Without causing damage for other deadline tasks. It is note worthy
    that the laxity cannot be negative because that would cause a negative
    runtime. Thus, this patch depends on the patch:
    
      df8eac8cafce ("sched/deadline: Throttle a constrained deadline task activated after the deadline")
    
    Which throttles a constrained deadline task activated after the
    deadline.
    
    Finally, it is also possible to use the revised wakeup rule for
    all other tasks, but that would require some more discussions
    about pros and cons.
    
    [The main difference from the original commit is that
     the BW_SHIFT define was not present yet. As BW_SHIFT was
     introduced in a new feature, I just used the value (20),
     likewise we used to use before the #define.
     Other changes were required because of comments. - bistrot]
    
    Reported-by: Xunlei Pang <xpang@redhat.com>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
    [peterz: replaced dl_is_constrained with dl_is_implicit]
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Juri Lelli <juri.lelli@arm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Luca Abeni <luca.abeni@santannapisa.it>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Romulo Silva de Oliveira <romulo.deoliveira@ufsc.br>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tommaso Cucinotta <tommaso.cucinotta@sssup.it>
    Link: http://lkml.kernel.org/r/5c800ab3a74a168a84ee5f3f84d12a02e11383be.1495803804.git.bristot@redhat.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 18bb117d1b7690181346e6365c6237b6ceaac4c4
Author: David Woodhouse <dwmw@amazon.co.uk>
Date:   Fri Jan 12 17:49:25 2018 +0000

    x86/retpoline: Fill RSB on context switch for affected CPUs
    
    commit c995efd5a740d9cbafbf58bde4973e8b50b4d761 upstream.
    
    On context switch from a shallow call stack to a deeper one, as the CPU
    does 'ret' up the deeper side it may encounter RSB entries (predictions for
    where the 'ret' goes to) which were populated in userspace.
    
    This is problematic if neither SMEP nor KPTI (the latter of which marks
    userspace pages as NX for the kernel) are active, as malicious code in
    userspace may then be executed speculatively.
    
    Overwrite the CPU's return prediction stack with calls which are predicted
    to return to an infinite loop, to "capture" speculation if this
    happens. This is required both for retpoline, and also in conjunction with
    IBRS for !SMEP && !KPTI.
    
    On Skylake+ the problem is slightly different, and an *underflow* of the
    RSB may cause errant branch predictions to occur. So there it's not so much
    overwrite, as *filling* the RSB to attempt to prevent it getting
    empty. This is only a partial solution for Skylake+ since there are many
    other conditions which may result in the RSB becoming empty. The full
    solution on Skylake+ is to use IBRS, which will prevent the problem even
    when the RSB becomes empty. With IBRS, the RSB-stuffing will not be
    required on context switch.
    
    [ tglx: Added missing vendor check and slighty massaged comments and
            changelog ]
    
    [js] backport to 4.4 -- __switch_to_asm does not exist there, we
         have to patch the switch_to macros for both x86_32 and x86_64.
    
    Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Acked-by: Arjan van de Ven <arjan@linux.intel.com>
    Cc: gnomes@lxorguk.ukuu.org.uk
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Josh Poimboeuf <jpoimboe@redhat.com>
    Cc: thomas.lendacky@amd.com
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Jiri Kosina <jikos@kernel.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: Kees Cook <keescook@google.com>
    Cc: Tim Chen <tim.c.chen@linux.intel.com>
    Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org>
    Cc: Paul Turner <pjt@google.com>
    Link: https://lkml.kernel.org/r/1515779365-9032-1-git-send-email-dwmw@amazon.co.uk
    Signed-off-by: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0dfd5fbcae5d40e5e58bc7c34305498e965bf1ef
Author: Dave Hansen <dave@sr71.net>
Date:   Thu Jun 2 17:19:27 2016 -0700

    x86/cpu/intel: Introduce macros for Intel family numbers
    
    commit 970442c599b22ccd644ebfe94d1d303bf6f87c05 upstream.
    
    Problem:
    
    We have a boatload of open-coded family-6 model numbers.  Half of
    them have these model numbers in hex and the other half in
    decimal.  This makes grepping for them tons of fun, if you were
    to try.
    
    Solution:
    
    Consolidate all the magic numbers.  Put all the definitions in
    one header.
    
    The names here are closely derived from the comments describing
    the models from arch/x86/events/intel/core.c.  We could easily
    make them shorter by doing things like s/SANDYBRIDGE/SNB/, but
    they seemed fine even with the longer versions to me.
    
    Do not take any of these names too literally, like "DESKTOP"
    or "MOBILE".  These are all colloquial names and not precise
    descriptions of everywhere a given model will show up.
    
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Andy Lutomirski <luto@kernel.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Darren Hart <dvhart@infradead.org>
    Cc: Dave Hansen <dave@sr71.net>
    Cc: Denys Vlasenko <dvlasenk@redhat.com>
    Cc: Doug Thompson <dougthompson@xmission.com>
    Cc: Eduardo Valentin <edubezval@gmail.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
    Cc: Kan Liang <kan.liang@intel.com>
    Cc: Len Brown <lenb@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@intel.com>
    Cc: Souvik Kumar Chakravarty <souvik.k.chakravarty@intel.com>
    Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: Ulf Hansson <ulf.hansson@linaro.org>
    Cc: Viresh Kumar <viresh.kumar@linaro.org>
    Cc: Vishwanath Somayaji <vishwanath.somayaji@intel.com>
    Cc: Zhang Rui <rui.zhang@intel.com>
    Cc: jacob.jun.pan@intel.com
    Cc: linux-acpi@vger.kernel.org
    Cc: linux-edac@vger.kernel.org
    Cc: linux-mmc@vger.kernel.org
    Cc: linux-pm@vger.kernel.org
    Cc: platform-driver-x86@vger.kernel.org
    Link: http://lkml.kernel.org/r/20160603001927.F2A7D828@viggo.jf.intel.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Cc: Jiri Slaby <jslaby@suse.cz>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 20e3fa5dd5818b425b18528571e133034833df27
Author: Ben Hutchings <ben.hutchings@codethink.co.uk>
Date:   Wed Jan 24 02:31:19 2018 +0000

    x86/microcode/intel: Fix BDW late-loading revision check
    
    The backport of commit b94b73733171 ("x86/microcode/intel: Extend BDW
    late-loading with a revision check") to 4.4-stable deleted a "return true"
    statement.  This bug is not present upstream or other stable branches.
    
    Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 579a9885cfe40645bc62207f318d172c4cad7942
Author: Jonathan Dieter <jdieter@lesbg.com>
Date:   Mon Feb 27 10:31:03 2017 +0200

    usbip: Fix potential format overflow in userspace tools
    
    commit e5dfa3f902b9a642ae8c6997d57d7c41e384a90b upstream.
    
    The usbip userspace tools call sprintf()/snprintf() and don't check for
    the return value which can lead the paths to overflow, truncating the
    final file in the path.
    
    More urgently, GCC 7 now warns that these aren't checked with
    -Wformat-overflow, and with -Werror enabled in configure.ac, that makes
    these tools unbuildable.
    
    This patch fixes these problems by replacing sprintf() with snprintf() in
    one place and adding checks for the return value of snprintf().
    
    Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
    Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
    Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 4493f49816acc5531ed31ffc600073330393cc61
Author: Jonathan Dieter <jdieter@lesbg.com>
Date:   Mon Feb 27 10:31:04 2017 +0200

    usbip: Fix implicit fallthrough warning
    
    commit cfd6ed4537a9e938fa76facecd4b9cd65b6d1563 upstream.
    
    GCC 7 now warns when switch statements fall through implicitly, and with
    -Werror enabled in configure.ac, that makes these tools unbuildable.
    
    We fix this by notifying the compiler that this particular case statement
    is meant to fall through.
    
    Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
    Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 28f467e0bdda754aa36390fd90b01823f0d3b18d
Author: Shuah Khan <shuahkh@osg.samsung.com>
Date:   Thu Dec 7 14:16:49 2017 -0700

    usbip: prevent vhci_hcd driver from leaking a socket pointer address
    
    commit 2f2d0088eb93db5c649d2a5e34a3800a8a935fc5 upstream.
    
    When a client has a USB device attached over IP, the vhci_hcd driver is
    locally leaking a socket pointer address via the
    
    /sys/devices/platform/vhci_hcd/status file (world-readable) and in debug
    output when "usbip --debug port" is run.
    
    Fix it to not leak. The socket pointer address is not used at the moment
    and it was made visible as a convenient way to find IP address from socket
    pointer address by looking up /proc/net/{tcp,tcp6}.
    
    As this opens a security hole, the fix replaces socket pointer address with
    sockfd.
    
    Reported-by: Secunia Research <vuln@secunia.com>
    Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8bb0c6a1b3b2fe92707ee6f6901bfdfc392f8cd1
Author: Andy Lutomirski <luto@kernel.org>
Date:   Fri Dec 9 10:24:05 2016 -0800

    x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels
    
    commit 1c52d859cb2d417e7216d3e56bb7fea88444cec9 upstream.
    
    We support various non-Intel CPUs that don't have the CPUID
    instruction, so the M486 test was wrong.  For now, fix it with a big
    hammer: handle missing CPUID on all 32-bit CPUs.
    
    Reported-by: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
    Signed-off-by: Andy Lutomirski <luto@kernel.org>
    Cc: Juergen Gross <jgross@suse.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Matthew Whitehead <tedheadster@gmail.com>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
    Cc: Andrew Cooper <andrew.cooper3@citrix.com>
    Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    Cc: xen-devel <Xen-devel@lists.xen.org>
    Link: http://lkml.kernel.org/r/685bd083a7c036f7769510b6846315b17d6ba71f.1481307769.git.luto@kernel.org
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: "Zhang, Ning A" <ning.a.zhang@intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>