1. 16 May, 2018 5 commits
    • Eric Dumazet's avatar
      netlink: fix uninit-value in netlink_sendmsg · bf2ecb93
      Eric Dumazet authored
      commit 6091f09c upstream.
      
      syzbot reported :
      
      BUG: KMSAN: uninit-value in ffs arch/x86/include/asm/bitops.h:432 [inline]
      BUG: KMSAN: uninit-value in netlink_sendmsg+0xb26/0x1310 net/netlink/af_netlink.c:1851
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bf2ecb93
    • Eric Dumazet's avatar
      crypto: af_alg - fix possible uninit-value in alg_bind() · 1b6d0db7
      Eric Dumazet authored
      commit a466856e upstream.
      
      syzbot reported :
      
      BUG: KMSAN: uninit-value in alg_bind+0xe3/0xd90 crypto/af_alg.c:162
      
      We need to check addr_len before dereferencing sa (or uaddr)
      
      Fixes: bb30b884 ("crypto: af_alg - whitelist mask and type")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Stephan Mueller <smueller@chronox.de>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1b6d0db7
    • Tom Herbert's avatar
      kcm: Call strp_stop before strp_done in kcm_attach · 19042316
      Tom Herbert authored
      commit dff8baa2 upstream.
      
      In kcm_attach strp_done is called when sk_user_data is already
      set to fail the attach. strp_done needs the strp to be stopped and
      warns if it isn't. Call strp_stop in this case to eliminate the
      warning message.
      
      Reported-by: syzbot+88dfb55e4c8b770d86e3@syzkaller.appspotmail.com
      Fixes: e5571240 ("kcm: Check if sk_user_data already set in kcm_attach"
      Signed-off-by: default avatarTom Herbert <tom@quantonium.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      19042316
    • Florian Westphal's avatar
      netfilter: ebtables: don't attempt to allocate 0-sized compat array · 725f5ae1
      Florian Westphal authored
      commit 3f1e53ab upstream.
      
      Dmitry reports 32bit ebtables on 64bit kernel got broken by
      a recent change that returns -EINVAL when ruleset has no entries.
      
      ebtables however only counts user-defined chains, so for the
      initial table nentries will be 0.
      
      Don't try to allocate the compat array in this case, as no user
      defined rules exist no rule will need 64bit translation.
      Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Fixes: 7d7d7e02 ("netfilter: compat: reject huge allocation requests")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      725f5ae1
    • Julian Anastasov's avatar
      ipvs: fix rtnl_lock lockups caused by start_sync_thread · 88c43b46
      Julian Anastasov authored
      commit 5c64576a upstream.
      
      syzkaller reports for wrong rtnl_lock usage in sync code [1] and [2]
      
      We have 2 problems in start_sync_thread if error path is
      taken, eg. on memory allocation error or failure to configure
      sockets for mcast group or addr/port binding:
      
      1. recursive locking: holding rtnl_lock while calling sock_release
      which in turn calls again rtnl_lock in ip_mc_drop_socket to leave
      the mcast group, as noticed by Florian Westphal. Additionally,
      sock_release can not be called while holding sync_mutex (ABBA
      deadlock).
      
      2. task hung: holding rtnl_lock while calling kthread_stop to
      stop the running kthreads. As the kthreads do the same to leave
      the mcast group (sock_release -> ip_mc_drop_socket -> rtnl_lock)
      they hang.
      
      Fix the problems by calling rtnl_unlock early in the error path,
      now sock_release is called after unlocking both mutexes.
      
      Problem 3 (task hung reported by syzkaller [2]) is variant of
      problem 2: use _trylock to prevent one user to call rtnl_lock and
      then while waiting for sync_mutex to block kthreads that execute
      sock_release when they are stopped by stop_sync_thread.
      
      [1]
      IPVS: stopping backup sync thread 4500 ...
      WARNING: possible recursive locking detected
      4.16.0-rc7+ #3 Not tainted
      --------------------------------------------
      syzkaller688027/4497 is trying to acquire lock:
        (rtnl_mutex){+.+.}, at: [<00000000bb14d7fb>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
      
      but task is already holding lock:
      IPVS: stopping backup sync thread 4495 ...
        (rtnl_mutex){+.+.}, at: [<00000000bb14d7fb>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
      
      other info that might help us debug this:
        Possible unsafe locking scenario:
      
              CPU0
              ----
         lock(rtnl_mutex);
         lock(rtnl_mutex);
      
        *** DEADLOCK ***
      
        May be due to missing lock nesting notation
      
      2 locks held by syzkaller688027/4497:
        #0:  (rtnl_mutex){+.+.}, at: [<00000000bb14d7fb>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
        #1:  (ipvs->sync_mutex){+.+.}, at: [<00000000703f78e3>]
      do_ip_vs_set_ctl+0x10f8/0x1cc0 net/netfilter/ipvs/ip_vs_ctl.c:2388
      
      stack backtrace:
      CPU: 1 PID: 4497 Comm: syzkaller688027 Not tainted 4.16.0-rc7+ #3
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      Call Trace:
        __dump_stack lib/dump_stack.c:17 [inline]
        dump_stack+0x194/0x24d lib/dump_stack.c:53
        print_deadlock_bug kernel/locking/lockdep.c:1761 [inline]
        check_deadlock kernel/locking/lockdep.c:1805 [inline]
        validate_chain kernel/locking/lockdep.c:2401 [inline]
        __lock_acquire+0xe8f/0x3e00 kernel/locking/lockdep.c:3431
        lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3920
        __mutex_lock_common kernel/locking/mutex.c:756 [inline]
        __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
        mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
        rtnl_lock+0x17/0x20 net/core/rtnetlink.c:74
        ip_mc_drop_socket+0x88/0x230 net/ipv4/igmp.c:2643
        inet_release+0x4e/0x1c0 net/ipv4/af_inet.c:413
        sock_release+0x8d/0x1e0 net/socket.c:595
        start_sync_thread+0x2213/0x2b70 net/netfilter/ipvs/ip_vs_sync.c:1924
        do_ip_vs_set_ctl+0x1139/0x1cc0 net/netfilter/ipvs/ip_vs_ctl.c:2389
        nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
        nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
        ip_setsockopt+0x97/0xa0 net/ipv4/ip_sockglue.c:1261
        udp_setsockopt+0x45/0x80 net/ipv4/udp.c:2406
        sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2975
        SYSC_setsockopt net/socket.c:1849 [inline]
        SyS_setsockopt+0x189/0x360 net/socket.c:1828
        do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
        entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x446a69
      RSP: 002b:00007fa1c3a64da8 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000446a69
      RDX: 000000000000048b RSI: 0000000000000000 RDI: 0000000000000003
      RBP: 00000000006e29fc R08: 0000000000000018 R09: 0000000000000000
      R10: 00000000200000c0 R11: 0000000000000246 R12: 00000000006e29f8
      R13: 00676e697279656b R14: 00007fa1c3a659c0 R15: 00000000006e2b60
      
      [2]
      IPVS: sync thread started: state = BACKUP, mcast_ifn = syz_tun, syncid = 4,
      id = 0
      IPVS: stopping backup sync thread 25415 ...
      INFO: task syz-executor7:25421 blocked for more than 120 seconds.
             Not tainted 4.16.0-rc6+ #284
      "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      syz-executor7   D23688 25421   4408 0x00000004
      Call Trace:
        context_switch kernel/sched/core.c:2862 [inline]
        __schedule+0x8fb/0x1ec0 kernel/sched/core.c:3440
        schedule+0xf5/0x430 kernel/sched/core.c:3499
        schedule_timeout+0x1a3/0x230 kernel/time/timer.c:1777
        do_wait_for_common kernel/sched/completion.c:86 [inline]
        __wait_for_common kernel/sched/completion.c:107 [inline]
        wait_for_common kernel/sched/completion.c:118 [inline]
        wait_for_completion+0x415/0x770 kernel/sched/completion.c:139
        kthread_stop+0x14a/0x7a0 kernel/kthread.c:530
        stop_sync_thread+0x3d9/0x740 net/netfilter/ipvs/ip_vs_sync.c:1996
        do_ip_vs_set_ctl+0x2b1/0x1cc0 net/netfilter/ipvs/ip_vs_ctl.c:2394
        nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
        nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
        ip_setsockopt+0x97/0xa0 net/ipv4/ip_sockglue.c:1253
        sctp_setsockopt+0x2ca/0x63e0 net/sctp/socket.c:4154
        sock_common_setsockopt+0x95/0xd0 net/core/sock.c:3039
        SYSC_setsockopt net/socket.c:1850 [inline]
        SyS_setsockopt+0x189/0x360 net/socket.c:1829
        do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
        entry_SYSCALL_64_after_hwframe+0x42/0xb7
      RIP: 0033:0x454889
      RSP: 002b:00007fc927626c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
      RAX: ffffffffffffffda RBX: 00007fc9276276d4 RCX: 0000000000454889
      RDX: 000000000000048c RSI: 0000000000000000 RDI: 0000000000000017
      RBP: 000000000072bf58 R08: 0000000000000018 R09: 0000000000000000
      R10: 0000000020000000 R11: 0000000000000246 R12: 00000000ffffffff
      R13: 000000000000051c R14: 00000000006f9b40 R15: 0000000000000001
      
      Showing all locks held in the system:
      2 locks held by khungtaskd/868:
        #0:  (rcu_read_lock){....}, at: [<00000000a1a8f002>]
      check_hung_uninterruptible_tasks kernel/hung_task.c:175 [inline]
        #0:  (rcu_read_lock){....}, at: [<00000000a1a8f002>] watchdog+0x1c5/0xd60
      kernel/hung_task.c:249
        #1:  (tasklist_lock){.+.+}, at: [<0000000037c2f8f9>]
      debug_show_all_locks+0xd3/0x3d0 kernel/locking/lockdep.c:4470
      1 lock held by rsyslogd/4247:
        #0:  (&f->f_pos_lock){+.+.}, at: [<000000000d8d6983>]
      __fdget_pos+0x12b/0x190 fs/file.c:765
      2 locks held by getty/4338:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4339:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4340:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4341:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4342:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4343:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      2 locks held by getty/4344:
        #0:  (&tty->ldisc_sem){++++}, at: [<00000000bee98654>]
      ldsem_down_read+0x37/0x40 drivers/tty/tty_ldsem.c:365
        #1:  (&ldata->atomic_read_lock){+.+.}, at: [<00000000c1d180aa>]
      n_tty_read+0x2ef/0x1a40 drivers/tty/n_tty.c:2131
      3 locks held by kworker/0:5/6494:
        #0:  ((wq_completion)"%s"("ipv6_addrconf")){+.+.}, at:
      [<00000000a062b18e>] work_static include/linux/workqueue.h:198 [inline]
        #0:  ((wq_completion)"%s"("ipv6_addrconf")){+.+.}, at:
      [<00000000a062b18e>] set_work_data kernel/workqueue.c:619 [inline]
        #0:  ((wq_completion)"%s"("ipv6_addrconf")){+.+.}, at:
      [<00000000a062b18e>] set_work_pool_and_clear_pending kernel/workqueue.c:646
      [inline]
        #0:  ((wq_completion)"%s"("ipv6_addrconf")){+.+.}, at:
      [<00000000a062b18e>] process_one_work+0xb12/0x1bb0 kernel/workqueue.c:2084
        #1:  ((addr_chk_work).work){+.+.}, at: [<00000000278427d5>]
      process_one_work+0xb89/0x1bb0 kernel/workqueue.c:2088
        #2:  (rtnl_mutex){+.+.}, at: [<00000000066e35ac>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
      1 lock held by syz-executor7/25421:
        #0:  (ipvs->sync_mutex){+.+.}, at: [<00000000d414a689>]
      do_ip_vs_set_ctl+0x277/0x1cc0 net/netfilter/ipvs/ip_vs_ctl.c:2393
      2 locks held by syz-executor7/25427:
        #0:  (rtnl_mutex){+.+.}, at: [<00000000066e35ac>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
        #1:  (ipvs->sync_mutex){+.+.}, at: [<00000000e6d48489>]
      do_ip_vs_set_ctl+0x10f8/0x1cc0 net/netfilter/ipvs/ip_vs_ctl.c:2388
      1 lock held by syz-executor7/25435:
        #0:  (rtnl_mutex){+.+.}, at: [<00000000066e35ac>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
      1 lock held by ipvs-b:2:0/25415:
        #0:  (rtnl_mutex){+.+.}, at: [<00000000066e35ac>] rtnl_lock+0x17/0x20
      net/core/rtnetlink.c:74
      
      Reported-and-tested-by: syzbot+a46d6abf9d56b1365a72@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+5fe074c01b2032ce9618@syzkaller.appspotmail.com
      Fixes: e0b26cc9 ("ipvs: call rtnl_lock early")
      Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Cc: Zubin Mithra <zsm@chromium.org>
      Cc: Guenter Roeck <groeck@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      88c43b46
  2. 09 May, 2018 35 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.14.40 · fc72a417
      Greg Kroah-Hartman authored
      fc72a417
    • Song Liu's avatar
      tracing: Fix bad use of igrab in trace_uprobe.c · 27f29dbc
      Song Liu authored
      commit 0c92c7a3 upstream.
      
      As Miklos reported and suggested:
      
        This pattern repeats two times in trace_uprobe.c and in
        kernel/events/core.c as well:
      
            ret = kern_path(filename, LOOKUP_FOLLOW, &path);
            if (ret)
                goto fail_address_parse;
      
            inode = igrab(d_inode(path.dentry));
            path_put(&path);
      
        And it's wrong.  You can only hold a reference to the inode if you
        have an active ref to the superblock as well (which is normally
        through path.mnt) or holding s_umount.
      
        This way unmounting the containing filesystem while the tracepoint is
        active will give you the "VFS: Busy inodes after unmount..." message
        and a crash when the inode is finally put.
      
        Solution: store path instead of inode.
      
      This patch fixes two instances in trace_uprobe.c. struct path is added to
      struct trace_uprobe to keep the inode and containing mount point
      referenced.
      
      Link: http://lkml.kernel.org/r/20180423172135.4050588-1-songliubraving@fb.com
      
      Fixes: f3f096cf ("tracing: Provide trace events interface for uprobes")
      Fixes: 33ea4b24 ("perf/core: Implement the 'perf_uprobe' PMU")
      Cc: stable@vger.kernel.org
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Howard McLauchlan <hmclauchlan@fb.com>
      Cc: Josef Bacik <jbacik@fb.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Acked-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Reported-by: default avatarMiklos Szeredi <miklos@szeredi.hu>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      27f29dbc
    • Agustin Vega-Frias's avatar
      irqchip/qcom: Fix check for spurious interrupts · d86aaca9
      Agustin Vega-Frias authored
      commit 1bc2463c upstream.
      
      When the interrupts for a combiner span multiple registers it must be
      checked if any interrupts have been asserted on each register before
      checking for spurious interrupts.
      
      Checking each register seperately leads to false positive warnings.
      
      [ tglx: Massaged changelog ]
      
      Fixes: f20cc9b0 ("irqchip/qcom: Add IRQ combiner driver")
      Signed-off-by: default avatarAgustin Vega-Frias <agustinv@codeaurora.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Jason Cooper <jason@lakedaemon.net>
      Cc: Marc Zyngier <marc.zyngier@arm.com>
      Cc: timur@codeaurora.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1525184090-26143-1-git-send-email-agustinv@codeaurora.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d86aaca9
    • João Paulo Rechi Vita's avatar
      platform/x86: asus-wireless: Fix NULL pointer dereference · bd2088d1
      João Paulo Rechi Vita authored
      commit 9f0a93de upstream.
      
      When the module is removed the led workqueue is destroyed in the remove
      callback, before the led device is unregistered from the led subsystem.
      
      This leads to a NULL pointer derefence when the led device is
      unregistered automatically later as part of the module removal cleanup.
      Bellow is the backtrace showing the problem.
      
        BUG: unable to handle kernel NULL pointer dereference at           (null)
        IP: __queue_work+0x8c/0x410
        PGD 0 P4D 0
        Oops: 0000 [#1] SMP NOPTI
        Modules linked in: ccm edac_mce_amd kvm_amd kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 joydev crypto_simd asus_nb_wmi glue_helper uvcvideo snd_hda_codec_conexant snd_hda_codec_generic snd_hda_codec_hdmi snd_hda_intel asus_wmi snd_hda_codec cryptd snd_hda_core sparse_keymap videobuf2_vmalloc arc4 videobuf2_memops snd_hwdep input_leds videobuf2_v4l2 ath9k psmouse videobuf2_core videodev ath9k_common snd_pcm ath9k_hw media fam15h_power ath k10temp snd_timer mac80211 i2c_piix4 r8169 mii mac_hid cfg80211 asus_wireless(-) snd soundcore wmi shpchp 8250_dw ip_tables x_tables amdkfd amd_iommu_v2 amdgpu radeon chash i2c_algo_bit drm_kms_helper syscopyarea serio_raw sysfillrect sysimgblt fb_sys_fops ahci ttm libahci drm video
        CPU: 3 PID: 2177 Comm: rmmod Not tainted 4.15.0-5-generic #6+dev94.b4287e5bem1-Endless
        Hardware name: ASUSTeK COMPUTER INC. X555DG/X555DG, BIOS 5.011 05/05/2015
        RIP: 0010:__queue_work+0x8c/0x410
        RSP: 0018:ffffbe8cc249fcd8 EFLAGS: 00010086
        RAX: ffff992ac6810800 RBX: 0000000000000000 RCX: 0000000000000008
        RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff992ac6400e18
        RBP: ffffbe8cc249fd18 R08: ffff992ac6400db0 R09: 0000000000000000
        R10: 0000000000000040 R11: ffff992ac6400dd8 R12: 0000000000002000
        R13: ffff992abd762e00 R14: ffff992abd763e38 R15: 000000000001ebe0
        FS:  00007f318203e700(0000) GS:ffff992aced80000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000000 CR3: 00000001c720e000 CR4: 00000000001406e0
        Call Trace:
         queue_work_on+0x38/0x40
         led_state_set+0x2c/0x40 [asus_wireless]
         led_set_brightness_nopm+0x14/0x40
         led_set_brightness+0x37/0x60
         led_trigger_set+0xfc/0x1d0
         led_classdev_unregister+0x32/0xd0
         devm_led_classdev_release+0x11/0x20
         release_nodes+0x109/0x1f0
         devres_release_all+0x3c/0x50
         device_release_driver_internal+0x16d/0x220
         driver_detach+0x3f/0x80
         bus_remove_driver+0x55/0xd0
         driver_unregister+0x2c/0x40
         acpi_bus_unregister_driver+0x15/0x20
         asus_wireless_driver_exit+0x10/0xb7c [asus_wireless]
         SyS_delete_module+0x1da/0x2b0
         entry_SYSCALL_64_fastpath+0x24/0x87
        RIP: 0033:0x7f3181b65fd7
        RSP: 002b:00007ffe74bcbe18 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
        RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3181b65fd7
        RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000555ea2559258
        RBP: 0000555ea25591f0 R08: 00007ffe74bcad91 R09: 000000000000000a
        R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000003
        R13: 00007ffe74bcae00 R14: 0000000000000000 R15: 0000555ea25591f0
        Code: 01 00 00 02 0f 85 7d 01 00 00 48 63 45 d4 48 c7 c6 00 f4 fa 87 49 8b 9d 08 01 00 00 48 03 1c c6 4c 89 f7 e8 87 fb ff ff 48 85 c0 <48> 8b 3b 0f 84 c5 01 00 00 48 39 f8 0f 84 bc 01 00 00 48 89 c7
        RIP: __queue_work+0x8c/0x410 RSP: ffffbe8cc249fcd8
        CR2: 0000000000000000
        ---[ end trace 7aa4f4a232e9c39c ]---
      
      Unregistering the led device on the remove callback before destroying the
      workqueue avoids this problem.
      
      https://bugzilla.kernel.org/show_bug.cgi?id=196097Reported-by: default avatarDun Hum <bitter.taste@gmx.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJoão Paulo Rechi Vita <jprvita@endlessm.com>
      Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd2088d1
    • Bin Liu's avatar
      usb: musb: trace: fix NULL pointer dereference in musb_g_tx() · 87fa7da6
      Bin Liu authored
      commit 9aea9b6c upstream.
      
      The usb_request pointer could be NULL in musb_g_tx(), where the
      tracepoint call would trigger the NULL pointer dereference failure when
      parsing the members of the usb_request pointer.
      
      Move the tracepoint call to where the usb_request pointer is already
      checked to solve the issue.
      
      Fixes: fc78003e ("usb: musb: gadget: add usb-request tracepoints")
      Cc: stable@vger.kernel.org # v4.8+
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87fa7da6
    • Bin Liu's avatar
      usb: musb: host: fix potential NULL pointer dereference · 303e99bd
      Bin Liu authored
      commit 2b63f132 upstream.
      
      musb_start_urb() doesn't check the pass-in parameter if it is NULL.  But
      in musb_bulk_nak_timeout() the parameter passed to musb_start_urb() is
      returned from first_qh(), which could be NULL.
      
      So wrap the musb_start_urb() call here with a if condition check to
      avoid the potential NULL pointer dereference.
      
      Fixes: f283862f ("usb: musb: NAK timeout scheme on bulk TX endpoint")
      Cc: stable@vger.kernel.org # v3.7+
      Signed-off-by: default avatarBin Liu <b-liu@ti.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      303e99bd
    • SZ Lin (林上智)'s avatar
      USB: serial: option: adding support for ublox R410M · ec6de93f
      SZ Lin (林上智) authored
      commit 4205cb01 upstream.
      
      This patch adds support for ublox R410M PID 0x90b2 USB modem to option
      driver, this module supports LTE Cat M1 / NB1.
      
      Interface layout:
      0: QCDM/DIAG
      1: ADB
      2: AT
      3: RMNET
      Signed-off-by: default avatarSZ Lin (林上智) <sz.lin@moxa.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec6de93f
    • Johan Hovold's avatar
      USB: serial: option: reimplement interface masking · 3f0c2479
      Johan Hovold authored
      commit c3a65808 upstream.
      
      Reimplement interface masking using device flags stored directly in the
      device-id table. This will make it easier to add and maintain device-id
      entries by using a more compact and readable notation compared to the
      current implementation (which manages pairs of masks in separate
      blacklist structs).
      
      Two convenience macros are used to flag an interface as either reserved
      or as not supporting modem-control requests:
      
      	{ USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
      	  .driver_info = NCTRL(0) | RSVD(3) },
      
      For now, we limit the highest maskable interface number to seven, which
      allows for (up to 16) additional device flags to be added later should
      need arise.
      
      Note that this will likely need to be backported to stable in order to
      make future device-id backports more manageable.
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f0c2479
    • Alan Stern's avatar
      USB: Accept bulk endpoints with 1024-byte maxpacket · 0e548f5a
      Alan Stern authored
      commit fb5ee84e upstream.
      
      Some non-compliant high-speed USB devices have bulk endpoints with a
      1024-byte maxpacket size.  Although such endpoints don't work with
      xHCI host controllers, they do work with EHCI controllers.  We used to
      accept these invalid sizes (with a warning), but we no longer do
      because of an unintentional change introduced by commit aed9d65a
      ("USB: validate wMaxPacketValue entries in endpoint descriptors").
      
      This patch restores the old behavior, so that people with these
      peculiar devices can use them without patching their kernels by hand.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Suggested-by: default avatarElvinas <elvinas@veikia.lt>
      Fixes: aed9d65a ("USB: validate wMaxPacketValue entries in endpoint descriptors")
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e548f5a
    • Mayank Rana's avatar
      usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue · 425a0254
      Mayank Rana authored
      commit 96bd39df upstream.
      
      dwc3_ep_dequeue() waits for completion of End Transfer command using
      wait_event_lock_irq(), which will release the dwc3->lock while waiting
      and reacquire after completion. This allows a potential race condition
      with ep_disable() which also removes all requests from started_list
      and pending_list.
      
      The check for NULL r->trb should catch this but currently it exits to
      the wrong 'out1' label which calls dwc3_gadget_giveback(). Since its
      list entry was already removed, if CONFIG_DEBUG_LIST is enabled a
      'list_del corruption' bug is thrown since its next/prev pointers are
      already LIST_POISON1/2. If r->trb is NULL it should simply exit to
      'out0'.
      
      Fixes: cf3113d8 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue")
      Cc: stable@vger.kernel.org # v4.12+
      Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
      Signed-off-by: default avatarJack Pham <jackp@codeaurora.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      425a0254
    • Greg Kroah-Hartman's avatar
      USB: serial: visor: handle potential invalid device configuration · 0cc49bb6
      Greg Kroah-Hartman authored
      commit 4842ed5b upstream.
      
      If we get an invalid device configuration from a palm 3 type device, we
      might incorrectly parse things, and we have the potential to crash in
      "interesting" ways.
      
      Fix this up by verifying the size of the configuration passed to us by
      the device, and only if it is correct, will we handle it.
      
      Note that this also fixes an information leak of slab data.
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [ johan: add comment about the info leak ]
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0cc49bb6
    • Matthew Wilcox's avatar
      errseq: Always report a writeback error once · 0799a0ea
      Matthew Wilcox authored
      commit b4678df1 upstream.
      
      The errseq_t infrastructure assumes that errors which occurred before
      the file descriptor was opened are of no interest to the application.
      This turns out to be a regression for some applications, notably Postgres.
      
      Before errseq_t, a writeback error would be reported exactly once (as
      long as the inode remained in memory), so Postgres could open a file,
      call fsync() and find out whether there had been a writeback error on
      that file from another process.
      
      This patch changes the errseq infrastructure to report errors to all
      file descriptors which are opened after the error occurred, but before
      it was reported to any file descriptor.  This restores the user-visible
      behaviour.
      
      Cc: stable@vger.kernel.org
      Fixes: 5660e13d ("fs: new infrastructure for writeback error handling and reporting")
      Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0799a0ea
    • Ben Hutchings's avatar
      test_firmware: fix setting old custom fw path back on exit, second try · b4f6e858
      Ben Hutchings authored
      commit e5384092 upstream.
      
      Commit 65c79230 tried to clear the custom firmware path on exit by
      writing a single space to the firmware_class.path parameter.  This
      doesn't work because nothing strips this space from the value stored
      and fw_get_filesystem_firmware() only ignores zero-length paths.
      
      Instead, write a null byte.
      
      Fixes: 0a8adf58 ("test: add firmware_class loader test")
      Fixes: 65c79230 ("test_firmware: fix setting old custom fw path back on exit")
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Acked-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      b4f6e858
    • Sean Paul's avatar
      drm/bridge: vga-dac: Fix edid memory leak · 43b3ba6e
      Sean Paul authored
      commit 49ceda9d upstream.
      
      edid should be freed once it's finished being used.
      
      Fixes: 56fe8b6f ("drm/bridge: Add RGB to VGA bridge support")
      Cc: Rob Herring <robh@kernel.org>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
      Cc: Archit Taneja <architt@codeaurora.org>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
      Cc: <stable@vger.kernel.org> # v4.9+
      Reviewed-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20180420190007.1572-1-seanpaul@chromium.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43b3ba6e
    • Thomas Hellstrom's avatar
      drm/vmwgfx: Fix a buffer object leak · df9703e7
      Thomas Hellstrom authored
      commit 13f149d4 upstream.
      
      A buffer object leak was introduced when fixing a premature buffer
      object release. Fix this.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 73a88250 ("Fix a destoy-while-held mutex problem.")
      Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
      Reviewed-by: default avatarDeepak Rawat <drawat@vmware.com>
      Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df9703e7
    • Bharat Potnuri's avatar
      iw_cxgb4: Atomically flush per QP HW CQEs · 758f3340
      Bharat Potnuri authored
      commit 2df19e19 upstream.
      
      When a CQ is shared by multiple QPs, c4iw_flush_hw_cq() needs to acquire
      corresponding QP lock before moving the CQEs into its corresponding SW
      queue and accessing the SQ contents for completing a WR.
      Ignore CQEs if corresponding QP is already flushed.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      758f3340
    • Sebastian Sanchez's avatar
      IB/hfi1: Fix NULL pointer dereference when invalid num_vls is used · d7683a5c
      Sebastian Sanchez authored
      commit 45d92457 upstream.
      
      When an invalid num_vls is used as a module parameter, the code
      execution follows an exception path where the macro dd_dev_err()
      expects dd->pcidev->dev not to be NULL in hfi1_init_dd(). This
      causes a NULL pointer dereference.
      
      Fix hfi1_init_dd() by initializing dd->pcidev and dd->pcidev->dev
      earlier in the code. If a dd exists, then dd->pcidev and
      dd->pcidev->dev always exists.
      
      BUG: unable to handle kernel NULL pointer dereference
      at 00000000000000f0
      IP: __dev_printk+0x15/0x90
      Workqueue: events work_for_cpu_fn
      RIP: 0010:__dev_printk+0x15/0x90
      Call Trace:
       dev_err+0x6c/0x90
       ? hfi1_init_pportdata+0x38d/0x3f0 [hfi1]
       hfi1_init_dd+0xdd/0x2530 [hfi1]
       ? pci_conf1_read+0xb2/0xf0
       ? pci_read_config_word.part.9+0x64/0x80
       ? pci_conf1_write+0xb0/0xf0
       ? pcie_capability_clear_and_set_word+0x57/0x80
       init_one+0x141/0x490 [hfi1]
       local_pci_probe+0x3f/0xa0
       work_for_cpu_fn+0x10/0x20
       process_one_work+0x152/0x350
       worker_thread+0x1cf/0x3e0
       kthread+0xf5/0x130
       ? max_active_store+0x80/0x80
       ? kthread_bind+0x10/0x10
       ? do_syscall_64+0x6e/0x1a0
       ? SyS_exit_group+0x10/0x10
       ret_from_fork+0x35/0x40
      
      Cc: <stable@vger.kernel.org> # 4.9.x
      Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Signed-off-by: default avatarSebastian Sanchez <sebastian.sanchez@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d7683a5c
    • Mike Marciniszyn's avatar
      IB/hfi1: Fix loss of BECN with AHG · 79181a45
      Mike Marciniszyn authored
      commit 0a0bcb04 upstream.
      
      AHG may be armed to use the stored header, which by design is limited
      to edits in the PSN/A 32 bit word (bth2).
      
      When the code is trying to send a BECN, the use of the stored header
      will lose the BECN bit.
      
      Fix by avoiding AHG when getting ready to send a BECN. This is
      accomplished by always claiming the packet is not a middle packet which
      is an AHG precursor.  BECNs are not a normal case and this should not
      hurt AHG optimizations.
      
      Cc: <stable@vger.kernel.org> # 4.14.x
      Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      79181a45
    • Mike Marciniszyn's avatar
      IB/hfi1: Fix handling of FECN marked multicast packet · 7f185bc7
      Mike Marciniszyn authored
      commit f59fb9e0 upstream.
      
      The code for handling a marked UD packet unconditionally returns the
      dlid in the header of the FECN marked packet.  This is not correct
      for multicast packets where the DLID is in the multicast range.
      
      The subsequent attempt to send the CNP with the multicast lid will
      cause the chip to halt the ack send context because the source
      lid doesn't match the chip programming.   The send context will
      be halted and flush any other pending packets in the pio ring causing
      the CNP to not be sent.
      
      A part of investigating the fix, it was determined that the 16B work
      broke the FECN routine badly with inconsistent use of 16 bit and 32 bits
      types for lids and pkeys.  Since the port's source lid was correctly 32
      bits the type mixmatches need to be dealt with at the same time as
      fixing the CNP header issue.
      
      Fix these issues by:
      - Using the ports lid for as the SLID for responding to FECN marked UD
        packets
      - Insure pkey is always 16 bit in this and subordinate routines
      - Insure lids are 32 bits in this and subordinate routines
      
      Cc: <stable@vger.kernel.org> # 4.14.x
      Fixes: 88733e3b ("IB/hfi1: Add 16B UD support")
      Reviewed-by: default avatarDon Hiatt <don.hiatt@intel.com>
      Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f185bc7
    • Danit Goldberg's avatar
      IB/mlx5: Use unlimited rate when static rate is not supported · b5ebbbc7
      Danit Goldberg authored
      commit 4f32ac2e upstream.
      
      Before the change, if the user passed a static rate value different
      than zero and the FW doesn't support static rate,
      it would end up configuring rate of 2.5 GBps.
      
      Fix this by using rate 0; unlimited, in cases where FW
      doesn't support static rate configuration.
      
      Cc: <stable@vger.kernel.org> # 3.10
      Fixes: e126ba97 ("mlx5: Add driver for Mellanox Connect-IB adapters")
      Reviewed-by: default avatarMajd Dibbiny <majd@mellanox.com>
      Signed-off-by: default avatarDanit Goldberg <danitg@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5ebbbc7
    • SZ Lin (林上智)'s avatar
      NET: usb: qmi_wwan: add support for ublox R410M PID 0x90b2 · a27293f2
      SZ Lin (林上智) authored
      commit 9306b38e upstream.
      
      This patch adds support for PID 0x90b2 of ublox R410M.
      
      qmicli -d /dev/cdc-wdm0 --dms-get-manufacturer
      [/dev/cdc-wdm0] Device manufacturer retrieved:
              Manufacturer: 'u-blox'
      
      qmicli -d /dev/cdc-wdm0 --dms-get-model
      [/dev/cdc-wdm0] Device model retrieved:
              Model: 'SARA-R410M-02B'
      Signed-off-by: default avatarSZ Lin (林上智) <sz.lin@moxa.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a27293f2
    • Leon Romanovsky's avatar
      RDMA/mlx5: Protect from shift operand overflow · 14ad5155
      Leon Romanovsky authored
      commit 002bf228 upstream.
      
      Ensure that user didn't supply values too large that can cause overflow.
      
      UBSAN: Undefined behaviour in drivers/infiniband/hw/mlx5/qp.c:263:23
      shift exponent -2147483648 is negative
      CPU: 0 PID: 292 Comm: syzkaller612609 Not tainted 4.16.0-rc1+ #131
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 Call
      Trace:
      dump_stack+0xde/0x164
      ubsan_epilogue+0xe/0x81
      set_rq_size+0x7c2/0xa90
      create_qp_common+0xc18/0x43c0
      mlx5_ib_create_qp+0x379/0x1ca0
      create_qp.isra.5+0xc94/0x2260
      ib_uverbs_create_qp+0x21b/0x2a0
      ib_uverbs_write+0xc2c/0x1010
      vfs_write+0x1b0/0x550
      SyS_write+0xc7/0x1a0
      do_syscall_64+0x1aa/0x740
      entry_SYSCALL_64_after_hwframe+0x26/0x9b
      RIP: 0033:0x433569
      RSP: 002b:00007ffc6e62f448 EFLAGS: 00000217 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 00000000004002f8 RCX: 0000000000433569
      RDX: 0000000000000070 RSI: 00000000200042c0 RDI: 0000000000000003
      RBP: 00000000006d5018 R08: 00000000004002f8 R09: 00000000004002f8
      R10: 00000000004002f8 R11: 0000000000000217 R12: 0000000000000000
      R13: 000000000040c9f0 R14: 000000000040ca80 R15: 0000000000000006
      
      Cc: <stable@vger.kernel.org> # 3.10
      Fixes: e126ba97 ("mlx5: Add driver for Mellanox Connect-IB adapters")
      Cc: syzkaller <syzkaller@googlegroups.com>
      Reported-by: default avatarNoa Osherovich <noaos@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14ad5155
    • Leon Romanovsky's avatar
      RDMA/mlx5: Fix multiple NULL-ptr deref errors in rereg_mr flow · be855252
      Leon Romanovsky authored
      commit b4bd701a upstream.
      
      Failure in rereg MR releases UMEM but leaves the MR to be destroyed
      by the user. As a result the following scenario may happen:
      "create MR -> rereg MR with failure -> call to rereg MR again" and
      hit "NULL-ptr deref or user memory access" errors.
      
      Ensure that rereg MR is only performed on a non-dead MR.
      
      Cc: syzkaller <syzkaller@googlegroups.com>
      Cc: <stable@vger.kernel.org> # 4.5
      Fixes: 395a8e4c ("IB/mlx5: Refactoring register MR code")
      Reported-by: default avatarNoa Osherovich <noaos@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be855252
    • Roland Dreier's avatar
      RDMA/ucma: Allow resolving address w/o specifying source address · 3ae1bf36
      Roland Dreier authored
      commit 09abfe7b upstream.
      
      The RDMA CM will select a source device and address by consulting
      the routing table if no source address is passed into
      rdma_resolve_address().  Userspace will ask for this by passing an
      all-zero source address in the RESOLVE_IP command.  Unfortunately
      the new check for non-zero address size rejects this with EINVAL,
      which breaks valid userspace applications.
      
      Fix this by explicitly allowing a zero address family for the source.
      
      Fixes: 2975d5de ("RDMA/ucma: Check AF family prior resolving address")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3ae1bf36
    • Raju Rangoju's avatar
      RDMA/cxgb4: release hw resources on device removal · 38a65e75
      Raju Rangoju authored
      commit 26bff1bd upstream.
      
      The c4iw_rdev_close() logic was not releasing all the hw
      resources (PBL and RQT memory) during the device removal
      event (driver unload / system reboot). This can cause panic
      in gen_pool_destroy().
      
      The module remove function will wait for all the hw
      resources to be released during the device removal event.
      
      Fixes c12a67fe(iw_cxgb4: free EQ queue memory on last deref)
      Signed-off-by: default avatarRaju Rangoju <rajur@chelsio.com>
      Reviewed-by: default avatarSteve Wise <swise@opengridcomputing.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      38a65e75
    • Darrick J. Wong's avatar
      xfs: prevent creating negative-sized file via INSERT_RANGE · bd9ca962
      Darrick J. Wong authored
      commit 7d83fb14 upstream.
      
      During the "insert range" fallocate operation, i_size grows by the
      specified 'len' bytes.  XFS verifies that i_size + len < s_maxbytes, as
      it should.  But this comparison is done using the signed 'loff_t', and
      'i_size + len' can wrap around to a negative value, causing the check to
      incorrectly pass, resulting in an inode with "negative" i_size.  This is
      possible on 64-bit platforms, where XFS sets s_maxbytes = LLONG_MAX.
      ext4 and f2fs don't run into this because they set a smaller s_maxbytes.
      
      Fix it by using subtraction instead.
      
      Reproducer:
          xfs_io -f file -c "truncate $(((1<<63)-1))" -c "finsert 0 4096"
      
      Fixes: a904b1ca ("xfs: Add support FALLOC_FL_INSERT_RANGE for fallocate")
      Cc: <stable@vger.kernel.org> # v4.1+
      Originally-From: Eric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      [darrick: fix signed integer addition overflow too]
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd9ca962
    • Ping-Ke Shih's avatar
      rtlwifi: cleanup 8723be ant_sel definition · b68c7af0
      Ping-Ke Shih authored
      commit af8a41cc upstream.
      
      Some HP laptops have only a single wifi antenna. This would not be a
      problem except that they were shipped with an incorrectly encoded
      EFUSE. It should have been possible to open the computer and transfer
      the antenna connection to the other terminal except that such action
      might void the warranty, and moving the antenna broke the Windows
      driver. The fix was to add a module option that would override the
      EFUSE encoding. That was done with commit c18d8f50 ("rtlwifi:
      rtl8723be: Add antenna select module parameter"). There was still a
      problem with Bluetooth coexistence, which was addressed with commit
      baa17022 ("rtlwifi: btcoexist: Implement antenna selection").
      There were still problems, thus there were commit 0ff78ade
      ("rtlwifi: rtl8723be: fix ant_sel code") and commit 6d622692
      ("rtlwifi: btcoexist: Fix antenna selection code"). Despite all these
      attempts at fixing the problem, the code is not yet right. A proper
      fix is important as there are now instances of laptops having
      RTL8723DE chips with the same problem.
      
      The module parameter ant_sel is used to control antenna number and path.
      At present enum ANT_{X2,X1} is used to define the antenna number, but
      this choice is not intuitive, thus change to a new enum ANT_{MAIN,AUX}
      to make it more readable. This change showed examples where incorrect
      values were used. It was also possible to remove a workaround in
      halbtcoutsrc.c.
      
      The experimental results with single antenna connected to specific path
      are now as follows:
        ant_sel  ANT_MAIN(#1)  ANT_AUX(#2)
           0        -8            -62
           1        -62           -10
           2        -6            -60
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Fixes: c18d8f50 ("rtlwifi: rtl8723be: Add antenna select module parameter")
      Fixes: baa17022 ("rtlwifi: btcoexist: Implement antenna selection")
      Fixes: 0ff78ade ("rtlwifi: rtl8723be: fix ant_sel code")
      Fixes: 6d622692 ("rtlwifi: btcoexist: Fix antenna selection code")
      Cc: Stable <stable@vger.kernel.org> # 4.7+
      Reviewed-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b68c7af0
    • Ping-Ke Shih's avatar
      rtlwifi: btcoex: Add power_on_setting routine · fcd835be
      Ping-Ke Shih authored
      commit a44709bb upstream.
      
      After mac power-on sequence, wifi will start to work so notify btcoex the
      event to configure registers especially related to antenna. This will not
      only help to assign antenna but also to yield better user experience.
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fcd835be
    • Vittorio Gambaletta (VittGam)'s avatar
      Input: atmel_mxt_ts - add touchpad button mapping for Samsung Chromebook Pro · 10579ed3
      Vittorio Gambaletta (VittGam) authored
      commit f372b811 upstream.
      
      This patch adds the correct platform data information for the Caroline
      Chromebook, so that the mouse button does not get stuck in pressed state
      after the first click.
      
      The Samus button keymap and platform data definition are the correct
      ones for Caroline, so they have been reused here.
      Signed-off-by: default avatarVittorio Gambaletta <linuxbugs@vittgam.net>
      Signed-off-by: default avatarSalvatore Bellizzi <lkml@seppia.net>
      Tested-by: default avatarGuenter Roeck <groeck@chromium.org>
      Cc: stable@vger.kernel.org
      [dtor: adjusted vendor spelling to match shipping firmware]
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      10579ed3
    • Dmitry Torokhov's avatar
      Input: leds - fix out of bound access · 89493702
      Dmitry Torokhov authored
      commit 6bd6ae63 upstream.
      
      UI_SET_LEDBIT ioctl() causes the following KASAN splat when used with
      led > LED_CHARGING:
      
      [ 1274.663418] BUG: KASAN: slab-out-of-bounds in input_leds_connect+0x611/0x730 [input_leds]
      [ 1274.663426] Write of size 8 at addr ffff88003377b2c0 by task ckb-next-daemon/5128
      
      This happens because we were writing to the led structure before making
      sure that it exists.
      Reported-by: default avatarTasos Sahanidis <tasos@tasossah.com>
      Tested-by: default avatarTasos Sahanidis <tasos@tasossah.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89493702
    • Bryant G Ly's avatar
      scsi: target: Fix fortify_panic kernel exception · 2c698f7b
      Bryant G Ly authored
      commit f5957dad upstream.
      
      memcmp() requires the two buffers passed as arguments to be at least
      'size' bytes long, otherwise a fortify_panic will trigger.
      
      Use memchr_inv() instead of memcmp() to determine whether the received
      payload is zeroed or not.
      
      The bug was found by running a block backstore via LIO.
      
      [  496.212958] Call Trace:
      [  496.212960] [c0000007e58e3800] [c000000000cbbefc] fortify_panic+0x24/0x38 (unreliable)
      [  496.212965] [c0000007e58e3860] [d00000000f150c28] iblock_execute_write_same+0x3b8/0x3c0 [target_core_iblock]
      [  496.212976] [c0000007e58e3910] [d000000006c737d4] __target_execute_cmd+0x54/0x150 [target_core_mod]
      [  496.212982] [c0000007e58e3940] [d000000006d32ce4] ibmvscsis_write_pending+0x74/0xe0 [ibmvscsis]
      [  496.212991] [c0000007e58e39b0] [d000000006c74fc8] transport_generic_new_cmd+0x318/0x370 [target_core_mod]
      [  496.213001] [c0000007e58e3a30] [d000000006c75084] transport_handle_cdb_direct+0x64/0xd0 [target_core_mod]
      [  496.213011] [c0000007e58e3aa0] [d000000006c75298] target_submit_cmd_map_sgls+0x1a8/0x320 [target_core_mod]
      [  496.213021] [c0000007e58e3b30] [d000000006c75458] target_submit_cmd+0x48/0x60 [target_core_mod]
      [  496.213026] [c0000007e58e3bd0] [d000000006d34c20] ibmvscsis_scheduler+0x370/0x600 [ibmvscsis]
      [  496.213031] [c0000007e58e3c90] [c00000000013135c] process_one_work+0x1ec/0x580
      [  496.213035] [c0000007e58e3d20] [c000000000131798] worker_thread+0xa8/0x600
      [  496.213039] [c0000007e58e3dc0] [c00000000013a468] kthread+0x168/0x1b0
      [  496.213044] [c0000007e58e3e30] [c00000000000b528] ret_from_kernel_thread+0x5c/0xb4
      
      [mkp: tweaked commit message]
      
      Fixes: 2237498f ("target/iblock: Convert WRITE_SAME to blkdev_issue_zeroout")
      Signed-off-by: default avatarBryant G. Ly <bryantly@linux.vnet.ibm.com>
      Reviewed-by: default avatarSteven Royer <seroyer@linux.vnet.ibm.com>
      Tested-by: default avatarTaylor Jakobson <tjakobs@us.ibm.com>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Cc: <stable@vger.kernel.org> # v4.13+
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c698f7b
    • Mathieu Desnoyers's avatar
      tracepoint: Do not warn on ENOMEM · f4438b15
      Mathieu Desnoyers authored
      commit d66a270b upstream.
      
      Tracepoint should only warn when a kernel API user does not respect the
      required preconditions (e.g. same tracepoint enabled twice, or called
      to remove a tracepoint that does not exist).
      
      Silence warning in out-of-memory conditions, given that the error is
      returned to the caller.
      
      This ensures that out-of-memory error-injection testing does not trigger
      warnings in tracepoint.c, which were seen by syzbot.
      
      Link: https://lkml.kernel.org/r/001a114465e241a8720567419a72@google.com
      Link: https://lkml.kernel.org/r/001a1140e0de15fc910567464190@google.com
      Link: http://lkml.kernel.org/r/20180315124424.32319-1-mathieu.desnoyers@efficios.com
      
      CC: Peter Zijlstra <peterz@infradead.org>
      CC: Jiri Olsa <jolsa@redhat.com>
      CC: Arnaldo Carvalho de Melo <acme@kernel.org>
      CC: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      CC: Namhyung Kim <namhyung@kernel.org>
      CC: stable@vger.kernel.org
      Fixes: de7b2973 ("tracepoint: Use struct pointer instead of name hash for reg/unreg tracepoints")
      Reported-by: syzbot+9c0d616860575a73166a@syzkaller.appspotmail.com
      Reported-by: syzbot+4e9ae7fa46233396f64d@syzkaller.appspotmail.com
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4438b15
    • Takashi Iwai's avatar
      ALSA: aloop: Add missing cable lock to ctl API callbacks · bd0e2aec
      Takashi Iwai authored
      commit 76b3421b upstream.
      
      Some control API callbacks in aloop driver are too lazy to take the
      loopback->cable_lock and it results in possible races of cable access
      while it's being freed.  It eventually lead to a UAF, as reported by
      fuzzer recently.
      
      This patch covers such control API callbacks and add the proper mutex
      locks.
      Reported-by: default avatarDaeRyong Jeong <threeearcat@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bd0e2aec
    • Robert Rosengren's avatar
      ALSA: aloop: Mark paused device as inactive · 4e3460ae
      Robert Rosengren authored
      commit 306a4f3c upstream.
      
      Show paused ALSA aloop device as inactive, i.e. the control
      "PCM Slave Active" set as false. Notification sent upon state change.
      
      This makes it possible for client capturing from aloop device to know if
      data is expected. Without it the client expects data even if playback
      is paused.
      Signed-off-by: default avatarRobert Rosengren <robert.rosengren@axis.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e3460ae
    • Takashi Sakamoto's avatar
      ALSA: dice: fix kernel NULL pointer dereference due to invalid calculation for array index · 9581fff3
      Takashi Sakamoto authored
      commit 52759c09 upstream.
      
      At a commit f91c9d76 ('ALSA: firewire-lib: cache maximum length of
      payload to reduce function calls'), maximum size of payload for tx
      isochronous packet is cached to reduce the number of function calls.
      
      This cache was programmed to updated at a first callback of ohci1394 IR
      context. However, the maximum size is required to queueing packets before
      starting the isochronous context.
      
      As a result, the cached value is reused to queue packets in next time to
      starting the isochronous context. Then the cache is updated in a first
      callback of the isochronous context. This can cause kernel NULL pointer
      dereference in a below call graph:
      
      (sound/firewire/amdtp-stream.c)
      amdtp_stream_start()
      ->queue_in_packet()
        ->queue_packet()
          (drivers/firewire/core-iso.c)
          ->fw_iso_context_queue()
            ->struct fw_card_driver.queue_iso()
            (drivers/firewire/ohci.c)
            = ohci_queue_iso()
              ->queue_iso_packet_per_buffer()
                buffer->pages[page]
      
      The issued dereference occurs in a case that:
       - target unit supports different stream formats for sampling transmission
         frequency.
       - maximum length of payload for tx stream in a first trial is bigger
         than the length in a second trial.
      
      In this case, correct number of pages are allocated for DMA and the 'pages'
      array has enough elements, while index of the element is wrongly calculated
      according to the old value of length of payload in a call of
      'queue_in_packet()'. Then it causes the issue.
      
      This commit fixes the critical bug. This affects all of drivers in ALSA
      firewire stack in Linux kernel v4.12 or later.
      
      [12665.302360] BUG: unable to handle kernel NULL pointer dereference at 0000000000000030
      [12665.302415] IP: ohci_queue_iso+0x47c/0x800 [firewire_ohci]
      [12665.302439] PGD 0
      [12665.302440] P4D 0
      [12665.302450]
      [12665.302470] Oops: 0000 [#1] SMP PTI
      [12665.302487] Modules linked in: ...
      [12665.303096] CPU: 1 PID: 12760 Comm: jackd Tainted: P           OE   4.13.0-38-generic #43-Ubuntu
      [12665.303154] Hardware name:                  /DH77DF, BIOS KCH7710H.86A.0069.2012.0224.1825 02/24/2012
      [12665.303215] task: ffff9ce87da2ae80 task.stack: ffffb5b8823d0000
      [12665.303258] RIP: 0010:ohci_queue_iso+0x47c/0x800 [firewire_ohci]
      [12665.303301] RSP: 0018:ffffb5b8823d3ab8 EFLAGS: 00010086
      [12665.303337] RAX: ffff9ce4f4876930 RBX: 0000000000000008 RCX: ffff9ce88a3955e0
      [12665.303384] RDX: 0000000000000000 RSI: 0000000034877f00 RDI: 0000000000000000
      [12665.303427] RBP: ffffb5b8823d3b68 R08: ffff9ce8ccb390a0 R09: ffff9ce877639ab0
      [12665.303475] R10: 0000000000000108 R11: 0000000000000000 R12: 0000000000000003
      [12665.303513] R13: 0000000000000000 R14: ffff9ce4f4876950 R15: 0000000000000000
      [12665.303554] FS:  00007f2ec467f8c0(0000) GS:ffff9ce8df280000(0000) knlGS:0000000000000000
      [12665.303600] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [12665.303633] CR2: 0000000000000030 CR3: 00000002dcf90004 CR4: 00000000000606e0
      [12665.303674] Call Trace:
      [12665.303698]  fw_iso_context_queue+0x18/0x20 [firewire_core]
      [12665.303735]  queue_packet+0x88/0xe0 [snd_firewire_lib]
      [12665.303770]  amdtp_stream_start+0x19b/0x270 [snd_firewire_lib]
      [12665.303811]  start_streams+0x276/0x3c0 [snd_dice]
      [12665.303840]  snd_dice_stream_start_duplex+0x1bf/0x480 [snd_dice]
      [12665.303882]  ? vma_gap_callbacks_rotate+0x1e/0x30
      [12665.303914]  ? __rb_insert_augmented+0xab/0x240
      [12665.303936]  capture_prepare+0x3c/0x70 [snd_dice]
      [12665.303961]  snd_pcm_do_prepare+0x1d/0x30 [snd_pcm]
      [12665.303985]  snd_pcm_action_single+0x3b/0x90 [snd_pcm]
      [12665.304009]  snd_pcm_action_nonatomic+0x68/0x70 [snd_pcm]
      [12665.304035]  snd_pcm_prepare+0x68/0x90 [snd_pcm]
      [12665.304058]  snd_pcm_common_ioctl1+0x4c0/0x940 [snd_pcm]
      [12665.304083]  snd_pcm_capture_ioctl1+0x19b/0x250 [snd_pcm]
      [12665.304108]  snd_pcm_capture_ioctl+0x27/0x40 [snd_pcm]
      [12665.304131]  do_vfs_ioctl+0xa8/0x630
      [12665.304148]  ? entry_SYSCALL_64_after_hwframe+0xe9/0x139
      [12665.304172]  ? entry_SYSCALL_64_after_hwframe+0xe2/0x139
      [12665.304195]  ? entry_SYSCALL_64_after_hwframe+0xdb/0x139
      [12665.304218]  ? entry_SYSCALL_64_after_hwframe+0xd4/0x139
      [12665.304242]  ? entry_SYSCALL_64_after_hwframe+0xcd/0x139
      [12665.304265]  ? entry_SYSCALL_64_after_hwframe+0xc6/0x139
      [12665.304288]  ? entry_SYSCALL_64_after_hwframe+0xbf/0x139
      [12665.304312]  ? entry_SYSCALL_64_after_hwframe+0xb8/0x139
      [12665.304335]  ? entry_SYSCALL_64_after_hwframe+0xb1/0x139
      [12665.304358]  SyS_ioctl+0x79/0x90
      [12665.304374]  ? entry_SYSCALL_64_after_hwframe+0x72/0x139
      [12665.304397]  entry_SYSCALL_64_fastpath+0x24/0xab
      [12665.304417] RIP: 0033:0x7f2ec3750ef7
      [12665.304433] RSP: 002b:00007fff99e31388 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      [12665.304465] RAX: ffffffffffffffda RBX: 00007fff99e312f0 RCX: 00007f2ec3750ef7
      [12665.304494] RDX: 0000000000000000 RSI: 0000000000004140 RDI: 0000000000000007
      [12665.304522] RBP: 0000556ebc63fd60 R08: 0000556ebc640560 R09: 0000000000000000
      [12665.304553] R10: 0000000000000001 R11: 0000000000000246 R12: 0000556ebc63fcf0
      [12665.304584] R13: 0000000000000000 R14: 0000000000000007 R15: 0000000000000000
      [12665.304612] Code: 01 00 00 44 89 eb 45 31 ed 45 31 db 66 41 89 1e 66 41 89 5e 0c 66 45 89 5e 0e 49 8b 49 08 49 63 d4 4d 85 c0 49 63 ff 48 8b 14 d1 <48> 8b 72 30 41 8d 14 37 41 89 56 04 48 63 d3 0f 84 ce 00 00 00
      [12665.304713] RIP: ohci_queue_iso+0x47c/0x800 [firewire_ohci] RSP: ffffb5b8823d3ab8
      [12665.304743] CR2: 0000000000000030
      [12665.317701] ---[ end trace 9d55b056dd52a19f ]---
      
      Fixes: f91c9d76 ('ALSA: firewire-lib: cache maximum length of payload to reduce function calls')
      Cc: <stable@vger.kernel.org> # v4.12+
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9581fff3