1. 05 3月, 2020 40 次提交
    • E
      inetpeer: fix data-race in inet_putpeer / inet_putpeer · 9b7eea5c
      Eric Dumazet 提交于
      commit 71685eb4ce80ae9c49eff82ca4dd15acab215de9 upstream.
      
      We need to explicitely forbid read/store tearing in inet_peer_gc()
      and inet_putpeer().
      
      The following syzbot report reminds us about inet_putpeer()
      running without a lock held.
      
      BUG: KCSAN: data-race in inet_putpeer / inet_putpeer
      
      write to 0xffff888121fb2ed0 of 4 bytes by interrupt on cpu 0:
       inet_putpeer+0x37/0xa0 net/ipv4/inetpeer.c:240
       ip4_frag_free+0x3d/0x50 net/ipv4/ip_fragment.c:102
       inet_frag_destroy_rcu+0x58/0x80 net/ipv4/inet_fragment.c:228
       __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
       rcu_do_batch+0x256/0x5b0 kernel/rcu/tree.c:2157
       rcu_core+0x369/0x4d0 kernel/rcu/tree.c:2377
       rcu_core_si+0x12/0x20 kernel/rcu/tree.c:2386
       __do_softirq+0x115/0x33f kernel/softirq.c:292
       invoke_softirq kernel/softirq.c:373 [inline]
       irq_exit+0xbb/0xe0 kernel/softirq.c:413
       exiting_irq arch/x86/include/asm/apic.h:536 [inline]
       smp_apic_timer_interrupt+0xe6/0x280 arch/x86/kernel/apic/apic.c:1137
       apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:830
       native_safe_halt+0xe/0x10 arch/x86/kernel/paravirt.c:71
       arch_cpu_idle+0x1f/0x30 arch/x86/kernel/process.c:571
       default_idle_call+0x1e/0x40 kernel/sched/idle.c:94
       cpuidle_idle_call kernel/sched/idle.c:154 [inline]
       do_idle+0x1af/0x280 kernel/sched/idle.c:263
      
      write to 0xffff888121fb2ed0 of 4 bytes by interrupt on cpu 1:
       inet_putpeer+0x37/0xa0 net/ipv4/inetpeer.c:240
       ip4_frag_free+0x3d/0x50 net/ipv4/ip_fragment.c:102
       inet_frag_destroy_rcu+0x58/0x80 net/ipv4/inet_fragment.c:228
       __rcu_reclaim kernel/rcu/rcu.h:222 [inline]
       rcu_do_batch+0x256/0x5b0 kernel/rcu/tree.c:2157
       rcu_core+0x369/0x4d0 kernel/rcu/tree.c:2377
       rcu_core_si+0x12/0x20 kernel/rcu/tree.c:2386
       __do_softirq+0x115/0x33f kernel/softirq.c:292
       run_ksoftirqd+0x46/0x60 kernel/softirq.c:603
       smpboot_thread_fn+0x37d/0x4a0 kernel/smpboot.c:165
       kthread+0x1d4/0x200 drivers/block/aoe/aoecmd.c:1253
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 16 Comm: ksoftirqd/1 Not tainted 5.4.0-rc3+ #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 4b9d9be8 ("inetpeer: remove unused list")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      9b7eea5c
    • E
      netfilter: bridge: make sure to pull arp header in br_nf_forward_arp() · 891a81d1
      Eric Dumazet 提交于
      commit 5604285839aaedfb23ebe297799c6e558939334d upstream.
      
      syzbot is kind enough to remind us we need to call skb_may_pull()
      
      BUG: KMSAN: uninit-value in br_nf_forward_arp+0xe61/0x1230 net/bridge/br_netfilter_hooks.c:665
      CPU: 1 PID: 11631 Comm: syz-executor.1 Not tainted 5.4.0-rc8-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x1c9/0x220 lib/dump_stack.c:118
       kmsan_report+0x128/0x220 mm/kmsan/kmsan_report.c:108
       __msan_warning+0x64/0xc0 mm/kmsan/kmsan_instr.c:245
       br_nf_forward_arp+0xe61/0x1230 net/bridge/br_netfilter_hooks.c:665
       nf_hook_entry_hookfn include/linux/netfilter.h:135 [inline]
       nf_hook_slow+0x18b/0x3f0 net/netfilter/core.c:512
       nf_hook include/linux/netfilter.h:260 [inline]
       NF_HOOK include/linux/netfilter.h:303 [inline]
       __br_forward+0x78f/0xe30 net/bridge/br_forward.c:109
       br_flood+0xef0/0xfe0 net/bridge/br_forward.c:234
       br_handle_frame_finish+0x1a77/0x1c20 net/bridge/br_input.c:162
       nf_hook_bridge_pre net/bridge/br_input.c:245 [inline]
       br_handle_frame+0xfb6/0x1eb0 net/bridge/br_input.c:348
       __netif_receive_skb_core+0x20b9/0x51a0 net/core/dev.c:4830
       __netif_receive_skb_one_core net/core/dev.c:4927 [inline]
       __netif_receive_skb net/core/dev.c:5043 [inline]
       process_backlog+0x610/0x13c0 net/core/dev.c:5874
       napi_poll net/core/dev.c:6311 [inline]
       net_rx_action+0x7a6/0x1aa0 net/core/dev.c:6379
       __do_softirq+0x4a1/0x83a kernel/softirq.c:293
       do_softirq_own_stack+0x49/0x80 arch/x86/entry/entry_64.S:1091
       </IRQ>
       do_softirq kernel/softirq.c:338 [inline]
       __local_bh_enable_ip+0x184/0x1d0 kernel/softirq.c:190
       local_bh_enable+0x36/0x40 include/linux/bottom_half.h:32
       rcu_read_unlock_bh include/linux/rcupdate.h:688 [inline]
       __dev_queue_xmit+0x38e8/0x4200 net/core/dev.c:3819
       dev_queue_xmit+0x4b/0x60 net/core/dev.c:3825
       packet_snd net/packet/af_packet.c:2959 [inline]
       packet_sendmsg+0x8234/0x9100 net/packet/af_packet.c:2984
       sock_sendmsg_nosec net/socket.c:637 [inline]
       sock_sendmsg net/socket.c:657 [inline]
       __sys_sendto+0xc44/0xc70 net/socket.c:1952
       __do_sys_sendto net/socket.c:1964 [inline]
       __se_sys_sendto+0x107/0x130 net/socket.c:1960
       __x64_sys_sendto+0x6e/0x90 net/socket.c:1960
       do_syscall_64+0xb6/0x160 arch/x86/entry/common.c:291
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x45a679
      Code: ad b6 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 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
      RSP: 002b:00007f0a3c9e5c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
      RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 000000000045a679
      RDX: 000000000000000e RSI: 0000000020000200 RDI: 0000000000000003
      RBP: 000000000075bf20 R08: 00000000200000c0 R09: 0000000000000014
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f0a3c9e66d4
      R13: 00000000004c8ec1 R14: 00000000004dfe28 R15: 00000000ffffffff
      
      Uninit was created at:
       kmsan_save_stack_with_flags mm/kmsan/kmsan.c:149 [inline]
       kmsan_internal_poison_shadow+0x5c/0x110 mm/kmsan/kmsan.c:132
       kmsan_slab_alloc+0x97/0x100 mm/kmsan/kmsan_hooks.c:86
       slab_alloc_node mm/slub.c:2773 [inline]
       __kmalloc_node_track_caller+0xe27/0x11a0 mm/slub.c:4381
       __kmalloc_reserve net/core/skbuff.c:141 [inline]
       __alloc_skb+0x306/0xa10 net/core/skbuff.c:209
       alloc_skb include/linux/skbuff.h:1049 [inline]
       alloc_skb_with_frags+0x18c/0xa80 net/core/skbuff.c:5662
       sock_alloc_send_pskb+0xafd/0x10a0 net/core/sock.c:2244
       packet_alloc_skb net/packet/af_packet.c:2807 [inline]
       packet_snd net/packet/af_packet.c:2902 [inline]
       packet_sendmsg+0x63a6/0x9100 net/packet/af_packet.c:2984
       sock_sendmsg_nosec net/socket.c:637 [inline]
       sock_sendmsg net/socket.c:657 [inline]
       __sys_sendto+0xc44/0xc70 net/socket.c:1952
       __do_sys_sendto net/socket.c:1964 [inline]
       __se_sys_sendto+0x107/0x130 net/socket.c:1960
       __x64_sys_sendto+0x6e/0x90 net/socket.c:1960
       do_syscall_64+0xb6/0x160 arch/x86/entry/common.c:291
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: c4e70a87 ("netfilter: bridge: rename br_netfilter.c to br_netfilter_hooks.c")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Reviewed-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      891a81d1
    • E
      6pack,mkiss: fix possible deadlock · c2e8f34e
      Eric Dumazet 提交于
      commit 5c9934b6767b16ba60be22ec3cbd4379ad64170d upstream.
      
      We got another syzbot report [1] that tells us we must use
      write_lock_irq()/write_unlock_irq() to avoid possible deadlock.
      
      [1]
      
      WARNING: inconsistent lock state
      5.5.0-rc1-syzkaller #0 Not tainted
      --------------------------------
      inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-R} usage.
      syz-executor826/9605 [HC1[1]:SC0[0]:HE0:SE1] takes:
      ffffffff8a128718 (disc_data_lock){+-..}, at: sp_get.isra.0+0x1d/0xf0 drivers/net/ppp/ppp_synctty.c:138
      {HARDIRQ-ON-W} state was registered at:
        lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4485
        __raw_write_lock_bh include/linux/rwlock_api_smp.h:203 [inline]
        _raw_write_lock_bh+0x33/0x50 kernel/locking/spinlock.c:319
        sixpack_close+0x1d/0x250 drivers/net/hamradio/6pack.c:657
        tty_ldisc_close.isra.0+0x119/0x1a0 drivers/tty/tty_ldisc.c:489
        tty_set_ldisc+0x230/0x6b0 drivers/tty/tty_ldisc.c:585
        tiocsetd drivers/tty/tty_io.c:2337 [inline]
        tty_ioctl+0xe8d/0x14f0 drivers/tty/tty_io.c:2597
        vfs_ioctl fs/ioctl.c:47 [inline]
        file_ioctl fs/ioctl.c:545 [inline]
        do_vfs_ioctl+0x977/0x14e0 fs/ioctl.c:732
        ksys_ioctl+0xab/0xd0 fs/ioctl.c:749
        __do_sys_ioctl fs/ioctl.c:756 [inline]
        __se_sys_ioctl fs/ioctl.c:754 [inline]
        __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:754
        do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      irq event stamp: 3946
      hardirqs last  enabled at (3945): [<ffffffff87c86e43>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:168 [inline]
      hardirqs last  enabled at (3945): [<ffffffff87c86e43>] _raw_spin_unlock_irq+0x23/0x80 kernel/locking/spinlock.c:199
      hardirqs last disabled at (3946): [<ffffffff8100675f>] trace_hardirqs_off_thunk+0x1a/0x1c arch/x86/entry/thunk_64.S:42
      softirqs last  enabled at (2658): [<ffffffff86a8b4df>] spin_unlock_bh include/linux/spinlock.h:383 [inline]
      softirqs last  enabled at (2658): [<ffffffff86a8b4df>] clusterip_netdev_event+0x46f/0x670 net/ipv4/netfilter/ipt_CLUSTERIP.c:222
      softirqs last disabled at (2656): [<ffffffff86a8b22b>] spin_lock_bh include/linux/spinlock.h:343 [inline]
      softirqs last disabled at (2656): [<ffffffff86a8b22b>] clusterip_netdev_event+0x1bb/0x670 net/ipv4/netfilter/ipt_CLUSTERIP.c:196
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(disc_data_lock);
        <Interrupt>
          lock(disc_data_lock);
      
       *** DEADLOCK ***
      
      5 locks held by syz-executor826/9605:
       #0: ffff8880a905e198 (&tty->legacy_mutex){+.+.}, at: tty_lock+0xc7/0x130 drivers/tty/tty_mutex.c:19
       #1: ffffffff899a56c0 (rcu_read_lock){....}, at: mutex_spin_on_owner+0x0/0x330 kernel/locking/mutex.c:413
       #2: ffff8880a496a2b0 (&(&i->lock)->rlock){-.-.}, at: spin_lock include/linux/spinlock.h:338 [inline]
       #2: ffff8880a496a2b0 (&(&i->lock)->rlock){-.-.}, at: serial8250_interrupt+0x2d/0x1a0 drivers/tty/serial/8250/8250_core.c:116
       #3: ffffffff8c104048 (&port_lock_key){-.-.}, at: serial8250_handle_irq.part.0+0x24/0x330 drivers/tty/serial/8250/8250_port.c:1823
       #4: ffff8880a905e090 (&tty->ldisc_sem){++++}, at: tty_ldisc_ref+0x22/0x90 drivers/tty/tty_ldisc.c:288
      
      stack backtrace:
      CPU: 1 PID: 9605 Comm: syz-executor826 Not tainted 5.5.0-rc1-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x197/0x210 lib/dump_stack.c:118
       print_usage_bug.cold+0x327/0x378 kernel/locking/lockdep.c:3101
       valid_state kernel/locking/lockdep.c:3112 [inline]
       mark_lock_irq kernel/locking/lockdep.c:3309 [inline]
       mark_lock+0xbb4/0x1220 kernel/locking/lockdep.c:3666
       mark_usage kernel/locking/lockdep.c:3554 [inline]
       __lock_acquire+0x1e55/0x4a00 kernel/locking/lockdep.c:3909
       lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4485
       __raw_read_lock include/linux/rwlock_api_smp.h:149 [inline]
       _raw_read_lock+0x32/0x50 kernel/locking/spinlock.c:223
       sp_get.isra.0+0x1d/0xf0 drivers/net/ppp/ppp_synctty.c:138
       sixpack_write_wakeup+0x25/0x340 drivers/net/hamradio/6pack.c:402
       tty_wakeup+0xe9/0x120 drivers/tty/tty_io.c:536
       tty_port_default_wakeup+0x2b/0x40 drivers/tty/tty_port.c:50
       tty_port_tty_wakeup+0x57/0x70 drivers/tty/tty_port.c:387
       uart_write_wakeup+0x46/0x70 drivers/tty/serial/serial_core.c:104
       serial8250_tx_chars+0x495/0xaf0 drivers/tty/serial/8250/8250_port.c:1761
       serial8250_handle_irq.part.0+0x2a2/0x330 drivers/tty/serial/8250/8250_port.c:1834
       serial8250_handle_irq drivers/tty/serial/8250/8250_port.c:1820 [inline]
       serial8250_default_handle_irq+0xc0/0x150 drivers/tty/serial/8250/8250_port.c:1850
       serial8250_interrupt+0xf1/0x1a0 drivers/tty/serial/8250/8250_core.c:126
       __handle_irq_event_percpu+0x15d/0x970 kernel/irq/handle.c:149
       handle_irq_event_percpu+0x74/0x160 kernel/irq/handle.c:189
       handle_irq_event+0xa7/0x134 kernel/irq/handle.c:206
       handle_edge_irq+0x25e/0x8d0 kernel/irq/chip.c:830
       generic_handle_irq_desc include/linux/irqdesc.h:156 [inline]
       do_IRQ+0xde/0x280 arch/x86/kernel/irq.c:250
       common_interrupt+0xf/0xf arch/x86/entry/entry_64.S:607
       </IRQ>
      RIP: 0010:cpu_relax arch/x86/include/asm/processor.h:685 [inline]
      RIP: 0010:mutex_spin_on_owner+0x247/0x330 kernel/locking/mutex.c:579
      Code: c3 be 08 00 00 00 4c 89 e7 e8 e5 06 59 00 4c 89 e0 48 c1 e8 03 42 80 3c 38 00 0f 85 e1 00 00 00 49 8b 04 24 a8 01 75 96 f3 90 <e9> 2f fe ff ff 0f 0b e8 0d 19 09 00 84 c0 0f 85 ff fd ff ff 48 c7
      RSP: 0018:ffffc90001eafa20 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffd7
      RAX: 0000000000000000 RBX: ffff88809fd9e0c0 RCX: 1ffffffff13266dd
      RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000000
      RBP: ffffc90001eafa60 R08: 1ffff11013d22898 R09: ffffed1013d22899
      R10: ffffed1013d22898 R11: ffff88809e9144c7 R12: ffff8880a905e138
      R13: ffff88809e9144c0 R14: 0000000000000000 R15: dffffc0000000000
       mutex_optimistic_spin kernel/locking/mutex.c:673 [inline]
       __mutex_lock_common kernel/locking/mutex.c:962 [inline]
       __mutex_lock+0x32b/0x13c0 kernel/locking/mutex.c:1106
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1121
       tty_lock+0xc7/0x130 drivers/tty/tty_mutex.c:19
       tty_release+0xb5/0xe90 drivers/tty/tty_io.c:1665
       __fput+0x2ff/0x890 fs/file_table.c:280
       ____fput+0x16/0x20 fs/file_table.c:313
       task_work_run+0x145/0x1c0 kernel/task_work.c:113
       exit_task_work include/linux/task_work.h:22 [inline]
       do_exit+0x8e7/0x2ef0 kernel/exit.c:797
       do_group_exit+0x135/0x360 kernel/exit.c:895
       __do_sys_exit_group kernel/exit.c:906 [inline]
       __se_sys_exit_group kernel/exit.c:904 [inline]
       __x64_sys_exit_group+0x44/0x50 kernel/exit.c:904
       do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
       entry_SYSCALL_64_after_hwframe+0x49/0xbe
      RIP: 0033:0x43fef8
      Code: Bad RIP value.
      RSP: 002b:00007ffdb07d2338 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043fef8
      RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
      RBP: 00000000004bf730 R08: 00000000000000e7 R09: ffffffffffffffd0
      R10: 00000000004002c8 R11: 0000000000000246 R12: 0000000000000001
      R13: 00000000006d1180 R14: 0000000000000000 R15: 0000000000000000
      
      Fixes: 6e4e2f81 ("6pack,mkiss: fix lock inconsistency")
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      c2e8f34e
    • F
      netfilter: ebtables: compat: reject all padding in matches/watchers · a8245dfb
      Florian Westphal 提交于
      commit e608f631f0ba5f1fc5ee2e260a3a35d13107cbfe upstream.
      
      syzbot reported following splat:
      
      BUG: KASAN: vmalloc-out-of-bounds in size_entry_mwt net/bridge/netfilter/ebtables.c:2063 [inline]
      BUG: KASAN: vmalloc-out-of-bounds in compat_copy_entries+0x128b/0x1380 net/bridge/netfilter/ebtables.c:2155
      Read of size 4 at addr ffffc900004461f4 by task syz-executor267/7937
      
      CPU: 1 PID: 7937 Comm: syz-executor267 Not tainted 5.5.0-rc1-syzkaller #0
       size_entry_mwt net/bridge/netfilter/ebtables.c:2063 [inline]
       compat_copy_entries+0x128b/0x1380 net/bridge/netfilter/ebtables.c:2155
       compat_do_replace+0x344/0x720 net/bridge/netfilter/ebtables.c:2249
       compat_do_ebt_set_ctl+0x22f/0x27e net/bridge/netfilter/ebtables.c:2333
       [..]
      
      Because padding isn't considered during computation of ->buf_user_offset,
      "total" is decremented by fewer bytes than it should.
      
      Therefore, the first part of
      
      if (*total < sizeof(*entry) || entry->next_offset < sizeof(*entry))
      
      will pass, -- it should not have.  This causes oob access:
      entry->next_offset is past the vmalloced size.
      
      Reject padding and check that computed user offset (sum of ebt_entry
      structure plus all individual matches/watchers/targets) is same
      value that userspace gave us as the offset of the next entry.
      
      Reported-by: syzbot+f68108fed972453a0ad4@syzkaller.appspotmail.com
      Fixes: 81e675c2 ("netfilter: ebtables: add CONFIG_COMPAT support")
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      a8245dfb
    • M
      bonding: fix active-backup transition after link failure · c7be4c3b
      Mahesh Bandewar 提交于
      [ Upstream commit 5d485ed88d48f8101a2067348e267c0aaf4ed486 ]
      
      After the recent fix in commit 1899bb325149 ("bonding: fix state
      transition issue in link monitoring"), the active-backup mode with
      miimon initially come-up fine but after a link-failure, both members
      transition into backup state.
      
      Following steps to reproduce the scenario (eth1 and eth2 are the
      slaves of the bond):
      
          ip link set eth1 up
          ip link set eth2 down
          sleep 1
          ip link set eth2 up
          ip link set eth1 down
          cat /sys/class/net/eth1/bonding_slave/state
          cat /sys/class/net/eth2/bonding_slave/state
      
      Fixes: 1899bb325149 ("bonding: fix state transition issue in link monitoring")
      CC: Jay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: NMahesh Bandewar <maheshb@google.com>
      Acked-by: NJay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      c7be4c3b
    • T
      ALSA: hda - Downgrade error message for single-cmd fallback · 25603234
      Takashi Iwai 提交于
      [ Upstream commit 475feec0c41ad71cb7d02f0310e56256606b57c5 ]
      
      We made the error message for the CORB/RIRB communication clearer by
      upgrading to dev_WARN() so that user can notice better.  But this
      struck us like a boomerang: now it caught syzbot and reported back as
      a fatal issue although it's not really any too serious bug that worth
      for stopping the whole system.
      
      OK, OK, let's be softy, downgrade it to the standard dev_err() again.
      
      Fixes: dd65f7e19c69 ("ALSA: hda - Show the fatal CORB/RIRB error more clearly")
      Reported-by: syzbot+b3028ac3933f5c466389@syzkaller.appspotmail.com
      Link: https://lore.kernel.org/r/20191216151224.30013-1-tiwai@suse.deSigned-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      25603234
    • M
      netfilter: nf_queue: enqueue skbs with NULL dst · 85f9f443
      Marco Oliverio 提交于
      [ Upstream commit 0b9173f4688dfa7c5d723426be1d979c24ce3d51 ]
      
      Bridge packets that are forwarded have skb->dst == NULL and get
      dropped by the check introduced by
      b60a77386b1d4868f72f6353d35dabe5fbe981f2 (net: make skb_dst_force
      return true when dst is refcounted).
      
      To fix this we check skb_dst() before skb_dst_force(), so we don't
      drop skb packet with dst == NULL. This holds also for skb at the
      PRE_ROUTING hook so we remove the second check.
      
      Fixes: b60a77386b1d ("net: make skb_dst_force return true when dst is refcounted")
      Signed-off-by: NMarco Oliverio <marco.oliverio@tanaza.com>
      Signed-off-by: NRocco Folino <rocco.folino@tanaza.com>
      Acked-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      85f9f443
    • A
      net, sysctl: Fix compiler warning when only cBPF is present · ce4e5678
      Alexander Lobakin 提交于
      [ Upstream commit 1148f9adbe71415836a18a36c1b4ece999ab0973 ]
      
      proc_dointvec_minmax_bpf_restricted() has been firstly introduced
      in commit 2e4a3098 ("bpf: restrict access to core bpf sysctls")
      under CONFIG_HAVE_EBPF_JIT. Then, this ifdef has been removed in
      ede95a63b5e8 ("bpf: add bpf_jit_limit knob to restrict unpriv
      allocations"), because a new sysctl, bpf_jit_limit, made use of it.
      Finally, this parameter has become long instead of integer with
      fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
      and thus, a new proc_dolongvec_minmax_bpf_restricted() has been
      added.
      
      With this last change, we got back to that
      proc_dointvec_minmax_bpf_restricted() is used only under
      CONFIG_HAVE_EBPF_JIT, but the corresponding ifdef has not been
      brought back.
      
      So, in configurations like CONFIG_BPF_JIT=y && CONFIG_HAVE_EBPF_JIT=n
      since v4.20 we have:
      
        CC      net/core/sysctl_net_core.o
      net/core/sysctl_net_core.c:292:1: warning: ‘proc_dointvec_minmax_bpf_restricted’ defined but not used [-Wunused-function]
        292 | proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
            | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Suppress this by guarding it with CONFIG_HAVE_EBPF_JIT again.
      
      Fixes: fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
      Signed-off-by: NAlexander Lobakin <alobakin@dlink.ru>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20191218091821.7080-1-alobakin@dlink.ruSigned-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ce4e5678
    • J
      x86/mce: Fix possibly incorrect severity calculation on AMD · ae126ba4
      Jan H. Schönherr 提交于
      [ Upstream commit a3a57ddad061acc90bef39635caf2b2330ce8f21 ]
      
      The function mce_severity_amd_smca() requires m->bank to be initialized
      for correct operation. Fix the one case, where mce_severity() is called
      without doing so.
      
      Fixes: 6bda529e ("x86/mce: Grade uncorrected errors for SMCA-enabled systems")
      Fixes: d28af26faa0b ("x86/MCE: Initialize mce.bank in the case of a fatal error in mce_no_way_out()")
      Signed-off-by: NJan H. Schönherr <jschoenh@amazon.de>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Reviewed-by: NTony Luck <tony.luck@intel.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: linux-edac <linux-edac@vger.kernel.org>
      Cc: <stable@vger.kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Cc: Yazen Ghannam <Yazen.Ghannam@amd.com>
      Link: https://lkml.kernel.org/r/20191210000733.17979-4-jschoenh@amazon.deSigned-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ae126ba4
    • G
      Revert "powerpc/vcpu: Assume dedicated processors as non-preempt" · f6ab004e
      Greg Kroah-Hartman 提交于
      This reverts commit 4ba32bdbd8c66d9c7822aea8dcf4e51410df84a8 which is
      commit 14c73bd344da60abaf7da3ea2e7733ddda35bbac upstream.
      
      It breaks the build.
      
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Parth Shah <parth@linux.ibm.com>
      Cc: Ihor Pasichnyk <Ihor.Pasichnyk@ibm.com>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Phil Auld <pauld@redhat.com>
      Cc: Vaidyanathan Srinivasan <svaidy@linux.ibm.com>
      Cc: Parth Shah <parth@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      f6ab004e
    • M
      userfaultfd: require CAP_SYS_PTRACE for UFFD_FEATURE_EVENT_FORK · bca5de8e
      Mike Rapoport 提交于
      [ Upstream commit 3c1c24d91ffd536de0a64688a9df7f49e58fadbc ]
      
      A while ago Andy noticed
      (http://lkml.kernel.org/r/CALCETrWY+5ynDct7eU_nDUqx=okQvjm=Y5wJvA4ahBja=CQXGw@mail.gmail.com)
      that UFFD_FEATURE_EVENT_FORK used by an unprivileged user may have
      security implications.
      
      As the first step of the solution the following patch limits the availably
      of UFFD_FEATURE_EVENT_FORK only for those having CAP_SYS_PTRACE.
      
      The usage of CAP_SYS_PTRACE ensures compatibility with CRIU.
      
      Yet, if there are other users of non-cooperative userfaultfd that run
      without CAP_SYS_PTRACE, they would be broken :(
      
      Current implementation of UFFD_FEATURE_EVENT_FORK modifies the file
      descriptor table from the read() implementation of uffd, which may have
      security implications for unprivileged use of the userfaultfd.
      
      Limit availability of UFFD_FEATURE_EVENT_FORK only for callers that have
      CAP_SYS_PTRACE.
      
      Link: http://lkml.kernel.org/r/1572967777-8812-2-git-send-email-rppt@linux.ibm.comSigned-off-by: NMike Rapoport <rppt@linux.ibm.com>
      Reviewed-by: NAndrea Arcangeli <aarcange@redhat.com>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Lokesh Gidra <lokeshgidra@google.com>
      Cc: Nick Kralevich <nnk@google.com>
      Cc: Nosh Minwalla <nosh@google.com>
      Cc: Pavel Emelyanov <ovzxemul@gmail.com>
      Cc: Tim Murray <timmurray@google.com>
      Cc: Aleksa Sarai <cyphar@cyphar.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      bca5de8e
    • J
      kernel: sysctl: make drop_caches write-only · 911f9155
      Johannes Weiner 提交于
      [ Upstream commit 204cb79ad42f015312a5bbd7012d09c93d9b46fb ]
      
      Currently, the drop_caches proc file and sysctl read back the last value
      written, suggesting this is somehow a stateful setting instead of a
      one-time command.  Make it write-only, like e.g.  compact_memory.
      
      While mitigating a VM problem at scale in our fleet, there was confusion
      about whether writing to this file will permanently switch the kernel into
      a non-caching mode.  This influences the decision making in a tense
      situation, where tens of people are trying to fix tens of thousands of
      affected machines: Do we need a rollback strategy?  What are the
      performance implications of operating in a non-caching state for several
      days?  It also caused confusion when the kernel team said we may need to
      write the file several times to make sure it's effective ("But it already
      reads back 3?").
      
      Link: http://lkml.kernel.org/r/20191031221602.9375-1-hannes@cmpxchg.orgSigned-off-by: NJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: NChris Down <chris@chrisdown.name>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: NDavid Hildenbrand <david@redhat.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Acked-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      911f9155
    • D
      mailbox: imx: Fix Tx doorbell shutdown path · 400a68dc
      Daniel Baluta 提交于
      [ Upstream commit bf159d151a0b844be28882f39e316b5800acaa2b ]
      
      Tx doorbell is handled by txdb_tasklet and doesn't
      have an associated IRQ.
      
      Anyhow, imx_mu_shutdown ignores this and tries to
      free an IRQ that wasn't requested for Tx DB resulting
      in the following warning:
      
      [    1.967644] Trying to free already-free IRQ 26
      [    1.972108] WARNING: CPU: 2 PID: 157 at kernel/irq/manage.c:1708 __free_irq+0xc0/0x358
      [    1.980024] Modules linked in:
      [    1.983088] CPU: 2 PID: 157 Comm: kworker/2:1 Tainted: G
      [    1.993524] Hardware name: Freescale i.MX8QXP MEK (DT)
      [    1.998668] Workqueue: events deferred_probe_work_func
      [    2.003812] pstate: 60000085 (nZCv daIf -PAN -UAO)
      [    2.008607] pc : __free_irq+0xc0/0x358
      [    2.012364] lr : __free_irq+0xc0/0x358
      [    2.016111] sp : ffff00001179b7e0
      [    2.019422] x29: ffff00001179b7e0 x28: 0000000000000018
      [    2.024736] x27: ffff000011233000 x26: 0000000000000004
      [    2.030053] x25: 000000000000001a x24: ffff80083bec74d4
      [    2.035369] x23: 0000000000000000 x22: ffff80083bec7588
      [    2.040686] x21: ffff80083b1fe8d8 x20: ffff80083bec7400
      [    2.046003] x19: 0000000000000000 x18: ffffffffffffffff
      [    2.051320] x17: 0000000000000000 x16: 0000000000000000
      [    2.056637] x15: ffff0000111296c8 x14: ffff00009179b517
      [    2.061953] x13: ffff00001179b525 x12: ffff000011142000
      [    2.067270] x11: ffff000011129f20 x10: ffff0000105da970
      [    2.072587] x9 : 00000000ffffffd0 x8 : 0000000000000194
      [    2.077903] x7 : 612065657266206f x6 : ffff0000111e7b09
      [    2.083220] x5 : 0000000000000003 x4 : 0000000000000000
      [    2.088537] x3 : 0000000000000000 x2 : 00000000ffffffff
      [    2.093854] x1 : 28b70f0a2b60a500 x0 : 0000000000000000
      [    2.099173] Call trace:
      [    2.101618]  __free_irq+0xc0/0x358
      [    2.105021]  free_irq+0x38/0x98
      [    2.108170]  imx_mu_shutdown+0x90/0xb0
      [    2.111921]  mbox_free_channel.part.2+0x24/0xb8
      [    2.116453]  mbox_free_channel+0x18/0x28
      
      This bug is present from the beginning of times.
      
      Cc: Oleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: NDaniel Baluta <daniel.baluta@nxp.com>
      Signed-off-by: NRichard Zhu <hongxing.zhu@nxp.com>
      Reviewed-by: NDong Aisheng <aisheng.dong@nxp.com>
      Signed-off-by: NJassi Brar <jaswinder.singh@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      400a68dc
    • D
      ocfs2: fix passing zero to 'PTR_ERR' warning · ba7ca5da
      Ding Xiang 提交于
      [ Upstream commit 188c523e1c271d537f3c9f55b6b65bf4476de32f ]
      
      Fix a static code checker warning:
      fs/ocfs2/acl.c:331
      	ocfs2_acl_chmod() warn: passing zero to 'PTR_ERR'
      
      Link: http://lkml.kernel.org/r/1dee278b-6c96-eec2-ce76-fe6e07c6e20f@linux.alibaba.com
      Fixes: 5ee0fbd5 ("ocfs2: revert using ocfs2_acl_chmod to avoid inode cluster lock hang")
      Signed-off-by: NDing Xiang <dingxiang@cmss.chinamobile.com>
      Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ba7ca5da
    • T
      s390/cpum_sf: Check for SDBT and SDB consistency · 39749c7d
      Thomas Richter 提交于
      [ Upstream commit 247f265fa502e7b17a0cb0cc330e055a36aafce4 ]
      
      Each SBDT is located at a 4KB page and contains 512 entries.
      Each entry of a SDBT points to a SDB, a 4KB page containing
      sampled data. The last entry is a link to another SDBT page.
      
      When an event is created the function sequence executed is:
      
        __hw_perf_event_init()
        +--> allocate_buffers()
             +--> realloc_sampling_buffers()
      	    +---> alloc_sample_data_block()
      
      Both functions realloc_sampling_buffers() and
      alloc_sample_data_block() allocate pages and the allocation
      can fail. This is handled correctly and all allocated
      pages are freed and error -ENOMEM is returned to the
      top calling function. Finally the event is not created.
      
      Once the event has been created, the amount of initially
      allocated SDBT and SDB can be too low. This is detected
      during measurement interrupt handling, where the amount
      of lost samples is calculated. If the number of lost samples
      is too high considering sampling frequency and already allocated
      SBDs, the number of SDBs is enlarged during the next execution
      of cpumsf_pmu_enable().
      
      If more SBDs need to be allocated, functions
      
             realloc_sampling_buffers()
             +---> alloc-sample_data_block()
      
      are called to allocate more pages. Page allocation may fail
      and the returned error is ignored. A SDBT and SDB setup
      already exists.
      
      However the modified SDBTs and SDBs might end up in a situation
      where the first entry of an SDBT does not point to an SDB,
      but another SDBT, basicly an SBDT without payload.
      This can not be handled by the interrupt handler, where an SDBT
      must have at least one entry pointing to an SBD.
      
      Add a check to avoid SDBTs with out payload (SDBs) when enlarging
      the buffer setup.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      39749c7d
    • M
      libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h · b409b11b
      Masahiro Yamada 提交于
      [ Upstream commit a8de1304b7df30e3a14f2a8b9709bb4ff31a0385 ]
      
      The DTC v1.5.1 added references to (U)INT32_MAX.
      
      This is no problem for user-space programs since <stdint.h> defines
      (U)INT32_MAX along with (u)int32_t.
      
      For the kernel space, libfdt_env.h needs to be adjusted before we
      pull in the changes.
      
      In the kernel, we usually use s/u32 instead of (u)int32_t for the
      fixed-width types.
      
      Accordingly, we already have S/U32_MAX for their max values.
      So, we should not add (U)INT32_MAX to <linux/limits.h> any more.
      
      Instead, add them to the in-kernel libfdt_env.h to compile the
      latest libfdt.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      b409b11b
    • H
      s390/zcrypt: handle new reply code FILTERED_BY_HYPERVISOR · 16b76268
      Harald Freudenberger 提交于
      [ Upstream commit 6733775a92eacd612ac88afa0fd922e4ffeb2bc7 ]
      
      This patch introduces support for a new architectured reply
      code 0x8B indicating that a hypervisor layer (if any) has
      rejected an ap message.
      
      Linux may run as a guest on top of a hypervisor like zVM
      or KVM. So the crypto hardware seen by the ap bus may be
      restricted by the hypervisor for example only a subset like
      only clear key crypto requests may be supported. Other
      requests will be filtered out - rejected by the hypervisor.
      The new reply code 0x8B will appear in such cases and needs
      to get recognized by the ap bus and zcrypt device driver zoo.
      Signed-off-by: NHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      16b76268
    • A
      perf regs: Make perf_reg_name() return "unknown" instead of NULL · 905184a9
      Arnaldo Carvalho de Melo 提交于
      [ Upstream commit 5b596e0ff0e1852197d4c82d3314db5e43126bf7 ]
      
      To avoid breaking the build on arches where this is not wired up, at
      least all the other features should be made available and when using
      this specific routine, the "unknown" should point the user/developer to
      the need to wire this up on this particular hardware architecture.
      
      Detected in a container mipsel debian cross build environment, where it
      shows up as:
      
        In file included from /usr/mipsel-linux-gnu/include/stdio.h:867,
                         from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
                         from util/session.c:13:
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2:
        /usr/mipsel-linux-gnu/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      cross compiler details:
      
        mipsel-linux-gnu-gcc (Debian 9.2.1-8) 9.2.1 20190909
      
      Also on mips64:
      
        In file included from /usr/mips64-linux-gnuabi64/include/stdio.h:867,
                         from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
                         from util/session.c:13:
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2,
            inlined from 'regs_user__printf' at util/session.c:1139:3,
            inlined from 'dump_sample' at util/session.c:1246:3,
            inlined from 'machines__deliver_event' at util/session.c:1421:3:
        /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2,
            inlined from 'regs_intr__printf' at util/session.c:1147:3,
            inlined from 'dump_sample' at util/session.c:1249:3,
            inlined from 'machines__deliver_event' at util/session.c:1421:3:
        /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      cross compiler details:
      
        mips64-linux-gnuabi64-gcc (Debian 9.2.1-8) 9.2.1 20190909
      
      Fixes: 2bcd355b ("perf tools: Add interface to arch registers sets")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-95wjyv4o65nuaeweq31t7l1s@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      905184a9
    • A
      perf script: Fix brstackinsn for AUXTRACE · 099a77b3
      Adrian Hunter 提交于
      [ Upstream commit 0cd032d3b5fcebf5454315400ab310746a81ca53 ]
      
      brstackinsn must be allowed to be set by the user when AUX area data has
      been captured because, in that case, the branch stack might be
      synthesized on the fly. This fixes the following error:
      
      Before:
      
        $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
        [ perf record: Woken up 19 times to write data ]
        [ perf record: Captured and wrote 2.274 MB perf.data ]
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
        Display of branch stack assembler requested, but non all-branch filter set
        Hint: run 'perf record -b ...'
      
      After:
      
        $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
        [ perf record: Woken up 19 times to write data ]
        [ perf record: Captured and wrote 2.274 MB perf.data ]
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                  grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
              bmexec+2485:
              00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
              00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
              00005641d5806bd6                        add %rdi, %rax
              00005641d5806bd9                        movzxb  -0x1(%rax), %edx
              00005641d5806bdd                        cmp %rax, %r14
              00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
              mismatch of LBR data and executable
              00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
      
      Fixes: 48d02a1d ("perf script: Add 'brstackinsn' for branch stacks")
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20191127095322.15417-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      099a77b3
    • D
      cdrom: respect device capabilities during opening action · b655b8d5
      Diego Elio Pettenò 提交于
      [ Upstream commit 366ba7c71ef77c08d06b18ad61b26e2df7352338 ]
      
      Reading the TOC only works if the device can play audio, otherwise
      these commands fail (and possibly bring the device to an unhealthy
      state.)
      
      Similarly, cdrom_mmc3_profile() should only be called if the device
      supports generic packet commands.
      
      To: Jens Axboe <axboe@kernel.dk>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-scsi@vger.kernel.org
      Signed-off-by: NDiego Elio Pettenò <flameeyes@flameeyes.com>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      b655b8d5
    • N
      powerpc: Don't add -mabi= flags when building with Clang · 4f0810c4
      Nathan Chancellor 提交于
      [ Upstream commit 465bfd9c44dea6b55962b5788a23ac87a467c923 ]
      
      When building pseries_defconfig, building vdso32 errors out:
      
        error: unknown target ABI 'elfv1'
      
      This happens because -m32 in clang changes the target to 32-bit,
      which does not allow the ABI to be changed.
      
      Commit 4dc831aa ("powerpc: Fix compiling a BE kernel with a
      powerpc64le toolchain") added these flags to fix building big endian
      kernels with a little endian GCC.
      
      Clang doesn't need -mabi because the target triple controls the
      default value. -mlittle-endian and -mbig-endian manipulate the triple
      into either powerpc64-* or powerpc64le-*, which properly sets the
      default ABI.
      
      Adding a debug print out in the PPC64TargetInfo constructor after line
      383 above shows this:
      
        $ echo | ./clang -E --target=powerpc64-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
        $ echo | ./clang -E --target=powerpc64le-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64le-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
      Don't specify -mabi when building with clang to avoid the build error
      with -m32 and not change any code generation.
      
      -mcall-aixdesc is not an implemented flag in clang so it can be safely
      excluded as well, see commit 238abecd ("powerpc: Don't use gcc
      specific options on clang").
      
      pseries_defconfig successfully builds after this patch and
      powernv_defconfig and ppc44x_defconfig don't regress.
      Reviewed-by: NDaniel Axtens <dja@axtens.net>
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      [mpe: Trim clang links in change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191119045712.39633-2-natechancellor@gmail.comSigned-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      4f0810c4
    • M
      scripts/kallsyms: fix definitely-lost memory leak · 7678eadc
      Masahiro Yamada 提交于
      [ Upstream commit 21915eca088dc271c970e8351290e83d938114ac ]
      
      build_initial_tok_table() overwrites unused sym_entry to shrink the
      table size. Before the entry is overwritten, table[i].sym must be freed
      since it is malloc'ed data.
      
      This fixes the 'definitely lost' report from valgrind. I ran valgrind
      against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary:
      
      [Before the fix]
      
        LEAK SUMMARY:
           definitely lost: 53,184 bytes in 2,874 blocks
      
      [After the fix]
      
        LEAK SUMMARY:
           definitely lost: 0 bytes in 0 blocks
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      7678eadc
    • C
      apparmor: fix unsigned len comparison with less than zero · e7cc1c8e
      Colin Ian King 提交于
      [ Upstream commit 00e0590dbaec6f1bcaa36a85467d7e3497ced522 ]
      
      The sanity check in macro update_for_len checks to see if len
      is less than zero, however, len is a size_t so it can never be
      less than zero, so this sanity check is a no-op.  Fix this by
      making len a ssize_t so the comparison will work and add ulen
      that is a size_t copy of len so that the min() macro won't
      throw warnings about comparing different types.
      
      Addresses-Coverity: ("Macro compares unsigned to 0")
      Fixes: f1bd9041 ("apparmor: add the base fns() for domain labels")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      e7cc1c8e
    • V
      gpio: mpc8xxx: Don't overwrite default irq_set_type callback · ba95214c
      Vladimir Oltean 提交于
      [ Upstream commit 4e50573f39229d5e9c985fa3b4923a8b29619ade ]
      
      The per-SoC devtype structures can contain their own callbacks that
      overwrite mpc8xxx_gpio_devtype_default.
      
      The clear intention is that mpc8xxx_irq_set_type is used in case the SoC
      does not specify a more specific callback. But what happens is that if
      the SoC doesn't specify one, its .irq_set_type is de-facto NULL, and
      this overwrites mpc8xxx_irq_set_type to a no-op. This means that the
      following SoCs are affected:
      
      - fsl,mpc8572-gpio
      - fsl,ls1028a-gpio
      - fsl,ls1088a-gpio
      
      On these boards, the irq_set_type does exactly nothing, and the GPIO
      controller keeps its GPICR register in the hardware-default state. On
      the LS1028A, that is ACTIVE_BOTH, which means 2 interrupts are raised
      even if the IRQ client requests LEVEL_HIGH. Another implication is that
      the IRQs are not checked (e.g. level-triggered interrupts are not
      rejected, although they are not supported).
      
      Fixes: 82e39b0d ("gpio: mpc8xxx: handle differences between incarnations at a single place")
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/20191115125551.31061-1-olteanv@gmail.comTested-by: NMichael Walle <michael@walle.cc>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ba95214c
    • B
      scsi: target: iscsi: Wait for all commands to finish before freeing a session · ad73d9eb
      Bart Van Assche 提交于
      [ Upstream commit e9d3009cb936bd0faf0719f68d98ad8afb1e613b ]
      
      The iSCSI target driver is the only target driver that does not wait for
      ongoing commands to finish before freeing a session. Make the iSCSI target
      driver wait for ongoing commands to finish before freeing a session. This
      patch fixes the following KASAN complaint:
      
      BUG: KASAN: use-after-free in __lock_acquire+0xb1a/0x2710
      Read of size 8 at addr ffff8881154eca70 by task kworker/0:2/247
      
      CPU: 0 PID: 247 Comm: kworker/0:2 Not tainted 5.4.0-rc1-dbg+ #6
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Workqueue: target_completion target_complete_ok_work [target_core_mod]
      Call Trace:
       dump_stack+0x8a/0xd6
       print_address_description.constprop.0+0x40/0x60
       __kasan_report.cold+0x1b/0x33
       kasan_report+0x16/0x20
       __asan_load8+0x58/0x90
       __lock_acquire+0xb1a/0x2710
       lock_acquire+0xd3/0x200
       _raw_spin_lock_irqsave+0x43/0x60
       target_release_cmd_kref+0x162/0x7f0 [target_core_mod]
       target_put_sess_cmd+0x2e/0x40 [target_core_mod]
       lio_check_stop_free+0x12/0x20 [iscsi_target_mod]
       transport_cmd_check_stop_to_fabric+0xd8/0xe0 [target_core_mod]
       target_complete_ok_work+0x1b0/0x790 [target_core_mod]
       process_one_work+0x549/0xa40
       worker_thread+0x7a/0x5d0
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      Allocated by task 889:
       save_stack+0x23/0x90
       __kasan_kmalloc.constprop.0+0xcf/0xe0
       kasan_slab_alloc+0x12/0x20
       kmem_cache_alloc+0xf6/0x360
       transport_alloc_session+0x29/0x80 [target_core_mod]
       iscsi_target_login_thread+0xcd6/0x18f0 [iscsi_target_mod]
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      Freed by task 1025:
       save_stack+0x23/0x90
       __kasan_slab_free+0x13a/0x190
       kasan_slab_free+0x12/0x20
       kmem_cache_free+0x146/0x400
       transport_free_session+0x179/0x2f0 [target_core_mod]
       transport_deregister_session+0x130/0x180 [target_core_mod]
       iscsit_close_session+0x12c/0x350 [iscsi_target_mod]
       iscsit_logout_post_handler+0x136/0x380 [iscsi_target_mod]
       iscsit_response_queue+0x8de/0xbe0 [iscsi_target_mod]
       iscsi_target_tx_thread+0x27f/0x370 [iscsi_target_mod]
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      The buggy address belongs to the object at ffff8881154ec9c0
       which belongs to the cache se_sess_cache of size 352
      The buggy address is located 176 bytes inside of
       352-byte region [ffff8881154ec9c0, ffff8881154ecb20)
      The buggy address belongs to the page:
      page:ffffea0004553b00 refcount:1 mapcount:0 mapping:ffff888101755400 index:0x0 compound_mapcount: 0
      flags: 0x2fff000000010200(slab|head)
      raw: 2fff000000010200 dead000000000100 dead000000000122 ffff888101755400
      raw: 0000000000000000 0000000080130013 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8881154ec900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff8881154ec980: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
      >ffff8881154eca00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                   ^
       ffff8881154eca80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff8881154ecb00: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
      
      Cc: Mike Christie <mchristi@redhat.com>
      Link: https://lore.kernel.org/r/20191113220508.198257-3-bvanassche@acm.orgReviewed-by: NRoman Bolshakov <r.bolshakov@yadro.com>
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      ad73d9eb
    • A
      scsi: iscsi: Don't send data to unbound connection · 9fccd321
      Anatol Pomazau 提交于
      [ Upstream commit 238191d65d7217982d69e21c1d623616da34b281 ]
      
      If a faulty initiator fails to bind the socket to the iSCSI connection
      before emitting a command, for instance, a subsequent send_pdu, it will
      crash the kernel due to a null pointer dereference in sock_sendmsg(), as
      shown in the log below.  This patch makes sure the bind succeeded before
      trying to use the socket.
      
      BUG: kernel NULL pointer dereference, address: 0000000000000018
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.4.0-rc2.iscsi+ #13
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      [   24.158246] Workqueue: iscsi_q_0 iscsi_xmitworker
      [   24.158883] RIP: 0010:apparmor_socket_sendmsg+0x5/0x20
      [...]
      [   24.161739] RSP: 0018:ffffab6440043ca0 EFLAGS: 00010282
      [   24.162400] RAX: ffffffff891c1c00 RBX: ffffffff89d53968 RCX: 0000000000000001
      [   24.163253] RDX: 0000000000000030 RSI: ffffab6440043d00 RDI: 0000000000000000
      [   24.164104] RBP: 0000000000000030 R08: 0000000000000030 R09: 0000000000000030
      [   24.165166] R10: ffffffff893e66a0 R11: 0000000000000018 R12: ffffab6440043d00
      [   24.166038] R13: 0000000000000000 R14: 0000000000000000 R15: ffff9d5575a62e90
      [   24.166919] FS:  0000000000000000(0000) GS:ffff9d557db80000(0000) knlGS:0000000000000000
      [   24.167890] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   24.168587] CR2: 0000000000000018 CR3: 000000007a838000 CR4: 00000000000006e0
      [   24.169451] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   24.170320] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   24.171214] Call Trace:
      [   24.171537]  security_socket_sendmsg+0x3a/0x50
      [   24.172079]  sock_sendmsg+0x16/0x60
      [   24.172506]  iscsi_sw_tcp_xmit_segment+0x77/0x120
      [   24.173076]  iscsi_sw_tcp_pdu_xmit+0x58/0x170
      [   24.173604]  ? iscsi_dbg_trace+0x63/0x80
      [   24.174087]  iscsi_tcp_task_xmit+0x101/0x280
      [   24.174666]  iscsi_xmit_task+0x83/0x110
      [   24.175206]  iscsi_xmitworker+0x57/0x380
      [   24.175757]  ? __schedule+0x2a2/0x700
      [   24.176273]  process_one_work+0x1b5/0x360
      [   24.176837]  worker_thread+0x50/0x3c0
      [   24.177353]  kthread+0xf9/0x130
      [   24.177799]  ? process_one_work+0x360/0x360
      [   24.178401]  ? kthread_park+0x90/0x90
      [   24.178915]  ret_from_fork+0x35/0x40
      [   24.179421] Modules linked in:
      [   24.179856] CR2: 0000000000000018
      [   24.180327] ---[ end trace b4b7674b6df5f480 ]---
      Signed-off-by: NAnatol Pomazau <anatol@google.com>
      Co-developed-by: NFrank Mayhar <fmayhar@google.com>
      Signed-off-by: NFrank Mayhar <fmayhar@google.com>
      Co-developed-by: NBharath Ravi <rbharath@google.com>
      Signed-off-by: NBharath Ravi <rbharath@google.com>
      Co-developed-by: NKhazhimsel Kumykov <khazhy@google.com>
      Signed-off-by: NKhazhimsel Kumykov <khazhy@google.com>
      Co-developed-by: NGabriel Krisman Bertazi <krisman@collabora.com>
      Signed-off-by: NGabriel Krisman Bertazi <krisman@collabora.com>
      Reviewed-by: NLee Duncan <lduncan@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      9fccd321
    • F
      scsi: NCR5380: Add disconnect_mask module parameter · 03ccea16
      Finn Thain 提交于
      [ Upstream commit 0b7a223552d455bcfba6fb9cfc5eef2b5fce1491 ]
      
      Add a module parameter to inhibit disconnect/reselect for individual
      targets. This gains compatibility with Aztec PowerMonster SCSI/SATA
      adapters with buggy firmware. (No fix is available from the vendor.)
      
      Apparently these adapters pass-through the product/vendor of the attached
      SATA device. Since they can't be identified from the response to an INQUIRY
      command, a device blacklist flag won't work.
      
      Cc: Michael Schmitz <schmitzmic@gmail.com>
      Link: https://lore.kernel.org/r/993b17545990f31f9fa5a98202b51102a68e7594.1573875417.git.fthain@telegraphics.com.auReviewed-and-tested-by: NMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      03ccea16
    • M
      scsi: scsi_debug: num_tgts must be >= 0 · cf9ccc36
      Maurizio Lombardi 提交于
      [ Upstream commit aa5334c4f3014940f11bf876e919c956abef4089 ]
      
      Passing the parameter "num_tgts=-1" will start an infinite loop that
      exhausts the system memory
      
      Link: https://lore.kernel.org/r/20191115163727.24626-1-mlombard@redhat.comSigned-off-by: NMaurizio Lombardi <mlombard@redhat.com>
      Acked-by: NDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      cf9ccc36
    • S
      scsi: ufs: Fix error handing during hibern8 enter · 473b5d25
      Subhash Jadavani 提交于
      [ Upstream commit 6d303e4b19d694cdbebf76bcdb51ada664ee953d ]
      
      During clock gating (ufshcd_gate_work()), we first put the link hibern8 by
      calling ufshcd_uic_hibern8_enter() and if ufshcd_uic_hibern8_enter()
      returns success (0) then we gate all the clocks.  Now let’s zoom in to what
      ufshcd_uic_hibern8_enter() does internally: It calls
      __ufshcd_uic_hibern8_enter() and if failure is encountered, link recovery
      shall put the link back to the highest HS gear and returns success (0) to
      ufshcd_uic_hibern8_enter() which is the issue as link is still in active
      state due to recovery!  Now ufshcd_uic_hibern8_enter() returns success to
      ufshcd_gate_work() and hence it goes ahead with gating the UFS clock while
      link is still in active state hence I believe controller would raise UIC
      error interrupts. But when we service the interrupt, clocks might have
      already been disabled!
      
      This change fixes for this by returning failure from
      __ufshcd_uic_hibern8_enter() if recovery succeeds as link is still not in
      hibern8, upon receiving the error ufshcd_hibern8_enter() would initiate
      retry to put the link state back into hibern8.
      
      Link: https://lore.kernel.org/r/1573798172-20534-8-git-send-email-cang@codeaurora.orgReviewed-by: NAvri Altman <avri.altman@wdc.com>
      Reviewed-by: NBean Huo <beanhuo@micron.com>
      Signed-off-by: NSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: NCan Guo <cang@codeaurora.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      473b5d25
    • P
      scsi: pm80xx: Fix for SATA device discovery · b6869488
      peter chang 提交于
      [ Upstream commit ce21c63ee995b7a8b7b81245f2cee521f8c3c220 ]
      
      Driver was missing complete() call in mpi_sata_completion which result in
      SATA abort error handling timing out. That causes the device to be left in
      the in_recovery state so subsequent commands sent to the device fail and
      the OS removes access to it.
      
      Link: https://lore.kernel.org/r/20191114100910.6153-2-deepak.ukey@microchip.comAcked-by: NJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: Npeter chang <dpf@google.com>
      Signed-off-by: NDeepak Ukey <deepak.ukey@microchip.com>
      Signed-off-by: NViswas G <Viswas.G@microchip.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      b6869488
    • K
      watchdog: Fix the race between the release of watchdog_core_data and cdev · 65a644df
      Kevin Hao 提交于
      [ Upstream commit 72139dfa2464e43957d330266994740bb7be2535 ]
      
      The struct cdev is embedded in the struct watchdog_core_data. In the
      current code, we manage the watchdog_core_data with a kref, but the
      cdev is manged by a kobject. There is no any relationship between
      this kref and kobject. So it is possible that the watchdog_core_data is
      freed before the cdev is entirely released. We can easily get the
      following call trace with CONFIG_DEBUG_KOBJECT_RELEASE and
      CONFIG_DEBUG_OBJECTS_TIMERS enabled.
        ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x38
        WARNING: CPU: 23 PID: 1028 at lib/debugobjects.c:481 debug_print_object+0xb0/0xf0
        Modules linked in: softdog(-) deflate ctr twofish_generic twofish_common camellia_generic serpent_generic blowfish_generic blowfish_common cast5_generic cast_common cmac xcbc af_key sch_fq_codel openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4
        CPU: 23 PID: 1028 Comm: modprobe Not tainted 5.3.0-next-20190924-yoctodev-standard+ #180
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        pstate: 00400009 (nzcv daif +PAN -UAO)
        pc : debug_print_object+0xb0/0xf0
        lr : debug_print_object+0xb0/0xf0
        sp : ffff80001cbcfc70
        x29: ffff80001cbcfc70 x28: ffff800010ea2128
        x27: ffff800010bad000 x26: 0000000000000000
        x25: ffff80001103c640 x24: ffff80001107b268
        x23: ffff800010bad9e8 x22: ffff800010ea2128
        x21: ffff000bc2c62af8 x20: ffff80001103c600
        x19: ffff800010e867d8 x18: 0000000000000060
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000bd7240470 x14: 6e6968207473696c
        x13: 5f72656d6974203a x12: 6570797420746365
        x11: 6a626f2029302065 x10: 7461747320657669
        x9 : 7463612820657669 x8 : 3378302f3078302b
        x7 : 0000000000001d7a x6 : ffff800010fd5889
        x5 : 0000000000000000 x4 : 0000000000000000
        x3 : 0000000000000000 x2 : ffff000bff948548
        x1 : 276a1c9e1edc2300 x0 : 0000000000000000
        Call trace:
         debug_print_object+0xb0/0xf0
         debug_check_no_obj_freed+0x1e8/0x210
         kfree+0x1b8/0x368
         watchdog_cdev_unregister+0x88/0xc8
         watchdog_dev_unregister+0x38/0x48
         watchdog_unregister_device+0xa8/0x100
         softdog_exit+0x18/0xfec4 [softdog]
         __arm64_sys_delete_module+0x174/0x200
         el0_svc_handler+0xd0/0x1c8
         el0_svc+0x8/0xc
      
      This is a common issue when using cdev embedded in a struct.
      Fortunately, we already have a mechanism to solve this kind of issue.
      Please see commit 233ed09d ("chardev: add helper function to
      register char devs with a struct device") for more detail.
      
      In this patch, we choose to embed the struct device into the
      watchdog_core_data, and use the API provided by the commit 233ed09d
      to make sure that the release of watchdog_core_data and cdev are
      in sequence.
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Reviewed-by: NGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20191008112934.29669-1-haokexin@gmail.comSigned-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      65a644df
    • A
      HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device · 3693588d
      Andrew Duggan 提交于
      [ Upstream commit 8725aa4fa7ded30211ebd28bb1c9bae806eb3841 ]
      
      In the event that the RMI device is unreachable, the calls to rmi_set_mode() or
      rmi_set_page() will fail before registering the RMI transport device. When the
      device is removed, rmi_remove() will call rmi_unregister_transport_device()
      which will attempt to access the rmi_dev pointer which was not set.
      This patch adds a check of the RMI_STARTED bit before calling
      rmi_unregister_transport_device().  The RMI_STARTED bit is only set
      after rmi_register_transport_device() completes successfully.
      
      The kernel oops was reported in this message:
      https://www.spinics.net/lists/linux-input/msg58433.html
      
      [jkosina@suse.cz: reworded changelog as agreed with Andrew]
      Signed-off-by: NAndrew Duggan <aduggan@synaptics.com>
      Reported-by: NFederico Cerutti <federico@ceres-c.it>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      3693588d
    • B
      HID: Improve Windows Precision Touchpad detection. · 7a3c3463
      Blaž Hrastnik 提交于
      [ Upstream commit 2dbc6f113acd74c66b04bf49fb027efd830b1c5a ]
      
      Per Microsoft spec, usage 0xC5 (page 0xFF) returns a blob containing
      data used to verify the touchpad as a Windows Precision Touchpad.
      
         0x85, REPORTID_PTPHQA,    //    REPORT_ID (PTPHQA)
          0x09, 0xC5,              //    USAGE (Vendor Usage 0xC5)
          0x15, 0x00,              //    LOGICAL_MINIMUM (0)
          0x26, 0xff, 0x00,        //    LOGICAL_MAXIMUM (0xff)
          0x75, 0x08,              //    REPORT_SIZE (8)
          0x96, 0x00, 0x01,        //    REPORT_COUNT (0x100 (256))
          0xb1, 0x02,              //    FEATURE (Data,Var,Abs)
      
      However, some devices, namely Microsoft's Surface line of products
      instead implement a "segmented device certification report" (usage 0xC6)
      which returns the same report, but in smaller chunks.
      
          0x06, 0x00, 0xff,        //     USAGE_PAGE (Vendor Defined)
          0x85, REPORTID_PTPHQA,   //     REPORT_ID (PTPHQA)
          0x09, 0xC6,              //     USAGE (Vendor usage for segment #)
          0x25, 0x08,              //     LOGICAL_MAXIMUM (8)
          0x75, 0x08,              //     REPORT_SIZE (8)
          0x95, 0x01,              //     REPORT_COUNT (1)
          0xb1, 0x02,              //     FEATURE (Data,Var,Abs)
          0x09, 0xC7,              //     USAGE (Vendor Usage)
          0x26, 0xff, 0x00,        //     LOGICAL_MAXIMUM (0xff)
          0x95, 0x20,              //     REPORT_COUNT (32)
          0xb1, 0x02,              //     FEATURE (Data,Var,Abs)
      
      By expanding Win8 touchpad detection to also look for the segmented
      report, all Surface touchpads are now properly recognized by
      hid-multitouch.
      Signed-off-by: NBlaž Hrastnik <blaz@mxxn.io>
      Signed-off-by: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      7a3c3463
    • Q
      libnvdimm/btt: fix variable 'rc' set but not used · 86eea95d
      Qian Cai 提交于
      [ Upstream commit 4e24e37d5313edca8b4ab86f240c046c731e28d6 ]
      
      drivers/nvdimm/btt.c: In function 'btt_read_pg':
      drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
      [-Wunused-but-set-variable]
          int rc;
              ^~
      
      Add a ratelimited message in case a storm of errors is encountered.
      
      Fixes: d9b83c75 ("libnvdimm, btt: rework error clearing")
      Signed-off-by: NQian Cai <cai@lca.pw>
      Reviewed-by: NVishal Verma <vishal.l.verma@intel.com>
      Link: https://lore.kernel.org/r/1572530719-32161-1-git-send-email-cai@lca.pwSigned-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      86eea95d
    • D
      ARM: 8937/1: spectre-v2: remove Brahma-B53 from hardening · f30e4ce0
      Doug Berger 提交于
      [ Upstream commit 4ae5061a19b550dfe25397843427ed2ebab16b16 ]
      
      When the default processor handling was added to the function
      cpu_v7_spectre_init() it only excluded other ARM implemented processor
      cores. The Broadcom Brahma B53 core is not implemented by ARM so it
      ended up falling through into the set of processors that attempt to use
      the ARM_SMCCC_ARCH_WORKAROUND_1 service to harden the branch predictor.
      
      Since this workaround is not necessary for the Brahma-B53 this commit
      explicitly checks for it and prevents it from applying a branch
      predictor hardening workaround.
      
      Fixes: 10115105 ("ARM: spectre-v2: add firmware based hardening")
      Signed-off-by: NDoug Berger <opendmb@gmail.com>
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      f30e4ce0
    • H
      HID: logitech-hidpp: Silence intermittent get_battery_capacity errors · e2ac49d5
      Hans de Goede 提交于
      [ Upstream commit 61005d65b6c7dcf61c19516e6ebe5acc02d2cdda ]
      
      My Logitech M185 (PID:4038) 2.4 GHz wireless HID++ mouse is causing
      intermittent errors like these in the log:
      
      [11091.034857] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [12388.031260] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [16613.718543] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [23529.938728] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      
      We are already silencing error-code 0x09 (HIDPP_ERROR_RESOURCE_ERROR)
      errors in other places, lets do the same in
      hidpp20_batterylevel_get_battery_capacity to remove these harmless,
      but scary looking errors from the dmesg output.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      e2ac49d5
    • J
      HID: quirks: Add quirk for HP MSU1465 PIXART OEM mouse · d1397dc2
      Jinke Fan 提交于
      [ Upstream commit f1a0094cbbe97a5f8aca7bdc64bfe43ac9dc6879 ]
      
      The PixArt OEM mouse disconnets/reconnects every minute on
      Linux. All contents of dmesg are repetitive:
      
      [ 1465.810014] usb 1-2.2: USB disconnect, device number 20
      [ 1467.431509] usb 1-2.2: new low-speed USB device number 21 using xhci_hcd
      [ 1467.654982] usb 1-2.2: New USB device found, idVendor=03f0,idProduct=1f4a, bcdDevice= 1.00
      [ 1467.654985] usb 1-2.2: New USB device strings: Mfr=1, Product=2,SerialNumber=0
      [ 1467.654987] usb 1-2.2: Product: HP USB Optical Mouse
      [ 1467.654988] usb 1-2.2: Manufacturer: PixArt
      [ 1467.699722] input: PixArt HP USB Optical Mouse as /devices/pci0000:00/0000:00:07.1/0000:05:00.3/usb1/1-2/1-2.2/1-2.2:1.0/0003:03F0:1F4A.0012/input/input19
      [ 1467.700124] hid-generic 0003:03F0:1F4A.0012: input,hidraw0: USB HID v1.11 Mouse [PixArt HP USB Optical Mouse] on usb-0000:05:00.3-2.2/input0
      
      So add HID_QUIRK_ALWAYS_POLL for this one as well.
      Test the patch, the mouse is no longer disconnected and there are no
      duplicate logs in dmesg.
      
      Reference:
      https://github.com/sriemer/fix-linux-mouseSigned-off-by: NJinke Fan <fanjinke@hygon.cn>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      d1397dc2
    • C
      bcache: at least try to shrink 1 node in bch_mca_scan() · 414f33cf
      Coly Li 提交于
      [ Upstream commit 9fcc34b1a6dd4b8e5337e2b6ef45e428897eca6b ]
      
      In bch_mca_scan(), the number of shrinking btree node is calculated
      by code like this,
      	unsigned long nr = sc->nr_to_scan;
      
              nr /= c->btree_pages;
              nr = min_t(unsigned long, nr, mca_can_free(c));
      variable sc->nr_to_scan is number of objects (here is bcache B+tree
      nodes' number) to shrink, and pointer variable sc is sent from memory
      management code as parametr of a callback.
      
      If sc->nr_to_scan is smaller than c->btree_pages, after the above
      calculation, variable 'nr' will be 0 and nothing will be shrunk. It is
      frequeently observed that only 1 or 2 is set to sc->nr_to_scan and make
      nr to be zero. Then bch_mca_scan() will do nothing more then acquiring
      and releasing mutex c->bucket_lock.
      
      This patch checkes whether nr is 0 after the above calculation, if 0
      is the result then set 1 to variable 'n'. Then at least bch_mca_scan()
      will try to shrink a single B+tree node.
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      414f33cf
    • R
      clk: pxa: fix one of the pxa RTC clocks · 28a3c6df
      Robert Jarzmik 提交于
      [ Upstream commit 46acbcb4849b2ca2e6e975e7c8130c1d61c8fd0c ]
      
      The pxa27x platforms have a single IP with 2 drivers, sa1100-rtc and
      rtc-pxa drivers.
      
      A previous patch fixed the sa1100-rtc case, but the pxa-rtc wasn't
      fixed. This patch completes the previous one.
      
      Fixes: 8b6d1034 ("clk: pxa: add missing pxa27x clocks for Irda and sa1100-rtc")
      Signed-off-by: NRobert Jarzmik <robert.jarzmik@free.fr>
      Link: https://lkml.kernel.org/r/20191026194420.11918-1-robert.jarzmik@free.frSigned-off-by: NStephen Boyd <sboyd@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      28a3c6df
    • F
      scsi: atari_scsi: sun3_scsi: Set sg_tablesize to 1 instead of SG_NONE · 3e619b62
      Finn Thain 提交于
      [ Upstream commit 79172ab20bfd8437b277254028efdb68484e2c21 ]
      
      Since the scsi subsystem adopted the blk-mq API, a host with zero
      sg_tablesize crashes with a NULL pointer dereference.
      
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:0: Beginning Domain Validation
      scsi target0:0:0: Domain Validation skipping write tests
      scsi target0:0:0: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:1:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:1: Beginning Domain Validation
      scsi target0:0:1: Domain Validation skipping write tests
      scsi target0:0:1: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
      scsi target0:0:2: Beginning Domain Validation
      scsi target0:0:2: Domain Validation skipping write tests
      scsi target0:0:2: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      sr 0:0:2:0: Power-on or device reset occurred
      sd 0:0:0:0: Power-on or device reset occurred
      sd 0:0:1:0: Power-on or device reset occurred
      sd 0:0:0:0: [sda] 10485762 512-byte logical blocks: (5.37 GB/5.00 GiB)
      sd 0:0:0:0: [sda] Write Protect is off
      sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
      Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
      Oops: 00000000
      Modules linked in:
      PC: [<001cd874>] blk_mq_free_request+0x66/0xe2
      SR: 2004  SP: (ptrval)  a2: 00874520
      d0: 00000000    d1: 00000000    d2: 009ba800    d3: 00000000
      d4: 00000000    d5: 08000002    a0: 0087be68    a1: 009a81e0
      Process kworker/u2:2 (pid: 15, task=(ptrval))
      Frame format=7 eff addr=0000007a ssw=0505 faddr=0000007a
      wb 1 stat/addr/data: 0000 00000000 00000000
      wb 2 stat/addr/data: 0000 00000000 00000000
      wb 3 stat/addr/data: 0000 0000007a 00000000
      push data: 00000000 00000000 00000000 00000000
      Stack from 0087bd98:
              00000002 00000000 0087be72 009a7820 0087bdb4 001c4f6c 009a7820 0087bdd4
              0024d200 009a7820 0024d0dc 0087be72 009baa00 0087be68 009a5000 0087be7c
              00265d10 009a5000 0087be72 00000003 00000000 00000000 00000000 0087be68
              00000bb8 00000005 00000000 00000000 00000000 00000000 00265c56 00000000
              009ba60c 0036ddf4 00000002 ffffffff 009baa00 009ba600 009a50d6 0087be74
              00227ba0 009baa08 00000001 009baa08 009ba60c 0036ddf4 00000000 00000000
      Call Trace: [<001c4f6c>] blk_put_request+0xe/0x14
       [<0024d200>] __scsi_execute+0x124/0x174
       [<0024d0dc>] __scsi_execute+0x0/0x174
       [<00265d10>] sd_revalidate_disk+0xba/0x1f02
       [<00265c56>] sd_revalidate_disk+0x0/0x1f02
       [<0036ddf4>] strlen+0x0/0x22
       [<00227ba0>] device_add+0x3da/0x604
       [<0036ddf4>] strlen+0x0/0x22
       [<00267e64>] sd_probe+0x30c/0x4b4
       [<0002da44>] process_one_work+0x0/0x402
       [<0022b978>] really_probe+0x226/0x354
       [<0022bc34>] driver_probe_device+0xa4/0xf0
       [<0002da44>] process_one_work+0x0/0x402
       [<0022bcd0>] __driver_attach_async_helper+0x50/0x70
       [<00035dae>] async_run_entry_fn+0x36/0x130
       [<0002db88>] process_one_work+0x144/0x402
       [<0002e1aa>] worker_thread+0x0/0x570
       [<0002e29a>] worker_thread+0xf0/0x570
       [<0002e1aa>] worker_thread+0x0/0x570
       [<003768d8>] schedule+0x0/0xb8
       [<0003f58c>] __init_waitqueue_head+0x0/0x12
       [<00033e92>] kthread+0xc2/0xf6
       [<000331e8>] kthread_parkme+0x0/0x4e
       [<003768d8>] schedule+0x0/0xb8
       [<00033dd0>] kthread+0x0/0xf6
       [<00002c10>] ret_from_kernel_thread+0xc/0x14
      Code: 0280 0006 0800 56c0 4400 0280 0000 00ff <52b4> 0c3a 082b 0006 0013 6706 2042 53a8 00c4 4ab9 0047 3374 6640 202d 000c 670c
      Disabling lock debugging due to kernel taint
      
      Avoid this by setting sg_tablesize = 1.
      
      Link: https://lore.kernel.org/r/4567bcae94523b47d6f3b77450ba305823bca479.1572656814.git.fthain@telegraphics.com.auReported-and-tested-by: NMichael Schmitz <schmitzmic@gmail.com>
      Reviewed-by: NMichael Schmitz <schmitzmic@gmail.com>
      References: commit 68ab2d76 ("scsi: cxlflash: Set sg_tablesize to 1 instead of SG_NONE")
      Signed-off-by: NFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      3e619b62