commit 754ca08efd83eeb9cccdb109da2fa0b3a27c1172
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sun Apr 29 07:45:30 2018 +0200

    Linux 3.18.107

commit 8e8a40578fac765527a5d55d258a2ca93904ed1b
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Wed Apr 18 12:51:31 2018 +0300

    cdrom: information leak in cdrom_ioctl_media_changed()
    
    commit 9de4ee40547fd315d4a0ed1dd15a2fa3559ad707 upstream.
    
    This cast is wrong.  "cdi->capacity" is an int and "arg" is an unsigned
    long.  The way the check is written now, if one of the high 32 bits is
    set then we could read outside the info->slots[] array.
    
    This bug is pretty old and it predates git.
    
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    Cc: stable@vger.kernel.org
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 2127751e26b0021638a3597ff302e177cdb861f9
Author: Martin K. Petersen <martin.petersen@oracle.com>
Date:   Wed Apr 18 22:54:59 2018 -0400

    scsi: mptsas: Disable WRITE SAME
    
    commit 94e5395d2403c8bc2504a7cbe4c4caaacb7b8b84 upstream.
    
    First generation MPT Fusion controllers can not translate WRITE SAME
    when the attached device is a SATA drive. Disable WRITE SAME support.
    
    Reported-by: Nikola Ciprich <nikola.ciprich@linuxbox.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f4dd54821e6331dacf886a7e4fa5cec73b84ed95
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Apr 22 18:29:23 2018 -0700

    ipv6: add RTA_TABLE and RTA_PREFSRC to rtm_ipv6_policy
    
    
    [ Upstream commit aa8f8778493c85fff480cdf8b349b1e1dcb5f243 ]
    
    KMSAN reported use of uninit-value that I tracked to lack
    of proper size check on RTA_TABLE attribute.
    
    I also believe RTA_PREFSRC lacks a similar check.
    
    Fixes: 86872cb57925 ("[IPv6] route: FIB6 configuration using struct fib6_config")
    Fixes: c3968a857a6b ("ipv6: RTA_PREFSRC support for ipv6 route source address selection")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Acked-by: David Ahern <dsahern@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit e2917cf238a2369f8e171b2eb3daad4ba43bcd05
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Thu Apr 19 12:25:38 2018 -0700

    llc: delete timers synchronously in llc_sk_free()
    
    
    [ Upstream commit b905ef9ab90115d001c1658259af4b1c65088779 ]
    
    The connection timers of an llc sock could be still flying
    after we delete them in llc_sk_free(), and even possibly
    after we free the sock. We could just wait synchronously
    here in case of troubles.
    
    Note, I leave other call paths as they are, since they may
    not have to wait, at least we can change them to synchronously
    when needed.
    
    Also, move the code to net/llc/llc_conn.c, which is apparently
    a better place.
    
    Reported-by: <syzbot+f922284c18ea23a8e457@syzkaller.appspotmail.com>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 14670e490ff9296d1bd3f0c515db942f66f65809
Author: Eric Dumazet <edumazet@google.com>
Date:   Sun Apr 15 17:52:04 2018 -0700

    net: af_packet: fix race in PACKET_{R|T}X_RING
    
    
    [ Upstream commit 5171b37d959641bbc619781caf62e61f7b940871 ]
    
    In order to remove the race caught by syzbot [1], we need
    to lock the socket before using po->tp_version as this could
    change under us otherwise.
    
    This means lock_sock() and release_sock() must be done by
    packet_set_ring() callers.
    
    [1] :
    BUG: KMSAN: uninit-value in packet_set_ring+0x1254/0x3870 net/packet/af_packet.c:4249
    CPU: 0 PID: 20195 Comm: syzkaller707632 Not tainted 4.16.0+ #83
    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+0x185/0x1d0 lib/dump_stack.c:53
     kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
     __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676
     packet_set_ring+0x1254/0x3870 net/packet/af_packet.c:4249
     packet_setsockopt+0x12c6/0x5a90 net/packet/af_packet.c:3662
     SYSC_setsockopt+0x4b8/0x570 net/socket.c:1849
     SyS_setsockopt+0x76/0xa0 net/socket.c:1828
     do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x449099
    RSP: 002b:00007f42b5307ce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
    RAX: ffffffffffffffda RBX: 000000000070003c RCX: 0000000000449099
    RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003
    RBP: 0000000000700038 R08: 000000000000001c R09: 0000000000000000
    R10: 00000000200000c0 R11: 0000000000000246 R12: 0000000000000000
    R13: 000000000080eecf R14: 00007f42b53089c0 R15: 0000000000000001
    
    Local variable description: ----req_u@packet_setsockopt
    Variable was created at:
     packet_setsockopt+0x13f/0x5a90 net/packet/af_packet.c:3612
     SYSC_setsockopt+0x4b8/0x570 net/socket.c:1849
    
    Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
    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 c4ded09147f0d0049f085f9b792abe6aff51aa98
Author: Eric Dumazet <edumazet@google.com>
Date:   Wed Apr 11 14:36:28 2018 -0700

    tcp: md5: reject TCP_MD5SIG or TCP_MD5SIG_EXT on established sockets
    
    
    [ Upstream commit 7212303268918b9a203aebeacfdbd83b5e87b20d ]
    
    syzbot/KMSAN reported an uninit-value in tcp_parse_options() [1]
    
    I believe this was caused by a TCP_MD5SIG being set on live
    flow.
    
    This is highly unexpected, since TCP option space is limited.
    
    For instance, presence of TCP MD5 option automatically disables
    TCP TimeStamp option at SYN/SYNACK time, which we can not do
    once flow has been established.
    
    Really, adding/deleting an MD5 key only makes sense on sockets
    in CLOSE or LISTEN state.
    
    [1]
    BUG: KMSAN: uninit-value in tcp_parse_options+0xd74/0x1a30 net/ipv4/tcp_input.c:3720
    CPU: 1 PID: 6177 Comm: syzkaller192004 Not tainted 4.16.0+ #83
    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+0x185/0x1d0 lib/dump_stack.c:53
     kmsan_report+0x142/0x240 mm/kmsan/kmsan.c:1067
     __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676
     tcp_parse_options+0xd74/0x1a30 net/ipv4/tcp_input.c:3720
     tcp_fast_parse_options net/ipv4/tcp_input.c:3858 [inline]
     tcp_validate_incoming+0x4f1/0x2790 net/ipv4/tcp_input.c:5184
     tcp_rcv_established+0xf60/0x2bb0 net/ipv4/tcp_input.c:5453
     tcp_v4_do_rcv+0x6cd/0xd90 net/ipv4/tcp_ipv4.c:1469
     sk_backlog_rcv include/net/sock.h:908 [inline]
     __release_sock+0x2d6/0x680 net/core/sock.c:2271
     release_sock+0x97/0x2a0 net/core/sock.c:2786
     tcp_sendmsg+0xd6/0x100 net/ipv4/tcp.c:1464
     inet_sendmsg+0x48d/0x740 net/ipv4/af_inet.c:764
     sock_sendmsg_nosec net/socket.c:630 [inline]
     sock_sendmsg net/socket.c:640 [inline]
     SYSC_sendto+0x6c3/0x7e0 net/socket.c:1747
     SyS_sendto+0x8a/0xb0 net/socket.c:1715
     do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x448fe9
    RSP: 002b:00007fd472c64d38 EFLAGS: 00000216 ORIG_RAX: 000000000000002c
    RAX: ffffffffffffffda RBX: 00000000006e5a30 RCX: 0000000000448fe9
    RDX: 000000000000029f RSI: 0000000020a88f88 RDI: 0000000000000004
    RBP: 00000000006e5a34 R08: 0000000020e68000 R09: 0000000000000010
    R10: 00000000200007fd R11: 0000000000000216 R12: 0000000000000000
    R13: 00007fff074899ef R14: 00007fd472c659c0 R15: 0000000000000009
    
    Uninit was created at:
     kmsan_save_stack_with_flags mm/kmsan/kmsan.c:278 [inline]
     kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:188
     kmsan_kmalloc+0x94/0x100 mm/kmsan/kmsan.c:314
     kmsan_slab_alloc+0x11/0x20 mm/kmsan/kmsan.c:321
     slab_post_alloc_hook mm/slab.h:445 [inline]
     slab_alloc_node mm/slub.c:2737 [inline]
     __kmalloc_node_track_caller+0xaed/0x11c0 mm/slub.c:4369
     __kmalloc_reserve net/core/skbuff.c:138 [inline]
     __alloc_skb+0x2cf/0x9f0 net/core/skbuff.c:206
     alloc_skb include/linux/skbuff.h:984 [inline]
     tcp_send_ack+0x18c/0x910 net/ipv4/tcp_output.c:3624
     __tcp_ack_snd_check net/ipv4/tcp_input.c:5040 [inline]
     tcp_ack_snd_check net/ipv4/tcp_input.c:5053 [inline]
     tcp_rcv_established+0x2103/0x2bb0 net/ipv4/tcp_input.c:5469
     tcp_v4_do_rcv+0x6cd/0xd90 net/ipv4/tcp_ipv4.c:1469
     sk_backlog_rcv include/net/sock.h:908 [inline]
     __release_sock+0x2d6/0x680 net/core/sock.c:2271
     release_sock+0x97/0x2a0 net/core/sock.c:2786
     tcp_sendmsg+0xd6/0x100 net/ipv4/tcp.c:1464
     inet_sendmsg+0x48d/0x740 net/ipv4/af_inet.c:764
     sock_sendmsg_nosec net/socket.c:630 [inline]
     sock_sendmsg net/socket.c:640 [inline]
     SYSC_sendto+0x6c3/0x7e0 net/socket.c:1747
     SyS_sendto+0x8a/0xb0 net/socket.c:1715
     do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
     entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    
    Fixes: cfb6eeb4c860 ("[TCP]: MD5 Signature Option (RFC2385) support.")
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: syzbot <syzkaller@googlegroups.com>
    Acked-by: Yuchung Cheng <ycheng@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 617b89aabca28f676617a106b940f75061ff578e
Author: Willem de Bruijn <willemb@google.com>
Date:   Mon Apr 23 17:37:03 2018 -0400

    packet: fix bitfield update race
    
    
    [ Upstream commit a6361f0ca4b25460f2cdf3235ebe8115f622901e ]
    
    Updates to the bitfields in struct packet_sock are not atomic.
    Serialize these read-modify-write cycles.
    
    Move po->running into a separate variable. Its writes are protected by
    po->bind_lock (except for one startup case at packet_create). Also
    replace a textual precondition warning with lockdep annotation.
    
    All others are set only in packet_setsockopt. Serialize these
    updates by holding the socket lock. Analogous to other field updates,
    also hold the lock when testing whether a ring is active (pg_vec).
    
    Fixes: 8dc419447415 ("[PACKET]: Add optional checksum computation for recvmsg")
    Reported-by: DaeRyong Jeong <threeearcat@gmail.com>
    Reported-by: Byoungyoung Lee <byoungyoung@purdue.edu>
    Signed-off-by: Willem de Bruijn <willemb@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit bae70a5f916feb66baa063ceb36716f0a207c29c
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Thu Apr 19 21:54:34 2018 -0700

    llc: fix NULL pointer deref for SOCK_ZAPPED
    
    
    [ Upstream commit 3a04ce7130a7e5dad4e78d45d50313747f8c830f ]
    
    For SOCK_ZAPPED socket, we don't need to care about llc->sap,
    so we should just skip these refcount functions in this case.
    
    Fixes: f7e43672683b ("llc: hold llc_sap before release_sock()")
    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a5db62f6225e9b5852215c3b0397ef093deb49ff
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date:   Wed Apr 18 11:51:56 2018 -0700

    llc: hold llc_sap before release_sock()
    
    
    [ Upstream commit f7e43672683b097bb074a8fe7af9bc600a23f231 ]
    
    syzbot reported we still access llc->sap in llc_backlog_rcv()
    after it is freed in llc_sap_remove_socket():
    
    Call Trace:
     __dump_stack lib/dump_stack.c:77 [inline]
     dump_stack+0x1b9/0x294 lib/dump_stack.c:113
     print_address_description+0x6c/0x20b mm/kasan/report.c:256
     kasan_report_error mm/kasan/report.c:354 [inline]
     kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
     __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
     llc_conn_ac_send_sabme_cmd_p_set_x+0x3a8/0x460 net/llc/llc_c_ac.c:785
     llc_exec_conn_trans_actions net/llc/llc_conn.c:475 [inline]
     llc_conn_service net/llc/llc_conn.c:400 [inline]
     llc_conn_state_process+0x4e1/0x13a0 net/llc/llc_conn.c:75
     llc_backlog_rcv+0x195/0x1e0 net/llc/llc_conn.c:891
     sk_backlog_rcv include/net/sock.h:909 [inline]
     __release_sock+0x12f/0x3a0 net/core/sock.c:2335
     release_sock+0xa4/0x2b0 net/core/sock.c:2850
     llc_ui_release+0xc8/0x220 net/llc/af_llc.c:204
    
    llc->sap is refcount'ed and llc_sap_remove_socket() is paired
    with llc_sap_add_socket(). This can be amended by holding its refcount
    before llc_sap_remove_socket() and releasing it after release_sock().
    
    Reported-by: <syzbot+6e181fc95081c2cf9051@syzkaller.appspotmail.com>
    Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8b467810a29ff4c2335225231a903f18dcf39d5a
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Mon Apr 23 16:38:27 2018 +0200

    pppoe: check sockaddr length in pppoe_connect()
    
    
    [ Upstream commit a49e2f5d5fb141884452ddb428f551b123d436b5 ]
    
    We must validate sockaddr_len, otherwise userspace can pass fewer data
    than we expect and we end up accessing invalid data.
    
    Fixes: 224cf5ad14c0 ("ppp: Move the PPP drivers")
    Reported-by: syzbot+4f03bdf92fdf9ef5ddab@syzkaller.appspotmail.com
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a0475be870ab18f56df3ee3e925efd1688243b4c
Author: Xin Long <lucien.xin@gmail.com>
Date:   Tue Apr 24 14:33:37 2018 +0800

    team: fix netconsole setup over team
    
    
    [ Upstream commit 9cf2f437ca5b39828984064fad213e68fc17ef11 ]
    
    The same fix in Commit dbe173079ab5 ("bridge: fix netconsole
    setup over bridge") is also needed for team driver.
    
    While at it, remove the unnecessary parameter *team from
    team_port_enable_netpoll().
    
    v1->v2:
      - fix it in a better way, as does bridge.
    
    Fixes: 0fb52a27a04a ("team: cleanup netpoll clode")
    Reported-by: João Avelino Bellomo Filho <jbellomo@redhat.com>
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5ac746d5032c3fe7e8e96343c218f928e12f86de
Author: Paolo Abeni <pabeni@redhat.com>
Date:   Fri Apr 13 13:59:25 2018 +0200

    team: avoid adding twice the same option to the event list
    
    
    [ Upstream commit 4fb0534fb7bbc2346ba7d3a072b538007f4135a5 ]
    
    When parsing the options provided by the user space,
    team_nl_cmd_options_set() insert them in a temporary list to send
    multiple events with a single message.
    While each option's attribute is correctly validated, the code does
    not check for duplicate entries before inserting into the event
    list.
    
    Exploiting the above, the syzbot was able to trigger the following
    splat:
    
    kernel BUG at lib/list_debug.c:31!
    invalid opcode: 0000 [#1] SMP KASAN
    Dumping ftrace buffer:
        (ftrace buffer empty)
    Modules linked in:
    CPU: 0 PID: 4466 Comm: syzkaller556835 Not tainted 4.16.0+ #17
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
    Google 01/01/2011
    RIP: 0010:__list_add_valid+0xaa/0xb0 lib/list_debug.c:29
    RSP: 0018:ffff8801b04bf248 EFLAGS: 00010286
    RAX: 0000000000000058 RBX: ffff8801c8fc7a90 RCX: 0000000000000000
    RDX: 0000000000000058 RSI: ffffffff815fbf41 RDI: ffffed0036097e3f
    RBP: ffff8801b04bf260 R08: ffff8801b0b2a700 R09: ffffed003b604f90
    R10: ffffed003b604f90 R11: ffff8801db027c87 R12: ffff8801c8fc7a90
    R13: ffff8801c8fc7a90 R14: dffffc0000000000 R15: 0000000000000000
    FS:  0000000000b98880(0000) GS:ffff8801db000000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 000000000043fc30 CR3: 00000001afe8e000 CR4: 00000000001406f0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
      __list_add include/linux/list.h:60 [inline]
      list_add include/linux/list.h:79 [inline]
      team_nl_cmd_options_set+0x9ff/0x12b0 drivers/net/team/team.c:2571
      genl_family_rcv_msg+0x889/0x1120 net/netlink/genetlink.c:599
      genl_rcv_msg+0xc6/0x170 net/netlink/genetlink.c:624
      netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2448
      genl_rcv+0x28/0x40 net/netlink/genetlink.c:635
      netlink_unicast_kernel net/netlink/af_netlink.c:1310 [inline]
      netlink_unicast+0x58b/0x740 net/netlink/af_netlink.c:1336
      netlink_sendmsg+0x9f0/0xfa0 net/netlink/af_netlink.c:1901
      sock_sendmsg_nosec net/socket.c:629 [inline]
      sock_sendmsg+0xd5/0x120 net/socket.c:639
      ___sys_sendmsg+0x805/0x940 net/socket.c:2117
      __sys_sendmsg+0x115/0x270 net/socket.c:2155
      SYSC_sendmsg net/socket.c:2164 [inline]
      SyS_sendmsg+0x29/0x30 net/socket.c:2162
      do_syscall_64+0x29e/0x9d0 arch/x86/entry/common.c:287
      entry_SYSCALL_64_after_hwframe+0x42/0xb7
    RIP: 0033:0x4458b9
    RSP: 002b:00007ffd1d4a7278 EFLAGS: 00000213 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 000000000000001b RCX: 00000000004458b9
    RDX: 0000000000000010 RSI: 0000000020000d00 RDI: 0000000000000004
    RBP: 00000000004a74ed R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000213 R12: 00007ffd1d4a7348
    R13: 0000000000402a60 R14: 0000000000000000 R15: 0000000000000000
    Code: 75 e8 eb a9 48 89 f7 48 89 75 e8 e8 d1 85 7b fe 48 8b 75 e8 eb bb 48
    89 f2 48 89 d9 4c 89 e6 48 c7 c7 a0 84 d8 87 e8 ea 67 28 fe <0f> 0b 0f 1f
    40 00 48 b8 00 00 00 00 00 fc ff df 55 48 89 e5 41
    RIP: __list_add_valid+0xaa/0xb0 lib/list_debug.c:29 RSP: ffff8801b04bf248
    
    This changeset addresses the avoiding list_add() if the current
    option is already present in the event list.
    
    Reported-and-tested-by: syzbot+4d4af685432dc0e56c91@syzkaller.appspotmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Fixes: 2fcdb2c9e659 ("team: allow to send multiple set events in one message")
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e04fc83dcf2ffb6bc4d947c3afad039260722fb
Author: Jann Horn <jannh@google.com>
Date:   Fri Apr 20 15:57:30 2018 +0200

    tcp: don't read out-of-bounds opsize
    
    
    [ Upstream commit 7e5a206ab686f098367b61aca989f5cdfa8114a3 ]
    
    The old code reads the "opsize" variable from out-of-bounds memory (first
    byte behind the segment) if a broken TCP segment ends directly after an
    opcode that is neither EOL nor NOP.
    
    The result of the read isn't used for anything, so the worst thing that
    could theoretically happen is a pagefault; and since the physmap is usually
    mostly contiguous, even that seems pretty unlikely.
    
    The following C reproducer triggers the uninitialized read - however, you
    can't actually see anything happen unless you put something like a
    pr_warn() in tcp_parse_md5sig_option() to print the opsize.
    
    ====================================
    #define _GNU_SOURCE
    #include <arpa/inet.h>
    #include <stdlib.h>
    #include <errno.h>
    #include <stdarg.h>
    #include <net/if.h>
    #include <linux/if.h>
    #include <linux/ip.h>
    #include <linux/tcp.h>
    #include <linux/in.h>
    #include <linux/if_tun.h>
    #include <err.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    #include <string.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/ioctl.h>
    #include <assert.h>
    
    void systemf(const char *command, ...) {
      char *full_command;
      va_list ap;
      va_start(ap, command);
      if (vasprintf(&full_command, command, ap) == -1)
        err(1, "vasprintf");
      va_end(ap);
      printf("systemf: <<<%s>>>\n", full_command);
      system(full_command);
    }
    
    char *devname;
    
    int tun_alloc(char *name) {
      int fd = open("/dev/net/tun", O_RDWR);
      if (fd == -1)
        err(1, "open tun dev");
      static struct ifreq req = { .ifr_flags = IFF_TUN|IFF_NO_PI };
      strcpy(req.ifr_name, name);
      if (ioctl(fd, TUNSETIFF, &req))
        err(1, "TUNSETIFF");
      devname = req.ifr_name;
      printf("device name: %s\n", devname);
      return fd;
    }
    
    #define IPADDR(a,b,c,d) (((a)<<0)+((b)<<8)+((c)<<16)+((d)<<24))
    
    void sum_accumulate(unsigned int *sum, void *data, int len) {
      assert((len&2)==0);
      for (int i=0; i<len/2; i++) {
        *sum += ntohs(((unsigned short *)data)[i]);
      }
    }
    
    unsigned short sum_final(unsigned int sum) {
      sum = (sum >> 16) + (sum & 0xffff);
      sum = (sum >> 16) + (sum & 0xffff);
      return htons(~sum);
    }
    
    void fix_ip_sum(struct iphdr *ip) {
      unsigned int sum = 0;
      sum_accumulate(&sum, ip, sizeof(*ip));
      ip->check = sum_final(sum);
    }
    
    void fix_tcp_sum(struct iphdr *ip, struct tcphdr *tcp) {
      unsigned int sum = 0;
      struct {
        unsigned int saddr;
        unsigned int daddr;
        unsigned char pad;
        unsigned char proto_num;
        unsigned short tcp_len;
      } fakehdr = {
        .saddr = ip->saddr,
        .daddr = ip->daddr,
        .proto_num = ip->protocol,
        .tcp_len = htons(ntohs(ip->tot_len) - ip->ihl*4)
      };
      sum_accumulate(&sum, &fakehdr, sizeof(fakehdr));
      sum_accumulate(&sum, tcp, tcp->doff*4);
      tcp->check = sum_final(sum);
    }
    
    int main(void) {
      int tun_fd = tun_alloc("inject_dev%d");
      systemf("ip link set %s up", devname);
      systemf("ip addr add 192.168.42.1/24 dev %s", devname);
    
      struct {
        struct iphdr ip;
        struct tcphdr tcp;
        unsigned char tcp_opts[20];
      } __attribute__((packed)) syn_packet = {
        .ip = {
          .ihl = sizeof(struct iphdr)/4,
          .version = 4,
          .tot_len = htons(sizeof(syn_packet)),
          .ttl = 30,
          .protocol = IPPROTO_TCP,
          /* FIXUP check */
          .saddr = IPADDR(192,168,42,2),
          .daddr = IPADDR(192,168,42,1)
        },
        .tcp = {
          .source = htons(1),
          .dest = htons(1337),
          .seq = 0x12345678,
          .doff = (sizeof(syn_packet.tcp)+sizeof(syn_packet.tcp_opts))/4,
          .syn = 1,
          .window = htons(64),
          .check = 0 /*FIXUP*/
        },
        .tcp_opts = {
          /* INVALID: trailing MD5SIG opcode after NOPs */
          1, 1, 1, 1, 1,
          1, 1, 1, 1, 1,
          1, 1, 1, 1, 1,
          1, 1, 1, 1, 19
        }
      };
      fix_ip_sum(&syn_packet.ip);
      fix_tcp_sum(&syn_packet.ip, &syn_packet.tcp);
      while (1) {
        int write_res = write(tun_fd, &syn_packet, sizeof(syn_packet));
        if (write_res != sizeof(syn_packet))
          err(1, "packet write failed");
      }
    }
    ====================================
    
    Fixes: cfb6eeb4c860 ("[TCP]: MD5 Signature Option (RFC2385) support.")
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 115af4416bfd3cb811a01a2444f5203e59dca03d
Author: Guillaume Nault <g.nault@alphalink.fr>
Date:   Mon Apr 23 16:15:14 2018 +0200

    l2tp: check sockaddr length in pppol2tp_connect()
    
    
    [ Upstream commit eb1c28c05894a4b1f6b56c5bf072205e64cfa280 ]
    
    Check sockaddr_len before dereferencing sp->sa_protocol, to ensure that
    it actually points to valid data.
    
    Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts")
    Reported-by: syzbot+a70ac890b23b1bf29f5c@syzkaller.appspotmail.com
    Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1f6945bbbfb3c6565e2c7fd244849ceb18d5bd0a
Author: Eric Biggers <ebiggers@google.com>
Date:   Tue Apr 17 12:07:06 2018 -0700

    KEYS: DNS: limit the length of option strings
    
    
    [ Upstream commit 9c438d7a3a52dcc2b9ed095cb87d3a5e83cf7e60 ]
    
    Adding a dns_resolver key whose payload contains a very long option name
    resulted in that string being printed in full.  This hit the WARN_ONCE()
    in set_precision() during the printk(), because printk() only supports a
    precision of up to 32767 bytes:
    
        precision 1000000 too large
        WARNING: CPU: 0 PID: 752 at lib/vsprintf.c:2189 vsnprintf+0x4bc/0x5b0
    
    Fix it by limiting option strings (combined name + value) to a much more
    reasonable 128 bytes.  The exact limit is arbitrary, but currently the
    only recognized option is formatted as "dnserror=%lu" which fits well
    within this limit.
    
    Also ratelimit the printks.
    
    Reproducer:
    
        perl -e 'print "#", "A" x 1000000, "\x00"' | keyctl padd dns_resolver desc @s
    
    This bug was found using syzkaller.
    
    Reported-by: Mark Rutland <mark.rutland@arm.com>
    Fixes: 4a2d789267e0 ("DNS: If the DNS server returns an error, allow that to be cached [ver #2]")
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a7c083702a6b1fa5501b625aa6c0f8e155734c61
Author: Xin Long <lucien.xin@gmail.com>
Date:   Sun Apr 22 19:11:50 2018 +0800

    bonding: do not set slave_dev npinfo before slave_enable_netpoll in bond_enslave
    
    
    [ Upstream commit ddea788c63094f7c483783265563dd5b50052e28 ]
    
    After Commit 8a8efa22f51b ("bonding: sync netpoll code with bridge"), it
    would set slave_dev npinfo in slave_enable_netpoll when enslaving a dev
    if bond->dev->npinfo was set.
    
    However now slave_dev npinfo is set with bond->dev->npinfo before calling
    slave_enable_netpoll. With slave_dev npinfo set, __netpoll_setup called
    in slave_enable_netpoll will not call slave dev's .ndo_netpoll_setup().
    It causes that the lower dev of this slave dev can't set its npinfo.
    
    One way to reproduce it:
    
      # modprobe bonding
      # brctl addbr br0
      # brctl addif br0 eth1
      # ifconfig bond0 192.168.122.1/24 up
      # ifenslave bond0 eth2
      # systemctl restart netconsole
      # ifenslave bond0 br0
      # ifconfig eth2 down
      # systemctl restart netconsole
    
    The netpoll won't really work.
    
    This patch is to remove that slave_dev npinfo setting in bond_enslave().
    
    Fixes: 8a8efa22f51b ("bonding: sync netpoll code with bridge")
    Signed-off-by: Xin Long <lucien.xin@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit f47bd1b5605e2a5cb89853e3fc595b7d84f4db4c
Author: Sahitya Tummala <stummala@codeaurora.org>
Date:   Wed Feb 1 20:49:35 2017 -0500

    jbd2: fix use after free in kjournald2()
    
    commit dbfcef6b0f4012c57bc0b6e0e660d5ed12a5eaed upstream.
    
    Below is the synchronization issue between unmount and kjournald2
    contexts, which results into use after free issue in kjournald2().
    Fix this issue by using journal->j_state_lock to synchronize the
    wait_event() done in journal_kill_thread() and the wake_up() done
    in kjournald2().
    
    TASK 1:
    umount cmd:
       |--jbd2_journal_destroy() {
           |--journal_kill_thread() {
                write_lock(&journal->j_state_lock);
                journal->j_flags |= JBD2_UNMOUNT;
                ...
                write_unlock(&journal->j_state_lock);
                wake_up(&journal->j_wait_commit);      TASK 2 wakes up here:
                                                       kjournald2() {
                                                         ...
                                                         checks JBD2_UNMOUNT flag and calls goto end-loop;
                                                         ...
                                                         end_loop:
                                                           write_unlock(&journal->j_state_lock);
                                                           journal->j_task = NULL; --> If this thread gets
                                                           pre-empted here, then TASK 1 wait_event will
                                                           exit even before this thread is completely
                                                           done.
                wait_event(journal->j_wait_done_commit, journal->j_task == NULL);
                ...
                write_lock(&journal->j_state_lock);
                write_unlock(&journal->j_state_lock);
              }
           |--kfree(journal);
         }
    }
                                                           wake_up(&journal->j_wait_done_commit); --> this step
                                                           now results into use after free issue.
                                                       }
    
    Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3e8f97bf940db6f08cb0ff65c2218cb9b6cf63f3
Author: Matthew Wilcox <mawilcox@microsoft.com>
Date:   Fri Apr 20 14:56:20 2018 -0700

    mm/filemap.c: fix NULL pointer in page_cache_tree_insert()
    
    commit abc1be13fd113ddef5e2d807a466286b864caed3 upstream.
    
    f2fs specifies the __GFP_ZERO flag for allocating some of its pages.
    Unfortunately, the page cache also uses the mapping's GFP flags for
    allocating radix tree nodes.  It always masked off the __GFP_HIGHMEM
    flag, and masks off __GFP_ZERO in some paths, but not all.  That causes
    radix tree nodes to be allocated with a NULL list_head, which causes
    backtraces like:
    
      __list_del_entry+0x30/0xd0
      list_lru_del+0xac/0x1ac
      page_cache_tree_insert+0xd8/0x110
    
    The __GFP_DMA and __GFP_DMA32 flags would also be able to sneak through
    if they are ever used.  Fix them all by using GFP_RECLAIM_MASK at the
    innermost location, and remove it from earlier in the callchain.
    
    Link: http://lkml.kernel.org/r/20180411060320.14458-2-willy@infradead.org
    Fixes: 449dd6984d0e ("mm: keep page cache radix tree nodes in check")
    Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
    Reported-by: Chris Fries <cfries@google.com>
    Debugged-by: Minchan Kim <minchan@kernel.org>
    Acked-by: Johannes Weiner <hannes@cmpxchg.org>
    Acked-by: Michal Hocko <mhocko@suse.com>
    Reviewed-by: Jan Kara <jack@suse.cz>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 19f50d844c5fda5555c38fe8853404491def5c70
Author: Jiri Olsa <jolsa@kernel.org>
Date:   Sun Apr 15 11:23:50 2018 +0200

    perf: Return proper values for user stack errors
    
    commit 78b562fbfa2cf0a9fcb23c3154756b690f4905c1 upstream.
    
    Return immediately when we find issue in the user stack checks. The
    error value could get overwritten by following check for
    PERF_SAMPLE_REGS_INTR.
    
    Signed-off-by: Jiri Olsa <jolsa@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <andi@firstfloor.org>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: syzkaller-bugs@googlegroups.com
    Cc: x86@kernel.org
    Fixes: 60e2364e60e8 ("perf: Add ability to sample machine state on interrupt")
    Link: http://lkml.kernel.org/r/20180415092352.12403-1-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ab3fc66b3dc8bcd9e15ce9ed48cde061f564f6ee
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Mon Feb 19 14:16:47 2018 -0500

    ext4: don't update checksum of new initialized bitmaps
    
    commit 044e6e3d74a3d7103a0c8a9305dfd94d64000660 upstream.
    
    When reading the inode or block allocation bitmap, if the bitmap needs
    to be initialized, do not update the checksum in the block group
    descriptor.  That's because we're not set up to journal those changes.
    Instead, just set the verified bit on the bitmap block, so that it's
    not necessary to validate the checksum.
    
    When a block or inode allocation actually happens, at that point the
    checksum will be calculated, and update of the bg descriptor block
    will be properly journalled.
    
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Cc: stable@vger.kernel.org
    Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 802ec698e07b01426f044fdd5d612570a0c22b33
Author: wangguang <wang.guang55@zte.com.cn>
Date:   Thu Sep 15 11:32:46 2016 -0400

    ext4: bugfix for mmaped pages in mpage_release_unused_pages()
    
    commit 4e800c0359d9a53e6bf0ab216954971b2515247f upstream.
    
    Pages clear buffers after ext4 delayed block allocation failed,
    However, it does not clean its pte_dirty flag.
    if the pages unmap ,in cording to the pte_dirty ,
    unmap_page_range may try to call __set_page_dirty,
    
    which may lead to the bugon at
    mpage_prepare_extent_to_map:head = page_buffers(page);.
    
    This patch just call clear_page_dirty_for_io to clean pte_dirty
    at mpage_release_unused_pages for pages mmaped.
    
    Steps to reproduce the bug:
    
    (1) mmap a file in ext4
            addr = (char *)mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED,
                                fd, 0);
            memset(addr, 'i', 4096);
    
    (2) return EIO at
    
            ext4_writepages->mpage_map_and_submit_extent->mpage_map_one_extent
    
    which causes this log message to be print:
    
                    ext4_msg(sb, KERN_CRIT,
                            "Delayed block allocation failed for "
                            "inode %lu at logical offset %llu with"
                            " max blocks %u with error %d",
                            inode->i_ino,
                            (unsigned long long)map->m_lblk,
                            (unsigned)map->m_len, -err);
    
    (3)Unmap the addr cause warning at
    
            __set_page_dirty:WARN_ON_ONCE(warn && !PageUptodate(page));
    
    (4) wait for a minute,then bugon happen.
    
    Cc: stable@vger.kernel.org
    Signed-off-by: wangguang <wangguang03@zte.com>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    [nathanchance: Resolved conflict from lack of 09cbfeaf1a5a6]
    Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 5781ac24bbd998ebb1ff30143bb06244d847af48
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Wed Jan 11 21:50:46 2017 -0500

    ext4: fix deadlock between inline_data and ext4_expand_extra_isize_ea()
    
    commit c755e251357a0cee0679081f08c3f4ba797a8009 upstream.
    
    The xattr_sem deadlock problems fixed in commit 2e81a4eeedca: "ext4:
    avoid deadlock when expanding inode size" didn't include the use of
    xattr_sem in fs/ext4/inline.c.  With the addition of project quota
    which added a new extra inode field, this exposed deadlocks in the
    inline_data code similar to the ones fixed by 2e81a4eeedca.
    
    The deadlock can be reproduced via:
    
       dmesg -n 7
       mke2fs -t ext4 -O inline_data -Fq -I 256 /dev/vdc 32768
       mount -t ext4 -o debug_want_extra_isize=24 /dev/vdc /vdc
       mkdir /vdc/a
       umount /vdc
       mount -t ext4 /dev/vdc /vdc
       echo foo > /vdc/a/foo
    
    and looks like this:
    
    [   11.158815]
    [   11.160276] =============================================
    [   11.161960] [ INFO: possible recursive locking detected ]
    [   11.161960] 4.10.0-rc3-00015-g011b30a8a3cf #160 Tainted: G        W
    [   11.161960] ---------------------------------------------
    [   11.161960] bash/2519 is trying to acquire lock:
    [   11.161960]  (&ei->xattr_sem){++++..}, at: [<c1225a4b>] ext4_expand_extra_isize_ea+0x3d/0x4cd
    [   11.161960]
    [   11.161960] but task is already holding lock:
    [   11.161960]  (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
    [   11.161960]
    [   11.161960] other info that might help us debug this:
    [   11.161960]  Possible unsafe locking scenario:
    [   11.161960]
    [   11.161960]        CPU0
    [   11.161960]        ----
    [   11.161960]   lock(&ei->xattr_sem);
    [   11.161960]   lock(&ei->xattr_sem);
    [   11.161960]
    [   11.161960]  *** DEADLOCK ***
    [   11.161960]
    [   11.161960]  May be due to missing lock nesting notation
    [   11.161960]
    [   11.161960] 4 locks held by bash/2519:
    [   11.161960]  #0:  (sb_writers#3){.+.+.+}, at: [<c11a2414>] mnt_want_write+0x1e/0x3e
    [   11.161960]  #1:  (&type->i_mutex_dir_key){++++++}, at: [<c119508b>] path_openat+0x338/0x67a
    [   11.161960]  #2:  (jbd2_handle){++++..}, at: [<c123314a>] start_this_handle+0x582/0x622
    [   11.161960]  #3:  (&ei->xattr_sem){++++..}, at: [<c1227941>] ext4_try_add_inline_entry+0x3a/0x152
    [   11.161960]
    [   11.161960] stack backtrace:
    [   11.161960] CPU: 0 PID: 2519 Comm: bash Tainted: G        W       4.10.0-rc3-00015-g011b30a8a3cf #160
    [   11.161960] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.1-1 04/01/2014
    [   11.161960] Call Trace:
    [   11.161960]  dump_stack+0x72/0xa3
    [   11.161960]  __lock_acquire+0xb7c/0xcb9
    [   11.161960]  ? kvm_clock_read+0x1f/0x29
    [   11.161960]  ? __lock_is_held+0x36/0x66
    [   11.161960]  ? __lock_is_held+0x36/0x66
    [   11.161960]  lock_acquire+0x106/0x18a
    [   11.161960]  ? ext4_expand_extra_isize_ea+0x3d/0x4cd
    [   11.161960]  down_write+0x39/0x72
    [   11.161960]  ? ext4_expand_extra_isize_ea+0x3d/0x4cd
    [   11.161960]  ext4_expand_extra_isize_ea+0x3d/0x4cd
    [   11.161960]  ? _raw_read_unlock+0x22/0x2c
    [   11.161960]  ? jbd2_journal_extend+0x1e2/0x262
    [   11.161960]  ? __ext4_journal_get_write_access+0x3d/0x60
    [   11.161960]  ext4_mark_inode_dirty+0x17d/0x26d
    [   11.161960]  ? ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
    [   11.161960]  ext4_add_dirent_to_inline.isra.12+0xa5/0xb2
    [   11.161960]  ext4_try_add_inline_entry+0x69/0x152
    [   11.161960]  ext4_add_entry+0xa3/0x848
    [   11.161960]  ? __brelse+0x14/0x2f
    [   11.161960]  ? _raw_spin_unlock_irqrestore+0x44/0x4f
    [   11.161960]  ext4_add_nondir+0x17/0x5b
    [   11.161960]  ext4_create+0xcf/0x133
    [   11.161960]  ? ext4_mknod+0x12f/0x12f
    [   11.161960]  lookup_open+0x39e/0x3fb
    [   11.161960]  ? __wake_up+0x1a/0x40
    [   11.161960]  ? lock_acquire+0x11e/0x18a
    [   11.161960]  path_openat+0x35c/0x67a
    [   11.161960]  ? sched_clock_cpu+0xd7/0xf2
    [   11.161960]  do_filp_open+0x36/0x7c
    [   11.161960]  ? _raw_spin_unlock+0x22/0x2c
    [   11.161960]  ? __alloc_fd+0x169/0x173
    [   11.161960]  do_sys_open+0x59/0xcc
    [   11.161960]  SyS_open+0x1d/0x1f
    [   11.161960]  do_int80_syscall_32+0x4f/0x61
    [   11.161960]  entry_INT80_32+0x2f/0x2f
    [   11.161960] EIP: 0xb76ad469
    [   11.161960] EFLAGS: 00000286 CPU: 0
    [   11.161960] EAX: ffffffda EBX: 08168ac8 ECX: 00008241 EDX: 000001b6
    [   11.161960] ESI: b75e46bc EDI: b7755000 EBP: bfbdb108 ESP: bfbdafc0
    [   11.161960]  DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b
    
    Cc: stable@vger.kernel.org # 3.10 (requires 2e81a4eeedca as a prereq)
    Reported-by: George Spelvin <linux@sciencehorizons.net>
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Harsh Shandilya <harsh@prjkt.io>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 48bb699237a420d2d0b5d2f6408b97580641e72b
Author: Xiaoming Gao <gxm.linux.kernel@gmail.com>
Date:   Fri Apr 13 17:48:08 2018 +0800

    x86/tsc: Prevent 32bit truncation in calc_hpet_ref()
    
    commit d3878e164dcd3925a237a20e879432400e369172 upstream.
    
    The TSC calibration code uses HPET as reference. The conversion normalizes
    the delta of two HPET timestamps:
    
        hpetref = ((tshpet1 - tshpet2) * HPET_PERIOD) / 1e6
    
    and then divides the normalized delta of the corresponding TSC timestamps
    by the result to calulate the TSC frequency.
    
        tscfreq = ((tstsc1 - tstsc2 ) * 1e6) / hpetref
    
    This uses do_div() which takes an u32 as the divisor, which worked so far
    because the HPET frequency was low enough that 'hpetref' never exceeded
    32bit.
    
    On Skylake machines the HPET frequency increased so 'hpetref' can exceed
    32bit. do_div() truncates the divisor, which causes the calibration to
    fail.
    
    Use div64_u64() to avoid the problem.
    
    [ tglx: Fixes whitespace mangled patch and rewrote changelog ]
    
    Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: stable@vger.kernel.org
    Cc: peterz@infradead.org
    Cc: hpa@zytor.com
    Link: https://lkml.kernel.org/r/38894564-4fc9-b8ec-353f-de702839e44e@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit a1a9d95d371e708b2a31090fa484fbdb4077e04c
Author: Steve French <smfrench@gmail.com>
Date:   Fri Apr 20 12:19:07 2018 -0500

    cifs: do not allow creating sockets except with SMB1 posix exensions
    
    commit 1d0cffa674cfa7d185a302c8c6850fc50b893bed upstream.
    
    RHBZ: 1453123
    
    Since at least the 3.10 kernel and likely a lot earlier we have
    not been able to create unix domain sockets in a cifs share
    when mounted using the SFU mount option (except when mounted
    with the cifs unix extensions to Samba e.g.)
    Trying to create a socket, for example using the af_unix command from
    xfstests will cause :
    BUG: unable to handle kernel NULL pointer dereference at 00000000
    00000040
    
    Since no one uses or depends on being able to create unix domains sockets
    on a cifs share the easiest fix to stop this vulnerability is to simply
    not allow creation of any other special files than char or block devices
    when sfu is used.
    
    Added update to Ronnie's patch to handle a tcon link leak, and
    to address a buf leak noticed by Gustavo and Colin.
    
    Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
    CC:  Colin Ian King <colin.king@canonical.com>
    Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
    Reported-by: Eryu Guan <eguan@redhat.com>
    Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <smfrench@gmail.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>