18 Oct, 2018

5 commits

  • [ Upstream commit ccfec9e5cb2d48df5a955b7bf47f7782157d3bc2]

    Cong noted that we need the same checks introduced by commit 76c0ddd8c3a6
    ("ip6_tunnel: be careful when accessing the inner header")
    even for ipv4 tunnels.

    Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
    Suggested-by: Cong Wang
    Signed-off-by: Paolo Abeni
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Paolo Abeni
     
  • [ Upstream commit 76c0ddd8c3a683f6e2c6e60e11dc1a1558caf4bc ]

    the ip6 tunnel xmit ndo assumes that the processed skb always
    contains an ip[v6] header, but syzbot has found a way to send
    frames that fall short of this assumption, leading to the following splat:

    BUG: KMSAN: uninit-value in ip6ip6_tnl_xmit net/ipv6/ip6_tunnel.c:1307
    [inline]
    BUG: KMSAN: uninit-value in ip6_tnl_start_xmit+0x7d2/0x1ef0
    net/ipv6/ip6_tunnel.c:1390
    CPU: 0 PID: 4504 Comm: syz-executor558 Not tainted 4.16.0+ #87
    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:683
    ip6ip6_tnl_xmit net/ipv6/ip6_tunnel.c:1307 [inline]
    ip6_tnl_start_xmit+0x7d2/0x1ef0 net/ipv6/ip6_tunnel.c:1390
    __netdev_start_xmit include/linux/netdevice.h:4066 [inline]
    netdev_start_xmit include/linux/netdevice.h:4075 [inline]
    xmit_one net/core/dev.c:3026 [inline]
    dev_hard_start_xmit+0x5f1/0xc70 net/core/dev.c:3042
    __dev_queue_xmit+0x27ee/0x3520 net/core/dev.c:3557
    dev_queue_xmit+0x4b/0x60 net/core/dev.c:3590
    packet_snd net/packet/af_packet.c:2944 [inline]
    packet_sendmsg+0x7c70/0x8a30 net/packet/af_packet.c:2969
    sock_sendmsg_nosec net/socket.c:630 [inline]
    sock_sendmsg net/socket.c:640 [inline]
    ___sys_sendmsg+0xec0/0x1310 net/socket.c:2046
    __sys_sendmmsg+0x42d/0x800 net/socket.c:2136
    SYSC_sendmmsg+0xc4/0x110 net/socket.c:2167
    SyS_sendmmsg+0x63/0x90 net/socket.c:2162
    do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2
    RIP: 0033:0x441819
    RSP: 002b:00007ffe58ee8268 EFLAGS: 00000213 ORIG_RAX: 0000000000000133
    RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000441819
    RDX: 0000000000000002 RSI: 0000000020000100 RDI: 0000000000000003
    RBP: 00000000006cd018 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000213 R12: 0000000000402510
    R13: 00000000004025a0 R14: 0000000000000000 R15: 0000000000000000

    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]
    alloc_skb_with_frags+0x1d4/0xb20 net/core/skbuff.c:5234
    sock_alloc_send_pskb+0xb56/0x1190 net/core/sock.c:2085
    packet_alloc_skb net/packet/af_packet.c:2803 [inline]
    packet_snd net/packet/af_packet.c:2894 [inline]
    packet_sendmsg+0x6454/0x8a30 net/packet/af_packet.c:2969
    sock_sendmsg_nosec net/socket.c:630 [inline]
    sock_sendmsg net/socket.c:640 [inline]
    ___sys_sendmsg+0xec0/0x1310 net/socket.c:2046
    __sys_sendmmsg+0x42d/0x800 net/socket.c:2136
    SYSC_sendmmsg+0xc4/0x110 net/socket.c:2167
    SyS_sendmmsg+0x63/0x90 net/socket.c:2162
    do_syscall_64+0x309/0x430 arch/x86/entry/common.c:287
    entry_SYSCALL_64_after_hwframe+0x3d/0xa2

    This change addresses the issue adding the needed check before
    accessing the inner header.

    The ipv4 side of the issue is apparently there since the ipv4 over ipv6
    initial support, and the ipv6 side predates git history.

    Fixes: c4d3efafcc93 ("[IPV6] IP6TUNNEL: Add support to IPv4 over IPv6 tunnel.")
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: syzbot+3fde91d4d394747d6db4@syzkaller.appspotmail.com
    Tested-by: Alexander Potapenko
    Signed-off-by: Paolo Abeni
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Paolo Abeni
     
  • [ Upstream commit d4859d749aa7090ffb743d15648adb962a1baeae ]

    Syzkaller reported this on a slightly older kernel but it's still
    applicable to the current kernel -

    ======================================================
    WARNING: possible circular locking dependency detected
    4.18.0-next-20180823+ #46 Not tainted
    ------------------------------------------------------
    syz-executor4/26841 is trying to acquire lock:
    00000000dd41ef48 ((wq_completion)bond_dev->name){+.+.}, at: flush_workqueue+0x2db/0x1e10 kernel/workqueue.c:2652

    but task is already holding lock:
    00000000768ab431 (rtnl_mutex){+.+.}, at: rtnl_lock net/core/rtnetlink.c:77 [inline]
    00000000768ab431 (rtnl_mutex){+.+.}, at: rtnetlink_rcv_msg+0x412/0xc30 net/core/rtnetlink.c:4708

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #2 (rtnl_mutex){+.+.}:
    __mutex_lock_common kernel/locking/mutex.c:925 [inline]
    __mutex_lock+0x171/0x1700 kernel/locking/mutex.c:1073
    mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1088
    rtnl_lock+0x17/0x20 net/core/rtnetlink.c:77
    bond_netdev_notify drivers/net/bonding/bond_main.c:1310 [inline]
    bond_netdev_notify_work+0x44/0xd0 drivers/net/bonding/bond_main.c:1320
    process_one_work+0xc73/0x1aa0 kernel/workqueue.c:2153
    worker_thread+0x189/0x13c0 kernel/workqueue.c:2296
    kthread+0x35a/0x420 kernel/kthread.c:246
    ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415

    -> #1 ((work_completion)(&(&nnw->work)->work)){+.+.}:
    process_one_work+0xc0b/0x1aa0 kernel/workqueue.c:2129
    worker_thread+0x189/0x13c0 kernel/workqueue.c:2296
    kthread+0x35a/0x420 kernel/kthread.c:246
    ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:415

    -> #0 ((wq_completion)bond_dev->name){+.+.}:
    lock_acquire+0x1e4/0x4f0 kernel/locking/lockdep.c:3901
    flush_workqueue+0x30a/0x1e10 kernel/workqueue.c:2655
    drain_workqueue+0x2a9/0x640 kernel/workqueue.c:2820
    destroy_workqueue+0xc6/0x9d0 kernel/workqueue.c:4155
    __alloc_workqueue_key+0xef9/0x1190 kernel/workqueue.c:4138
    bond_init+0x269/0x940 drivers/net/bonding/bond_main.c:4734
    register_netdevice+0x337/0x1100 net/core/dev.c:8410
    bond_newlink+0x49/0xa0 drivers/net/bonding/bond_netlink.c:453
    rtnl_newlink+0xef4/0x1d50 net/core/rtnetlink.c:3099
    rtnetlink_rcv_msg+0x46e/0xc30 net/core/rtnetlink.c:4711
    netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2454
    rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4729
    netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
    netlink_unicast+0x5a0/0x760 net/netlink/af_netlink.c:1343
    netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1908
    sock_sendmsg_nosec net/socket.c:622 [inline]
    sock_sendmsg+0xd5/0x120 net/socket.c:632
    ___sys_sendmsg+0x7fd/0x930 net/socket.c:2115
    __sys_sendmsg+0x11d/0x290 net/socket.c:2153
    __do_sys_sendmsg net/socket.c:2162 [inline]
    __se_sys_sendmsg net/socket.c:2160 [inline]
    __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2160
    do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
    entry_SYSCALL_64_after_hwframe+0x49/0xbe

    other info that might help us debug this:

    Chain exists of:
    (wq_completion)bond_dev->name --> (work_completion)(&(&nnw->work)->work) --> rtnl_mutex

    Possible unsafe locking scenario:

    CPU0 CPU1
    ---- ----
    lock(rtnl_mutex);
    lock((work_completion)(&(&nnw->work)->work));
    lock(rtnl_mutex);
    lock((wq_completion)bond_dev->name);

    *** DEADLOCK ***

    1 lock held by syz-executor4/26841:

    stack backtrace:
    CPU: 1 PID: 26841 Comm: syz-executor4 Not tainted 4.18.0-next-20180823+ #46
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
    __dump_stack lib/dump_stack.c:77 [inline]
    dump_stack+0x1c9/0x2b4 lib/dump_stack.c:113
    print_circular_bug.isra.34.cold.55+0x1bd/0x27d kernel/locking/lockdep.c:1222
    check_prev_add kernel/locking/lockdep.c:1862 [inline]
    check_prevs_add kernel/locking/lockdep.c:1975 [inline]
    validate_chain kernel/locking/lockdep.c:2416 [inline]
    __lock_acquire+0x3449/0x5020 kernel/locking/lockdep.c:3412
    lock_acquire+0x1e4/0x4f0 kernel/locking/lockdep.c:3901
    flush_workqueue+0x30a/0x1e10 kernel/workqueue.c:2655
    drain_workqueue+0x2a9/0x640 kernel/workqueue.c:2820
    destroy_workqueue+0xc6/0x9d0 kernel/workqueue.c:4155
    __alloc_workqueue_key+0xef9/0x1190 kernel/workqueue.c:4138
    bond_init+0x269/0x940 drivers/net/bonding/bond_main.c:4734
    register_netdevice+0x337/0x1100 net/core/dev.c:8410
    bond_newlink+0x49/0xa0 drivers/net/bonding/bond_netlink.c:453
    rtnl_newlink+0xef4/0x1d50 net/core/rtnetlink.c:3099
    rtnetlink_rcv_msg+0x46e/0xc30 net/core/rtnetlink.c:4711
    netlink_rcv_skb+0x172/0x440 net/netlink/af_netlink.c:2454
    rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:4729
    netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
    netlink_unicast+0x5a0/0x760 net/netlink/af_netlink.c:1343
    netlink_sendmsg+0xa18/0xfc0 net/netlink/af_netlink.c:1908
    sock_sendmsg_nosec net/socket.c:622 [inline]
    sock_sendmsg+0xd5/0x120 net/socket.c:632
    ___sys_sendmsg+0x7fd/0x930 net/socket.c:2115
    __sys_sendmsg+0x11d/0x290 net/socket.c:2153
    __do_sys_sendmsg net/socket.c:2162 [inline]
    __se_sys_sendmsg net/socket.c:2160 [inline]
    __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2160
    do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x457089
    Code: fd b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 0f 83 cb b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00
    RSP: 002b:00007f2df20a5c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 00007f2df20a66d4 RCX: 0000000000457089
    RDX: 0000000000000000 RSI: 0000000020000180 RDI: 0000000000000003
    RBP: 0000000000930140 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
    R13: 00000000004d40b8 R14: 00000000004c8ad8 R15: 0000000000000001

    Signed-off-by: Mahesh Bandewar
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Mahesh Bandewar
     
  • [ Upstream commit a2bf74f4e1b82395dad2b08d2a911d9151db71c1 ]

    When the driver probe fails, all the resources that were allocated prior
    to the failure must be freed. However, hwrm dma response memory is not
    getting freed.

    This patch fixes the problem described above.

    Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.")
    Signed-off-by: Venkat Duvvuru
    Signed-off-by: Michael Chan
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Venkat Duvvuru
     
  • [ Upstream commit 73f21c653f930f438d53eed29b5e4c65c8a0f906 ]

    The current netpoll implementation in the bnxt_en driver has problems
    that may miss TX completion events. bnxt_poll_work() in effect is
    only handling at most 1 TX packet before exiting. In addition,
    there may be in flight TX completions that ->poll() may miss even
    after we fix bnxt_poll_work() to handle all visible TX completions.
    netpoll may not call ->poll() again and HW may not generate IRQ
    because the driver does not ARM the IRQ when the budget (0 for netpoll)
    is reached.

    We fix it by handling all TX completions and to always ARM the IRQ
    when we exit ->poll() with 0 budget.

    Also, the logic to ACK the completion ring in case it is almost filled
    with TX completions need to be adjusted to take care of the 0 budget
    case, as discussed with Eric Dumazet

    Reported-by: Song Liu
    Reviewed-by: Song Liu
    Tested-by: Song Liu
    Signed-off-by: Michael Chan
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Michael Chan
     

13 Oct, 2018

35 commits

  • Greg Kroah-Hartman
     
  • commit c8291988806407e02a01b4b15b4504eafbcc04e0 upstream.

    Length of WMI scan message was not calculated correctly. The allocated
    buffer was smaller than what we expected. So WMI message corrupted
    skb_info, which is at the end of skb->data. This fix takes TLV header
    into account even if the element is zero-length.

    Crash log:
    [49.629986] Unhandled kernel unaligned access[#1]:
    [49.634932] CPU: 0 PID: 1176 Comm: logd Not tainted 4.4.60 #180
    [49.641040] task: 83051460 ti: 8329c000 task.ti: 8329c000
    [49.646608] $ 0 : 00000000 00000001 80984a80 00000000
    [49.652038] $ 4 : 45259e89 8046d484 8046df30 8024ba70
    [49.657468] $ 8 : 00000000 804cc4c0 00000001 20306320
    [49.662898] $12 : 33322037 000110f2 00000000 31203930
    [49.668327] $16 : 82792b40 80984a80 00000001 804207fc
    [49.673757] $20 : 00000000 0000012c 00000040 80470000
    [49.679186] $24 : 00000000 8024af7c
    [49.684617] $28 : 8329c000 8329db88 00000001 802c58d0
    [49.690046] Hi : 00000000
    [49.693022] Lo : 453c0000
    [49.696013] epc : 800efae4 put_page+0x0/0x58
    [49.700615] ra : 802c58d0 skb_release_data+0x148/0x1d4
    [49.706184] Status: 1000fc03 KERNEL EXL IE
    [49.710531] Cause : 00800010 (ExcCode 04)
    [49.714669] BadVA : 45259e89
    [49.717644] PrId : 00019374 (MIPS 24Kc)

    Signed-off-by: Zhi Chen
    Signed-off-by: Kalle Valo
    Cc: Brian Norris
    Signed-off-by: Greg Kroah-Hartman

    Zhi Chen
     
  • commit d9e427f6ab8142d6868eb719e6a7851aafea56b6 upstream.

    commit c7cdff0e8647 ("virtio_balloon: fix deadlock on OOM")
    changed code to increment vb->num_pfns before call to
    set_page_pfns(), which used to happen only after.

    This patch fixes boot hang for me on ppc64le KVM guests.

    Fixes: c7cdff0e8647 ("virtio_balloon: fix deadlock on OOM")
    Cc: Michael S. Tsirkin
    Cc: Tetsuo Handa
    Cc: Michal Hocko
    Cc: Wei Wang
    Cc: stable@vger.kernel.org
    Signed-off-by: Jan Stancek
    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Jan Stancek
     
  • commit c7cdff0e864713a089d7cb3a2b1136ba9a54881a upstream.

    fill_balloon doing memory allocations under balloon_lock
    can cause a deadlock when leak_balloon is called from
    virtballoon_oom_notify and tries to take same lock.

    To fix, split page allocation and enqueue and do allocations outside the lock.

    Here's a detailed analysis of the deadlock by Tetsuo Handa:

    In leak_balloon(), mutex_lock(&vb->balloon_lock) is called in order to
    serialize against fill_balloon(). But in fill_balloon(),
    alloc_page(GFP_HIGHUSER[_MOVABLE] | __GFP_NOMEMALLOC | __GFP_NORETRY) is
    called with vb->balloon_lock mutex held. Since GFP_HIGHUSER[_MOVABLE]
    implies __GFP_DIRECT_RECLAIM | __GFP_IO | __GFP_FS, despite __GFP_NORETRY
    is specified, this allocation attempt might indirectly depend on somebody
    else's __GFP_DIRECT_RECLAIM memory allocation. And such indirect
    __GFP_DIRECT_RECLAIM memory allocation might call leak_balloon() via
    virtballoon_oom_notify() via blocking_notifier_call_chain() callback via
    out_of_memory() when it reached __alloc_pages_may_oom() and held oom_lock
    mutex. Since vb->balloon_lock mutex is already held by fill_balloon(), it
    will cause OOM lockup.

    Thread1 Thread2
    fill_balloon()
    takes a balloon_lock
    balloon_page_enqueue()
    alloc_page(GFP_HIGHUSER_MOVABLE)
    direct reclaim (__GFP_FS context) takes a fs lock
    waits for that fs lock alloc_page(GFP_NOFS)
    __alloc_pages_may_oom()
    takes the oom_lock
    out_of_memory()
    blocking_notifier_call_chain()
    leak_balloon()
    tries to take that balloon_lock and deadlocks

    Reported-by: Tetsuo Handa
    Cc: Michal Hocko
    Cc: Wei Wang
    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Michael S. Tsirkin
     
  • commit f394ad28feffbeebab77c8bf9a203bd49b957c9a upstream.

    Currently, rds_ib_conn_alloc() calls rds_ib_recv_alloc_caches()
    without passing along the gfp_t flag. But rds_ib_recv_alloc_caches()
    and rds_ib_recv_alloc_cache() should take a gfp_t parameter so that
    rds_ib_recv_alloc_cache() can call alloc_percpu_gfp() using the
    correct flag instead of calling alloc_percpu().

    Signed-off-by: Ka-Cheong Poon
    Acked-by: Santosh Shilimkar
    Signed-off-by: David S. Miller
    Cc: Håkon Bugge
    Signed-off-by: Greg Kroah-Hartman

    Ka-Cheong Poon
     
  • commit 37f31b6ca4311b94d985fb398a72e5399ad57925 upstream.

    The requested device name can be NULL or an empty string.
    Check for that and refuse to continue. UBIFS has to do this manually
    since we cannot use mount_bdev(), which checks for this condition.

    Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")
    Reported-by: syzbot+38bd0f7865e5c6379280@syzkaller.appspotmail.com
    Signed-off-by: Richard Weinberger
    Signed-off-by: Greg Kroah-Hartman

    Richard Weinberger
     
  • commit 5fe23f262e0548ca7f19fb79f89059a60d087d22 upstream.

    There is a race condition between ucma_close() and ucma_resolve_ip():

    CPU0 CPU1
    ucma_resolve_ip(): ucma_close():

    ctx = ucma_get_ctx(file, cmd.id);

    list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
    mutex_lock(&mut);
    idr_remove(&ctx_idr, ctx->id);
    mutex_unlock(&mut);
    ...
    mutex_lock(&mut);
    if (!ctx->closing) {
    mutex_unlock(&mut);
    rdma_destroy_id(ctx->cm_id);
    ...
    ucma_free_ctx(ctx);

    ret = rdma_resolve_addr();
    ucma_put_ctx(ctx);

    Before idr_remove(), ucma_get_ctx() could still find the ctx
    and after rdma_destroy_id(), rdma_resolve_addr() may still
    access id_priv pointer. Also, ucma_put_ctx() may use ctx after
    ucma_free_ctx() too.

    ucma_close() should call ucma_put_ctx() too which tests the
    refcnt and waits for the last one releasing it. The similar
    pattern is already used by ucma_destroy_id().

    Reported-and-tested-by: syzbot+da2591e115d57a9cbb8b@syzkaller.appspotmail.com
    Reported-by: syzbot+cfe3c1e8ef634ba8964b@syzkaller.appspotmail.com
    Cc: Jason Gunthorpe
    Cc: Doug Ledford
    Cc: Leon Romanovsky
    Signed-off-by: Cong Wang
    Reviewed-by: Leon Romanovsky
    Signed-off-by: Doug Ledford
    Signed-off-by: Greg Kroah-Hartman

    Cong Wang
     
  • commit d3f07c049dab1a3f1740f476afd3d5e5b738c21c upstream.

    syzbot found the following crash on:

    HEAD commit: d9bd94c0bcaa Add linux-next specific files for 20180801
    git tree: linux-next
    console output: https://syzkaller.appspot.com/x/log.txt?x=1001189c400000
    kernel config: https://syzkaller.appspot.com/x/.config?x=cc8964ea4d04518c
    dashboard link: https://syzkaller.appspot.com/bug?extid=c966a82db0b14aa37e81
    compiler: gcc (GCC) 8.0.1 20180413 (experimental)

    Unfortunately, I don't have any reproducer for this crash yet.

    IMPORTANT: if you fix the bug, please add the following tag to the commit:
    Reported-by: syzbot+c966a82db0b14aa37e81@syzkaller.appspotmail.com

    loop7: rw=12288, want=8200, limit=20
    netlink: 65342 bytes leftover after parsing attributes in process `syz-executor4'.
    openvswitch: netlink: Message has 8 unknown bytes.
    kasan: CONFIG_KASAN_INLINE enabled
    kasan: GPF could be caused by NULL-ptr deref or user memory access
    general protection fault: 0000 [#1] SMP KASAN
    CPU: 1 PID: 7615 Comm: syz-executor7 Not tainted 4.18.0-rc7-next-20180801+ #29
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    RIP: 0010:__read_once_size include/linux/compiler.h:188 [inline]
    RIP: 0010:compound_head include/linux/page-flags.h:142 [inline]
    RIP: 0010:PageLocked include/linux/page-flags.h:272 [inline]
    RIP: 0010:f2fs_put_page fs/f2fs/f2fs.h:2011 [inline]
    RIP: 0010:validate_checkpoint+0x66d/0xec0 fs/f2fs/checkpoint.c:835
    Code: e8 58 05 7f fe 4c 8d 6b 80 4d 8d 74 24 08 48 b8 00 00 00 00 00 fc ff df 4c 89 ea 48 c1 ea 03 c6 04 02 00 4c 89 f2 48 c1 ea 03 3c 02 00 0f 85 f4 06 00 00 4c 89 ea 4d 8b 7c 24 08 48 b8 00 00
    RSP: 0018:ffff8801937cebe8 EFLAGS: 00010246
    RAX: dffffc0000000000 RBX: ffff8801937cef30 RCX: ffffc90006035000
    RDX: 0000000000000000 RSI: ffffffff82fd9658 RDI: 0000000000000005
    RBP: ffff8801937cef58 R08: ffff8801ab254700 R09: fffff94000d9e026
    R10: fffff94000d9e026 R11: ffffea0006cf0137 R12: fffffffffffffffb
    R13: ffff8801937ceeb0 R14: 0000000000000003 R15: ffff880193419b40
    FS: 00007f36a61d5700(0000) GS:ffff8801db100000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fc04ff93000 CR3: 00000001d0562000 CR4: 00000000001426e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    f2fs_get_valid_checkpoint+0x436/0x1ec0 fs/f2fs/checkpoint.c:860
    f2fs_fill_super+0x2d42/0x8110 fs/f2fs/super.c:2883
    mount_bdev+0x314/0x3e0 fs/super.c:1344
    f2fs_mount+0x3c/0x50 fs/f2fs/super.c:3133
    legacy_get_tree+0x131/0x460 fs/fs_context.c:729
    vfs_get_tree+0x1cb/0x5c0 fs/super.c:1743
    do_new_mount fs/namespace.c:2603 [inline]
    do_mount+0x6f2/0x1e20 fs/namespace.c:2927
    ksys_mount+0x12d/0x140 fs/namespace.c:3143
    __do_sys_mount fs/namespace.c:3157 [inline]
    __se_sys_mount fs/namespace.c:3154 [inline]
    __x64_sys_mount+0xbe/0x150 fs/namespace.c:3154
    do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x45943a
    Code: b8 a6 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 bd 8a fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 49 89 ca b8 a5 00 00 00 0f 05 3d 01 f0 ff ff 0f 83 9a 8a fb ff c3 66 0f 1f 84 00 00 00 00 00
    RSP: 002b:00007f36a61d4a88 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5
    RAX: ffffffffffffffda RBX: 00007f36a61d4b30 RCX: 000000000045943a
    RDX: 00007f36a61d4ad0 RSI: 0000000020000100 RDI: 00007f36a61d4af0
    RBP: 0000000020000100 R08: 00007f36a61d4b30 R09: 00007f36a61d4ad0
    R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000013
    R13: 0000000000000000 R14: 00000000004c8ea0 R15: 0000000000000000
    Modules linked in:
    Dumping ftrace buffer:
    (ftrace buffer empty)
    ---[ end trace bd8550c129352286 ]---
    RIP: 0010:__read_once_size include/linux/compiler.h:188 [inline]
    RIP: 0010:compound_head include/linux/page-flags.h:142 [inline]
    RIP: 0010:PageLocked include/linux/page-flags.h:272 [inline]
    RIP: 0010:f2fs_put_page fs/f2fs/f2fs.h:2011 [inline]
    RIP: 0010:validate_checkpoint+0x66d/0xec0 fs/f2fs/checkpoint.c:835
    Code: e8 58 05 7f fe 4c 8d 6b 80 4d 8d 74 24 08 48 b8 00 00 00 00 00 fc ff df 4c 89 ea 48 c1 ea 03 c6 04 02 00 4c 89 f2 48 c1 ea 03 3c 02 00 0f 85 f4 06 00 00 4c 89 ea 4d 8b 7c 24 08 48 b8 00 00
    RSP: 0018:ffff8801937cebe8 EFLAGS: 00010246
    RAX: dffffc0000000000 RBX: ffff8801937cef30 RCX: ffffc90006035000
    RDX: 0000000000000000 RSI: ffffffff82fd9658 RDI: 0000000000000005
    netlink: 65342 bytes leftover after parsing attributes in process `syz-executor4'.
    RBP: ffff8801937cef58 R08: ffff8801ab254700 R09: fffff94000d9e026
    openvswitch: netlink: Message has 8 unknown bytes.
    R10: fffff94000d9e026 R11: ffffea0006cf0137 R12: fffffffffffffffb
    R13: ffff8801937ceeb0 R14: 0000000000000003 R15: ffff880193419b40
    FS: 00007f36a61d5700(0000) GS:ffff8801db100000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00007fc04ff93000 CR3: 00000001d0562000 CR4: 00000000001426e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

    In validate_checkpoint(), if we failed to call get_checkpoint_version(), we
    will pass returned invalid page pointer into f2fs_put_page, cause accessing
    invalid memory, this patch tries to handle error path correctly to fix this
    issue.

    Signed-off-by: Chao Yu
    Signed-off-by: Greg Kroah-Hartman

    Signed-off-by: Jaegeuk Kim

    Chao Yu
     
  • commit 06c3f2aa9fc68e7f3fe3d83e7569d2a2801d9f99 upstream.

    So that it can be used more widely, like in the next patch, when it will
    be used to fix a bug in 'perf test' handling of dirent.d_type ==
    DT_UNKNOWN.

    Signed-off-by: Jiri Olsa
    Cc: David Ahern
    Cc: Michael Petlan
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20171206174535.25380-1-jolsa@kernel.org
    [ Split from a larger patch, removed needless includes in path.h ]
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Ignat Korchagin
    Signed-off-by: Greg Kroah-Hartman

    Jiri Olsa
     
  • commit add92a817e60e308a419693413a38d9d1e663aff upstream.

    Update PCI Id in "cpl_rx_phys_dsgl" header. In case pci_chan_id and
    tx_chan_id are not derived from same queue, H/W can send request
    completion indication before completing DMA Transfer.

    Herbert, It would be good if fix can be merge to stable tree.
    For 4.14 kernel, It requires some update to avoid mege conficts.

    Cc:
    Signed-off-by: Harsh Jain
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Harsh Jain
     
  • commit c58a584f05e35d1d4342923cd7aac07d9c3d3d16 upstream.

    Per ARC TLS ABI, r25 is designated TP (thread pointer register).
    However so far kernel didn't do any special treatment, like setting up
    usermode r25, even for CLONE_SETTLS. We instead relied on libc runtime
    to do this, in say clone libc wrapper [1]. This was deliberate to keep
    kernel ABI agnostic (userspace could potentially change TP, specially
    for different ARC ISA say ARCompact vs. ARCv2 with different spare
    registers etc)

    However userspace setting up r25, after clone syscall opens a race, if
    child is not scheduled and gets a signal instead. It starts off in
    userspace not in clone but in a signal handler and anything TP sepcific
    there such as pthread_self() fails which showed up with uClibc
    testsuite nptl/tst-kill6 [2]

    Fix this by having kernel populate r25 to TP value. So this locks in
    ABI, but it was not going to change anyways, and fwiw is same for both
    ARCompact (arc700 core) and ARCvs (HS3x cores)

    [1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/arc/clone.S
    [2] https://github.com/wbx-github/uclibc-ng-test/blob/master/test/nptl/tst-kill6.c

    Fixes: ARC STAR 9001378481
    Cc: stable@vger.kernel.org
    Reported-by: Nikita Sobolev
    Signed-off-by: Vineet Gupta
    Signed-off-by: Greg Kroah-Hartman

    Vineet Gupta
     
  • commit b45ba4a51cde29b2939365ef0c07ad34c8321789 upstream.

    Commit 51c3c62b58b3 ("powerpc: Avoid code patching freed init
    sections") accesses 'init_mem_is_free' flag too early, before the
    kernel is relocated. This provokes early boot failure (before the
    console is active).

    As it is not necessary to do this verification that early, this
    patch moves the test into patch_instruction() instead of
    __patch_instruction().

    This modification also has the advantage of avoiding unnecessary
    remappings.

    Fixes: 51c3c62b58b3 ("powerpc: Avoid code patching freed init sections")
    Cc: stable@vger.kernel.org # 4.13+
    Signed-off-by: Christophe Leroy
    Signed-off-by: Michael Ellerman
    Signed-off-by: Greg Kroah-Hartman

    Christophe Leroy
     
  • commit 51c3c62b58b357e8d35e4cc32f7b4ec907426fe3 upstream.

    This stops us from doing code patching in init sections after they've
    been freed.

    In this chain:
    kvm_guest_init() ->
    kvm_use_magic_page() ->
    fault_in_pages_readable() ->
    __get_user() ->
    __get_user_nocheck() ->
    barrier_nospec();

    We have a code patching location at barrier_nospec() and
    kvm_guest_init() is an init function. This whole chain gets inlined,
    so when we free the init section (hence kvm_guest_init()), this code
    goes away and hence should no longer be patched.

    We seen this as userspace memory corruption when using a memory
    checker while doing partition migration testing on powervm (this
    starts the code patching post migration via
    /sys/kernel/mobility/migration). In theory, it could also happen when
    using /sys/kernel/debug/powerpc/barrier_nospec.

    Cc: stable@vger.kernel.org # 4.13+
    Signed-off-by: Michael Neuling
    Reviewed-by: Nicholas Piggin
    Reviewed-by: Christophe Leroy
    Signed-off-by: Michael Ellerman
    Signed-off-by: Greg Kroah-Hartman

    Michael Neuling
     
  • commit 8cf4c05712f04a405f0dacebcca8f042b391694a upstream.

    patch_instruction() uses almost the same sequence as
    __patch_instruction()

    This patch refactor it so that patch_instruction() uses
    __patch_instruction() instead of duplicating code.

    Signed-off-by: Christophe Leroy
    Acked-by: Balbir Singh
    Signed-off-by: Michael Ellerman
    Signed-off-by: Greg Kroah-Hartman

    Christophe Leroy
     
  • commit cf25809bec2c7df4b45df5b2196845d9a4a3c89b upstream.

    If there are errors during initial controller create, the transport
    will teardown the partially initialized controller struct and free
    the ctlr memory. Trouble is - most of those errors can occur due
    to asynchronous events happening such io timeouts and subsystem
    connectivity failures. Those failures invoke async workq items to
    reset the controller and attempt reconnect. Those may be in progress
    as the main thread frees the ctrl memory, resulting in NULL ptr oops.

    Prevent this from happening by having the main ctrl failure thread
    changing state to DELETING followed by synchronously cancelling any
    pending queued work item. The change of state will prevent the
    scheduling of resets or reconnect events.

    Signed-off-by: James Smart
    Signed-off-by: Keith Busch
    Signed-off-by: Jens Axboe
    Signed-off-by: Amit Pundir
    Signed-off-by: Greg Kroah-Hartman

    James Smart
     
  • commit 50e79e25250bf928369996277e85b00536b380c7 upstream.

    If device gone during chip reset, ar->normal_mode_fw.board is not
    initialized, but ath10k_debug_print_hwfw_info() will try to access its
    member, which will cause 'kernel NULL pointer' issue. This was found
    using a faulty device (pci link went down sometimes) in a random
    insmod/rmmod/other-op test.
    To fix it, check ar->normal_mode_fw.board before accessing the member.

    pci 0000:02:00.0: BAR 0: assigned [mem 0xf7400000-0xf75fffff 64bit]
    ath10k_pci 0000:02:00.0: enabling device (0000 -> 0002)
    ath10k_pci 0000:02:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
    ath10k_pci 0000:02:00.0: failed to read device register, device is gone
    ath10k_pci 0000:02:00.0: failed to wait for target init: -5
    ath10k_pci 0000:02:00.0: failed to warm reset: -5
    ath10k_pci 0000:02:00.0: firmware crashed during chip reset
    ath10k_pci 0000:02:00.0: firmware crashed! (uuid 5d018951-b8e1-404a-8fde-923078b4423a)
    ath10k_pci 0000:02:00.0: (null) target 0x00000000 chip_id 0x00340aff sub 0000:0000
    ath10k_pci 0000:02:00.0: kconfig debug 1 debugfs 1 tracing 1 dfs 1 testmode 1
    ath10k_pci 0000:02:00.0: firmware ver api 0 features crc32 00000000
    ...
    BUG: unable to handle kernel NULL pointer dereference at 00000004
    ...
    Call Trace:
    [] ath10k_print_driver_info+0x12/0x20 [ath10k_core]
    [] ath10k_pci_fw_crashed_dump+0x6d/0x4d0 [ath10k_pci]
    [] ? ath10k_pci_sleep.part.19+0x57/0xc0 [ath10k_pci]
    [] ath10k_pci_hif_power_up+0x14e/0x1b0 [ath10k_pci]
    [] ? do_page_fault+0xb/0x10
    [] ath10k_core_register_work+0x24/0x840 [ath10k_core]
    [] ? netlbl_unlhsh_remove+0x178/0x410
    [] ? __do_page_fault+0x480/0x480
    [] process_one_work+0x114/0x3e0
    [] worker_thread+0x37/0x4a0
    [] kthread+0xa4/0xc0
    [] ? create_worker+0x180/0x180
    [] ? kthread_park+0x50/0x50
    [] ret_from_fork+0x1b/0x28
    Code: 78 80 b8 50 09 00 00 00 75 5d 8d 75 94 c7 44 24 08 aa d7 52 fb c7 44 24 04 64 00 00 00
    89 34 24 e8 82 52 e2 c5 8b 83 dc 08 00 00 50 04 8b 08 31 c0 e8 20 57 e3 c5 89 44 24 10 8b 83 58 09 00
    EIP: []-
    ath10k_debug_print_board_info+0x34/0xb0 [ath10k_core]
    SS:ESP 0068:f4921d90
    CR2: 0000000000000004

    Signed-off-by: Yu Wang
    Signed-off-by: Kalle Valo
    [AmitP: Minor rebasing for 4.14.y and 4.9.y]
    Signed-off-by: Amit Pundir
    Signed-off-by: Greg Kroah-Hartman

    Yu Wang
     
  • commit 9ef0f58ed7b4a55da4a64641d538e0d9e46579ac upstream.

    The skb may be freed in tx completion context before
    trace_ath10k_wmi_cmd is called. This can be easily captured when
    KASAN(Kernel Address Sanitizer) is enabled. The fix is to move
    trace_ath10k_wmi_cmd before the send operation. As the ret has no
    meaning in trace_ath10k_wmi_cmd then, so remove this parameter too.

    Signed-off-by: Carl Huang
    Tested-by: Brian Norris
    Reviewed-by: Brian Norris
    Signed-off-by: Kalle Valo
    Signed-off-by: Amit Pundir
    Signed-off-by: Greg Kroah-Hartman

    Carl Huang
     
  • commit b7a313d84e853049062011d78cb04b6decd12f5c upstream.

    The gcc 8 compiler won't compile the python extension code with the
    following errors (one example):

    python.c:830:15: error: cast between incompatible function types from \
    ‘PyObject * (*)(struct pyrf_evsel *, PyObject *, PyObject *)’ \
    uct _object * (*)(struct pyrf_evsel *, struct _object *, struct _object *)’} to \
    ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _objeuct \
    _object *)’} [-Werror=cast-function-type]
    .ml_meth = (PyCFunction)pyrf_evsel__open,

    The problem with the PyMethodDef::ml_meth callback is that its type is
    determined based on the PyMethodDef::ml_flags value, which we set as
    METH_VARARGS | METH_KEYWORDS.

    That indicates that the callback is expecting an extra PyObject* arg, and is
    actually PyCFunctionWithKeywords type, but the base PyMethodDef::ml_meth type
    stays PyCFunction.

    Previous gccs did not find this, gcc8 now does. Fixing this by silencing this
    warning for python.c build.

    Commiter notes:

    Do not do that for CC=clang, as it breaks the build in some clang
    versions, like the ones in fedora up to fedora27:

    fedora:25:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
    fedora:26:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
    fedora:27:error: unknown warning option '-Wno-cast-function-type'; did you mean '-Wno-bad-function-cast'? [-Werror,-Wunknown-warning-option]
    #

    those have:

    clang version 3.9.1 (tags/RELEASE_391/final)

    The one in rawhide accepts that:

    clang version 6.0.0 (tags/RELEASE_600/final)

    Signed-off-by: Jiri Olsa
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: David Ahern
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Sergey Senozhatsky
    Link: http://lkml.kernel.org/r/20180319082902.4518-2-jolsa@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Ignat Korchagin
    Signed-off-by: Greg Kroah-Hartman

    Jiri Olsa
     
  • commit 6810158d526e483868e519befff407b91e76b3db upstream.

    We were using a local buffer with an arbitrary size, that would have to
    get increased to avoid truncation as warned by gcc 8:

    util/annotate.c: In function 'symbol__disassemble':
    util/annotate.c:1488:4: error: '%s' directive output may be truncated writing up to 4095 bytes into a region of size between 3966 and 8086 [-Werror=format-truncation=]
    "%s %s%s --start-address=0x%016" PRIx64
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    util/annotate.c:1498:20:
    symfs_filename, symfs_filename);
    ~~~~~~~~~~~~~~
    util/annotate.c:1490:50: note: format string is defined here
    " -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
    ^~
    In file included from /usr/include/stdio.h:861,
    from util/color.h:5,
    from util/sort.h:8,
    from util/annotate.c:14:
    /usr/include/bits/stdio2.h:67:10: note: '__builtin___snprintf_chk' output 116 or more bytes (assuming 8331) into a destination of size 8192
    return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    __bos (__s), __fmt, __va_arg_pack ());
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    So switch to asprintf, that will make sure enough space is available.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jin Yao
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: https://lkml.kernel.org/n/tip-qagoy2dmbjpc9gdnaj0r3mml@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Ignat Korchagin
    Signed-off-by: Greg Kroah-Hartman

    Arnaldo Carvalho de Melo
     
  • commit 8894891446c9380709451b99ab45c5c53adfd2fc upstream.

    On systems with OF_IMAP_OLDWORLD_MAC set in of_irq_workarounds, the
    devicetree interrupt parsing code is different, causing unit tests of
    devicetree interrupt nodes to fail. Due to a bug in unittest code, which
    tries to dereference an uninitialized pointer, this results in a crash.

    OF: /testcase-data/phandle-tests/consumer-a: arguments longer than property
    Unable to handle kernel paging request for data at address 0x00bc616e
    Faulting instruction address: 0xc08e9468
    Oops: Kernel access of bad area, sig: 11 [#1]
    BE PREEMPT PowerMac
    Modules linked in:
    CPU: 0 PID: 1 Comm: swapper Not tainted 4.14.72-rc1-yocto-standard+ #1
    task: cf8e0000 task.stack: cf8da000
    NIP: c08e9468 LR: c08ea5bc CTR: c08ea5ac
    REGS: cf8dbb50 TRAP: 0300 Not tainted (4.14.72-rc1-yocto-standard+)
    MSR: 00001032 CR: 82004044 XER: 00000000
    DAR: 00bc616e DSISR: 40000000
    GPR00: c08ea5bc cf8dbc00 cf8e0000 c13ca517 c13ca517 c13ca8a0 00000066 00000002
    GPR08: 00000063 00bc614e c0b05865 000affff 82004048 00000000 c00047f0 00000000
    GPR16: c0a80000 c0a9cc34 c13ca517 c0ad1134 05ffffff 000affff c0b05860 c0abeef8
    GPR24: cecec278 cecec278 c0a8c4d0 c0a885e0 c13ca8a0 05ffffff c13ca8a0 c13ca517

    NIP [c08e9468] device_node_gen_full_name+0x30/0x15c
    LR [c08ea5bc] device_node_string+0x190/0x3c8
    Call Trace:
    [cf8dbc00] [c007f670] trace_hardirqs_on_caller+0x118/0x1fc (unreliable)
    [cf8dbc40] [c08ea5bc] device_node_string+0x190/0x3c8
    [cf8dbcb0] [c08eb794] pointer+0x25c/0x4d0
    [cf8dbd00] [c08ebcbc] vsnprintf+0x2b4/0x5ec
    [cf8dbd60] [c08ec00c] vscnprintf+0x18/0x48
    [cf8dbd70] [c008e268] vprintk_store+0x4c/0x22c
    [cf8dbda0] [c008ecac] vprintk_emit+0x94/0x130
    [cf8dbdd0] [c008ff54] printk+0x5c/0x6c
    [cf8dbe10] [c0b8ddd4] of_unittest+0x2220/0x26f8
    [cf8dbea0] [c0004434] do_one_initcall+0x4c/0x184
    [cf8dbf00] [c0b4534c] kernel_init_freeable+0x13c/0x1d8
    [cf8dbf30] [c0004814] kernel_init+0x24/0x118
    [cf8dbf40] [c0013398] ret_from_kernel_thread+0x5c/0x64

    The problem was observed when running a qemu test for the g3beige machine
    with devicetree unittests enabled.

    Disable interrupt node tests on affected systems to avoid both false
    unittest failures and the crash.

    With this patch in place, unittest on the affected system passes with
    the following message.

    dt-test ### end of unittest - 144 passed, 0 failed

    Fixes: 53a42093d96ef ("of: Add device tree selftests")
    Signed-off-by: Guenter Roeck
    Reviewed-by: Frank Rowand
    Signed-off-by: Rob Herring
    Signed-off-by: Greg Kroah-Hartman

    Guenter Roeck
     
  • commit fe32416790093b31364c08395727de17ec96ace1 upstream.

    In case of tty_ldisc_reinit() failure, tty->count should be decremented
    back, otherwise we will never release_tty().
    Tetsuo reported that it fixes noisy warnings on tty release like:
    pts pts4033: tty_release: tty->count(10529) != (#fd's(7) + #kopen's(0))

    Fixes: commit 892d1fa7eaae ("tty: Destroy ldisc instance on hangup")

    Cc: stable@vger.kernel.org # v4.6+
    Cc: Greg Kroah-Hartman
    Cc: Jiri Slaby
    Reviewed-by: Jiri Slaby
    Tested-by: Jiri Slaby
    Tested-by: Mark Rutland
    Tested-by: Tetsuo Handa
    Signed-off-by: Dmitry Safonov
    Signed-off-by: Greg Kroah-Hartman

    Dmitry Safonov
     
  • commit f2924d4b16ae138c2de6a0e73f526fb638330858 upstream.

    When the ACM TTY port is disconnected, the URBs it uses must be killed, and
    then the buffers must be freed. Unfortunately a previous refactor removed
    the code freeing the buffers because it looked extremely similar to the
    code killing the URBs.

    As a result, there were many new leaks for each plug/unplug cycle of a
    CDC-ACM device, that were detected by kmemleak.

    Restore the missing code, and the memory leak is removed.

    Fixes: ba8c931ded8d ("cdc-acm: refactor killing urbs")
    Signed-off-by: Romain Izard
    Acked-by: Oliver Neukum
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Romain Izard
     
  • commit f5fad711c06e652f90f581fc7c2caee327c33d31 upstream.

    Add device-id for the Motorola Tetra radio MTP6550.

    Bus 001 Device 004: ID 0cad:9012 Motorola CGISS
    Device Descriptor:
    bLength 18
    bDescriptorType 1
    bcdUSB 2.00
    bDeviceClass 0 (Defined at Interface level)
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 64
    idVendor 0x0cad Motorola CGISS
    idProduct 0x9012
    bcdDevice 24.16
    iManufacturer 1 Motorola Solutions, Inc.
    iProduct 2 TETRA PEI interface
    iSerial 0
    bNumConfigurations 1
    Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 55
    bNumInterfaces 2
    bConfigurationValue 1
    iConfiguration 3 Generic Serial config
    bmAttributes 0x80
    (Bus Powered)
    MaxPower 500mA
    Interface Descriptor:
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 0
    bAlternateSetting 0
    bNumEndpoints 2
    bInterfaceClass 255 Vendor Specific Class
    bInterfaceSubClass 0
    bInterfaceProtocol 0
    iInterface 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x81 EP 1 IN
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0200 1x 512 bytes
    bInterval 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x01 EP 1 OUT
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0200 1x 512 bytes
    Interface Descriptor:
    bLength 9
    bDescriptorType 4
    bInterfaceNumber 1
    bAlternateSetting 0
    bNumEndpoints 2
    bInterfaceClass 255 Vendor Specific Class
    bInterfaceSubClass 0
    bInterfaceProtocol 0
    iInterface 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x82 EP 2 IN
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0200 1x 512 bytes
    bInterval 0
    Endpoint Descriptor:
    bLength 7
    bDescriptorType 5
    bEndpointAddress 0x02 EP 2 OUT
    bmAttributes 2
    Transfer Type Bulk
    Synch Type None
    Usage Type Data
    wMaxPacketSize 0x0200 1x 512 bytes
    bInterval 0
    Device Qualifier (for other device speed):
    bLength 10
    bDescriptorType 6
    bcdUSB 2.00
    bDeviceClass 0 (Defined at Interface level)
    bDeviceSubClass 0
    bDeviceProtocol 0
    bMaxPacketSize0 64
    bNumConfigurations 1
    Device Status: 0x0000
    (Bus Powered)

    Reported-by: Hans Hult
    Cc: stable
    Signed-off-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Johan Hovold
     
  • commit 555df5820e733cded7eb8d0bf78b2a791be51d75 upstream.

    Give USB3 devices a better chance to enumerate at USB3 speeds if
    they are connected to a suspended host.
    Porting from "671ffdff5b13 xhci: resume USB 3 roothub first"

    Cc:
    Signed-off-by: Chunfeng Yun
    Signed-off-by: Mathias Nyman
    Signed-off-by: Greg Kroah-Hartman

    Chunfeng Yun
     
  • commit ffe84e01bb1b38c7eb9c6b6da127a6c136d251df upstream.

    The workaround for missing CAS bit is also needed for xHC on Intel
    sunrisepoint PCH. For more details see:

    Intel 100/c230 series PCH specification update Doc #332692-006 Errata #8

    Cc:
    Signed-off-by: Mathias Nyman
    Signed-off-by: Greg Kroah-Hartman

    Mathias Nyman
     
  • commit 5d07384a666d4b2f781dc056bfeec2c27fbdf383 upstream.

    A reload of the cache's DM table is needed during resize because
    otherwise a crash will occur when attempting to access smq policy
    entries associated with the portion of the cache that was recently
    extended.

    The reason is cache-size based data structures in the policy will not be
    resized, the only way to safely extend the cache is to allow for a
    proper cache policy initialization that occurs when the cache table is
    loaded. For example the smq policy's space_init(), init_allocator(),
    calc_hotspot_params() must be sized based on the extended cache size.

    The fix for this is to disallow cache resizes of this pattern:
    1) suspend "cache" target's device
    2) resize the fast device used for the cache
    3) resume "cache" target's device

    Instead, the last step must be a full reload of the cache's DM table.

    Fixes: 66a636356 ("dm cache: add stochastic-multi-queue (smq) policy")
    Cc: stable@vger.kernel.org
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Mike Snitzer
     
  • commit 4561ffca88c546f96367f94b8f1e4715a9c62314 upstream.

    Commit fd2fa9541 ("dm cache metadata: save in-core policy_hint_size to
    on-disk superblock") enabled previously written policy hints to be
    used after a cache is reactivated. But in doing so the cache
    metadata's hint array was left exposed to out of bounds access because
    on resize the metadata's on-disk hint array wasn't ever extended.

    Fix this by ignoring that there are no on-disk hints associated with the
    newly added cache blocks. An expanded on-disk hint array is later
    rewritten upon the next clean shutdown of the cache.

    Fixes: fd2fa9541 ("dm cache metadata: save in-core policy_hint_size to on-disk superblock")
    Cc: stable@vger.kernel.org
    Signed-off-by: Joe Thornber
    Signed-off-by: Mike Snitzer
    Signed-off-by: Greg Kroah-Hartman

    Joe Thornber
     
  • commit 69e445ab8b66a9f30519842ef18be555d3ee9b51 upstream.

    If __device_suspend() runs asynchronously (in which case the device
    passed to it is in dpm_suspended_list at that point) and it returns
    early on an error or pending wakeup, and the power.direct_complete
    flag has been set for the device already, the subsequent
    device_resume() will be confused by that and it will call
    pm_runtime_enable() incorrectly, as runtime PM has not been
    disabled for the device by __device_suspend().

    To avoid that, clear power.direct_complete if __device_suspend()
    is not going to disable runtime PM for the device before returning.

    Fixes: aae4518b3124 (PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily)
    Reported-by: Al Cooper
    Tested-by: Al Cooper
    Reviewed-by: Ulf Hansson
    Cc: 3.16+ # 3.16+
    Signed-off-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     
  • commit 211710ca74adf790b46ab3867fcce8047b573cd1 upstream.

    key->sta is only valid after ieee80211_key_link, which is called later
    in this function. Because of that, the IEEE80211_KEY_FLAG_RX_MGMT is
    never set when management frame protection is enabled.

    Fixes: e548c49e6dc6b ("mac80211: add key flag for management keys")
    Cc: stable@vger.kernel.org
    Signed-off-by: Felix Fietkau
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     
  • commit 083874549fdfefa629dfa752785e20427dde1511 upstream.

    On 38+ Intel-based ASUS products, the NVIDIA GPU becomes unusable after S3
    suspend/resume. The affected products include multiple generations of
    NVIDIA GPUs and Intel SoCs. After resume, nouveau logs many errors such
    as:

    fifo: fault 00 [READ] at 0000005555555000 engine 00 [GR] client 04
    [HUB/FE] reason 4a [] on channel -1 [007fa91000 unknown]
    DRM: failed to idle channel 0 [DRM]

    Similarly, the NVIDIA proprietary driver also fails after resume (black
    screen, 100% CPU usage in Xorg process). We shipped a sample to NVIDIA for
    diagnosis, and their response indicated that it's a problem with the parent
    PCI bridge (on the Intel SoC), not the GPU.

    Runtime suspend/resume works fine, only S3 suspend is affected.

    We found a workaround: on resume, rewrite the Intel PCI bridge
    'Prefetchable Base Upper 32 Bits' register (PCI_PREF_BASE_UPPER32). In the
    cases that I checked, this register has value 0 and we just have to rewrite
    that value.

    Linux already saves and restores PCI config space during suspend/resume,
    but this register was being skipped because upon resume, it already has
    value 0 (the correct, pre-suspend value).

    Intel appear to have previously acknowledged this behaviour and the
    requirement to rewrite this register:
    https://bugzilla.kernel.org/show_bug.cgi?id=116851#c23

    Based on that, rewrite the prefetch register values even when that appears
    unnecessary.

    We have confirmed this solution on all the affected models we have in-hands
    (X542UQ, UX533FD, X530UN, V272UN).

    Additionally, this solves an issue where r8169 MSI-X interrupts were broken
    after S3 suspend/resume on ASUS X441UAR. This issue was recently worked
    around in commit 7bb05b85bc2d ("r8169: don't use MSI-X on RTL8106e"). It
    also fixes the same issue on RTL6186evl/8111evl on an Aimfor-tech laptop
    that we had not yet patched. I suspect it will also fix the issue that was
    worked around in commit 7c53a722459c ("r8169: don't use MSI-X on
    RTL8168g").

    Thomas Martitz reports that this change also solves an issue where the AMD
    Radeon Polaris 10 GPU on the HP Zbook 14u G5 is unresponsive after S3
    suspend/resume.

    Link: https://bugzilla.kernel.org/show_bug.cgi?id=201069
    Signed-off-by: Daniel Drake
    Signed-off-by: Bjorn Helgaas
    Reviewed-by: Rafael J. Wysocki
    Reviewed-By: Peter Wu
    CC: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Daniel Drake
     
  • commit 02e425668f5c9deb42787d10001a3b605993ad15 upstream.

    When I added the missing memory outputs, I failed to update the
    index of the first argument (ebx) on 32-bit builds, which broke the
    fallbacks. Somehow I must have screwed up my testing or gotten
    lucky.

    Add another test to cover gettimeofday() as well.

    Signed-off-by: Andy Lutomirski
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Fixes: 715bd9d12f84 ("x86/vdso: Fix asm constraints on vDSO syscall fallbacks")
    Link: http://lkml.kernel.org/r/21bd45ab04b6d838278fa5bebfa9163eceffa13c.1538608971.git.luto@kernel.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     
  • commit 4f166564014aba65ad6f15b612f6711fd0f117ee upstream.

    When I fixed the vDSO build to use inline retpolines, I messed up
    the Makefile logic and made it unconditional. It should have
    depended on CONFIG_RETPOLINE and on the availability of compiler
    support. This broke the build on some older compilers.

    Reported-by: nikola.ciprich@linuxbox.cz
    Signed-off-by: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: David Woodhouse
    Cc: Linus Torvalds
    Cc: Matt Rickard
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: jason.vas.dias@gmail.com
    Cc: stable@vger.kernel.org
    Fixes: 2e549b2ee0e3 ("x86/vdso: Fix vDSO build if a retpoline is emitted")
    Link: http://lkml.kernel.org/r/08a1f29f2c238dd1f493945e702a521f8a5aa3ae.1538540801.git.luto@kernel.org
    Signed-off-by: Ingo Molnar
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     
  • commit 7c03e7035ac1cf2a6165754e4f3a49c2f1977838 upstream.

    Now that the vDSO implementation of clock_gettime() is getting
    reworked, add a selftest for it. This tests that its output is
    consistent with the syscall version.

    This is marked for stable to serve as a test for commit

    715bd9d12f84 ("x86/vdso: Fix asm constraints on vDSO syscall fallbacks")

    Signed-off-by: Andy Lutomirski
    Signed-off-by: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/082399674de2619b2befd8c0dde49b260605b126.1538422295.git.luto@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     
  • commit 715bd9d12f84d8f5cc8ad21d888f9bc304a8eb0b upstream.

    The syscall fallbacks in the vDSO have incorrect asm constraints.
    They are not marked as writing to their outputs -- instead, they are
    marked as clobbering "memory", which is useless. In particular, gcc
    is smart enough to know that the timespec parameter hasn't escaped,
    so a memory clobber doesn't clobber it. And passing a pointer as an
    asm *input* does not tell gcc that the pointed-to value is changed.

    Add in the fact that the asm instructions weren't volatile, and gcc
    was free to omit them entirely unless their sole output (the return
    value) is used. Which it is (phew!), but that stops happening with
    some upcoming patches.

    As a trivial example, the following code:

    void test_fallback(struct timespec *ts)
    {
    vdso_fallback_gettime(CLOCK_MONOTONIC, ts);
    }

    compiles to:

    00000000000000c0 :
    c0: c3 retq

    To add insult to injury, the RCX and R11 clobbers on 64-bit
    builds were missing.

    The "memory" clobber is also unnecessary -- no ordering with respect to
    other memory operations is needed, but that's going to be fixed in a
    separate not-for-stable patch.

    Fixes: 2aae950b21e4 ("x86_64: Add vDSO for x86-64 with gettimeofday/clock_gettime/getcpu")
    Signed-off-by: Andy Lutomirski
    Signed-off-by: Thomas Gleixner
    Cc: stable@vger.kernel.org
    Link: https://lkml.kernel.org/r/2c0231690551989d2fafa60ed0e7b5cc8b403908.1538422295.git.luto@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Andy Lutomirski
     
  • commit 337fe9f5c1e7de1f391c6a692531379d2aa2ee11 upstream.

    We attempt to get fences earlier in the hopes that everything will
    already have fences and no callbacks will be needed. If we do succeed
    in getting a fence, getting one a second time will result in a duplicate
    ref with no unref. This is causing memory leaks in Vulkan applications
    that create a lot of fences; playing for a few hours can, apparently,
    bring down the system.

    Cc: stable@vger.kernel.org
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=107899
    Reviewed-by: Chris Wilson
    Signed-off-by: Jason Ekstrand
    Signed-off-by: Sean Paul
    Link: https://patchwork.freedesktop.org/patch/msgid/20180926071703.15257-1-jason.ekstrand@intel.com
    Signed-off-by: Greg Kroah-Hartman

    Jason Ekstrand