1. 09 Jan, 2020 40 commits
    • Eric Dumazet's avatar
      tcp: annotate tp->rcv_nxt lockless reads · 67f028ac
      Eric Dumazet authored
      [ Upstream commit dba7d9b8 ]
      
      There are few places where we fetch tp->rcv_nxt while
      this field can change from IRQ or other cpu.
      
      We need to add READ_ONCE() annotations, and also make
      sure write sides use corresponding WRITE_ONCE() to avoid
      store-tearing.
      
      Note that tcp_inq_hint() was already using READ_ONCE(tp->rcv_nxt)
      
      syzbot reported :
      
      BUG: KCSAN: data-race in tcp_poll / tcp_queue_rcv
      
      write to 0xffff888120425770 of 4 bytes by interrupt on cpu 0:
       tcp_rcv_nxt_update net/ipv4/tcp_input.c:3365 [inline]
       tcp_queue_rcv+0x180/0x380 net/ipv4/tcp_input.c:4638
       tcp_rcv_established+0xbf1/0xf50 net/ipv4/tcp_input.c:5616
       tcp_v4_do_rcv+0x381/0x4e0 net/ipv4/tcp_ipv4.c:1542
       tcp_v4_rcv+0x1a03/0x1bf0 net/ipv4/tcp_ipv4.c:1923
       ip_protocol_deliver_rcu+0x51/0x470 net/ipv4/ip_input.c:204
       ip_local_deliver_finish+0x110/0x140 net/ipv4/ip_input.c:231
       NF_HOOK include/linux/netfilter.h:305 [inline]
       NF_HOOK include/linux/netfilter.h:299 [inline]
       ip_local_deliver+0x133/0x210 net/ipv4/ip_input.c:252
       dst_input include/net/dst.h:442 [inline]
       ip_rcv_finish+0x121/0x160 net/ipv4/ip_input.c:413
       NF_HOOK include/linux/netfilter.h:305 [inline]
       NF_HOOK include/linux/netfilter.h:299 [inline]
       ip_rcv+0x18f/0x1a0 net/ipv4/ip_input.c:523
       __netif_receive_skb_one_core+0xa7/0xe0 net/core/dev.c:5004
       __netif_receive_skb+0x37/0xf0 net/core/dev.c:5118
       netif_receive_skb_internal+0x59/0x190 net/core/dev.c:5208
       napi_skb_finish net/core/dev.c:5671 [inline]
       napi_gro_receive+0x28f/0x330 net/core/dev.c:5704
       receive_buf+0x284/0x30b0 drivers/net/virtio_net.c:1061
      
      read to 0xffff888120425770 of 4 bytes by task 7254 on cpu 1:
       tcp_stream_is_readable net/ipv4/tcp.c:480 [inline]
       tcp_poll+0x204/0x6b0 net/ipv4/tcp.c:554
       sock_poll+0xed/0x250 net/socket.c:1256
       vfs_poll include/linux/poll.h:90 [inline]
       ep_item_poll.isra.0+0x90/0x190 fs/eventpoll.c:892
       ep_send_events_proc+0x113/0x5c0 fs/eventpoll.c:1749
       ep_scan_ready_list.constprop.0+0x189/0x500 fs/eventpoll.c:704
       ep_send_events fs/eventpoll.c:1793 [inline]
       ep_poll+0xe3/0x900 fs/eventpoll.c:1930
       do_epoll_wait+0x162/0x180 fs/eventpoll.c:2294
       __do_sys_epoll_pwait fs/eventpoll.c:2325 [inline]
       __se_sys_epoll_pwait fs/eventpoll.c:2311 [inline]
       __x64_sys_epoll_pwait+0xcd/0x170 fs/eventpoll.c:2311
       do_syscall_64+0xcf/0x2f0 arch/x86/entry/common.c:296
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 7254 Comm: syz-fuzzer Not tainted 5.3.0+ #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      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 avatarSasha Levin <sashal@kernel.org>
      67f028ac
    • David Howells's avatar
      rxrpc: Fix possible NULL pointer access in ICMP handling · d9f4d60a
      David Howells authored
      [ Upstream commit f0308fb0 ]
      
      If an ICMP packet comes in on the UDP socket backing an AF_RXRPC socket as
      the UDP socket is being shut down, rxrpc_error_report() may get called to
      deal with it after sk_user_data on the UDP socket has been cleared, leading
      to a NULL pointer access when this local endpoint record gets accessed.
      
      Fix this by just returning immediately if sk_user_data was NULL.
      
      The oops looks like the following:
      
      #PF: supervisor read access in kernel mode
      #PF: error_code(0x0000) - not-present page
      ...
      RIP: 0010:rxrpc_error_report+0x1bd/0x6a9
      ...
      Call Trace:
       ? sock_queue_err_skb+0xbd/0xde
       ? __udp4_lib_err+0x313/0x34d
       __udp4_lib_err+0x313/0x34d
       icmp_unreach+0x1ee/0x207
       icmp_rcv+0x25b/0x28f
       ip_protocol_deliver_rcu+0x95/0x10e
       ip_local_deliver+0xe9/0x148
       __netif_receive_skb_one_core+0x52/0x6e
       process_backlog+0xdc/0x177
       net_rx_action+0xf9/0x270
       __do_softirq+0x1b6/0x39a
       ? smpboot_register_percpu_thread+0xce/0xce
       run_ksoftirqd+0x1d/0x42
       smpboot_thread_fn+0x19e/0x1b3
       kthread+0xf1/0xf6
       ? kthread_delayed_work_timer_fn+0x83/0x83
       ret_from_fork+0x24/0x30
      
      Fixes: 17926a79 ("[AF_RXRPC]: Provide secure RxRPC sockets for use by userspace and kernel both")
      Reported-by: syzbot+611164843bd48cc2190c@syzkaller.appspotmail.com
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d9f4d60a
    • Michael Roth's avatar
      KVM: PPC: Book3S HV: use smp_mb() when setting/clearing host_ipi flag · a2118e6e
      Michael Roth authored
      [ Upstream commit 3a83f677 ]
      
      On a 2-socket Power9 system with 32 cores/128 threads (SMT4) and 1TB
      of memory running the following guest configs:
      
        guest A:
          - 224GB of memory
          - 56 VCPUs (sockets=1,cores=28,threads=2), where:
            VCPUs 0-1 are pinned to CPUs 0-3,
            VCPUs 2-3 are pinned to CPUs 4-7,
            ...
            VCPUs 54-55 are pinned to CPUs 108-111
      
        guest B:
          - 4GB of memory
          - 4 VCPUs (sockets=1,cores=4,threads=1)
      
      with the following workloads (with KSM and THP enabled in all):
      
        guest A:
          stress --cpu 40 --io 20 --vm 20 --vm-bytes 512M
      
        guest B:
          stress --cpu 4 --io 4 --vm 4 --vm-bytes 512M
      
        host:
          stress --cpu 4 --io 4 --vm 2 --vm-bytes 256M
      
      the below soft-lockup traces were observed after an hour or so and
      persisted until the host was reset (this was found to be reliably
      reproducible for this configuration, for kernels 4.15, 4.18, 5.0,
      and 5.3-rc5):
      
        [ 1253.183290] rcu: INFO: rcu_sched self-detected stall on CPU
        [ 1253.183319] rcu:     124-....: (5250 ticks this GP) idle=10a/1/0x4000000000000002 softirq=5408/5408 fqs=1941
        [ 1256.287426] watchdog: BUG: soft lockup - CPU#105 stuck for 23s! [CPU 52/KVM:19709]
        [ 1264.075773] watchdog: BUG: soft lockup - CPU#24 stuck for 23s! [worker:19913]
        [ 1264.079769] watchdog: BUG: soft lockup - CPU#31 stuck for 23s! [worker:20331]
        [ 1264.095770] watchdog: BUG: soft lockup - CPU#45 stuck for 23s! [worker:20338]
        [ 1264.131773] watchdog: BUG: soft lockup - CPU#64 stuck for 23s! [avocado:19525]
        [ 1280.408480] watchdog: BUG: soft lockup - CPU#124 stuck for 22s! [ksmd:791]
        [ 1316.198012] rcu: INFO: rcu_sched self-detected stall on CPU
        [ 1316.198032] rcu:     124-....: (21003 ticks this GP) idle=10a/1/0x4000000000000002 softirq=5408/5408 fqs=8243
        [ 1340.411024] watchdog: BUG: soft lockup - CPU#124 stuck for 22s! [ksmd:791]
        [ 1379.212609] rcu: INFO: rcu_sched self-detected stall on CPU
        [ 1379.212629] rcu:     124-....: (36756 ticks this GP) idle=10a/1/0x4000000000000002 softirq=5408/5408 fqs=14714
        [ 1404.413615] watchdog: BUG: soft lockup - CPU#124 stuck for 22s! [ksmd:791]
        [ 1442.227095] rcu: INFO: rcu_sched self-detected stall on CPU
        [ 1442.227115] rcu:     124-....: (52509 ticks this GP) idle=10a/1/0x4000000000000002 softirq=5408/5408 fqs=21403
        [ 1455.111787] INFO: task worker:19907 blocked for more than 120 seconds.
        [ 1455.111822]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.111833] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.111884] INFO: task worker:19908 blocked for more than 120 seconds.
        [ 1455.111905]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.111925] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.111966] INFO: task worker:20328 blocked for more than 120 seconds.
        [ 1455.111986]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.111998] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.112048] INFO: task worker:20330 blocked for more than 120 seconds.
        [ 1455.112068]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.112097] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.112138] INFO: task worker:20332 blocked for more than 120 seconds.
        [ 1455.112159]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.112179] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.112210] INFO: task worker:20333 blocked for more than 120 seconds.
        [ 1455.112231]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.112242] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.112282] INFO: task worker:20335 blocked for more than 120 seconds.
        [ 1455.112303]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
        [ 1455.112332] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
        [ 1455.112372] INFO: task worker:20336 blocked for more than 120 seconds.
        [ 1455.112392]       Tainted: G             L    5.3.0-rc5-mdr-vanilla+ #1
      
      CPUs 45, 24, and 124 are stuck on spin locks, likely held by
      CPUs 105 and 31.
      
      CPUs 105 and 31 are stuck in smp_call_function_many(), waiting on
      target CPU 42. For instance:
      
        # CPU 105 registers (via xmon)
        R00 = c00000000020b20c   R16 = 00007d1bcd800000
        R01 = c00000363eaa7970   R17 = 0000000000000001
        R02 = c0000000019b3a00   R18 = 000000000000006b
        R03 = 000000000000002a   R19 = 00007d537d7aecf0
        R04 = 000000000000002a   R20 = 60000000000000e0
        R05 = 000000000000002a   R21 = 0801000000000080
        R06 = c0002073fb0caa08   R22 = 0000000000000d60
        R07 = c0000000019ddd78   R23 = 0000000000000001
        R08 = 000000000000002a   R24 = c00000000147a700
        R09 = 0000000000000001   R25 = c0002073fb0ca908
        R10 = c000008ffeb4e660   R26 = 0000000000000000
        R11 = c0002073fb0ca900   R27 = c0000000019e2464
        R12 = c000000000050790   R28 = c0000000000812b0
        R13 = c000207fff623e00   R29 = c0002073fb0ca808
        R14 = 00007d1bbee00000   R30 = c0002073fb0ca800
        R15 = 00007d1bcd600000   R31 = 0000000000000800
        pc  = c00000000020b260 smp_call_function_many+0x3d0/0x460
        cfar= c00000000020b270 smp_call_function_many+0x3e0/0x460
        lr  = c00000000020b20c smp_call_function_many+0x37c/0x460
        msr = 900000010288b033   cr  = 44024824
        ctr = c000000000050790   xer = 0000000000000000   trap =  100
      
      CPU 42 is running normally, doing VCPU work:
      
        # CPU 42 stack trace (via xmon)
        [link register   ] c00800001be17188 kvmppc_book3s_radix_page_fault+0x90/0x2b0 [kvm_hv]
        [c000008ed3343820] c000008ed3343850 (unreliable)
        [c000008ed33438d0] c00800001be11b6c kvmppc_book3s_hv_page_fault+0x264/0xe30 [kvm_hv]
        [c000008ed33439d0] c00800001be0d7b4 kvmppc_vcpu_run_hv+0x8dc/0xb50 [kvm_hv]
        [c000008ed3343ae0] c00800001c10891c kvmppc_vcpu_run+0x34/0x48 [kvm]
        [c000008ed3343b00] c00800001c10475c kvm_arch_vcpu_ioctl_run+0x244/0x420 [kvm]
        [c000008ed3343b90] c00800001c0f5a78 kvm_vcpu_ioctl+0x470/0x7c8 [kvm]
        [c000008ed3343d00] c000000000475450 do_vfs_ioctl+0xe0/0xc70
        [c000008ed3343db0] c0000000004760e4 ksys_ioctl+0x104/0x120
        [c000008ed3343e00] c000000000476128 sys_ioctl+0x28/0x80
        [c000008ed3343e20] c00000000000b388 system_call+0x5c/0x70
        --- Exception: c00 (System Call) at 00007d545cfd7694
        SP (7d53ff7edf50) is in userspace
      
      It was subsequently found that ipi_message[PPC_MSG_CALL_FUNCTION]
      was set for CPU 42 by at least 1 of the CPUs waiting in
      smp_call_function_many(), but somehow the corresponding
      call_single_queue entries were never processed by CPU 42, causing the
      callers to spin in csd_lock_wait() indefinitely.
      
      Nick Piggin suggested something similar to the following sequence as
      a possible explanation (interleaving of CALL_FUNCTION/RESCHEDULE
      IPI messages seems to be most common, but any mix of CALL_FUNCTION and
      !CALL_FUNCTION messages could trigger it):
      
          CPU
            X: smp_muxed_ipi_set_message():
            X:   smp_mb()
            X:   message[RESCHEDULE] = 1
            X: doorbell_global_ipi(42):
            X:   kvmppc_set_host_ipi(42, 1)
            X:   ppc_msgsnd_sync()/smp_mb()
            X:   ppc_msgsnd() -> 42
           42: doorbell_exception(): // from CPU X
           42:   ppc_msgsync()
          105: smp_muxed_ipi_set_message():
          105:   smb_mb()
               // STORE DEFERRED DUE TO RE-ORDERING
        --105:   message[CALL_FUNCTION] = 1
        | 105: doorbell_global_ipi(42):
        | 105:   kvmppc_set_host_ipi(42, 1)
        |  42:   kvmppc_set_host_ipi(42, 0)
        |  42: smp_ipi_demux_relaxed()
        |  42: // returns to executing guest
        |      // RE-ORDERED STORE COMPLETES
        ->105:   message[CALL_FUNCTION] = 1
          105:   ppc_msgsnd_sync()/smp_mb()
          105:   ppc_msgsnd() -> 42
           42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored
          105: // hangs waiting on 42 to process messages/call_single_queue
      
      This can be prevented with an smp_mb() at the beginning of
      kvmppc_set_host_ipi(), such that stores to message[<type>] (or other
      state indicated by the host_ipi flag) are ordered vs. the store to
      to host_ipi.
      
      However, doing so might still allow for the following scenario (not
      yet observed):
      
          CPU
            X: smp_muxed_ipi_set_message():
            X:   smp_mb()
            X:   message[RESCHEDULE] = 1
            X: doorbell_global_ipi(42):
            X:   kvmppc_set_host_ipi(42, 1)
            X:   ppc_msgsnd_sync()/smp_mb()
            X:   ppc_msgsnd() -> 42
           42: doorbell_exception(): // from CPU X
           42:   ppc_msgsync()
               // STORE DEFERRED DUE TO RE-ORDERING
        -- 42:   kvmppc_set_host_ipi(42, 0)
        |  42: smp_ipi_demux_relaxed()
        | 105: smp_muxed_ipi_set_message():
        | 105:   smb_mb()
        | 105:   message[CALL_FUNCTION] = 1
        | 105: doorbell_global_ipi(42):
        | 105:   kvmppc_set_host_ipi(42, 1)
        |      // RE-ORDERED STORE COMPLETES
        -> 42:   kvmppc_set_host_ipi(42, 0)
           42: // returns to executing guest
          105:   ppc_msgsnd_sync()/smp_mb()
          105:   ppc_msgsnd() -> 42
           42: local_paca->kvm_hstate.host_ipi == 0 // IPI ignored
          105: // hangs waiting on 42 to process messages/call_single_queue
      
      Fixing this scenario would require an smp_mb() *after* clearing
      host_ipi flag in kvmppc_set_host_ipi() to order the store vs.
      subsequent processing of IPI messages.
      
      To handle both cases, this patch splits kvmppc_set_host_ipi() into
      separate set/clear functions, where we execute smp_mb() prior to
      setting host_ipi flag, and after clearing host_ipi flag. These
      functions pair with each other to synchronize the sender and receiver
      sides.
      
      With that change in place the above workload ran for 20 hours without
      triggering any lock-ups.
      
      Fixes: 755563bc ("powerpc/powernv: Fixes for hypervisor doorbell handling") # v4.0
      Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
      Acked-by: default avatarPaul Mackerras <paulus@ozlabs.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190911223155.16045-1-mdroth@linux.vnet.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      a2118e6e
    • Florian Westphal's avatar
      selftests: rtnetlink: add addresses with fixed life time · 107726ad
      Florian Westphal authored
      [ Upstream commit 3cfa1488 ]
      
      This exercises kernel code path that deal with addresses that have
      a limited lifetime.
      
      Without previous fix, this triggers following crash on net-next:
       BUG: KASAN: null-ptr-deref in check_lifetime+0x403/0x670
       Read of size 8 at addr 0000000000000010 by task kworker [..]
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      107726ad
    • Daniel Axtens's avatar
      powerpc/pseries/hvconsole: Fix stack overread via udbg · 3d14b83e
      Daniel Axtens authored
      [ Upstream commit 934bda59 ]
      
      While developing KASAN for 64-bit book3s, I hit the following stack
      over-read.
      
      It occurs because the hypercall to put characters onto the terminal
      takes 2 longs (128 bits/16 bytes) of characters at a time, and so
      hvc_put_chars() would unconditionally copy 16 bytes from the argument
      buffer, regardless of supplied length. However, udbg_hvc_putc() can
      call hvc_put_chars() with a single-byte buffer, leading to the error.
      
        ==================================================================
        BUG: KASAN: stack-out-of-bounds in hvc_put_chars+0xdc/0x110
        Read of size 8 at addr c0000000023e7a90 by task swapper/0
      
        CPU: 0 PID: 0 Comm: swapper Not tainted 5.2.0-rc2-next-20190528-02824-g048a6ab4835b #113
        Call Trace:
          dump_stack+0x104/0x154 (unreliable)
          print_address_description+0xa0/0x30c
          __kasan_report+0x20c/0x224
          kasan_report+0x18/0x30
          __asan_report_load8_noabort+0x24/0x40
          hvc_put_chars+0xdc/0x110
          hvterm_raw_put_chars+0x9c/0x110
          udbg_hvc_putc+0x154/0x200
          udbg_write+0xf0/0x240
          console_unlock+0x868/0xd30
          register_console+0x970/0xe90
          register_early_udbg_console+0xf8/0x114
          setup_arch+0x108/0x790
          start_kernel+0x104/0x784
          start_here_common+0x1c/0x534
      
        Memory state around the buggy address:
         c0000000023e7980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         c0000000023e7a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1
        >c0000000023e7a80: f1 f1 01 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
                                 ^
         c0000000023e7b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
         c0000000023e7b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
        ==================================================================
      
      Document that a 16-byte buffer is requred, and provide it in udbg.
      Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d14b83e
    • Imre Deak's avatar
      drm/mst: Fix MST sideband up-reply failure handling · efa13b32
      Imre Deak authored
      [ Upstream commit d8fd3722 ]
      
      Fix the breakage resulting in the stacktrace below, due to tx queue
      being full when trying to send an up-reply. txmsg->seqno is -1 in this
      case leading to a corruption of the mstb object by
      
      	txmsg->dst->tx_slots[txmsg->seqno] = NULL;
      
      in process_single_up_tx_qlock().
      
      [  +0,005162] [drm:process_single_tx_qlock [drm_kms_helper]] set_hdr_from_dst_qlock: failed to find slot
      [  +0,000015] [drm:drm_dp_send_up_ack_reply.constprop.19 [drm_kms_helper]] failed to send msg in q -11
      [  +0,000939] BUG: kernel NULL pointer dereference, address: 00000000000005a0
      [  +0,006982] #PF: supervisor write access in kernel mode
      [  +0,005223] #PF: error_code(0x0002) - not-present page
      [  +0,005135] PGD 0 P4D 0
      [  +0,002581] Oops: 0002 [#1] PREEMPT SMP NOPTI
      [  +0,004359] CPU: 1 PID: 1200 Comm: kworker/u16:3 Tainted: G     U            5.2.0-rc1+ #410
      [  +0,008433] Hardware name: Intel Corporation Ice Lake Client Platform/IceLake U DDR4 SODIMM PD RVP, BIOS ICLSFWR1.R00.3175.A00.1904261428 04/26/2019
      [  +0,013323] Workqueue: i915-dp i915_digport_work_func [i915]
      [  +0,005676] RIP: 0010:queue_work_on+0x19/0x70
      [  +0,004372] Code: ff ff ff 0f 1f 40 00 66 2e 0f 1f 84 00 00 00 00 00 41 56 49 89 f6 41 55 41 89 fd 41 54 55 53 48 89 d3 9c 5d fa e8 e7 81 0c 00 <f0> 48 0f ba 2b 00 73 31 45 31 e4 f7 c5 00 02 00 00 74 13 e8 cf 7f
      [  +0,018750] RSP: 0018:ffffc900007dfc50 EFLAGS: 00010006
      [  +0,005222] RAX: 0000000000000046 RBX: 00000000000005a0 RCX: 0000000000000001
      [  +0,007133] RDX: 000000000001b608 RSI: 0000000000000000 RDI: ffffffff82121972
      [  +0,007129] RBP: 0000000000000202 R08: 0000000000000000 R09: 0000000000000001
      [  +0,007129] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88847bfa5096
      [  +0,007131] R13: 0000000000000010 R14: ffff88849c08f3f8 R15: 0000000000000000
      [  +0,007128] FS:  0000000000000000(0000) GS:ffff88849dc80000(0000) knlGS:0000000000000000
      [  +0,008083] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  +0,005749] CR2: 00000000000005a0 CR3: 0000000005210006 CR4: 0000000000760ee0
      [  +0,007128] PKRU: 55555554
      [  +0,002722] Call Trace:
      [  +0,002458]  drm_dp_mst_handle_up_req+0x517/0x540 [drm_kms_helper]
      [  +0,006197]  ? drm_dp_mst_hpd_irq+0x5b/0x9c0 [drm_kms_helper]
      [  +0,005764]  drm_dp_mst_hpd_irq+0x5b/0x9c0 [drm_kms_helper]
      [  +0,005623]  ? intel_dp_hpd_pulse+0x205/0x370 [i915]
      [  +0,005018]  intel_dp_hpd_pulse+0x205/0x370 [i915]
      [  +0,004836]  i915_digport_work_func+0xbb/0x140 [i915]
      [  +0,005108]  process_one_work+0x245/0x610
      [  +0,004027]  worker_thread+0x37/0x380
      [  +0,003684]  ? process_one_work+0x610/0x610
      [  +0,004184]  kthread+0x119/0x130
      [  +0,003240]  ? kthread_park+0x80/0x80
      [  +0,003668]  ret_from_fork+0x24/0x50
      
      Cc: Lyude Paul <lyude@redhat.com>
      Cc: Dave Airlie <airlied@redhat.com>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190523212433.9058-1-imre.deak@intel.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      efa13b32
    • Chad Dupuis's avatar
      scsi: qedf: Do not retry ELS request if qedf_alloc_cmd fails · 359a3d6f
      Chad Dupuis authored
      [ Upstream commit f1c43590 ]
      
      If we cannot allocate an ELS middlepath request, simply fail instead of
      trying to delay and then reallocate.  This delay logic is causing soft
      lockup messages:
      
      NMI watchdog: BUG: soft lockup - CPU#2 stuck for 22s! [kworker/2:1:7639]
      Modules linked in: xt_CHECKSUM ipt_MASQUERADE nf_nat_masquerade_ipv4 tun devlink ip6t_rpfilter ipt_REJECT nf_reject_ipv4 ip6t_REJECT nf_reject_ipv6 xt_conntrack ip_set nfnetlink ebtable_nat ebtable_broute bridge stp llc ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack iptable_mangle iptable_security iptable_raw ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter dm_service_time vfat fat rpcrdma sunrpc ib_isert iscsi_target_mod ib_iser libiscsi scsi_transport_iscsi ib_srpt target_core_mod ib_srp scsi_transport_srp ib_ipoib rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm sb_edac intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm
      irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper cryptd iTCO_wdt iTCO_vendor_support qedr(OE) ib_core joydev ipmi_ssif pcspkr hpilo hpwdt sg ipmi_si ipmi_devintf ipmi_msghandler ioatdma shpchp lpc_ich wmi dca acpi_power_meter dm_multipath ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic qedf(OE) libfcoe mgag200 libfc i2c_algo_bit drm_kms_helper scsi_transport_fc qede(OE) syscopyarea sysfillrect sysimgblt fb_sys_fops ttm qed(OE) drm crct10dif_pclmul e1000e crct10dif_common crc32c_intel scsi_tgt hpsa i2c_core ptp scsi_transport_sas pps_core dm_mirror dm_region_hash dm_log dm_mod
      CPU: 2 PID: 7639 Comm: kworker/2:1 Kdump: loaded Tainted: G           OEL ------------   3.10.0-861.el7.x86_64 #1
      Hardware name: HP ProLiant DL580 Gen9/ProLiant DL580 Gen9, BIOS U17 07/21/2016
      Workqueue: qedf_2_dpc qedf_handle_rrq [qedf]
      task: ffff959edd628fd0 ti: ffff959ed6f08000 task.ti: ffff959ed6f08000
      RIP: 0010:[<ffffffff8355913a>]  [<ffffffff8355913a>] delay_tsc+0x3a/0x60
      RSP: 0018:ffff959ed6f0bd30  EFLAGS: 00000246
      RAX: 000000008ef5f791 RBX: 5f646d635f666465 RCX: 0000025b8ededa2f
      RDX: 000000000000025b RSI: 0000000000000002 RDI: 0000000000217d1e
      RBP: ffff959ed6f0bd30 R08: ffffffffc079aae8 R09: 0000000000000200
      R10: ffffffffc07952c6 R11: 0000000000000000 R12: 6c6c615f66646571
      R13: ffff959ed6f0bcc8 R14: ffff959ed6f0bd08 R15: ffff959e00000028
      FS:  0000000000000000(0000) GS:ffff959eff480000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f4117fa1eb0 CR3: 0000002039e66000 CR4: 00000000003607e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
      [<ffffffff8355907d>] __const_udelay+0x2d/0x30
      [<ffffffffc079444a>] qedf_initiate_els+0x13a/0x450 [qedf]
      [<ffffffffc0794210>] ? qedf_srr_compl+0x2a0/0x2a0 [qedf]
      [<ffffffffc0795337>] qedf_send_rrq+0x127/0x230 [qedf]
      [<ffffffffc078ed55>] qedf_handle_rrq+0x15/0x20 [qedf]
      [<ffffffff832b2dff>] process_one_work+0x17f/0x440
      [<ffffffff832b3ac6>] worker_thread+0x126/0x3c0
      [<ffffffff832b39a0>] ? manage_workers.isra.24+0x2a0/0x2a0
      [<ffffffff832bae31>] kthread+0xd1/0xe0
      [<ffffffff832bad60>] ? insert_kthread_work+0x40/0x40
      [<ffffffff8391f637>] ret_from_fork_nospec_begin+0x21/0x21
      [<ffffffff832bad60>] ? insert_kthread_work+0x40/0x40
      Signed-off-by: default avatarChad Dupuis <cdupuis@marvell.com>
      Signed-off-by: default avatarSaurav Kashyap <skashyap@marvell.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      359a3d6f
    • Jan Kara's avatar
      bdev: Refresh bdev size for disks without partitioning · a06ee0d2
      Jan Kara authored
      commit cba22d86 upstream.
      
      Currently, block device size in not updated on second and further open
      for block devices where partition scan is disabled. This is particularly
      annoying for example for DVD drives as that means block device size does
      not get updated once the media is inserted into a drive if the device is
      already open when inserting the media. This is actually always the case
      for example when pktcdvd is in use.
      
      Fix the problem by revalidating block device size on every open even for
      devices with partition scan disabled.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a06ee0d2
    • Jan Kara's avatar
      bdev: Factor out bdev revalidation into a common helper · 2a5b5131
      Jan Kara authored
      commit 731dc486 upstream.
      
      Factor out code handling revalidation of bdev on disk change into a
      common helper.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a5b5131
    • Al Viro's avatar
      fix compat handling of FICLONERANGE, FIDEDUPERANGE and FS_IOC_FIEMAP · 0e7dd198
      Al Viro authored
      commit 6b2daec1 upstream.
      
      Unlike FICLONE, all of those take a pointer argument; they do need
      compat_ptr() applied to arg.
      
      Fixes: d79bdd52 ("vfs: wire up compat ioctl for CLONE/CLONE_RANGE")
      Fixes: 54dbc151 ("vfs: hoist the btrfs deduplication ioctl to the vfs")
      Fixes: ceac204e ("fs: make fiemap work from compat_ioctl")
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e7dd198
    • Leo Yan's avatar
      tty: serial: msm_serial: Fix lockup for sysrq and oops · 2db81976
      Leo Yan authored
      commit 0e4f7f92 upstream.
      
      As the commit 677fe555 ("serial: imx: Fix recursive locking bug")
      has mentioned the uart driver might cause recursive locking between
      normal printing and the kernel debugging facilities (e.g. sysrq and
      oops).  In the commit it gave out suggestion for fixing recursive
      locking issue: "The solution is to avoid locking in the sysrq case
      and trylock in the oops_in_progress case."
      
      This patch follows the suggestion (also used the exactly same code with
      other serial drivers, e.g. amba-pl011.c) to fix the recursive locking
      issue, this can avoid stuck caused by deadlock and print out log for
      sysrq and oops.
      
      Fixes: 04896a77 ("msm_serial: serial driver for MSM7K onboard serial peripheral.")
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Reviewed-by: default avatarJeffrey Hugo <jeffrey.l.hugo@gmail.com>
      Link: https://lore.kernel.org/r/20191127141544.4277-2-leo.yan@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2db81976
    • Anand Moon's avatar
      arm64: dts: meson: odroid-c2: Disable usb_otg bus to avoid power failed warning · 679d4ed5
      Anand Moon authored
      commit 72c9b5f6 upstream.
      
      usb_otg bus needs to get initialize from the u-boot to be configured
      to used as power source to SBC or usb otg port will get configured
      as host device. Right now this support is missing in the u-boot and
      phy driver so to avoid power failed warning, we would disable this
      feature  until proper fix is found.
      
      [    2.716048] phy phy-c0000000.phy.0: USB ID detect failed!
      [    2.720186] phy phy-c0000000.phy.0: phy poweron failed --> -22
      [    2.726001] ------------[ cut here ]------------
      [    2.730583] WARNING: CPU: 0 PID: 12 at drivers/regulator/core.c:2039 _regulator_put+0x3c/0xe8
      [    2.738983] Modules linked in:
      [    2.742005] CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.2.9-1-ARCH #1
      [    2.748643] Hardware name: Hardkernel ODROID-C2 (DT)
      [    2.753566] Workqueue: events deferred_probe_work_func
      [    2.758649] pstate: 60000005 (nZCv daif -PAN -UAO)
      [    2.763394] pc : _regulator_put+0x3c/0xe8
      [    2.767361] lr : _regulator_put+0x3c/0xe8
      [    2.771326] sp : ffff000011aa3a50
      [    2.774604] x29: ffff000011aa3a50 x28: ffff80007ed1b600
      [    2.779865] x27: ffff80007f7036a8 x26: ffff80007f7036a8
      [    2.785126] x25: 0000000000000000 x24: ffff000011a44458
      [    2.790387] x23: ffff000011344218 x22: 0000000000000009
      [    2.795649] x21: ffff000011aa3b68 x20: ffff80007ed1b500
      [    2.800910] x19: ffff80007ed1b500 x18: 0000000000000010
      [    2.806171] x17: 000000005be5943c x16: 00000000f1c73b29
      [    2.811432] x15: ffffffffffffffff x14: ffff0000117396c8
      [    2.816694] x13: ffff000091aa37a7 x12: ffff000011aa37af
      [    2.821955] x11: ffff000011763000 x10: ffff000011aa3730
      [    2.827216] x9 : 00000000ffffffd0 x8 : ffff000010871760
      [    2.832477] x7 : 00000000000000d0 x6 : ffff0000119d151b
      [    2.837739] x5 : 000000000000000f x4 : 0000000000000000
      [    2.843000] x3 : 0000000000000000 x2 : 38104b2678c20100
      [    2.848261] x1 : 0000000000000000 x0 : 0000000000000024
      [    2.853523] Call trace:
      [    2.855940]  _regulator_put+0x3c/0xe8
      [    2.859562]  regulator_put+0x34/0x48
      [    2.863098]  regulator_bulk_free+0x40/0x58
      [    2.867153]  devm_regulator_bulk_release+0x24/0x30
      [    2.871896]  release_nodes+0x1f0/0x2e0
      [    2.875604]  devres_release_all+0x64/0xa4
      [    2.879571]  really_probe+0x1c8/0x3e0
      [    2.883194]  driver_probe_device+0xe4/0x138
      [    2.887334]  __device_attach_driver+0x90/0x110
      [    2.891733]  bus_for_each_drv+0x8c/0xd8
      [    2.895527]  __device_attach+0xdc/0x160
      [    2.899322]  device_initial_probe+0x24/0x30
      [    2.903463]  bus_probe_device+0x9c/0xa8
      [    2.907258]  deferred_probe_work_func+0xa0/0xf0
      [    2.911745]  process_one_work+0x1b4/0x408
      [    2.915711]  worker_thread+0x54/0x4b8
      [    2.919334]  kthread+0x12c/0x130
      [    2.922526]  ret_from_fork+0x10/0x1c
      [    2.926060] ---[ end trace 51a68f4c0035d6c0 ]---
      [    2.930691] ------------[ cut here ]------------
      [    2.935242] WARNING: CPU: 0 PID: 12 at drivers/regulator/core.c:2039 _regulator_put+0x3c/0xe8
      [    2.943653] Modules linked in:
      [    2.946675] CPU: 0 PID: 12 Comm: kworker/0:1 Tainted: G        W         5.2.9-1-ARCH #1
      [    2.954694] Hardware name: Hardkernel ODROID-C2 (DT)
      [    2.959613] Workqueue: events deferred_probe_work_func
      [    2.964700] pstate: 60000005 (nZCv daif -PAN -UAO)
      [    2.969445] pc : _regulator_put+0x3c/0xe8
      [    2.973412] lr : _regulator_put+0x3c/0xe8
      [    2.977377] sp : ffff000011aa3a50
      [    2.980655] x29: ffff000011aa3a50 x28: ffff80007ed1b600
      [    2.985916] x27: ffff80007f7036a8 x26: ffff80007f7036a8
      [    2.991177] x25: 0000000000000000 x24: ffff000011a44458
      [    2.996439] x23: ffff000011344218 x22: 0000000000000009
      [    3.001700] x21: ffff000011aa3b68 x20: ffff80007ed1bd00
      [    3.006961] x19: ffff80007ed1bd00 x18: 0000000000000010
      [    3.012222] x17: 000000005be5943c x16: 00000000f1c73b29
      [    3.017484] x15: ffffffffffffffff x14: ffff0000117396c8
      [    3.022745] x13: ffff000091aa37a7 x12: ffff000011aa37af
      [    3.028006] x11: ffff000011763000 x10: ffff000011aa3730
      [    3.033267] x9 : 00000000ffffffd0 x8 : ffff000010871760
      [    3.038528] x7 : 00000000000000fd x6 : ffff0000119d151b
      [    3.043790] x5 : 000000000000000f x4 : 0000000000000000
      [    3.049051] x3 : 0000000000000000 x2 : 38104b2678c20100
      [    3.054312] x1 : 0000000000000000 x0 : 0000000000000024
      [    3.059574] Call trace:
      [    3.061991]  _regulator_put+0x3c/0xe8
      [    3.065613]  regulator_put+0x34/0x48
      [    3.069149]  regulator_bulk_free+0x40/0x58
      [    3.073203]  devm_regulator_bulk_release+0x24/0x30
      [    3.077947]  release_nodes+0x1f0/0x2e0
      [    3.081655]  devres_release_all+0x64/0xa4
      [    3.085622]  really_probe+0x1c8/0x3e0
      [    3.089245]  driver_probe_device+0xe4/0x138
      [    3.093385]  __device_attach_driver+0x90/0x110
      [    3.097784]  bus_for_each_drv+0x8c/0xd8
      [    3.101578]  __device_attach+0xdc/0x160
      [    3.105373]  device_initial_probe+0x24/0x30
      [    3.109514]  bus_probe_device+0x9c/0xa8
      [    3.113309]  deferred_probe_work_func+0xa0/0xf0
      [    3.117796]  process_one_work+0x1b4/0x408
      [    3.121762]  worker_thread+0x54/0x4b8
      [    3.125384]  kthread+0x12c/0x130
      [    3.128575]  ret_from_fork+0x10/0x1c
      [    3.132110] ---[ end trace 51a68f4c0035d6c1 ]---
      [    3.136753] dwc2: probe of c9000000.usb failed with error -22
      
      Fixes: 5a0803bd ("ARM64: dts: meson-gxbb-odroidc2: Enable USB Nodes")
      Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
      Cc: Jerome Brunet <jbrunet@baylibre.com>
      Cc: Neil Armstrong <narmstrong@baylibre.com>
      Acked-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: default avatarAnand Moon <linux.amoon@gmail.com>
      Signed-off-by: default avatarKevin Hilman <khilman@baylibre.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      679d4ed5
    • Geert Uytterhoeven's avatar
      dt-bindings: clock: renesas: rcar-usb2-clock-sel: Fix typo in example · f6aa433c
      Geert Uytterhoeven authored
      commit 830dbce7 upstream.
      
      The documented compatible value for R-Car H3 is
      "renesas,r8a7795-rcar-usb2-clock-sel", not
      "renesas,r8a77950-rcar-usb2-clock-sel".
      
      Fixes: 311accb6 ("clk: renesas: rcar-usb2-clock-sel: Add R-Car USB 2.0 clock selector PHY")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Reviewed-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Link: https://lore.kernel.org/r/20191016145650.30003-1-geert+renesas@glider.beSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f6aa433c
    • Navid Emamdoost's avatar
      media: usb: fix memory leak in af9005_identify_state · d933de81
      Navid Emamdoost authored
      commit 2289adbf upstream.
      
      In af9005_identify_state when returning -EIO the allocated buffer should
      be released. Replace the "return -EIO" with assignment into ret and move
      deb_info() under a check.
      
      Fixes: af4e067e ("V4L/DVB (5625): Add support for the AF9005 demodulator from Afatech")
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d933de81
    • Stephan Gerhold's avatar
      regulator: ab8500: Remove AB8505 USB regulator · 50b55230
      Stephan Gerhold authored
      commit 99c4f70d upstream.
      
      The USB regulator was removed for AB8500 in
      commit 41a06aa7 ("regulator: ab8500: Remove USB regulator").
      It was then added for AB8505 in
      commit 547f384f ("regulator: ab8500: add support for ab8505").
      
      However, there was never an entry added for it in
      ab8505_regulator_match. This causes all regulators after it
      to be initialized with the wrong device tree data, eventually
      leading to an out-of-bounds array read.
      
      Given that it is not used anywhere in the kernel, it seems
      likely that similar arguments against supporting it exist for
      AB8505 (it is controlled by hardware).
      
      Therefore, simply remove it like for AB8500 instead of adding
      an entry in ab8505_regulator_match.
      
      Fixes: 547f384f ("regulator: ab8500: add support for ab8505")
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarStephan Gerhold <stephan@gerhold.net>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20191106173125.14496-1-stephan@gerhold.netSigned-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50b55230
    • Colin Ian King's avatar
      media: flexcop-usb: ensure -EIO is returned on error condition · 51ebfce1
      Colin Ian King authored
      commit 74a96b51 upstream.
      
      An earlier commit hard coded a return 0 to function flexcop_usb_i2c_req
      even though the an -EIO was intended to be returned in the case where
      ret != buflen.  Fix this by replacing the return 0 with the return of
      ret to return the error return code.
      
      Addresses-Coverity: ("Unused value")
      
      Fixes: b430eaba ("[media] flexcop-usb: don't use stack for DMA")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarSean Young <sean@mess.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51ebfce1
    • Navid Emamdoost's avatar
      Bluetooth: Fix memory leak in hci_connect_le_scan · dfde3147
      Navid Emamdoost authored
      commit d088337c upstream.
      
      In the implementation of hci_connect_le_scan() when conn is added via
      hci_conn_add(), if hci_explicit_conn_params_set() fails the allocated
      memory for conn is leaked. Use hci_conn_del() to release it.
      
      Fixes: f75113a2 ("Bluetooth: add hci_connect_le_scan")
      Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dfde3147
    • Dan Carpenter's avatar
      Bluetooth: delete a stray unlock · cf223ff1
      Dan Carpenter authored
      commit df66499a upstream.
      
      We used to take a lock in amp_physical_cfm() but then we moved it to
      the caller function.  Unfortunately the unlock on this error path was
      overlooked so it leads to a double unlock.
      
      Fixes: a514b17f ("Bluetooth: Refactor locking in amp_physical_cfm")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cf223ff1
    • Oliver Neukum's avatar
      Bluetooth: btusb: fix PM leak in error case of setup · a0a5f3d3
      Oliver Neukum authored
      commit 3d44a6fd upstream.
      
      If setup() fails a reference for runtime PM has already
      been taken. Proper use of the error handling in btusb_open()is needed.
      You cannot just return.
      
      Fixes: ace31982 ("Bluetooth: btusb: Add setup callback for chip init on USB")
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a0a5f3d3
    • Michael Haener's avatar
      platform/x86: pmc_atom: Add Siemens CONNECT X300 to critclk_systems DMI table · b1ecf978
      Michael Haener authored
      commit e8796c6c upstream.
      
      The CONNECT X300 uses the PMC clock for on-board components and gets
      stuck during boot if the clock is disabled. Therefore, add this
      device to the critical systems list.
      Tested on CONNECT X300.
      
      Fixes: 648e9218 ("clk: x86: Stop marking clocks as CLK_IS_CRITICAL")
      Signed-off-by: default avatarMichael Haener <michael.haener@siemens.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1ecf978
    • Omar Sandoval's avatar
      xfs: don't check for AG deadlock for realtime files in bunmapi · e1ceceb4
      Omar Sandoval authored
      commit 69ffe596 upstream.
      
      Commit 5b094d6d ("xfs: fix multi-AG deadlock in xfs_bunmapi") added
      a check in __xfs_bunmapi() to stop early if we would touch multiple AGs
      in the wrong order. However, this check isn't applicable for realtime
      files. In most cases, it just makes us do unnecessary commits. However,
      without the fix from the previous commit ("xfs: fix realtime file data
      space leak"), if the last and second-to-last extents also happen to have
      different "AG numbers", then the break actually causes __xfs_bunmapi()
      to return without making any progress, which sends
      xfs_itruncate_extents_flags() into an infinite loop.
      
      Fixes: 5b094d6d ("xfs: fix multi-AG deadlock in xfs_bunmapi")
      Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e1ceceb4
    • Yunfeng Ye's avatar
      ACPI: sysfs: Change ACPI_MASKABLE_GPE_MAX to 0x100 · dba77370
      Yunfeng Ye authored
      commit a7583e72 upstream.
      
      The commit 0f27cff8 ("ACPI: sysfs: Make ACPI GPE mask kernel
      parameter cover all GPEs") says:
        "Use a bitmap of size 0xFF instead of a u64 for the GPE mask so 256
         GPEs can be masked"
      
      But the masking of GPE 0xFF it not supported and the check condition
      "gpe > ACPI_MASKABLE_GPE_MAX" is not valid because the type of gpe is
      u8.
      
      So modify the macro ACPI_MASKABLE_GPE_MAX to 0x100, and drop the "gpe >
      ACPI_MASKABLE_GPE_MAX" check. In addition, update the docs "Format" for
      acpi_mask_gpe parameter.
      
      Fixes: 0f27cff8 ("ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs")
      Signed-off-by: default avatarYunfeng Ye <yeyunfeng@huawei.com>
      [ rjw: Use u16 as gpe data type in acpi_gpe_apply_masked_gpes() ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dba77370
    • Kai-Heng Feng's avatar
      HID: i2c-hid: Reset ALPS touchpads on resume · 9d833862
      Kai-Heng Feng authored
      commit fd70466d upstream.
      
      Commit 52cf93e6 ("HID: i2c-hid: Don't reset device upon system
      resume") fixes many touchpads and touchscreens, however ALPS touchpads
      start to trigger IRQ storm after system resume.
      
      Since it's total silence from ALPS, let's bring the old behavior back
      to ALPS touchpads.
      
      Fixes: 52cf93e6 ("HID: i2c-hid: Don't reset device upon system resume")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9d833862
    • Scott Mayhew's avatar
      nfsd4: fix up replay_matches_cache() · 58f7525f
      Scott Mayhew authored
      commit 6e73e92b upstream.
      
      When running an nfs stress test, I see quite a few cached replies that
      don't match up with the actual request.  The first comment in
      replay_matches_cache() makes sense, but the code doesn't seem to
      match... fix it.
      
      This isn't exactly a bugfix, as the server isn't required to catch every
      case of a false retry.  So, we may as well do this, but if this is
      fixing a problem then that suggests there's a client bug.
      
      Fixes: 53da6a53 ("nfsd4: catch some false session retries")
      Signed-off-by: default avatarScott Mayhew <smayhew@redhat.com>
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58f7525f
    • Leonard Crestez's avatar
      PM / devfreq: Check NULL governor in available_governors_show · ac57e160
      Leonard Crestez authored
      commit d68adc8f upstream.
      
      The governor is initialized after sysfs attributes become visible so in
      theory the governor field can be NULL here.
      
      Fixes: bcf23c79 ("PM / devfreq: Fix available_governor sysfs")
      Signed-off-by: default avatarLeonard Crestez <leonard.crestez@nxp.com>
      Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac57e160
    • Arnd Bergmann's avatar
      drm/msm: include linux/sched/task.h · 062ec830
      Arnd Bergmann authored
      commit 70082a52 upstream.
      
      Without this header file, compile-testing may run into a missing
      declaration:
      
      drivers/gpu/drm/msm/msm_gpu.c:444:4: error: implicit declaration of function 'put_task_struct' [-Werror,-Wimplicit-function-declaration]
      
      Fixes: 482f9632 ("drm/msm: Fix task dump in gpu recovery")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      062ec830
    • Wen Yang's avatar
      ftrace: Avoid potential division by zero in function profiler · 010a7e84
      Wen Yang authored
      commit e31f7939 upstream.
      
      The ftrace_profile->counter is unsigned long and
      do_div truncates it to 32 bits, which means it can test
      non-zero and be truncated to zero for division.
      Fix this issue by using div64_ul() instead.
      
      Link: http://lkml.kernel.org/r/20200103030248.14516-1-wenyang@linux.alibaba.com
      
      Cc: stable@vger.kernel.org
      Fixes: e330b3bc ("tracing: Show sample std dev in function profiling")
      Fixes: 34886c8b ("tracing: add average time in function to function profiler")
      Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      010a7e84
    • Catalin Marinas's avatar
      arm64: Revert support for execute-only user mappings · d89a351b
      Catalin Marinas authored
      commit 24cecc37 upstream.
      
      The ARMv8 64-bit architecture supports execute-only user permissions by
      clearing the PTE_USER and PTE_UXN bits, practically making it a mostly
      privileged mapping but from which user running at EL0 can still execute.
      
      The downside, however, is that the kernel at EL1 inadvertently reading
      such mapping would not trip over the PAN (privileged access never)
      protection.
      
      Revert the relevant bits from commit cab15ce6 ("arm64: Introduce
      execute-only page access permissions") so that PROT_EXEC implies
      PROT_READ (and therefore PTE_USER) until the architecture gains proper
      support for execute-only user mappings.
      
      Fixes: cab15ce6 ("arm64: Introduce execute-only page access permissions")
      Cc: <stable@vger.kernel.org> # 4.9.x-
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d89a351b
    • chenqiwu's avatar
      exit: panic before exit_mm() on global init exit · b9227aac
      chenqiwu authored
      commit 43cf75d9 upstream.
      
      Currently, when global init and all threads in its thread-group have exited
      we panic via:
      do_exit()
      -> exit_notify()
         -> forget_original_parent()
            -> find_child_reaper()
      This makes it hard to extract a useable coredump for global init from a
      kernel crashdump because by the time we panic exit_mm() will have already
      released global init's mm.
      This patch moves the panic futher up before exit_mm() is called. As was the
      case previously, we only panic when global init and all its threads in the
      thread-group have exited.
      Signed-off-by: default avatarchenqiwu <chenqiwu@xiaomi.com>
      Acked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      [christian.brauner@ubuntu.com: fix typo, rewrite commit message]
      Link: https://lore.kernel.org/r/1576736993-10121-1-git-send-email-qiwuchen55@gmail.comSigned-off-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b9227aac
    • Takashi Iwai's avatar
      ALSA: firewire-motu: Correct a typo in the clock proc string · aa94893f
      Takashi Iwai authored
      commit 0929249e upstream.
      
      Just fix a typo of "S/PDIF" in the clock name string.
      
      Fixes: 4638ec6e ("ALSA: firewire-motu: add proc node to show current statuc of clock and packet formats")
      Acked-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Link: https://lore.kernel.org/r/20191030100921.3826-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aa94893f
    • Colin Ian King's avatar
      ALSA: cs4236: fix error return comparison of an unsigned integer · 8f093a21
      Colin Ian King authored
      commit d60229d8 upstream.
      
      The return from pnp_irq is an unsigned integer type resource_size_t
      and hence the error check for a positive non-error code is always
      going to be true.  A check for a non-failure return from pnp_irq
      should in fact be for (resource_size_t)-1 rather than >= 0.
      
      Addresses-Coverity: ("Unsigned compared against 0")
      Fixes: a9824c86 ("[ALSA] Add CS4232 PnP BIOS support")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Link: https://lore.kernel.org/r/20191122131354.58042-1-colin.king@canonical.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f093a21
    • John Johansen's avatar
      apparmor: fix aa_xattrs_match() may sleep while holding a RCU lock · f3248d6d
      John Johansen authored
      commit 8c62ed27 upstream.
      
      aa_xattrs_match() is unfortunately calling vfs_getxattr_alloc() from a
      context protected by an rcu_read_lock. This can not be done as
      vfs_getxattr_alloc() may sleep regardles of the gfp_t value being
      passed to it.
      
      Fix this by breaking the rcu_read_lock on the policy search when the
      xattr match feature is requested and restarting the search if a policy
      changes occur.
      
      Fixes: 8e51f908 ("apparmor: Add support for attaching profiles via xattr, presence and value")
      Reported-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3248d6d
    • Sven Schnelle's avatar
      tracing: Fix endianness bug in histogram trigger · 1c662483
      Sven Schnelle authored
      commit fe6e096a upstream.
      
      At least on PA-RISC and s390 synthetic histogram triggers are failing
      selftests because trace_event_raw_event_synth() always writes a 64 bit
      values, but the reader expects a field->size sized value. On little endian
      machines this doesn't hurt, but on big endian this makes the reader always
      read zero values.
      
      Link: http://lore.kernel.org/linux-trace-devel/20191218074427.96184-4-svens@linux.ibm.com
      
      Cc: stable@vger.kernel.org
      Fixes: 4b147936 ("tracing: Add support for 'synthetic' events")
      Acked-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1c662483
    • Steven Rostedt (VMware)'s avatar
      tracing: Have the histogram compare functions convert to u64 first · 0c815959
      Steven Rostedt (VMware) authored
      commit 106f41f5 upstream.
      
      The compare functions of the histogram code would be specific for the size
      of the value being compared (byte, short, int, long long). It would
      reference the value from the array via the type of the compare, but the
      value was stored in a 64 bit number. This is fine for little endian
      machines, but for big endian machines, it would end up comparing zeros or
      all ones (depending on the sign) for anything but 64 bit numbers.
      
      To fix this, first derference the value as a u64 then convert it to the type
      being compared.
      
      Link: http://lkml.kernel.org/r/20191211103557.7bed6928@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Fixes: 08d43a5f ("tracing: Add lock-free tracing_map")
      Acked-by: default avatarTom Zanussi <zanussi@kernel.org>
      Reported-by: default avatarSven Schnelle <svens@stackframe.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c815959
    • Keita Suzuki's avatar
      tracing: Avoid memory leak in process_system_preds() · 8595e2aa
      Keita Suzuki authored
      commit 79e65c27 upstream.
      
      When failing in the allocation of filter_item, process_system_preds()
      goes to fail_mem, where the allocated filter is freed.
      
      However, this leads to memory leak of filter->filter_string and
      filter->prog, which is allocated before and in process_preds().
      This bug has been detected by kmemleak as well.
      
      Fix this by changing kfree to __free_fiter.
      
      unreferenced object 0xffff8880658007c0 (size 32):
        comm "bash", pid 579, jiffies 4295096372 (age 17.752s)
        hex dump (first 32 bytes):
          63 6f 6d 6d 6f 6e 5f 70 69 64 20 20 3e 20 31 30  common_pid  > 10
          00 00 00 00 00 00 00 00 65 73 00 00 00 00 00 00  ........es......
        backtrace:
          [<0000000067441602>] kstrdup+0x2d/0x60
          [<00000000141cf7b7>] apply_subsystem_event_filter+0x378/0x932
          [<000000009ca32334>] subsystem_filter_write+0x5a/0x90
          [<0000000072da2bee>] vfs_write+0xe1/0x240
          [<000000004f14f473>] ksys_write+0xb4/0x150
          [<00000000a968b4a0>] do_syscall_64+0x6d/0x1e0
          [<000000001a189f40>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      unreferenced object 0xffff888060c22d00 (size 64):
        comm "bash", pid 579, jiffies 4295096372 (age 17.752s)
        hex dump (first 32 bytes):
          01 00 00 00 00 00 00 00 00 e8 d7 41 80 88 ff ff  ...........A....
          01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<00000000b8c1b109>] process_preds+0x243/0x1820
          [<000000003972c7f0>] apply_subsystem_event_filter+0x3be/0x932
          [<000000009ca32334>] subsystem_filter_write+0x5a/0x90
          [<0000000072da2bee>] vfs_write+0xe1/0x240
          [<000000004f14f473>] ksys_write+0xb4/0x150
          [<00000000a968b4a0>] do_syscall_64+0x6d/0x1e0
          [<000000001a189f40>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      unreferenced object 0xffff888041d7e800 (size 512):
        comm "bash", pid 579, jiffies 4295096372 (age 17.752s)
        hex dump (first 32 bytes):
          70 bc 85 97 ff ff ff ff 0a 00 00 00 00 00 00 00  p...............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<000000001e04af34>] process_preds+0x71a/0x1820
          [<000000003972c7f0>] apply_subsystem_event_filter+0x3be/0x932
          [<000000009ca32334>] subsystem_filter_write+0x5a/0x90
          [<0000000072da2bee>] vfs_write+0xe1/0x240
          [<000000004f14f473>] ksys_write+0xb4/0x150
          [<00000000a968b4a0>] do_syscall_64+0x6d/0x1e0
          [<000000001a189f40>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Link: http://lkml.kernel.org/r/20191211091258.11310-1-keitasuzuki.park@sslab.ics.keio.ac.jp
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 404a3add ("tracing: Only add filter list when needed")
      Signed-off-by: default avatarKeita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8595e2aa
    • Prateek Sood's avatar
      tracing: Fix lock inversion in trace_event_enable_tgid_record() · 0e48d030
      Prateek Sood authored
      commit 3a53acf1 upstream.
      
             Task T2                             Task T3
      trace_options_core_write()            subsystem_open()
      
       mutex_lock(trace_types_lock)           mutex_lock(event_mutex)
      
       set_tracer_flag()
      
         trace_event_enable_tgid_record()       mutex_lock(trace_types_lock)
      
          mutex_lock(event_mutex)
      
      This gives a circular dependency deadlock between trace_types_lock and
      event_mutex. To fix this invert the usage of trace_types_lock and
      event_mutex in trace_options_core_write(). This keeps the sequence of
      lock usage consistent.
      
      Link: http://lkml.kernel.org/r/0101016eef175e38-8ca71caf-a4eb-480d-a1e6-6f0bbc015495-000000@us-west-2.amazonses.com
      
      Cc: stable@vger.kernel.org
      Fixes: d914ba37 ("tracing: Add support for recording tgid of tasks")
      Signed-off-by: default avatarPrateek Sood <prsood@codeaurora.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0e48d030
    • Mathieu Desnoyers's avatar
      rseq/selftests: Fix: Namespace gettid() for compatibility with glibc 2.30 · 349e05e9
      Mathieu Desnoyers authored
      commit 8df34c56 upstream.
      
      glibc 2.30 introduces gettid() in public headers, which clashes with
      the internal static definition within rseq selftests.
      
      Rename gettid() to rseq_gettid() to eliminate this symbol name clash.
      Reported-by: default avatarTommi T. Rantala <tommi.t.rantala@nokia.com>
      Signed-off-by: default avatarMathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Shuah Khan <skhan@linuxfoundation.org>
      Cc: Tommi T. Rantala <tommi.t.rantala@nokia.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: "Paul E. McKenney" <paulmck@linux.ibm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: "H . Peter Anvin" <hpa@zytor.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: <stable@vger.kernel.org>	# v4.18+
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      349e05e9
    • Zong Li's avatar
      riscv: ftrace: correct the condition logic in function graph tracer · ac8e28a9
      Zong Li authored
      commit 1d8f6579 upstream.
      
      The condition should be logical NOT to assign the hook address to parent
      address. Because the return value 0 of function_graph_enter upon
      success.
      
      Fixes: e949b6db (riscv/function_graph: Simplify with function_graph_enter())
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Reviewed-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaul Walmsley <paul.walmsley@sifive.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac8e28a9
    • Russell King's avatar
      gpiolib: fix up emulated open drain outputs · 316a9a84
      Russell King authored
      commit 256efaea upstream.
      
      gpiolib has a corner case with open drain outputs that are emulated.
      When such outputs are outputting a logic 1, emulation will set the
      hardware to input mode, which will cause gpiod_get_direction() to
      report that it is in input mode. This is different from the behaviour
      with a true open-drain output.
      
      Unify the semantics here.
      
      Cc: <stable@vger.kernel.org>
      Suggested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      316a9a84
    • Sascha Hauer's avatar
      libata: Fix retrieving of active qcs · c89e7917
      Sascha Hauer authored
      commit 8385d756 upstream.
      
      ata_qc_complete_multiple() is called with a mask of the still active
      tags.
      
      mv_sata doesn't have this information directly and instead calculates
      the still active tags from the started tags (ap->qc_active) and the
      finished tags as (ap->qc_active ^ done_mask)
      
      Since 28361c40 the hw_tag and tag are no longer the same and the
      equation is no longer valid. In ata_exec_internal_sg() ap->qc_active is
      initialized as 1ULL << ATA_TAG_INTERNAL, but in hardware tag 0 is
      started and this will be in done_mask on completion. ap->qc_active ^
      done_mask becomes 0x100000000 ^ 0x1 = 0x100000001 and thus tag 0 used as
      the internal tag will never be reported as completed.
      
      This is fixed by introducing ata_qc_get_active() which returns the
      active hardware tags and calling it where appropriate.
      
      This is tested on mv_sata, but sata_fsl and sata_nv suffer from the same
      problem. There is another case in sata_nv that most likely needs fixing
      as well, but this looks a little different, so I wasn't confident enough
      to change that.
      
      Fixes: 28361c40 ("libata: add extra internal command")
      Cc: stable@vger.kernel.org
      Tested-by: default avatarPali Rohár <pali.rohar@gmail.com>
      Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      Add missing export of ata_qc_get_active(), as per Pali.
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      c89e7917