Skip to content
Snippets Groups Projects
  1. Mar 16, 2022
    • Hans de Goede's avatar
      staging: rtl8723bs: Fix access-point mode deadlock · 441bc1e3
      Hans de Goede authored
      
      commit 8f4347081be32e67b0873827e0138ab0fdaaf450 upstream.
      
      Commit 54659ca0 ("staging: rtl8723bs: remove possible deadlock when
      disconnect (v2)") split the locking of pxmitpriv->lock vs sleep_q/lock
      into 2 locks in attempt to fix a lockdep reported issue with the locking
      order of the sta_hash_lock vs pxmitpriv->lock.
      
      But in the end this turned out to not fully solve the sta_hash_lock issue
      so commit a7ac783c ("staging: rtl8723bs: remove a second possible
      deadlock") was added to fix this in another way.
      
      The original fix was kept as it was still seen as a good thing to have,
      but now it turns out that it creates a deadlock in access-point mode:
      
      [Feb20 23:47] ======================================================
      [  +0.074085] WARNING: possible circular locking dependency detected
      [  +0.074077] 5.16.0-1-amd64 #1 Tainted: G         C  E
      [  +0.064710] ------------------------------------------------------
      [  +0.074075] ksoftirqd/3/29 is trying to acquire lock:
      [  +0.060542] ffffb8b30062ab00 (&pxmitpriv->lock){+.-.}-{2:2}, at: rtw_xmit_classifier+0x8a/0x140 [r8723bs]
      [  +0.114921]
                    but task is already holding lock:
      [  +0.069908] ffffb8b3007ab704 (&psta->sleep_q.lock){+.-.}-{2:2}, at: wakeup_sta_to_xmit+0x3b/0x300 [r8723bs]
      [  +0.116976]
                    which lock already depends on the new lock.
      
      [  +0.098037]
                    the existing dependency chain (in reverse order) is:
      [  +0.089704]
                    -> #1 (&psta->sleep_q.lock){+.-.}-{2:2}:
      [  +0.077232]        _raw_spin_lock_bh+0x34/0x40
      [  +0.053261]        xmitframe_enqueue_for_sleeping_sta+0xc1/0x2f0 [r8723bs]
      [  +0.082572]        rtw_xmit+0x58b/0x940 [r8723bs]
      [  +0.056528]        _rtw_xmit_entry+0xba/0x350 [r8723bs]
      [  +0.062755]        dev_hard_start_xmit+0xf1/0x320
      [  +0.056381]        sch_direct_xmit+0x9e/0x360
      [  +0.052212]        __dev_queue_xmit+0xce4/0x1080
      [  +0.055334]        ip6_finish_output2+0x18f/0x6e0
      [  +0.056378]        ndisc_send_skb+0x2c8/0x870
      [  +0.052209]        ndisc_send_ns+0xd3/0x210
      [  +0.050130]        addrconf_dad_work+0x3df/0x5a0
      [  +0.055338]        process_one_work+0x274/0x5a0
      [  +0.054296]        worker_thread+0x52/0x3b0
      [  +0.050124]        kthread+0x16c/0x1a0
      [  +0.044925]        ret_from_fork+0x1f/0x30
      [  +0.049092]
                    -> #0 (&pxmitpriv->lock){+.-.}-{2:2}:
      [  +0.074101]        __lock_acquire+0x10f5/0x1d80
      [  +0.054298]        lock_acquire+0xd7/0x300
      [  +0.049088]        _raw_spin_lock_bh+0x34/0x40
      [  +0.053248]        rtw_xmit_classifier+0x8a/0x140 [r8723bs]
      [  +0.066949]        rtw_xmitframe_enqueue+0xa/0x20 [r8723bs]
      [  +0.066946]        rtl8723bs_hal_xmitframe_enqueue+0x14/0x50 [r8723bs]
      [  +0.078386]        wakeup_sta_to_xmit+0xa6/0x300 [r8723bs]
      [  +0.065903]        rtw_recv_entry+0xe36/0x1160 [r8723bs]
      [  +0.063809]        rtl8723bs_recv_tasklet+0x349/0x6c0 [r8723bs]
      [  +0.071093]        tasklet_action_common.constprop.0+0xe5/0x110
      [  +0.070966]        __do_softirq+0x16f/0x50a
      [  +0.050134]        __irq_exit_rcu+0xeb/0x140
      [  +0.051172]        irq_exit_rcu+0xa/0x20
      [  +0.047006]        common_interrupt+0xb8/0xd0
      [  +0.052214]        asm_common_interrupt+0x1e/0x40
      [  +0.056381]        finish_task_switch.isra.0+0x100/0x3a0
      [  +0.063670]        __schedule+0x3ad/0xd20
      [  +0.048047]        schedule+0x4e/0xc0
      [  +0.043880]        smpboot_thread_fn+0xc4/0x220
      [  +0.054298]        kthread+0x16c/0x1a0
      [  +0.044922]        ret_from_fork+0x1f/0x30
      [  +0.049088]
                    other info that might help us debug this:
      
      [  +0.095950]  Possible unsafe locking scenario:
      
      [  +0.070952]        CPU0                    CPU1
      [  +0.054282]        ----                    ----
      [  +0.054285]   lock(&psta->sleep_q.lock);
      [  +0.047004]                                lock(&pxmitpriv->lock);
      [  +0.074082]                                lock(&psta->sleep_q.lock);
      [  +0.077209]   lock(&pxmitpriv->lock);
      [  +0.043873]
                     *** DEADLOCK ***
      
      [  +0.070950] 1 lock held by ksoftirqd/3/29:
      [  +0.049082]  #0: ffffb8b3007ab704 (&psta->sleep_q.lock){+.-.}-{2:2}, at: wakeup_sta_to_xmit+0x3b/0x300 [r8723bs]
      
      Analysis shows that in hindsight the splitting of the lock was not
      a good idea, so revert this to fix the access-point mode deadlock.
      
      Note this is a straight-forward revert done with git revert, the commented
      out "/* spin_lock_bh(&psta_bmc->sleep_q.lock); */" lines were part of the
      code before the reverted changes.
      
      Fixes: 54659ca0 ("staging: rtl8723bs: remove possible deadlock when disconnect (v2)")
      Cc: stable <stable@vger.kernel.org>
      Cc: Fabio Aiuto <fabioaiuto83@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215542
      Link: https://lore.kernel.org/r/20220302101637.26542-1-hdegoede@redhat.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      441bc1e3
    • Miklos Szeredi's avatar
      fuse: fix pipe buffer lifetime for direct_io · ca62747b
      Miklos Szeredi authored
      
      commit 0c4bcfdecb1ac0967619ee7ff44871d93c08c909 upstream.
      
      In FOPEN_DIRECT_IO mode, fuse_file_write_iter() calls
      fuse_direct_write_iter(), which normally calls fuse_direct_io(), which then
      imports the write buffer with fuse_get_user_pages(), which uses
      iov_iter_get_pages() to grab references to userspace pages instead of
      actually copying memory.
      
      On the filesystem device side, these pages can then either be read to
      userspace (via fuse_dev_read()), or splice()d over into a pipe using
      fuse_dev_splice_read() as pipe buffers with &nosteal_pipe_buf_ops.
      
      This is wrong because after fuse_dev_do_read() unlocks the FUSE request,
      the userspace filesystem can mark the request as completed, causing write()
      to return. At that point, the userspace filesystem should no longer have
      access to the pipe buffer.
      
      Fix by copying pages coming from the user address space to new pipe
      buffers.
      
      Reported-by: default avatarJann Horn <jannh@google.com>
      Fixes: c3021629 ("fuse: support splice() reading from fuse device")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca62747b
    • Miklos Szeredi's avatar
      fuse: fix fileattr op failure · d60d34b4
      Miklos Szeredi authored
      
      commit a679a61520d8a7b0211a1da990404daf5cc80b72 upstream.
      
      The fileattr API conversion broke lsattr on ntfs3g.
      
      Previously the ioctl(... FS_IOC_GETFLAGS) returned an EINVAL error, but
      after the conversion the error returned by the fuse filesystem was not
      propagated back to the ioctl() system call, resulting in success being
      returned with bogus values.
      
      Fix by checking for outarg.result in fuse_priv_ioctl(), just as generic
      ioctl code does.
      
      Reported-by: default avatarJean-Pierre André <jean-pierre.andre@wanadoo.fr>
      Fixes: 72227eac ("fuse: convert to fileattr")
      Cc: <stable@vger.kernel.org> # v5.13
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d60d34b4
    • Randy Dunlap's avatar
      ARM: Spectre-BHB: provide empty stub for non-config · 64147ce8
      Randy Dunlap authored
      
      commit 68453767131a5deec1e8f9ac92a9042f929e585d upstream.
      
      When CONFIG_GENERIC_CPU_VULNERABILITIES is not set, references
      to spectre_v2_update_state() cause a build error, so provide an
      empty stub for that function when the Kconfig option is not set.
      
      Fixes this build error:
      
        arm-linux-gnueabi-ld: arch/arm/mm/proc-v7-bugs.o: in function `cpu_v7_bugs_init':
        proc-v7-bugs.c:(.text+0x52): undefined reference to `spectre_v2_update_state'
        arm-linux-gnueabi-ld: proc-v7-bugs.c:(.text+0x82): undefined reference to `spectre_v2_update_state'
      
      Fixes: b9baf5c8c5c3 ("ARM: Spectre-BHB workaround")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Cc: Russell King <rmk+kernel@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: patches@armlinux.org.uk
      Acked-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64147ce8
    • Mike Kravetz's avatar
      selftests/memfd: clean up mapping in mfd_fail_write · 5c237251
      Mike Kravetz authored
      [ Upstream commit fda153c89af344d21df281009a9d046cf587ea0f ]
      
      Running the memfd script ./run_hugetlbfs_test.sh will often end in error
      as follows:
      
          memfd-hugetlb: CREATE
          memfd-hugetlb: BASIC
          memfd-hugetlb: SEAL-WRITE
          memfd-hugetlb: SEAL-FUTURE-WRITE
          memfd-hugetlb: SEAL-SHRINK
          fallocate(ALLOC) failed: No space left on device
          ./run_hugetlbfs_test.sh: line 60: 166855 Aborted                 (core dumped) ./memfd_test hugetlbfs
          opening: ./mnt/memfd
          fuse: DONE
      
      If no hugetlb pages have been preallocated, run_hugetlbfs_test.sh will
      allocate 'just enough' pages to run the test.  In the SEAL-FUTURE-WRITE
      test the mfd_fail_write routine maps the file, but does not unmap.  As a
      result, two hugetlb pages remain reserved for the mapping.  When the
      fallocate call in the SEAL-SHRINK test attempts allocate all hugetlb
      pages, it is short by the two reserved pages.
      
      Fix by making sure to unmap in mfd_fail_write.
      
      Link: https://lkml.kernel.org/r/20220219004340.56478-1-mike.kravetz@oracle.com
      
      
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: Joel Fernandes <joel@joelfernandes.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5c237251
    • Aneesh Kumar K.V's avatar
      selftest/vm: fix map_fixed_noreplace test failure · e22807ee
      Aneesh Kumar K.V authored
      [ Upstream commit f39c58008dee7ab5fc94c3f1995a21e886801df0 ]
      
      On the latest RHEL the test fails due to executable mapped at 256MB
      address
      
           # ./map_fixed_noreplace
          mmap() @ 0x10000000-0x10050000 p=0xffffffffffffffff result=File exists
          10000000-10010000 r-xp 00000000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10010000-10020000 r--p 00000000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10020000-10030000 rw-p 00010000 fd:04 34905657                           /root/rpmbuild/BUILD/kernel-5.14.0-56.el9/linux-5.14.0-56.el9.ppc64le/tools/testing/selftests/vm/map_fixed_noreplace
          10029b90000-10029bc0000 rw-p 00000000 00:00 0                            [heap]
          7fffbb510000-7fffbb750000 r-xp 00000000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb750000-7fffbb760000 r--p 00230000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb760000-7fffbb770000 rw-p 00240000 fd:04 24534                      /usr/lib64/libc.so.6
          7fffbb780000-7fffbb7a0000 r--p 00000000 00:00 0                          [vvar]
          7fffbb7a0000-7fffbb7b0000 r-xp 00000000 00:00 0                          [vdso]
          7fffbb7b0000-7fffbb800000 r-xp 00000000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffbb800000-7fffbb810000 r--p 00040000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffbb810000-7fffbb820000 rw-p 00050000 fd:04 24514                      /usr/lib64/ld64.so.2
          7fffd93f0000-7fffd9420000 rw-p 00000000 00:00 0                          [stack]
          Error: couldn't map the space we need for the test
      
      Fix this by finding a free address using mmap instead of hardcoding
      BASE_ADDRESS.
      
      Link: https://lkml.kernel.org/r/20220217083417.373823-1-aneesh.kumar@linux.ibm.com
      
      
      Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Jann Horn <jannh@google.com>
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e22807ee
    • Daniel Bristot de Oliveira's avatar
      tracing/osnoise: Make osnoise_main to sleep for microseconds · 9d95b7e2
      Daniel Bristot de Oliveira authored
      [ Upstream commit dd990352f01ee9a6c6eee152e5d11c021caccfe4 ]
      
      osnoise's runtime and period are in the microseconds scale, but it is
      currently sleeping in the millisecond's scale. This behavior roots in the
      usage of hwlat as the skeleton for osnoise.
      
      Make osnoise to sleep in the microseconds scale. Also, move the sleep to
      a specialized function.
      
      Link: https://lkml.kernel.org/r/302aa6c7bdf2d131719b22901905e9da122a11b2.1645197336.git.bristot@kernel.org
      
      
      
      Cc: Ingo Molnar <mingo@redhat.com>
      Signed-off-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d95b7e2
    • Sven Schnelle's avatar
      tracing: Ensure trace buffer is at least 4096 bytes large · 4d288969
      Sven Schnelle authored
      [ Upstream commit 7acf3a127bb7c65ff39099afd78960e77b2ca5de ]
      
      Booting the kernel with 'trace_buf_size=1' give a warning at
      boot during the ftrace selftests:
      
      [    0.892809] Running postponed tracer tests:
      [    0.892893] Testing tracer function:
      [    0.901899] Callback from call_rcu_tasks_trace() invoked.
      [    0.983829] Callback from call_rcu_tasks_rude() invoked.
      [    1.072003] .. bad ring buffer .. corrupted trace buffer ..
      [    1.091944] Callback from call_rcu_tasks() invoked.
      [    1.097695] PASSED
      [    1.097701] Testing dynamic ftrace: .. filter failed count=0 ..FAILED!
      [    1.353474] ------------[ cut here ]------------
      [    1.353478] WARNING: CPU: 0 PID: 1 at kernel/trace/trace.c:1951 run_tracer_selftest+0x13c/0x1b0
      
      Therefore enforce a minimum of 4096 bytes to make the selftest pass.
      
      Link: https://lkml.kernel.org/r/20220214134456.1751749-1-svens@linux.ibm.com
      
      
      
      Signed-off-by: default avatarSven Schnelle <svens@linux.ibm.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4d288969
    • Niels Dossche's avatar
      ipv6: prevent a possible race condition with lifetimes · 041616a2
      Niels Dossche authored
      
      [ Upstream commit 6c0d8833a605e195ae219b5042577ce52bf71fff ]
      
      valid_lft, prefered_lft and tstamp are always accessed under the lock
      "lock" in other places. Reading these without taking the lock may result
      in inconsistencies regarding the calculation of the valid and preferred
      variables since decisions are taken on these fields for those variables.
      
      Signed-off-by: default avatarNiels Dossche <dossche.niels@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarNiels Dossche <niels.dossche@ugent.be>
      Link: https://lore.kernel.org/r/20220223131954.6570-1-niels.dossche@ugent.be
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      041616a2
    • Marek Marczykowski-Górecki's avatar
      Revert "xen-netback: Check for hotplug-status existence before watching" · 2708ceb4
      Marek Marczykowski-Górecki authored
      [ Upstream commit e8240addd0a3919e0fd7436416afe9aa6429c484 ]
      
      This reverts commit 2afeec08.
      
      The reasoning in the commit was wrong - the code expected to setup the
      watch even if 'hotplug-status' didn't exist. In fact, it relied on the
      watch being fired the first time - to check if maybe 'hotplug-status' is
      already set to 'connected'. Not registering a watch for non-existing
      path (which is the case if hotplug script hasn't been executed yet),
      made the backend not waiting for the hotplug script to execute. This in
      turns, made the netfront think the interface is fully operational, while
      in fact it was not (the vif interface on xen-netback side might not be
      configured yet).
      
      This was a workaround for 'hotplug-status' erroneously being removed.
      But since that is reverted now, the workaround is not necessary either.
      
      More discussion at
      https://lore.kernel.org/xen-devel/afedd7cb-a291-e773-8b0d-4db9b291fa98@ipxe.org/T/#u
      
      
      
      Signed-off-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Reviewed-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      Link: https://lore.kernel.org/r/20220222001817.2264967-2-marmarek@invisiblethingslab.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2708ceb4
    • Marek Marczykowski-Górecki's avatar
      Revert "xen-netback: remove 'hotplug-status' once it has served its purpose" · fe39ab30
      Marek Marczykowski-Górecki authored
      [ Upstream commit 0f4558ae91870692ce7f509c31c9d6ee721d8cdc ]
      
      This reverts commit 1f256578.
      
      The 'hotplug-status' node should not be removed as long as the vif
      device remains configured. Otherwise the xen-netback would wait for
      re-running the network script even if it was already called (in case of
      the frontent re-connecting). But also, it _should_ be removed when the
      vif device is destroyed (for example when unbinding the driver) -
      otherwise hotplug script would not configure the device whenever it
      re-appear.
      
      Moving removal of the 'hotplug-status' node was a workaround for nothing
      calling network script after xen-netback module is reloaded. But when
      vif interface is re-created (on xen-netback unbind/bind for example),
      the script should be called, regardless of who does that - currently
      this case is not handled by the toolstack, and requires manual
      script call. Keeping hotplug-status=connected to skip the call is wrong
      and leads to not configured interface.
      
      More discussion at
      https://lore.kernel.org/xen-devel/afedd7cb-a291-e773-8b0d-4db9b291fa98@ipxe.org/T/#u
      
      
      
      Signed-off-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Link: https://lore.kernel.org/r/20220222001817.2264967-1-marmarek@invisiblethingslab.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe39ab30
    • Guchun Chen's avatar
      drm/amdgpu: bypass tiling flag check in virtual display case (v2) · fcd1d79a
      Guchun Chen authored
      
      [ Upstream commit e2b993302f40c4eb714ecf896dd9e1c5be7d4cd7 ]
      
      vkms leverages common amdgpu framebuffer creation, and
      also as it does not support FB modifier, there is no need
      to check tiling flags when initing framebuffer when virtual
      display is enabled.
      
      This can fix below calltrace:
      
      amdgpu 0000:00:08.0: GFX9+ requires FB check based on format modifier
      WARNING: CPU: 0 PID: 1023 at drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:1150 amdgpu_display_framebuffer_init+0x8e7/0xb40 [amdgpu]
      
      v2: check adev->enable_virtual_display instead as vkms can be
      	enabled in bare metal as well.
      
      Signed-off-by: default avatarLeslie Shi <Yuliang.Shi@amd.com>
      Signed-off-by: default avatarGuchun Chen <guchun.chen@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fcd1d79a
    • Shreeya Patel's avatar
      gpio: Return EPROBE_DEFER if gc->to_irq is NULL · 5cf4dd01
      Shreeya Patel authored
      [ Upstream commit ae42f9288846353982e2eab181fb41e7fd8bf60f ]
      
      We are racing the registering of .to_irq when probing the
      i2c driver. This results in random failure of touchscreen
      devices.
      
      Following explains the race condition better.
      
      [gpio driver] gpio driver registers gpio chip
      [gpio consumer] gpio is acquired
      [gpio consumer] gpiod_to_irq() fails with -ENXIO
      [gpio driver] gpio driver registers irqchip
      gpiod_to_irq works at this point, but -ENXIO is fatal
      
      We could see the following errors in dmesg logs when gc->to_irq is NULL
      
      [2.101857] i2c_hid i2c-FTS3528:00: HID over i2c has not been provided an Int IRQ
      [2.101953] i2c_hid: probe of i2c-FTS3528:00 failed with error -22
      
      To avoid this situation, defer probing until to_irq is registered.
      Returning -EPROBE_DEFER would be the first step towards avoiding
      the failure of devices due to the race in registration of .to_irq.
      Final solution to this issue would be to avoid using gc irq members
      until they are fully initialized.
      
      This issue has been reported many times in past and people have been
      using workarounds like changing the pinctrl_amd to built-in instead
      of loading it as a module or by adding a softdep for pinctrl_amd into
      the config file.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209413
      
      
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarShreeya Patel <shreeya.patel@collabora.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5cf4dd01
    • Alex Deucher's avatar
      PCI: Mark all AMD Navi10 and Navi14 GPU ATS as broken · 94b568a9
      Alex Deucher authored
      [ Upstream commit 3f1271b54edcc692da5a3663f2aa2a64781f9bc3 ]
      
      There are enough VBIOS escapes without the proper workaround that some
      users still hit this.  Microsoft never productized ATS on Windows so OEM
      platforms that were Windows-only didn't always validate ATS.
      
      The advantages of ATS are not worth it compared to the potential
      instabilities on harvested boards.  Disable ATS on all Navi10 and Navi14
      boards.
      
      Symptoms include:
      
        amdgpu 0000:07:00.0: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0007 address=0xffffc02000 flags=0x0000]
        AMD-Vi: Event logged [IO_PAGE_FAULT device=07:00.0 domain=0x0007 address=0xffffc02000 flags=0x0000]
        [drm:amdgpu_job_timedout [amdgpu]] *ERROR* ring sdma0 timeout, signaled seq=6047, emitted seq=6049
        amdgpu 0000:07:00.0: amdgpu: GPU reset begin!
        amdgpu 0000:07:00.0: amdgpu: GPU reset succeeded, trying to resume
        amdgpu 0000:07:00.0: [drm:amdgpu_ring_test_helper [amdgpu]] *ERROR* ring sdma0 test failed (-110)
        [drm:amdgpu_device_ip_resume_phase2 [amdgpu]] *ERROR* resume of IP block <sdma_v4_0> failed -110
        amdgpu 0000:07:00.0: amdgpu: GPU reset(1) failed
      
      Related commits:
      
        e8946a53 ("PCI: Mark AMD Navi14 GPU ATS as broken")
        a2da5d8c ("PCI: Mark AMD Raven iGPU ATS as broken in some platforms")
        45beb31d ("PCI: Mark AMD Navi10 GPU rev 0x00 ATS as broken")
        5e89cd30 ("PCI: Mark AMD Navi14 GPU rev 0xc5 ATS as broken")
        d28ca864 ("PCI: Mark AMD Stoney Radeon R7 GPU ATS as broken")
        9b44b0b0 ("PCI: Mark AMD Stoney GPU ATS as broken")
      
      [bhelgaas: add symptoms and related commits]
      Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1760
      Link: https://lore.kernel.org/r/20220222160801.841643-1-alexander.deucher@amd.com
      
      
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Acked-by: default avatarGuchun Chen <guchun.chen@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      94b568a9
    • Vikash Chandola's avatar
      hwmon: (pmbus) Clear pmbus fault/warning bits after read · bb9795b6
      Vikash Chandola authored
      
      [ Upstream commit 35f165f08950a876f1b95a61d79c93678fba2fd6 ]
      
      Almost all fault/warning bits in pmbus status registers remain set even
      after fault/warning condition are removed. As per pmbus specification
      these faults must be cleared by user.
      Modify hwmon behavior to clear fault/warning bit after fetching data if
      fault/warning bit was set. This allows to get fresh data in next read.
      
      Signed-off-by: default avatarVikash Chandola <vikash.chandola@linux.intel.com>
      Link: https://lore.kernel.org/r/20220222131253.2426834-1-vikash.chandola@linux.intel.com
      
      
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb9795b6
    • suresh kumar's avatar
      net-sysfs: add check for netdevice being present to speed_show · 8d5e69d8
      suresh kumar authored
      
      [ Upstream commit 4224cfd7fb6523f7a9d1c8bb91bb5df1e38eb624 ]
      
      When bringing down the netdevice or system shutdown, a panic can be
      triggered while accessing the sysfs path because the device is already
      removed.
      
          [  755.549084] mlx5_core 0000:12:00.1: Shutdown was called
          [  756.404455] mlx5_core 0000:12:00.0: Shutdown was called
          ...
          [  757.937260] BUG: unable to handle kernel NULL pointer dereference at           (null)
          [  758.031397] IP: [<ffffffff8ee11acb>] dma_pool_alloc+0x1ab/0x280
      
          crash> bt
          ...
          PID: 12649  TASK: ffff8924108f2100  CPU: 1   COMMAND: "amsd"
          ...
           #9 [ffff89240e1a38b0] page_fault at ffffffff8f38c778
              [exception RIP: dma_pool_alloc+0x1ab]
              RIP: ffffffff8ee11acb  RSP: ffff89240e1a3968  RFLAGS: 00010046
              RAX: 0000000000000246  RBX: ffff89243d874100  RCX: 0000000000001000
              RDX: 0000000000000000  RSI: 0000000000000246  RDI: ffff89243d874090
              RBP: ffff89240e1a39c0   R8: 000000000001f080   R9: ffff8905ffc03c00
              R10: ffffffffc04680d4  R11: ffffffff8edde9fd  R12: 00000000000080d0
              R13: ffff89243d874090  R14: ffff89243d874080  R15: 0000000000000000
              ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
          #10 [ffff89240e1a39c8] mlx5_alloc_cmd_msg at ffffffffc04680f3 [mlx5_core]
          #11 [ffff89240e1a3a18] cmd_exec at ffffffffc046ad62 [mlx5_core]
          #12 [ffff89240e1a3ab8] mlx5_cmd_exec at ffffffffc046b4fb [mlx5_core]
          #13 [ffff89240e1a3ae8] mlx5_core_access_reg at ffffffffc0475434 [mlx5_core]
          #14 [ffff89240e1a3b40] mlx5e_get_fec_caps at ffffffffc04a7348 [mlx5_core]
          #15 [ffff89240e1a3bb0] get_fec_supported_advertised at ffffffffc04992bf [mlx5_core]
          #16 [ffff89240e1a3c08] mlx5e_get_link_ksettings at ffffffffc049ab36 [mlx5_core]
          #17 [ffff89240e1a3ce8] __ethtool_get_link_ksettings at ffffffff8f25db46
          #18 [ffff89240e1a3d48] speed_show at ffffffff8f277208
          #19 [ffff89240e1a3dd8] dev_attr_show at ffffffff8f0b70e3
          #20 [ffff89240e1a3df8] sysfs_kf_seq_show at ffffffff8eedbedf
          #21 [ffff89240e1a3e18] kernfs_seq_show at ffffffff8eeda596
          #22 [ffff89240e1a3e28] seq_read at ffffffff8ee76d10
          #23 [ffff89240e1a3e98] kernfs_fop_read at ffffffff8eedaef5
          #24 [ffff89240e1a3ed8] vfs_read at ffffffff8ee4e3ff
          #25 [ffff89240e1a3f08] sys_read at ffffffff8ee4f27f
          #26 [ffff89240e1a3f50] system_call_fastpath at ffffffff8f395f92
      
          crash> net_device.state ffff89443b0c0000
            state = 0x5  (__LINK_STATE_START| __LINK_STATE_NOCARRIER)
      
      To prevent this scenario, we also make sure that the netdevice is present.
      
      Signed-off-by: default avatarsuresh kumar <suresh2514@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8d5e69d8
    • Wanpeng Li's avatar
      x86/kvm: Don't use pv tlb/ipi/sched_yield if on 1 vCPU · 1280c8ae
      Wanpeng Li authored
      
      [ Upstream commit ec756e40e271866f951d77c5e923d8deb6002b15 ]
      
      Inspired by commit 3553ae56 (x86/kvm: Don't use pvqspinlock code if
      only 1 vCPU), on a VM with only 1 vCPU, there is no need to enable
      pv tlb/ipi/sched_yield and we can save the memory for __pv_cpu_mask.
      
      Signed-off-by: default avatarWanpeng Li <wanpengli@tencent.com>
      Message-Id: <1645171838-2855-1-git-send-email-wanpengli@tencent.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1280c8ae
    • Maxime Ripard's avatar
      drm/vc4: hdmi: Unregister codec device on unbind · ee22082c
      Maxime Ripard authored
      
      [ Upstream commit e40945ab7c7f966d0c37b7bd7b0596497dfe228d ]
      
      On bind we will register the HDMI codec device but we don't unregister
      it on unbind, leading to a device leakage. Unregister our device at
      unbind.
      
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220127111452.222002-1-maxime@cerno.tech
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee22082c
    • Jon Lin's avatar
      spi: rockchip: terminate dma transmission when slave abort · 5bef4e50
      Jon Lin authored
      
      [ Upstream commit 80808768e41324d2e23de89972b5406c1020e6e4 ]
      
      After slave abort, all DMA should be stopped, or it will affect the
      next transmission and maybe abort again.
      
      Signed-off-by: default avatarJon Lin <jon.lin@rock-chips.com>
      Link: https://lore.kernel.org/r/20220216014028.8123-3-jon.lin@rock-chips.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5bef4e50
    • Jon Lin's avatar
      spi: rockchip: Fix error in getting num-cs property · 1f04bbd2
      Jon Lin authored
      
      [ Upstream commit 9382df0a98aad5bbcd4d634790305a1d786ad224 ]
      
      Get num-cs u32 from dts of_node property rather than u16.
      
      Signed-off-by: default avatarJon Lin <jon.lin@rock-chips.com>
      Link: https://lore.kernel.org/r/20220216014028.8123-2-jon.lin@rock-chips.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1f04bbd2
    • Anton Romanov's avatar
      kvm: x86: Disable KVM_HC_CLOCK_PAIRING if tsc is in always catchup mode · bcd4279b
      Anton Romanov authored
      
      [ Upstream commit 3a55f729240a686aa8af00af436306c0cd532522 ]
      
      If vcpu has tsc_always_catchup set each request updates pvclock data.
      KVM_HC_CLOCK_PAIRING consumers such as ptp_kvm_x86 rely on tsc read on
      host's side and do hypercall inside pvclock_read_retry loop leading to
      infinite loop in such situation.
      
      v3:
          Removed warn
          Changed return code to KVM_EFAULT
      v2:
          Added warn
      
      Signed-off-by: default avatarAnton Romanov <romanton@google.com>
      Message-Id: <20220216182653.506850-1-romanton@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bcd4279b
    • Wanpeng Li's avatar
      KVM: Fix lockdep false negative during host resume · e160ee96
      Wanpeng Li authored
      
      [ Upstream commit 4cb9a998b1ce25fad74a82f5a5c45a4ef40de337 ]
      
      I saw the below splatting after the host suspended and resumed.
      
         WARNING: CPU: 0 PID: 2943 at kvm/arch/x86/kvm/../../../virt/kvm/kvm_main.c:5531 kvm_resume+0x2c/0x30 [kvm]
         CPU: 0 PID: 2943 Comm: step_after_susp Tainted: G        W IOE     5.17.0-rc3+ #4
         RIP: 0010:kvm_resume+0x2c/0x30 [kvm]
         Call Trace:
          <TASK>
          syscore_resume+0x90/0x340
          suspend_devices_and_enter+0xaee/0xe90
          pm_suspend.cold+0x36b/0x3c2
          state_store+0x82/0xf0
          kernfs_fop_write_iter+0x1b6/0x260
          new_sync_write+0x258/0x370
          vfs_write+0x33f/0x510
          ksys_write+0xc9/0x160
          do_syscall_64+0x3b/0xc0
          entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      lockdep_is_held() can return -1 when lockdep is disabled which triggers
      this warning. Let's use lockdep_assert_not_held() which can detect
      incorrect calls while holding a lock and it also avoids false negatives
      when lockdep is disabled.
      
      Signed-off-by: default avatarWanpeng Li <wanpengli@tencent.com>
      Message-Id: <1644920142-81249-1-git-send-email-wanpengli@tencent.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e160ee96
    • Andy Shevchenko's avatar
      pinctrl: tigerlake: Revert "Add Alder Lake-M ACPI ID" · 302ce294
      Andy Shevchenko authored
      
      [ Upstream commit 6f66db29e2415cbe8759c48584f9cae19b3c2651 ]
      
      It appears that last minute change moved ACPI ID of Alder Lake-M
      to the INTC1055, which is already in the driver.
      
      This ID on the other hand will be used elsewhere.
      
      This reverts commit 258435a1.
      
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      302ce294
    • Heikki Krogerus's avatar
      usb: dwc3: pci: add support for the Intel Raptor Lake-S · 839ddf78
      Heikki Krogerus authored
      
      [ Upstream commit 038438a25c45d5ac996e95a22fa9e76ff3d1f8c7 ]
      
      This patch adds the necessary PCI ID for Intel Raptor Lake-S
      devices.
      
      Signed-off-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Link: https://lore.kernel.org/r/20220214141948.18637-1-heikki.krogerus@linux.intel.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      839ddf78
    • Halil Pasic's avatar
      swiotlb: fix info leak with DMA_FROM_DEVICE · 7403f411
      Halil Pasic authored
      
      [ Upstream commit ddbd89deb7d32b1fbb879f48d68fda1a8ac58e8e ]
      
      The problem I'm addressing was discovered by the LTP test covering
      cve-2018-1000204.
      
      A short description of what happens follows:
      1) The test case issues a command code 00 (TEST UNIT READY) via the SG_IO
         interface with: dxfer_len == 524288, dxdfer_dir == SG_DXFER_FROM_DEV
         and a corresponding dxferp. The peculiar thing about this is that TUR
         is not reading from the device.
      2) In sg_start_req() the invocation of blk_rq_map_user() effectively
         bounces the user-space buffer. As if the device was to transfer into
         it. Since commit a45b599a ("scsi: sg: allocate with __GFP_ZERO in
         sg_build_indirect()") we make sure this first bounce buffer is
         allocated with GFP_ZERO.
      3) For the rest of the story we keep ignoring that we have a TUR, so the
         device won't touch the buffer we prepare as if the we had a
         DMA_FROM_DEVICE type of situation. My setup uses a virtio-scsi device
         and the  buffer allocated by SG is mapped by the function
         virtqueue_add_split() which uses DMA_FROM_DEVICE for the "in" sgs (here
         scatter-gather and not scsi generics). This mapping involves bouncing
         via the swiotlb (we need swiotlb to do virtio in protected guest like
         s390 Secure Execution, or AMD SEV).
      4) When the SCSI TUR is done, we first copy back the content of the second
         (that is swiotlb) bounce buffer (which most likely contains some
         previous IO data), to the first bounce buffer, which contains all
         zeros.  Then we copy back the content of the first bounce buffer to
         the user-space buffer.
      5) The test case detects that the buffer, which it zero-initialized,
        ain't all zeros and fails.
      
      One can argue that this is an swiotlb problem, because without swiotlb
      we leak all zeros, and the swiotlb should be transparent in a sense that
      it does not affect the outcome (if all other participants are well
      behaved).
      
      Copying the content of the original buffer into the swiotlb buffer is
      the only way I can think of to make swiotlb transparent in such
      scenarios. So let's do just that if in doubt, but allow the driver
      to tell us that the whole mapped buffer is going to be overwritten,
      in which case we can preserve the old behavior and avoid the performance
      impact of the extra bounce.
      
      Signed-off-by: default avatarHalil Pasic <pasic@linux.ibm.com>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7403f411
    • Kumar Kartikeya Dwivedi's avatar
      selftests/bpf: Add test for bpf_timer overwriting crash · b0028e1c
      Kumar Kartikeya Dwivedi authored
      
      [ Upstream commit a7e75016a0753c24d6c995bc02501ae35368e333 ]
      
      Add a test that validates that timer value is not overwritten when doing
      a copy_map_value call in the kernel. Without the prior fix, this test
      triggers a crash.
      
      Signed-off-by: default avatarKumar Kartikeya Dwivedi <memxor@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20220209070324.1093182-3-memxor@gmail.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0028e1c
    • Heiner Kallweit's avatar
      net: phy: meson-gxl: improve link-up behavior · 732c7172
      Heiner Kallweit authored
      
      [ Upstream commit 2c87c6f9fbddc5b84d67b2fa3f432fcac6d99d93 ]
      
      Sometimes the link comes up but no data flows. This patch fixes
      this behavior. It's not clear what's the root cause of the issue.
      
      According to the tests one other link-up issue remains.
      In very rare cases the link isn't even reported as up.
      
      Fixes: 84c8f773 ("net: phy: meson-gxl: remove the use of .ack_callback()")
      Tested-by: default avatarErico Nunes <nunes.erico@gmail.com>
      Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Link: https://lore.kernel.org/r/e3473452-a1f9-efcf-5fdd-02b6f44c3fcd@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      732c7172
    • Jeremy Linton's avatar
      net: bcmgenet: Don't claim WOL when its not available · 6c0d2f34
      Jeremy Linton authored
      
      [ Upstream commit 00b022f8f876a3a036b0df7f971001bef6398605 ]
      
      Some of the bcmgenet platforms don't correctly support WOL, yet
      ethtool returns:
      
      "Supports Wake-on: gsf"
      
      which is false.
      
      Ideally if there isn't a wol_irq, or there is something else that
      keeps the device from being able to wakeup it should display:
      
      "Supports Wake-on: d"
      
      This patch checks whether the device can wakup, before using the
      hard-coded supported flags. This corrects the ethtool reporting, as
      well as the WOL configuration because ethtool verifies that the mode
      is supported before attempting it.
      
      Fixes: c51de7f3 ("net: bcmgenet: add Wake-on-LAN support code")
      Signed-off-by: default avatarJeremy Linton <jeremy.linton@arm.com>
      Tested-by: default avatarPeter Robinson <pbrobinson@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220310045535.224450-1-jeremy.linton@arm.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6c0d2f34
    • Eric Dumazet's avatar
      sctp: fix kernel-infoleak for SCTP sockets · 1502f15b
      Eric Dumazet authored
      
      [ Upstream commit 633593a808980f82d251d0ca89730d8bb8b0220c ]
      
      syzbot reported a kernel infoleak [1] of 4 bytes.
      
      After analysis, it turned out r->idiag_expires is not initialized
      if inet_sctp_diag_fill() calls inet_diag_msg_common_fill()
      
      Make sure to clear idiag_timer/idiag_retrans/idiag_expires
      and let inet_diag_msg_sctpasoc_fill() fill them again if needed.
      
      [1]
      
      BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:121 [inline]
      BUG: KMSAN: kernel-infoleak in copyout lib/iov_iter.c:154 [inline]
      BUG: KMSAN: kernel-infoleak in _copy_to_iter+0x6ef/0x25a0 lib/iov_iter.c:668
       instrument_copy_to_user include/linux/instrumented.h:121 [inline]
       copyout lib/iov_iter.c:154 [inline]
       _copy_to_iter+0x6ef/0x25a0 lib/iov_iter.c:668
       copy_to_iter include/linux/uio.h:162 [inline]
       simple_copy_to_iter+0xf3/0x140 net/core/datagram.c:519
       __skb_datagram_iter+0x2d5/0x11b0 net/core/datagram.c:425
       skb_copy_datagram_iter+0xdc/0x270 net/core/datagram.c:533
       skb_copy_datagram_msg include/linux/skbuff.h:3696 [inline]
       netlink_recvmsg+0x669/0x1c80 net/netlink/af_netlink.c:1977
       sock_recvmsg_nosec net/socket.c:948 [inline]
       sock_recvmsg net/socket.c:966 [inline]
       __sys_recvfrom+0x795/0xa10 net/socket.c:2097
       __do_sys_recvfrom net/socket.c:2115 [inline]
       __se_sys_recvfrom net/socket.c:2111 [inline]
       __x64_sys_recvfrom+0x19d/0x210 net/socket.c:2111
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Uninit was created at:
       slab_post_alloc_hook mm/slab.h:737 [inline]
       slab_alloc_node mm/slub.c:3247 [inline]
       __kmalloc_node_track_caller+0xe0c/0x1510 mm/slub.c:4975
       kmalloc_reserve net/core/skbuff.c:354 [inline]
       __alloc_skb+0x545/0xf90 net/core/skbuff.c:426
       alloc_skb include/linux/skbuff.h:1158 [inline]
       netlink_dump+0x3e5/0x16c0 net/netlink/af_netlink.c:2248
       __netlink_dump_start+0xcf8/0xe90 net/netlink/af_netlink.c:2373
       netlink_dump_start include/linux/netlink.h:254 [inline]
       inet_diag_handler_cmd+0x2e7/0x400 net/ipv4/inet_diag.c:1341
       sock_diag_rcv_msg+0x24a/0x620
       netlink_rcv_skb+0x40c/0x7e0 net/netlink/af_netlink.c:2494
       sock_diag_rcv+0x63/0x80 net/core/sock_diag.c:277
       netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
       netlink_unicast+0x1093/0x1360 net/netlink/af_netlink.c:1343
       netlink_sendmsg+0x14d9/0x1720 net/netlink/af_netlink.c:1919
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       sock_write_iter+0x594/0x690 net/socket.c:1061
       do_iter_readv_writev+0xa7f/0xc70
       do_iter_write+0x52c/0x1500 fs/read_write.c:851
       vfs_writev fs/read_write.c:924 [inline]
       do_writev+0x645/0xe00 fs/read_write.c:967
       __do_sys_writev fs/read_write.c:1040 [inline]
       __se_sys_writev fs/read_write.c:1037 [inline]
       __x64_sys_writev+0xe5/0x120 fs/read_write.c:1037
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:82
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Bytes 68-71 of 2508 are uninitialized
      Memory access of size 2508 starts at ffff888114f9b000
      Data copied to user address 00007f7fe09ff2e0
      
      CPU: 1 PID: 3478 Comm: syz-executor306 Not tainted 5.17.0-rc4-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 8f840e47 ("sctp: add the sctp_diag.c file")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Vlad Yasevich <vyasevich@gmail.com>
      Cc: Neil Horman <nhorman@tuxdriver.com>
      Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Reviewed-by: default avatarXin Long <lucien.xin@gmail.com>
      Link: https://lore.kernel.org/r/20220310001145.297371-1-eric.dumazet@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1502f15b
    • Clément Léger's avatar
      net: phy: DP83822: clear MISR2 register to disable interrupts · 9ca50a73
      Clément Léger authored
      
      [ Upstream commit 37c9d66c95564c85a001d8a035354f0220a1e1c3 ]
      
      MISR1 was cleared twice but the original author intention was probably
      to clear MISR1 & MISR2 to completely disable interrupts. Fix it to
      clear MISR2.
      
      Fixes: 87461f7a ("net: phy: DP83822 initial driver submission")
      Signed-off-by: default avatarClément Léger <clement.leger@bootlin.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220309142228.761153-1-clement.leger@bootlin.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ca50a73
    • Miaoqian Lin's avatar
      gianfar: ethtool: Fix refcount leak in gfar_get_ts_info · f49f646f
      Miaoqian Lin authored
      
      [ Upstream commit 2ac5b58e645c66932438bb021cb5b52097ce70b0 ]
      
      The of_find_compatible_node() function returns a node pointer with
      refcount incremented, We should use of_node_put() on it when done
      Add the missing of_node_put() to release the refcount.
      
      Fixes: 7349a74e ("net: ethernet: gianfar_ethtool: get phc index through drvdata")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarClaudiu Manoil <claudiu.manoil@nxp.com>
      Link: https://lore.kernel.org/r/20220310015313.14938-1-linmq006@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f49f646f
    • Mark Featherston's avatar
      gpio: ts4900: Do not set DAT and OE together · c7f6accc
      Mark Featherston authored
      
      [ Upstream commit 03fe003547975680fdb9ff5ab0e41cb68276c4f2 ]
      
      This works around an issue with the hardware where both OE and
      DAT are exposed in the same register. If both are updated
      simultaneously, the harware makes no guarantees that OE or DAT
      will actually change in any given order and may result in a
      glitch of a few ns on a GPIO pin when changing direction and value
      in a single write.
      
      Setting direction to input now only affects OE bit. Setting
      direction to output updates DAT first, then OE.
      
      Fixes: 9c668632 ("gpio: add Technologic I2C-FPGA gpio support")
      Signed-off-by: default avatarMark Featherston <mark@embeddedTS.com>
      Signed-off-by: default avatarKris Bahnsen <kris@embeddedTS.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c7f6accc
    • Guillaume Nault's avatar
      selftests: pmtu.sh: Kill nettest processes launched in subshell. · c614aad2
      Guillaume Nault authored
      
      [ Upstream commit 94a4a4fe4c696413932eed8bdec46574de9576b8 ]
      
      When using "run_cmd <command> &", then "$!" refers to the PID of the
      subshell used to run <command>, not the command itself. Therefore
      nettest_pids actually doesn't contain the list of the nettest commands
      running in the background. So cleanup() can't kill them and the nettest
      processes run until completion (fortunately they have a 5s timeout).
      
      Fix this by defining a new command for running processes in the
      background, for which "$!" really refers to the PID of the command run.
      
      Also, double quote variables on the modified lines, to avoid shellcheck
      warnings.
      
      Fixes: ece1278a ("selftests: net: add ESP-in-UDP PMTU test")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c614aad2
    • Guillaume Nault's avatar
      selftests: pmtu.sh: Kill tcpdump processes launched by subshell. · d4dfc94c
      Guillaume Nault authored
      
      [ Upstream commit 18dfc667550fe9c032a6dcc3402b50e691e18029 ]
      
      The cleanup() function takes care of killing processes launched by the
      test functions. It relies on variables like ${tcpdump_pids} to get the
      relevant PIDs. But tests are run in their own subshell, so updated
      *_pids values are invisible to other shells. Therefore cleanup() never
      sees any process to kill:
      
      $ ./tools/testing/selftests/net/pmtu.sh -t pmtu_ipv4_exception
      TEST: ipv4: PMTU exceptions                                         [ OK ]
      TEST: ipv4: PMTU exceptions - nexthop objects                       [ OK ]
      
      $ pgrep -af tcpdump
      6084 tcpdump -s 0 -i veth_A-R1 -w pmtu_ipv4_exception_veth_A-R1.pcap
      6085 tcpdump -s 0 -i veth_R1-A -w pmtu_ipv4_exception_veth_R1-A.pcap
      6086 tcpdump -s 0 -i veth_R1-B -w pmtu_ipv4_exception_veth_R1-B.pcap
      6087 tcpdump -s 0 -i veth_B-R1 -w pmtu_ipv4_exception_veth_B-R1.pcap
      6088 tcpdump -s 0 -i veth_A-R2 -w pmtu_ipv4_exception_veth_A-R2.pcap
      6089 tcpdump -s 0 -i veth_R2-A -w pmtu_ipv4_exception_veth_R2-A.pcap
      6090 tcpdump -s 0 -i veth_R2-B -w pmtu_ipv4_exception_veth_R2-B.pcap
      6091 tcpdump -s 0 -i veth_B-R2 -w pmtu_ipv4_exception_veth_B-R2.pcap
      6228 tcpdump -s 0 -i veth_A-R1 -w pmtu_ipv4_exception_veth_A-R1.pcap
      6229 tcpdump -s 0 -i veth_R1-A -w pmtu_ipv4_exception_veth_R1-A.pcap
      6230 tcpdump -s 0 -i veth_R1-B -w pmtu_ipv4_exception_veth_R1-B.pcap
      6231 tcpdump -s 0 -i veth_B-R1 -w pmtu_ipv4_exception_veth_B-R1.pcap
      6232 tcpdump -s 0 -i veth_A-R2 -w pmtu_ipv4_exception_veth_A-R2.pcap
      6233 tcpdump -s 0 -i veth_R2-A -w pmtu_ipv4_exception_veth_R2-A.pcap
      6234 tcpdump -s 0 -i veth_R2-B -w pmtu_ipv4_exception_veth_R2-B.pcap
      6235 tcpdump -s 0 -i veth_B-R2 -w pmtu_ipv4_exception_veth_B-R2.pcap
      
      Fix this by running cleanup() in the context of the test subshell.
      Now that each test cleans the environment after completion, there's no
      need for calling cleanup() again when the next test starts. So let's
      drop it from the setup() function. This is okay because cleanup() is
      also called when pmtu.sh starts, so even the first test starts in a
      clean environment.
      
      Also, use tcpdump's immediate mode. Otherwise it might not have time to
      process buffered packets, resulting in missing packets or even empty
      pcap files for short tests.
      
      Note: PAUSE_ON_FAIL is still evaluated before cleanup(), so one can
      still inspect the test environment upon failure when using -p.
      
      Fixes: a92a0a7b ("selftests: pmtu: Simplify cleanup and namespace names")
      Signed-off-by: default avatarGuillaume Nault <gnault@redhat.com>
      Reviewed-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d4dfc94c
    • Pavel Skripkin's avatar
      NFC: port100: fix use-after-free in port100_send_complete · 0e721b8f
      Pavel Skripkin authored
      
      [ Upstream commit f80cfe2f26581f188429c12bd937eb905ad3ac7b ]
      
      Syzbot reported UAF in port100_send_complete(). The root case is in
      missing usb_kill_urb() calls on error handling path of ->probe function.
      
      port100_send_complete() accesses devm allocated memory which will be
      freed on probe failure. We should kill this urbs before returning an
      error from probe function to prevent reported use-after-free
      
      Fail log:
      
      BUG: KASAN: use-after-free in port100_send_complete+0x16e/0x1a0 drivers/nfc/port100.c:935
      Read of size 1 at addr ffff88801bb59540 by task ksoftirqd/2/26
      ...
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       print_address_description.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255
       __kasan_report mm/kasan/report.c:442 [inline]
       kasan_report.cold+0x83/0xdf mm/kasan/report.c:459
       port100_send_complete+0x16e/0x1a0 drivers/nfc/port100.c:935
       __usb_hcd_giveback_urb+0x2b0/0x5c0 drivers/usb/core/hcd.c:1670
      
      ...
      
      Allocated by task 1255:
       kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
       kasan_set_track mm/kasan/common.c:45 [inline]
       set_alloc_info mm/kasan/common.c:436 [inline]
       ____kasan_kmalloc mm/kasan/common.c:515 [inline]
       ____kasan_kmalloc mm/kasan/common.c:474 [inline]
       __kasan_kmalloc+0xa6/0xd0 mm/kasan/common.c:524
       alloc_dr drivers/base/devres.c:116 [inline]
       devm_kmalloc+0x96/0x1d0 drivers/base/devres.c:823
       devm_kzalloc include/linux/device.h:209 [inline]
       port100_probe+0x8a/0x1320 drivers/nfc/port100.c:1502
      
      Freed by task 1255:
       kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
       kasan_set_track+0x21/0x30 mm/kasan/common.c:45
       kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
       ____kasan_slab_free mm/kasan/common.c:366 [inline]
       ____kasan_slab_free+0xff/0x140 mm/kasan/common.c:328
       kasan_slab_free include/linux/kasan.h:236 [inline]
       __cache_free mm/slab.c:3437 [inline]
       kfree+0xf8/0x2b0 mm/slab.c:3794
       release_nodes+0x112/0x1a0 drivers/base/devres.c:501
       devres_release_all+0x114/0x190 drivers/base/devres.c:530
       really_probe+0x626/0xcc0 drivers/base/dd.c:670
      
      Reported-and-tested-by: default avatar <syzbot+16bcb127fb73baeecb14@syzkaller.appspotmail.com>
      Fixes: 0347a6ab ("NFC: port100: Commands mechanism implementation")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Link: https://lore.kernel.org/r/20220308185007.6987-1-paskripkin@gmail.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0e721b8f
    • Roi Dayan's avatar
      net/mlx5e: Lag, Only handle events from highest priority multipath entry · a2355333
      Roi Dayan authored
      
      [ Upstream commit ad11c4f1d8fd1f03639460e425a36f7fd0ea83f5 ]
      
      There could be multiple multipath entries but changing the port affinity
      for each one doesn't make much sense and there should be a default one.
      So only track the entry with lowest priority value.
      The commit doesn't affect existing users with a single entry.
      
      Fixes: 544fe7c2 ("net/mlx5e: Activate HW multipath and handle port affinity based on FIB events")
      Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
      Reviewed-by: default avatarMaor Dickman <maord@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a2355333
    • Moshe Shemesh's avatar
      net/mlx5: Fix a race on command flush flow · 7c519f76
      Moshe Shemesh authored
      
      [ Upstream commit 063bd355595428750803d8736a9bb7c8db67d42d ]
      
      Fix a refcount use after free warning due to a race on command entry.
      Such race occurs when one of the commands releases its last refcount and
      frees its index and entry while another process running command flush
      flow takes refcount to this command entry. The process which handles
      commands flush may see this command as needed to be flushed if the other
      process released its refcount but didn't release the index yet. Fix it
      by adding the needed spin lock.
      
      It fixes the following warning trace:
      
      refcount_t: addition on 0; use-after-free.
      WARNING: CPU: 11 PID: 540311 at lib/refcount.c:25 refcount_warn_saturate+0x80/0xe0
      ...
      RIP: 0010:refcount_warn_saturate+0x80/0xe0
      ...
      Call Trace:
       <TASK>
       mlx5_cmd_trigger_completions+0x293/0x340 [mlx5_core]
       mlx5_cmd_flush+0x3a/0xf0 [mlx5_core]
       enter_error_state+0x44/0x80 [mlx5_core]
       mlx5_fw_fatal_reporter_err_work+0x37/0xe0 [mlx5_core]
       process_one_work+0x1be/0x390
       worker_thread+0x4d/0x3d0
       ? rescuer_thread+0x350/0x350
       kthread+0x141/0x160
       ? set_kthread_struct+0x40/0x40
       ret_from_fork+0x1f/0x30
       </TASK>
      
      Fixes: 50b2412b ("net/mlx5: Avoid possible free of command entry while timeout comp handler")
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarEran Ben Elisha <eranbe@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7c519f76
    • Mohammad Kabat's avatar
      net/mlx5: Fix size field in bufferx_reg struct · b3d4a7dc
      Mohammad Kabat authored
      
      [ Upstream commit ac77998b7ac3044f0509b097da9637184598980d ]
      
      According to HW spec the field "size" should be 16 bits
      in bufferx register.
      
      Fixes: e281682b ("net/mlx5_core: HW data structs/types definitions cleanup")
      Signed-off-by: default avatarMohammad Kabat <mohammadkab@nvidia.com>
      Reviewed-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b3d4a7dc
    • Duoming Zhou's avatar
      ax25: Fix NULL pointer dereference in ax25_kill_by_device · 46ad629e
      Duoming Zhou authored
      
      [ Upstream commit 71171ac8eb34ce7fe6b3267dce27c313ab3cb3ac ]
      
      When two ax25 devices attempted to establish connection, the requester use ax25_create(),
      ax25_bind() and ax25_connect() to initiate connection. The receiver use ax25_rcv() to
      accept connection and use ax25_create_cb() in ax25_rcv() to create ax25_cb, but the
      ax25_cb->sk is NULL. When the receiver is detaching, a NULL pointer dereference bug
      caused by sock_hold(sk) in ax25_kill_by_device() will happen. The corresponding
      fail log is shown below:
      
      ===============================================================
      BUG: KASAN: null-ptr-deref in ax25_device_event+0xfd/0x290
      Call Trace:
      ...
      ax25_device_event+0xfd/0x290
      raw_notifier_call_chain+0x5e/0x70
      dev_close_many+0x174/0x220
      unregister_netdevice_many+0x1f7/0xa60
      unregister_netdevice_queue+0x12f/0x170
      unregister_netdev+0x13/0x20
      mkiss_close+0xcd/0x140
      tty_ldisc_release+0xc0/0x220
      tty_release_struct+0x17/0xa0
      tty_release+0x62d/0x670
      ...
      
      This patch add condition check in ax25_kill_by_device(). If s->sk is
      NULL, it will goto if branch to kill device.
      
      Fixes: 4e0f718daf97 ("ax25: improve the incomplete fix to avoid UAF and NPD bugs")
      Reported-by: default avatarThomas Osterried <thomas@osterried.de>
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      46ad629e
    • Miaoqian Lin's avatar
      net: marvell: prestera: Add missing of_node_put() in prestera_switch_set_base_mac_addr · b7c2fd1d
      Miaoqian Lin authored
      
      [ Upstream commit c9ffa3e2bc451816ce0295e40063514fabf2bd36 ]
      
      This node pointer is returned by of_find_compatible_node() with
      refcount incremented. Calling of_node_put() to aovid the refcount leak.
      
      Fixes: 501ef306 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b7c2fd1d
Loading