Skip to content
  1. Jun 29, 2022
    • Kai-Heng Feng's avatar
      igb: Make DMA faster when CPU is active on the PCIe link · 8eb02236
      Kai-Heng Feng authored
      [ Upstream commit 4e0effd9 ]
      
      Intel I210 on some Intel Alder Lake platforms can only achieve ~750Mbps
      Tx speed via iperf. The RR2DCDELAY shows around 0x2xxx DMA delay, which
      will be significantly lower when 1) ASPM is disabled or 2) SoC package
      c-state stays above PC3. When the RR2DCDELAY is around 0x1xxx the Tx
      speed can reach to ~950Mbps.
      
      According to the I210 datasheet "8.26.1 PCIe Misc. Register - PCIEMISC",
      "DMA Idle Indication" doesn't seem to tie to DMA coalesce anymore, so
      set it to 1b for "DMA is considered idle when there is no Rx or Tx AND
      when there are no TLPs indicating that CPU is active detected on the
      PCIe link (such as the host executes CSR or Configuration register read
      or write operation)" and performing Tx should also fall under "active
      CPU on PCIe link" case.
      
      In addition to that, commit b6e0c419 ("igb: Move DMA Coalescing init
      code to separate function.") seems to wrongly changed from enabling
      E1000_PCIEMISC_LX_DECISION to disabling it, also fix that.
      
      Fixes: b6e0c419
      
       ("igb: Move DMA Coalescing init code to separate function.")
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Link: https://lore.kernel.org/r/20220621221056.604304-1-anthony.l.nguyen@intel.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8eb02236
    • Aidan MacDonald's avatar
      regmap-irq: Fix offset/index mismatch in read_sub_irq_data() · 60fd29f1
      Aidan MacDonald authored
      [ Upstream commit 3f05010f ]
      
      We need to divide the sub-irq status register offset by register
      stride to get an index for the status buffer to avoid an out of
      bounds write when the register stride is greater than 1.
      
      Fixes: a2d21848
      
       ("regmap: regmap-irq: Add main status register support")
      Signed-off-by: default avatarAidan MacDonald <aidanmacdonald.0x0@gmail.com>
      Link: https://lore.kernel.org/r/20220620200644.1961936-3-aidanmacdonald.0x0@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      60fd29f1
    • Aidan MacDonald's avatar
      regmap-irq: Fix a bug in regmap_irq_enable() for type_in_mask chips · b0581f93
      Aidan MacDonald authored
      [ Upstream commit 485037ae ]
      
      When enabling a type_in_mask irq, the type_buf contents must be
      AND'd with the mask of the IRQ we're enabling to avoid enabling
      other IRQs by accident, which can happen if several type_in_mask
      irqs share a mask register.
      
      Fixes: bc998a73
      
       ("regmap: irq: handle HW using separate rising/falling edge interrupts")
      Signed-off-by: default avatarAidan MacDonald <aidanmacdonald.0x0@gmail.com>
      Link: https://lore.kernel.org/r/20220620200644.1961936-2-aidanmacdonald.0x0@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0581f93
    • Anatolii Gerasymenko's avatar
      ice: ethtool: advertise 1000M speeds properly · 20229bb9
      Anatolii Gerasymenko authored
      [ Upstream commit c3d184c8 ]
      
      In current implementation ice_update_phy_type enables all link modes
      for selected speed. This approach doesn't work for 1000M speeds,
      because both copper (1000baseT) and optical (1000baseX) standards
      cannot be enabled at once.
      
      Fix this, by adding the function `ice_set_phy_type_from_speed()`
      for 1000M speeds.
      
      Fixes: 48cb27f2
      
       ("ice: Implement handlers for ethtool PHY/link operations")
      Signed-off-by: default avatarAnatolii Gerasymenko <anatolii.gerasymenko@intel.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20229bb9
    • David Howells's avatar
      afs: Fix dynamic root getattr · 2b2bba96
      David Howells authored
      [ Upstream commit cb78d1b5 ]
      
      The recent patch to make afs_getattr consult the server didn't account
      for the pseudo-inodes employed by the dynamic root-type afs superblock
      not having a volume or a server to access, and thus an oops occurs if
      such a directory is stat'd.
      
      Fix this by checking to see if the vnode->volume pointer actually points
      anywhere before following it in afs_getattr().
      
      This can be tested by stat'ing a directory in /afs.  It may be
      sufficient just to do "ls /afs" and the oops looks something like:
      
              BUG: kernel NULL pointer dereference, address: 0000000000000020
              ...
              RIP: 0010:afs_getattr+0x8b/0x14b
              ...
              Call Trace:
               <TASK>
               vfs_statx+0x79/0xf5
               vfs_fstatat+0x49/0x62
      
      Fixes: 2aeb8c86
      
       ("afs: Fix afs_getattr() to refetch file status if callback break occurred")
      Reported-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      Tested-by: default avatarMarc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/165408450783.1031787.7941404776393751186.stgit@warthog.procyon.org.uk/
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b2bba96
    • huhai's avatar
      MIPS: Remove repetitive increase irq_err_count · ab150a2b
      huhai authored
      [ Upstream commit c81aba8f ]
      
      commit 979934da ("[PATCH] mips: update IRQ handling for vr41xx") added
      a function irq_dispatch, and it'll increase irq_err_count when the get_irq
      callback returns a negative value, but increase irq_err_count in get_irq
      was not removed.
      
      And also, modpost complains once gpio-vr41xx drivers become modules.
        ERROR: modpost: "irq_err_count" [drivers/gpio/gpio-vr41xx.ko] undefined!
      
      So it would be a good idea to remove repetitive increase irq_err_count in
      get_irq callback.
      
      Fixes: 27fdd325 ("MIPS: Update VR41xx GPIO driver to use gpiolib")
      Fixes: 979934da
      
       ("[PATCH] mips: update IRQ handling for vr41xx")
      Reported-by: default avatark2ci <kernel-bot@kylinos.cn>
      Signed-off-by: default avatarhuhai <huhai@kylinos.cn>
      Signed-off-by: default avatarGenjian Zhang <zhanggenjian@kylinos.cn>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab150a2b
    • Julien Grall's avatar
      x86/xen: Remove undefined behavior in setup_features() · 3e2c9ee9
      Julien Grall authored
      [ Upstream commit ecb6237f ]
      
      1 << 31 is undefined. So switch to 1U << 31.
      
      Fixes: 5ead97c8
      
       ("xen: Core Xen implementation")
      Signed-off-by: default avatarJulien Grall <jgrall@amazon.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220617103037.57828-1-julien@xen.org
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e2c9ee9
    • Jason Andryuk's avatar
      xen-blkfront: Handle NULL gendisk · ffa12a32
      Jason Andryuk authored
      [ Upstream commit f9710c35 ]
      
      When a VBD is not fully created and then closed, the kernel can have a
      NULL pointer dereference:
      
      The reproducer is trivial:
      
      [user@dom0 ~]$ sudo xl block-attach work backend=sys-usb vdev=xvdi target=/dev/sdz
      [user@dom0 ~]$ xl block-list work
      Vdev  BE  handle state evt-ch ring-ref BE-path
      51712 0   241    4     -1     -1       /local/domain/0/backend/vbd/241/51712
      51728 0   241    4     -1     -1       /local/domain/0/backend/vbd/241/51728
      51744 0   241    4     -1     -1       /local/domain/0/backend/vbd/241/51744
      51760 0   241    4     -1     -1       /local/domain/0/backend/vbd/241/51760
      51840 3   241    3     -1     -1       /local/domain/3/backend/vbd/241/51840
                       ^ note state, the /dev/sdz doesn't exist in the backend
      
      [user@dom0 ~]$ sudo xl block-detach work xvdi
      [user@dom0 ~]$ xl block-list work
      Vdev  BE  handle state evt-ch ring-ref BE-path
      work is an invalid domain identifier
      
      And its console has:
      
      BUG: kernel NULL pointer dereference, address: 0000000000000050
      PGD 80000000edebb067 P4D 80000000edebb067 PUD edec2067 PMD 0
      Oops: 0000 [#1] PREEMPT SMP PTI
      CPU: 1 PID: 52 Comm: xenwatch Not tainted 5.16.18-2.43.fc32.qubes.x86_64 #1
      RIP: 0010:blk_mq_stop_hw_queues+0x5/0x40
      Code: 00 48 83 e0 fd 83 c3 01 48 89 85 a8 00 00 00 41 39 5c 24 50 77 c0 5b 5d 41 5c 41 5d c3 c3 0f 1f 80 00 00 00 00 0f 1f 44 00 00 <8b> 47 50 85 c0 74 32 41 54 49 89 fc 55 53 31 db 49 8b 44 24 48 48
      RSP: 0018:ffffc90000bcfe98 EFLAGS: 00010293
      RAX: ffffffffc0008370 RBX: 0000000000000005 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000005 RDI: 0000000000000000
      RBP: ffff88800775f000 R08: 0000000000000001 R09: ffff888006e620b8
      R10: ffff888006e620b0 R11: f000000000000000 R12: ffff8880bff39000
      R13: ffff8880bff39000 R14: 0000000000000000 R15: ffff88800604be00
      FS:  0000000000000000(0000) GS:ffff8880f3300000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000050 CR3: 00000000e932e002 CR4: 00000000003706e0
      Call Trace:
       <TASK>
       blkback_changed+0x95/0x137 [xen_blkfront]
       ? read_reply+0x160/0x160
       xenwatch_thread+0xc0/0x1a0
       ? do_wait_intr_irq+0xa0/0xa0
       kthread+0x16b/0x190
       ? set_kthread_struct+0x40/0x40
       ret_from_fork+0x22/0x30
       </TASK>
      Modules linked in: snd_seq_dummy snd_hrtimer snd_seq snd_seq_device snd_timer snd soundcore ipt_REJECT nf_reject_ipv4 xt_state xt_conntrack nft_counter nft_chain_nat xt_MASQUERADE nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nf_tables nfnetlink intel_rapl_msr intel_rapl_common crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel xen_netfront pcspkr xen_scsiback target_core_mod xen_netback xen_privcmd xen_gntdev xen_gntalloc xen_blkback xen_evtchn ipmi_devintf ipmi_msghandler fuse bpf_preload ip_tables overlay xen_blkfront
      CR2: 0000000000000050
      ---[ end trace 7bc9597fd06ae89d ]---
      RIP: 0010:blk_mq_stop_hw_queues+0x5/0x40
      Code: 00 48 83 e0 fd 83 c3 01 48 89 85 a8 00 00 00 41 39 5c 24 50 77 c0 5b 5d 41 5c 41 5d c3 c3 0f 1f 80 00 00 00 00 0f 1f 44 00 00 <8b> 47 50 85 c0 74 32 41 54 49 89 fc 55 53 31 db 49 8b 44 24 48 48
      RSP: 0018:ffffc90000bcfe98 EFLAGS: 00010293
      RAX: ffffffffc0008370 RBX: 0000000000000005 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000005 RDI: 0000000000000000
      RBP: ffff88800775f000 R08: 0000000000000001 R09: ffff888006e620b8
      R10: ffff888006e620b0 R11: f000000000000000 R12: ffff8880bff39000
      R13: ffff8880bff39000 R14: 0000000000000000 R15: ffff88800604be00
      FS:  0000000000000000(0000) GS:ffff8880f3300000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000050 CR3: 00000000e932e002 CR4: 00000000003706e0
      Kernel panic - not syncing: Fatal exception
      Kernel Offset: disabled
      
      info->rq and info->gd are only set in blkfront_connect(), which is
      called for state 4 (XenbusStateConnected).  Guard against using NULL
      variables in blkfront_closing() to avoid the issue.
      
      The rest of blkfront_closing looks okay.  If info->nr_rings is 0, then
      for_each_rinfo won't do anything.
      
      blkfront_remove also needs to check for non-NULL pointers before
      cleaning up the gendisk and request queue.
      
      Fixes: 05d69d95
      
       "xen-blkfront: sanitize the removal state machine"
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: default avatarJason Andryuk <jandryuk@gmail.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220601195341.28581-1-jandryuk@gmail.com
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ffa12a32
    • Jie2x Zhou's avatar
      selftests: netfilter: correct PKTGEN_SCRIPT_PATHS in nft_concat_range.sh · 0315bd8a
      Jie2x Zhou authored
      [ Upstream commit 5d79d8af ]
      
      Before change:
      make -C netfilter
       TEST: performance
         net,port                                                      [SKIP]
         perf not supported
         port,net                                                      [SKIP]
         perf not supported
         net6,port                                                     [SKIP]
         perf not supported
         port,proto                                                    [SKIP]
         perf not supported
         net6,port,mac                                                 [SKIP]
         perf not supported
         net6,port,mac,proto                                           [SKIP]
         perf not supported
         net,mac                                                       [SKIP]
         perf not supported
      
      After change:
         net,mac                                                       [ OK ]
           baseline (drop from netdev hook):               2061098pps
           baseline hash (non-ranged entries):             1606741pps
           baseline rbtree (match on first field only):    1191607pps
           set with  1000 full, ranged entries:            1639119pps
      ok 8 selftests: netfilter: nft_concat_range.sh
      
      Fixes: 611973c1
      
       ("selftests: netfilter: Introduce tests for sets with range concatenation")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJie2x Zhou <jie2x.zhou@intel.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0315bd8a
    • Gerd Hoffmann's avatar
      udmabuf: add back sanity check · 5b455358
      Gerd Hoffmann authored
      [ Upstream commit 05b252cc ]
      
      Check vm_fault->pgoff before using it.  When we removed the warning, we
      also removed the check.
      
      Fixes: 7b26e4e2
      
       ("udmabuf: drop WARN_ON() check.")
      Reported-by: default avatar <zdi-disclosures@trendmicro.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linuxfoundation.org>
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5b455358
    • Ziyang Xuan's avatar
      net/tls: fix tls_sk_proto_close executed repeatedly · be64f54a
      Ziyang Xuan authored
      [ Upstream commit 69135c57 ]
      
      After setting the sock ktls, update ctx->sk_proto to sock->sk_prot by
      tls_update(), so now ctx->sk_proto->close is tls_sk_proto_close(). When
      close the sock, tls_sk_proto_close() is called for sock->sk_prot->close
      is tls_sk_proto_close(). But ctx->sk_proto->close() will be executed later
      in tls_sk_proto_close(). Thus tls_sk_proto_close() executed repeatedly
      occurred. That will trigger the following bug.
      
      =================================================================
      KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
      RIP: 0010:tls_sk_proto_close+0xd8/0xaf0 net/tls/tls_main.c:306
      Call Trace:
       <TASK>
       tls_sk_proto_close+0x356/0xaf0 net/tls/tls_main.c:329
       inet_release+0x12e/0x280 net/ipv4/af_inet.c:428
       __sock_release+0xcd/0x280 net/socket.c:650
       sock_close+0x18/0x20 net/socket.c:1365
      
      Updating a proto which is same with sock->sk_prot is incorrect. Add proto
      and sock->sk_prot equality check at the head of tls_update() to fix it.
      
      Fixes: 95fa1454
      
       ("bpf: sockmap/tls, close can race with map free")
      Reported-by: default avatar <syzbot+29c3c12f3214b85ad081@syzkaller.appspotmail.com>
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be64f54a
    • Eric Dumazet's avatar
      erspan: do not assume transport header is always set · a3b24703
      Eric Dumazet authored
      [ Upstream commit 301bd140 ]
      
      Rewrite tests in ip6erspan_tunnel_xmit() and
      erspan_fb_xmit() to not assume transport header is set.
      
      syzbot reported:
      
      WARNING: CPU: 0 PID: 1350 at include/linux/skbuff.h:2911 skb_transport_header include/linux/skbuff.h:2911 [inline]
      WARNING: CPU: 0 PID: 1350 at include/linux/skbuff.h:2911 ip6erspan_tunnel_xmit+0x15af/0x2eb0 net/ipv6/ip6_gre.c:963
      Modules linked in:
      CPU: 0 PID: 1350 Comm: aoe_tx0 Not tainted 5.19.0-rc2-syzkaller-00160-g274295c6e53f #0
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014
      RIP: 0010:skb_transport_header include/linux/skbuff.h:2911 [inline]
      RIP: 0010:ip6erspan_tunnel_xmit+0x15af/0x2eb0 net/ipv6/ip6_gre.c:963
      Code: 0f 47 f0 40 88 b5 7f fe ff ff e8 8c 16 4b f9 89 de bf ff ff ff ff e8 a0 12 4b f9 66 83 fb ff 0f 85 1d f1 ff ff e8 71 16 4b f9 <0f> 0b e9 43 f0 ff ff e8 65 16 4b f9 48 8d 85 30 ff ff ff ba 60 00
      RSP: 0018:ffffc90005daf910 EFLAGS: 00010293
      RAX: 0000000000000000 RBX: 000000000000ffff RCX: 0000000000000000
      RDX: ffff88801f032100 RSI: ffffffff882e8d3f RDI: 0000000000000003
      RBP: ffffc90005dafab8 R08: 0000000000000003 R09: 000000000000ffff
      R10: 000000000000ffff R11: 0000000000000000 R12: ffff888024f21d40
      R13: 000000000000a288 R14: 00000000000000b0 R15: ffff888025a2e000
      FS: 0000000000000000(0000) GS:ffff88802c800000(0000) knlGS:0000000000000000
      CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000001b2e425000 CR3: 000000006d099000 CR4: 0000000000152ef0
      Call Trace:
      <TASK>
      __netdev_start_xmit include/linux/netdevice.h:4805 [inline]
      netdev_start_xmit include/linux/netdevice.h:4819 [inline]
      xmit_one net/core/dev.c:3588 [inline]
      dev_hard_start_xmit+0x188/0x880 net/core/dev.c:3604
      sch_direct_xmit+0x19f/0xbe0 net/sched/sch_generic.c:342
      __dev_xmit_skb net/core/dev.c:3815 [inline]
      __dev_queue_xmit+0x14a1/0x3900 net/core/dev.c:4219
      dev_queue_xmit include/linux/netdevice.h:2994 [inline]
      tx+0x6a/0xc0 drivers/block/aoe/aoenet.c:63
      kthread+0x1e7/0x3b0 drivers/block/aoe/aoecmd.c:1229
      kthread+0x2e9/0x3a0 kernel/kthread.c:376
      ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302
      </TASK>
      
      Fixes: d5db21a3
      
       ("erspan: auto detect truncated ipv6 packets.")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: William Tu <u9012063@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a3b24703
    • Leo Yan's avatar
      perf arm-spe: Don't set data source if it's not a memory operation · 26e70f89
      Leo Yan authored
      [ Upstream commit 51ba539f ]
      
      Except for memory load and store operations, ARM SPE records also can
      support other operation types, bug when set the data source field the
      current code assumes a record is a either load operation or store
      operation, this leads to wrongly synthesize memory samples.
      
      This patch strictly checks the record operation type, it only sets data
      source only for the operation types ARM_SPE_LD and ARM_SPE_ST,
      otherwise, returns zero for data source.  Therefore, we can synthesize
      memory samples only when data source is a non-zero value, the function
      arm_spe__is_memory_event() is useless and removed.
      
      Fixes: e55ed342
      
       ("perf arm-spe: Synthesize memory event")
      Reviewed-by: default avatarAli Saidi <alisaidi@amazon.com>
      Reviewed-by: default avatarGerman Gomez <german.gomez@arm.com>
      Signed-off-by: default avatarLeo Yan <leo.yan@linaro.org>
      Tested-by: default avatarAli Saidi <alisaidi@amazon.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: alisaidi@amazon.com
      Cc: Andrew Kilroy <andrew.kilroy@arm.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kajol Jain <kjain@linux.ibm.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Li Huafei <lihuafei1@huawei.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nick Forrington <nick.forrington@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lore.kernel.org/lkml/20220517020326.18580-5-alisaidi@amazon.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26e70f89
    • Kuogee Hsieh's avatar
      drm/msm/dp: force link training for display resolution change · e24709e8
      Kuogee Hsieh authored
      [ Upstream commit a6e2af64 ]
      
      Display resolution change is implemented through drm modeset. Older
      modeset (resolution) has to be disabled first before newer modeset
      (resolution) can be enabled. Display disable will turn off both
      pixel clock and main link clock so that main link have to be
      re-trained during display enable to have new video stream flow
      again. At current implementation, display enable function manually
      kicks up irq_hpd_handle which will read panel link status and start
      link training if link status is not in sync state.
      
      However, there is rare case that a particular panel links status keep
      staying in sync for some period of time after main link had been shut
      down previously at display disabled. In this case, main link retraining
      will not be executed by irq_hdp_handle(). Hence video stream of newer
      display resolution will fail to be transmitted to panel due to main
      link is not in sync between host and panel.
      
      This patch will bypass irq_hpd_handle() in favor of directly call
      dp_ctrl_on_stream() to always perform link training in regardless of
      main link status. So that no unexpected exception resolution change
      failure cases will happen. Also this implementation are more efficient
      than manual kicking off irq_hpd_handle function.
      
      Changes in v2:
      -- set force_link_train flag on DP only (is_edp == false)
      
      Changes in v3:
      -- revise commit  text
      -- add Fixes tag
      
      Changes in v4:
      -- revise commit  text
      
      Changes in v5:
      -- fix spelling at commit text
      
      Changes in v6:
      -- split dp_ctrl_on_stream() for phy test case
      -- revise commit text for modeset
      
      Changes in v7:
      -- drop 0 assignment at local variable (ret = 0)
      
      Changes in v8:
      -- add patch to remove pixel_rate from dp_ctrl
      
      Changes in v9:
      -- forward declare dp_ctrl_on_stream_phy_test_report()
      
      Fixes: 62671d2e
      
       ("drm/msm/dp: fixes wrong connection state caused by failure of link train")
      Signed-off-by: default avatarKuogee Hsieh <quic_khsieh@quicinc.com>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Patchwork: https://patchwork.freedesktop.org/patch/489895/
      Link: https://lore.kernel.org/r/1655411200-7255-1-git-send-email-quic_khsieh@quicinc.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e24709e8
    • Kuogee Hsieh's avatar
      drm/msm/dp: do not initialize phy until plugin interrupt received · 796d3acd
      Kuogee Hsieh authored
      [ Upstream commit 989ebe7b ]
      
      Current DP drivers have regulators, clocks, irq and phy are grouped
      together within a function and executed not in a symmetric manner.
      This increase difficulty of code maintenance and limited code scalability.
      This patch divides the driver life cycle of operation into four states,
      resume (including booting up), dongle plugin, dongle unplugged and suspend.
      Regulators, core clocks and irq are grouped together and enabled at resume
      (or booting up) so that the DP controller is armed and ready to receive HPD
      plugin interrupts. HPD plugin interrupt is generated when a dongle plugs
      into DUT (device under test). Once HPD plugin interrupt is received, DP
      controller will initialize phy so that dpcd read/write will function and
      following link training can be proceeded successfully. DP phy will be
      disabled after main link is teared down at end of unplugged HPD interrupt
      handle triggered by dongle unplugged out of DUT. Finally regulators, code
      clocks and irq are disabled at corresponding suspension.
      
      Changes in V2:
      -- removed unnecessary dp_ctrl NULL check
      -- removed unnecessary phy init_count and power_count DRM_DEBUG_DP logs
      -- remove flip parameter out of dp_ctrl_irq_enable()
      -- add fixes tag
      
      Changes in V3:
      -- call dp_display_host_phy_init() instead of dp_ctrl_phy_init() at
              dp_display_host_init() for eDP
      
      Changes in V4:
      -- rewording commit text to match this commit changes
      
      Changes in V5:
      -- rebase on top of msm-next branch
      
      Changes in V6:
      -- delete flip variable
      
      Changes in V7:
      -- dp_ctrl_irq_enable/disabe() merged into dp_ctrl_reset_irq_ctrl()
      
      Changes in V8:
      -- add more detail comment regrading dp phy at dp_display_host_init()
      
      Changes in V9:
      -- remove set phy_initialized to false when -ECONNRESET detected
      
      Changes in v10:
      --  group into one series
      
      Changes in v11:
      -- drop drm/msm/dp: dp_link_parse_sink_count() return immediately
      	if aux read
      
      Changes in v12:
      -- move dp_display_host_phy_exit() after dp_display_host_deinit()
      
      Changes in v13:
      -- do not execute phy_init until plugged_in interrupt for edp, same as DP.
      
      Changes in v14:
      -- remove redundant dp->core_initialized = false form dp_pm_suspend.
      
      Changes in v15:
      -- remove core_initialized flag check at both host_init and host_deinit
      
      Changes in v16:
      -- remove dp_display_host_phy_exit core_initialized=false at dp_pm_suspend
      
      Changes in v17:
      -- remove core_initialized checking before execute attention_cb()
      
      Changes in v18:
      -- remove core_initialized checking at dp_pm_suspend
      
      Fixes: 8ede2ecc
      
       ("drm/msm/dp: Add DP compliance tests on Snapdragon Chipsets")
      Signed-off-by: default avatarKuogee Hsieh <quic_khsieh@quicinc.com>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://lore.kernel.org/r/1642531648-8448-2-git-send-email-quic_khsieh@quicinc.com
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      796d3acd
    • Kuogee Hsieh's avatar
      drm/msm/dp: dp_link_parse_sink_count() return immediately if aux read failed · 40e9efdc
      Kuogee Hsieh authored
      [ Upstream commit f61550b3
      
       ]
      
      Add checking aux read/write status at both dp_link_parse_sink_count()
      and dp_link_parse_sink_status_filed() to avoid long timeout delay if
      dp aux read/write failed at timeout due to cable unplugged.
      
      Changes in V4:
      -- split this patch as stand alone patch
      
      Changes in v5:
      -- rebase on msm-next branch
      
      Signed-off-by: default avatarKuogee Hsieh <quic_khsieh@quicinc.com>
      
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Tested-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://lore.kernel.org/r/1638985262-2072-1-git-send-email-quic_khsieh@quicinc.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      40e9efdc
    • Bjorn Andersson's avatar
      drm/msm/dp: Drop now unused hpd_high member · 2ecf5ff9
      Bjorn Andersson authored
      [ Upstream commit fabae667 ]
      
      Since '8ede2ecc
      
       ("drm/msm/dp: Add DP compliance tests on Snapdragon
      Chipsets")' the hpd_high member of struct dp_usbpd has been write-only.
      
      Let's clean up the code a little bit by removing the writes as well.
      
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Link: https://lore.kernel.org/r/20211106172246.2597431-1-bjorn.andersson@linaro.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ecf5ff9
    • Kuogee Hsieh's avatar
      drm/msm/dp: check core_initialized before disable interrupts at dp_display_unbind() · d0b4a61f
      Kuogee Hsieh authored
      [ Upstream commit d80c3ba0 ]
      
      During msm initialize phase, dp_display_unbind() will be called to undo
      initializations had been done by dp_display_bind() previously if there is
      error happen at msm_drm_bind. In this case, core_initialized flag had to
      be check to make sure clocks is on before update DP controller register
      to disable HPD interrupts. Otherwise system will crash due to below NOC
      fatal error.
      
      QTISECLIB [01f01a7ad]CNOC2 ERROR: ERRLOG0_LOW = 0x00061007
      QTISECLIB [01f01a7ad]GEM_NOC ERROR: ERRLOG0_LOW = 0x00001007
      QTISECLIB [01f0371a0]CNOC2 ERROR: ERRLOG0_HIGH = 0x00000003
      QTISECLIB [01f055297]GEM_NOC ERROR: ERRLOG0_HIGH = 0x00000003
      QTISECLIB [01f072beb]CNOC2 ERROR: ERRLOG1_LOW = 0x00000024
      QTISECLIB [01f0914b8]GEM_NOC ERROR: ERRLOG1_LOW = 0x00000042
      QTISECLIB [01f0ae639]CNOC2 ERROR: ERRLOG1_HIGH = 0x00004002
      QTISECLIB [01f0cc73f]GEM_NOC ERROR: ERRLOG1_HIGH = 0x00004002
      QTISECLIB [01f0ea092]CNOC2 ERROR: ERRLOG2_LOW = 0x0009020c
      QTISECLIB [01f10895f]GEM_NOC ERROR: ERRLOG2_LOW = 0x0ae9020c
      QTISECLIB [01f125ae1]CNOC2 ERROR: ERRLOG2_HIGH = 0x00000000
      QTISECLIB [01f143be7]GEM_NOC ERROR: ERRLOG2_HIGH = 0x00000000
      QTISECLIB [01f16153a]CNOC2 ERROR: ERRLOG3_LOW = 0x00000000
      QTISECLIB [01f17fe07]GEM_NOC ERROR: ERRLOG3_LOW = 0x00000000
      QTISECLIB [01f19cf89]CNOC2 ERROR: ERRLOG3_HIGH = 0x00000000
      QTISECLIB [01f1bb08e]GEM_NOC ERROR: ERRLOG3_HIGH = 0x00000000
      QTISECLIB [01f1d8a31]CNOC2 ERROR: SBM1 FAULTINSTATUS0_LOW = 0x00000002
      QTISECLIB [01f1f72a4]GEM_NOC ERROR: SBM0 FAULTINSTATUS0_LOW = 0x00000001
      QTISECLIB [01f21a217]CNOC3 ERROR: ERRLOG0_LOW = 0x00000006
      QTISECLIB [01f23dfd3]NOC error fatal
      
      changes in v2:
      -- drop the first patch (drm/msm: enable msm irq after all initializations are done successfully at msm_drm_init()) since the problem had been fixed by other patch
      
      Fixes: 570d3e5d
      
       ("drm/msm/dp: stop event kernel thread when DP unbind")
      Signed-off-by: default avatarKuogee Hsieh <quic_khsieh@quicinc.com>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Patchwork: https://patchwork.freedesktop.org/patch/488387/
      Link: https://lore.kernel.org/r/1654538139-7450-1-git-send-email-quic_khsieh@quicinc.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0b4a61f
    • Miaoqian Lin's avatar
      drm/msm/mdp4: Fix refcount leak in mdp4_modeset_init_intf · 3c39a171
      Miaoqian Lin authored
      [ Upstream commit b9cc4598 ]
      
      of_graph_get_remote_node() returns remote device node pointer with
      refcount incremented, we should use of_node_put() on it
      when not need anymore.
      Add missing of_node_put() to avoid refcount leak.
      
      Fixes: 86418f90
      
       ("drm: convert drivers to use of_graph_get_remote_node")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Patchwork: https://patchwork.freedesktop.org/patch/488473/
      Link: https://lore.kernel.org/r/20220607110841.53889-1-linmq006@gmail.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c39a171
    • Peilin Ye's avatar
      net/sched: sch_netem: Fix arithmetic in netem_dump() for 32-bit platforms · 45bd293b
      Peilin Ye authored
      [ Upstream commit a2b1a5d4
      
       ]
      
      As reported by Yuming, currently tc always show a latency of UINT_MAX
      for netem Qdisc's on 32-bit platforms:
      
          $ tc qdisc add dev dummy0 root netem latency 100ms
          $ tc qdisc show dev dummy0
          qdisc netem 8001: root refcnt 2 limit 1000 delay 275s  275s
                                                     ^^^^^^^^^^^^^^^^
      
      Let us take a closer look at netem_dump():
      
              qopt.latency = min_t(psched_tdiff_t, PSCHED_NS2TICKS(q->latency,
                                   UINT_MAX);
      
      qopt.latency is __u32, psched_tdiff_t is signed long,
      (psched_tdiff_t)(UINT_MAX) is negative for 32-bit platforms, so
      qopt.latency is always UINT_MAX.
      
      Fix it by using psched_time_t (u64) instead.
      
      Note: confusingly, users have two ways to specify 'latency':
      
        1. normally, via '__u32 latency' in struct tc_netem_qopt;
        2. via the TCA_NETEM_LATENCY64 attribute, which is s64.
      
      For the second case, theoretically 'latency' could be negative.  This
      patch ignores that corner case, since it is broken (i.e. assigning a
      negative s64 to __u32) anyways, and should be handled separately.
      
      Thanks Ted Lin for the analysis [1] .
      
      [1] https://github.com/raspberrypi/linux/issues/3512
      
      Reported-by: default avatarYuming Chen <chenyuming.junnan@bytedance.com>
      Fixes: 112f9cb6
      
       ("netem: convert to qdisc_watchdog_schedule_ns")
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
      Acked-by: default avatarStephen Hemminger <stephen@networkplumber.org>
      Link: https://lore.kernel.org/r/20220616234336.2443-1-yepeilin.cs@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      45bd293b
    • Ivan Vecera's avatar
      ethtool: Fix get module eeprom fallback · efb10d2a
      Ivan Vecera authored
      [ Upstream commit a3bb7b63 ]
      
      Function fallback_set_params() checks if the module type returned
      by a driver is ETH_MODULE_SFF_8079 and in this case it assumes
      that buffer returns a concatenated content of page  A0h and A2h.
      The check is wrong because the correct type is ETH_MODULE_SFF_8472.
      
      Fixes: 96d971e3
      
       ("ethtool: Add fallback to get_module_eeprom from netlink command")
      Signed-off-by: default avatarIvan Vecera <ivecera@redhat.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Link: https://lore.kernel.org/r/20220616160856.3623273-1-ivecera@redhat.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      efb10d2a
    • Jay Vosburgh's avatar
      bonding: ARP monitor spams NETDEV_NOTIFY_PEERS notifiers · 6386fdde
      Jay Vosburgh authored
      [ Upstream commit 7a9214f3
      
       ]
      
      The bonding ARP monitor fails to decrement send_peer_notif, the
      number of peer notifications (gratuitous ARP or ND) to be sent. This
      results in a continuous series of notifications.
      
      Correct this by decrementing the counter for each notification.
      
      Reported-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Signed-off-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
      Fixes: b0929915
      
       ("bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for ab arp monitor")
      Link: https://lore.kernel.org/netdev/b2fd4147-8f50-bebd-963a-1a3e8d1d9715@redhat.com/
      Tested-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Reviewed-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Link: https://lore.kernel.org/r/9400.1655407960@famine
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6386fdde
    • Lorenzo Bianconi's avatar
      igb: fix a use-after-free issue in igb_clean_tx_ring · 2af94421
      Lorenzo Bianconi authored
      [ Upstream commit 3f6a57ee ]
      
      Fix the following use-after-free bug in igb_clean_tx_ring routine when
      the NIC is running in XDP mode. The issue can be triggered redirecting
      traffic into the igb NIC and then closing the device while the traffic
      is flowing.
      
      [   73.322719] CPU: 1 PID: 487 Comm: xdp_redirect Not tainted 5.18.3-apu2 #9
      [   73.330639] Hardware name: PC Engines APU2/APU2, BIOS 4.0.7 02/28/2017
      [   73.337434] RIP: 0010:refcount_warn_saturate+0xa7/0xf0
      [   73.362283] RSP: 0018:ffffc9000081f798 EFLAGS: 00010282
      [   73.367761] RAX: 0000000000000000 RBX: ffffc90000420f80 RCX: 0000000000000000
      [   73.375200] RDX: ffff88811ad22d00 RSI: ffff88811ad171e0 RDI: ffff88811ad171e0
      [   73.382590] RBP: 0000000000000900 R08: ffffffff82298f28 R09: 0000000000000058
      [   73.390008] R10: 0000000000000219 R11: ffffffff82280f40 R12: 0000000000000090
      [   73.397356] R13: ffff888102343a40 R14: ffff88810359e0e4 R15: 0000000000000000
      [   73.404806] FS:  00007ff38d31d740(0000) GS:ffff88811ad00000(0000) knlGS:0000000000000000
      [   73.413129] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   73.419096] CR2: 000055cff35f13f8 CR3: 0000000106391000 CR4: 00000000000406e0
      [   73.426565] Call Trace:
      [   73.429087]  <TASK>
      [   73.431314]  igb_clean_tx_ring+0x43/0x140 [igb]
      [   73.436002]  igb_down+0x1d7/0x220 [igb]
      [   73.439974]  __igb_close+0x3c/0x120 [igb]
      [   73.444118]  igb_xdp+0x10c/0x150 [igb]
      [   73.447983]  ? igb_pci_sriov_configure+0x70/0x70 [igb]
      [   73.453362]  dev_xdp_install+0xda/0x110
      [   73.457371]  dev_xdp_attach+0x1da/0x550
      [   73.461369]  do_setlink+0xfd0/0x10f0
      [   73.465166]  ? __nla_validate_parse+0x89/0xc70
      [   73.469714]  rtnl_setlink+0x11a/0x1e0
      [   73.473547]  rtnetlink_rcv_msg+0x145/0x3d0
      [   73.477709]  ? rtnl_calcit.isra.0+0x130/0x130
      [   73.482258]  netlink_rcv_skb+0x8d/0x110
      [   73.486229]  netlink_unicast+0x230/0x340
      [   73.490317]  netlink_sendmsg+0x215/0x470
      [   73.494395]  __sys_sendto+0x179/0x190
      [   73.498268]  ? move_addr_to_user+0x37/0x70
      [   73.502547]  ? __sys_getsockname+0x84/0xe0
      [   73.506853]  ? netlink_setsockopt+0x1c1/0x4a0
      [   73.511349]  ? __sys_setsockopt+0xc8/0x1d0
      [   73.515636]  __x64_sys_sendto+0x20/0x30
      [   73.519603]  do_syscall_64+0x3b/0x80
      [   73.523399]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [   73.528712] RIP: 0033:0x7ff38d41f20c
      [   73.551866] RSP: 002b:00007fff3b945a68 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
      [   73.559640] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff38d41f20c
      [   73.567066] RDX: 0000000000000034 RSI: 00007fff3b945b30 RDI: 0000000000000003
      [   73.574457] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
      [   73.581852] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fff3b945ab0
      [   73.589179] R13: 0000000000000000 R14: 0000000000000003 R15: 00007fff3b945b30
      [   73.596545]  </TASK>
      [   73.598842] ---[ end trace 0000000000000000 ]---
      
      Fixes: 9cbc948b
      
       ("igb: add XDP support")
      Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
      Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Link: https://lore.kernel.org/r/e5c01d549dc37bff18e46aeabd6fb28a7bcf84be.1655388571.git.lorenzo@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2af94421
    • Hoang Le's avatar
      tipc: fix use-after-free Read in tipc_named_reinit · cd7789e6
      Hoang Le authored
      [ Upstream commit 911600bf ]
      
      syzbot found the following issue on:
      ==================================================================
      BUG: KASAN: use-after-free in tipc_named_reinit+0x94f/0x9b0
      net/tipc/name_distr.c:413
      Read of size 8 at addr ffff88805299a000 by task kworker/1:9/23764
      
      CPU: 1 PID: 23764 Comm: kworker/1:9 Not tainted
      5.18.0-rc4-syzkaller-00878-g17d49e6e8012 #0
      Hardware name: Google Compute Engine/Google Compute Engine,
      BIOS Google 01/01/2011
      Workqueue: events tipc_net_finalize_work
      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+0xeb/0x495
      mm/kasan/report.c:313
       print_report mm/kasan/report.c:429 [inline]
       kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
       tipc_named_reinit+0x94f/0x9b0 net/tipc/name_distr.c:413
       tipc_net_finalize+0x234/0x3d0 net/tipc/net.c:138
       process_one_work+0x996/0x1610 kernel/workqueue.c:2289
       worker_thread+0x665/0x1080 kernel/workqueue.c:2436
       kthread+0x2e9/0x3a0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
       </TASK>
      [...]
      ==================================================================
      
      In the commit
      d966ddcc
      
       ("tipc: fix a deadlock when flushing scheduled work"),
      the cancel_work_sync() function just to make sure ONLY the work
      tipc_net_finalize_work() is executing/pending on any CPU completed before
      tipc namespace is destroyed through tipc_exit_net(). But this function
      is not guaranteed the work is the last queued. So, the destroyed instance
      may be accessed in the work which will try to enqueue later.
      
      In order to completely fix, we re-order the calling of cancel_work_sync()
      to make sure the work tipc_net_finalize_work() was last queued and it
      must be completed by calling cancel_work_sync().
      
      Reported-by: default avatar <syzbot+47af19f3307fc9c5c82e@syzkaller.appspotmail.com>
      Fixes: d966ddcc
      
       ("tipc: fix a deadlock when flushing scheduled work")
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
      Signed-off-by: default avatarHoang Le <hoang.h.le@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd7789e6
    • Eric Dumazet's avatar
      net: fix data-race in dev_isalive() · ad10d61c
      Eric Dumazet authored
      [ Upstream commit cc26c266 ]
      
      dev_isalive() is called under RTNL or dev_base_lock protection.
      
      This means that changes to dev->reg_state should be done with both locks held.
      
      syzbot reported:
      
      BUG: KCSAN: data-race in register_netdevice / type_show
      
      write to 0xffff888144ecf518 of 1 bytes by task 20886 on cpu 0:
      register_netdevice+0xb9f/0xdf0 net/core/dev.c:10050
      lapbeth_new_device drivers/net/wan/lapbether.c:414 [inline]
      lapbeth_device_event+0x4a0/0x6c0 drivers/net/wan/lapbether.c:456
      notifier_call_chain kernel/notifier.c:87 [inline]
      raw_notifier_call_chain+0x53/0xb0 kernel/notifier.c:455
      __dev_notify_flags+0x1d6/0x3a0
      dev_change_flags+0xa2/0xc0 net/core/dev.c:8607
      do_setlink+0x778/0x2230 net/core/rtnetlink.c:2780
      __rtnl_newlink net/core/rtnetlink.c:3546 [inline]
      rtnl_newlink+0x114c/0x16a0 net/core/rtnetlink.c:3593
      rtnetlink_rcv_msg+0x811/0x8c0 net/core/rtnetlink.c:6089
      netlink_rcv_skb+0x13e/0x240 net/netlink/af_netlink.c:2501
      rtnetlink_rcv+0x18/0x20 net/core/rtnetlink.c:6107
      netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
      netlink_unicast+0x58a/0x660 net/netlink/af_netlink.c:1345
      netlink_sendmsg+0x661/0x750 net/netlink/af_netlink.c:1921
      sock_sendmsg_nosec net/socket.c:714 [inline]
      sock_sendmsg net/socket.c:734 [inline]
      __sys_sendto+0x21e/0x2c0 net/socket.c:2119
      __do_sys_sendto net/socket.c:2131 [inline]
      __se_sys_sendto net/socket.c:2127 [inline]
      __x64_sys_sendto+0x74/0x90 net/socket.c:2127
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      read to 0xffff888144ecf518 of 1 bytes by task 20423 on cpu 1:
      dev_isalive net/core/net-sysfs.c:38 [inline]
      netdev_show net/core/net-sysfs.c:50 [inline]
      type_show+0x24/0x90 net/core/net-sysfs.c:112
      dev_attr_show+0x35/0x90 drivers/base/core.c:2095
      sysfs_kf_seq_show+0x175/0x240 fs/sysfs/file.c:59
      kernfs_seq_show+0x75/0x80 fs/kernfs/file.c:162
      seq_read_iter+0x2c3/0x8e0 fs/seq_file.c:230
      kernfs_fop_read_iter+0xd1/0x2f0 fs/kernfs/file.c:235
      call_read_iter include/linux/fs.h:2052 [inline]
      new_sync_read fs/read_write.c:401 [inline]
      vfs_read+0x5a5/0x6a0 fs/read_write.c:482
      ksys_read+0xe8/0x1a0 fs/read_write.c:620
      __do_sys_read fs/read_write.c:630 [inline]
      __se_sys_read fs/read_write.c:628 [inline]
      __x64_sys_read+0x3e/0x50 fs/read_write.c:628
      do_syscall_x64 arch/x86/entry/common.c:50 [inline]
      do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      value changed: 0x00 -> 0x01
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 20423 Comm: udevd Tainted: G W 5.19.0-rc2-syzkaller-dirty #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad10d61c
    • Sebastian Andrzej Siewior's avatar
      net: Write lock dev_base_lock without disabling bottom halves. · f617cef4
      Sebastian Andrzej Siewior authored
      [ Upstream commit fd888e85
      
       ]
      
      The writer acquires dev_base_lock with disabled bottom halves.
      The reader can acquire dev_base_lock without disabling bottom halves
      because there is no writer in softirq context.
      
      On PREEMPT_RT the softirqs are preemptible and local_bh_disable() acts
      as a lock to ensure that resources, that are protected by disabling
      bottom halves, remain protected.
      This leads to a circular locking dependency if the lock acquired with
      disabled bottom halves (as in write_lock_bh()) and somewhere else with
      enabled bottom halves (as by read_lock() in netstat_show()) followed by
      disabling bottom halves (cxgb_get_stats() -> t4_wr_mbox_meat_timeout()
      -> spin_lock_bh()). This is the reverse locking order.
      
      All read_lock() invocation are from sysfs callback which are not invoked
      from softirq context. Therefore there is no need to disable bottom
      halves while acquiring a write lock.
      
      Acquire the write lock of dev_base_lock without disabling bottom halves.
      
      Reported-by: default avatarPei Zhang <pezhang@redhat.com>
      Reported-by: default avatarLuis Claudio R. Goncalves <lgoncalv@redhat.com>
      Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f617cef4
    • Quentin Perret's avatar
      KVM: arm64: Prevent kmemleak from accessing pKVM memory · 638be56a
      Quentin Perret authored
      [ Upstream commit 56961c63 ]
      
      Commit a7259df7 ("memblock: make memblock_find_in_range method
      private") changed the API using which memory is reserved for the pKVM
      hypervisor. However, memblock_phys_alloc() differs from the original API in
      terms of kmemleak semantics -- the old one didn't report the reserved
      regions to kmemleak while the new one does. Unfortunately, when protected
      KVM is enabled, all kernel accesses to pKVM-private memory result in a
      fatal exception, which can now happen because of kmemleak scans:
      
      $ echo scan > /sys/kernel/debug/kmemleak
      [   34.991354] kvm [304]: nVHE hyp BUG at: [<ffff800008fa3750>] __kvm_nvhe_handle_host_mem_abort+0x270/0x290!
      [   34.991580] kvm [304]: Hyp Offset: 0xfffe8be807e00000
      [   34.991813] Kernel panic - not syncing: HYP panic:
      [   34.991813] PS:600003c9 PC:0000f418011a3750 ESR:00000000f2000800
      [   34.991813] FAR:ffff000439200000 HPFAR:0000000004792000 PAR:0000000000000000
      [   34.991813] VCPU:0000000000000000
      [   34.993660] CPU: 0 PID: 304 Comm: bash Not tainted 5.19.0-rc2 #102
      [   34.994059] Hardware name: linux,dummy-virt (DT)
      [   34.994452] Call trace:
      [   34.994641]  dump_backtrace.part.0+0xcc/0xe0
      [   34.994932]  show_stack+0x18/0x6c
      [   34.995094]  dump_stack_lvl+0x68/0x84
      [   34.995276]  dump_stack+0x18/0x34
      [   34.995484]  panic+0x16c/0x354
      [   34.995673]  __hyp_pgtable_total_pages+0x0/0x60
      [   34.995933]  scan_block+0x74/0x12c
      [   34.996129]  scan_gray_list+0xd8/0x19c
      [   34.996332]  kmemleak_scan+0x2c8/0x580
      [   34.996535]  kmemleak_write+0x340/0x4a0
      [   34.996744]  full_proxy_write+0x60/0xbc
      [   34.996967]  vfs_write+0xc4/0x2b0
      [   34.997136]  ksys_write+0x68/0xf4
      [   34.997311]  __arm64_sys_write+0x20/0x2c
      [   34.997532]  invoke_syscall+0x48/0x114
      [   34.997779]  el0_svc_common.constprop.0+0x44/0xec
      [   34.998029]  do_el0_svc+0x2c/0xc0
      [   34.998205]  el0_svc+0x2c/0x84
      [   34.998421]  el0t_64_sync_handler+0xf4/0x100
      [   34.998653]  el0t_64_sync+0x18c/0x190
      [   34.999252] SMP: stopping secondary CPUs
      [   35.000034] Kernel Offset: disabled
      [   35.000261] CPU features: 0x800,00007831,00001086
      [   35.000642] Memory Limit: none
      [   35.001329] ---[ end Kernel panic - not syncing: HYP panic:
      [   35.001329] PS:600003c9 PC:0000f418011a3750 ESR:00000000f2000800
      [   35.001329] FAR:ffff000439200000 HPFAR:0000000004792000 PAR:0000000000000000
      [   35.001329] VCPU:0000000000000000 ]---
      
      Fix this by explicitly excluding the hypervisor's memory pool from
      kmemleak like we already do for the hyp BSS.
      
      Cc: Mike Rapoport <rppt@kernel.org>
      Fixes: a7259df7
      
       ("memblock: make memblock_find_in_range method private")
      Signed-off-by: default avatarQuentin Perret <qperret@google.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220616161135.3997786-1-qperret@google.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      638be56a
    • Claudiu Manoil's avatar
      phy: aquantia: Fix AN when higher speeds than 1G are not advertised · d7fe6be4
      Claudiu Manoil authored
      [ Upstream commit 9b7fd167 ]
      
      Even when the eth port is resticted to work with speeds not higher than 1G,
      and so the eth driver is requesting the phy (via phylink) to advertise up
      to 1000BASET support, the aquantia phy device is still advertising for 2.5G
      and 5G speeds.
      Clear these advertising defaults when requested.
      
      Cc: Ondrej Spacek <ondrej.spacek@nxp.com>
      Fixes: 09c4c57f
      
       ("net: phy: aquantia: add support for auto-negotiation configuration")
      Signed-off-by: default avatarClaudiu Manoil <claudiu.manoil@nxp.com>
      Link: https://lore.kernel.org/r/20220610084037.7625-1-claudiu.manoil@nxp.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7fe6be4
    • Saurabh Sengar's avatar
      scsi: storvsc: Correct reporting of Hyper-V I/O size limits · 8e74f5ce
      Saurabh Sengar authored
      [ Upstream commit 1d3e0980 ]
      
      Current code is based on the idea that the max number of SGL entries
      also determines the max size of an I/O request.  While this idea was
      true in older versions of the storvsc driver when SGL entry length
      was limited to 4 Kbytes, commit 3d9c3dcc ("scsi: storvsc: Enable
      scatterlist entry lengths > 4Kbytes") removed that limitation. It's
      now theoretically possible for the block layer to send requests that
      exceed the maximum size supported by Hyper-V. This problem doesn't
      currently happen in practice because the block layer defaults to a
      512 Kbyte maximum, while Hyper-V in Azure supports 2 Mbyte I/O sizes.
      But some future configuration of Hyper-V could have a smaller max I/O
      size, and the block layer could exceed that max.
      
      Fix this by correctly setting max_sectors as well as sg_tablesize to
      reflect the maximum I/O size that Hyper-V reports. While allowing
      I/O sizes larger than the block layer default of 512 Kbytes doesn’t
      provide any noticeable performance benefit in the tests we ran, it's
      still appropriate to report the correct underlying Hyper-V capabilities
      to the Linux block layer.
      
      Also tweak the virt_boundary_mask to reflect that the required
      alignment derives from Hyper-V communication using a 4 Kbyte page size,
      and not on the guest page size, which might be bigger (eg. ARM64).
      
      Link: https://lore.kernel.org/r/1655190355-28722-1-git-send-email-ssengar@linux.microsoft.com
      Fixes: 3d9c3dcc
      
       ("scsi: storvsc: Enable scatter list entry lengths > 4Kbytes")
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: default avatarSaurabh Sengar <ssengar@linux.microsoft.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8e74f5ce
    • Jakub Sitnicki's avatar
      bpf, x86: Fix tail call count offset calculation on bpf2bpf call · b28e4e3f
      Jakub Sitnicki authored
      [ Upstream commit ff672c67 ]
      
      On x86-64 the tail call count is passed from one BPF function to another
      through %rax. Additionally, on function entry, the tail call count value
      is stored on stack right after the BPF program stack, due to register
      shortage.
      
      The stored count is later loaded from stack either when performing a tail
      call - to check if we have not reached the tail call limit - or before
      calling another BPF function call in order to pass it via %rax.
      
      In the latter case, we miscalculate the offset at which the tail call count
      was stored on function entry. The JIT does not take into account that the
      allocated BPF program stack is always a multiple of 8 on x86, while the
      actual stack depth does not have to be.
      
      This leads to a load from an offset that belongs to the BPF stack, as shown
      in the example below:
      
      SEC("tc")
      int entry(struct __sk_buff *skb)
      {
      	/* Have data on stack which size is not a multiple of 8 */
      	volatile char arr[1] = {};
      	return subprog_tail(skb);
      }
      
      int entry(struct __sk_buff * skb):
         0: (b4) w2 = 0
         1: (73) *(u8 *)(r10 -1) = r2
         2: (85) call pc+1#bpf_prog_ce2f79bb5f3e06dd_F
         3: (95) exit
      
      int entry(struct __sk_buff * skb):
         0xffffffffa0201788:  nop    DWORD PTR [rax+rax*1+0x0]
         0xffffffffa020178d:  xor    eax,eax
         0xffffffffa020178f:  push   rbp
         0xffffffffa0201790:  mov    rbp,rsp
         0xffffffffa0201793:  sub    rsp,0x8
         0xffffffffa020179a:  push   rax
         0xffffffffa020179b:  xor    esi,esi
         0xffffffffa020179d:  mov    BYTE PTR [rbp-0x1],sil
         0xffffffffa02017a1:  mov    rax,QWORD PTR [rbp-0x9]	!!! tail call count
         0xffffffffa02017a8:  call   0xffffffffa02017d8       !!! is at rbp-0x10
         0xffffffffa02017ad:  leave
         0xffffffffa02017ae:  ret
      
      Fix it by rounding up the BPF stack depth to a multiple of 8, when
      calculating the tail call count offset on stack.
      
      Fixes: ebf7d1f5
      
       ("bpf, x64: rework pro/epilogue and tailcall handling in JIT")
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20220616162037.535469-2-jakub@cloudflare.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b28e4e3f
    • Samuel Holland's avatar
      drm/sun4i: Fix crash during suspend after component bind failure · 0eef1dcb
      Samuel Holland authored
      [ Upstream commit 1342b5b2 ]
      
      If the component driver fails to bind, or is unbound, the driver data
      for the top-level platform device points to a freed drm_device. If the
      system is then suspended, the driver passes this dangling pointer to
      drm_mode_config_helper_suspend(), which crashes.
      
      Fix this by only setting the driver data while the platform driver holds
      a reference to the drm_device.
      
      Fixes: 624b4b48
      
       ("drm: sun4i: Add support for suspending the display driver")
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Reviewed-by: default avatarJernej Skrabec <jernej.skrabec@gmail.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Link: https://lore.kernel.org/r/20220615054254.16352-1-samuel@sholland.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0eef1dcb
    • Jon Maxwell's avatar
      bpf: Fix request_sock leak in sk lookup helpers · b0360743
      Jon Maxwell authored
      [ Upstream commit 3046a827 ]
      
      A customer reported a request_socket leak in a Calico cloud environment. We
      found that a BPF program was doing a socket lookup with takes a refcnt on
      the socket and that it was finding the request_socket but returning the parent
      LISTEN socket via sk_to_full_sk() without decrementing the child request socket
      1st, resulting in request_sock slab object leak. This patch retains the
      existing behaviour of returning full socks to the caller but it also decrements
      the child request_socket if one is present before doing so to prevent the leak.
      
      Thanks to Curtis Taylor for all the help in diagnosing and testing this. And
      thanks to Antoine Tenart for the reproducer and patch input.
      
      v2 of this patch contains, refactor as per Daniel Borkmann's suggestions to
      validate RCU flags on the listen socket so that it balances with bpf_sk_release()
      and update comments as per Martin KaFai Lau's suggestion. One small change to
      Daniels suggestion, put "sk = sk2" under "if (sk2 != sk)" to avoid an extra
      instruction.
      
      Fixes: f7355a6c ("bpf: Check sk_fullsock() before returning from bpf_sk_lookup()")
      Fixes: edbf8c01
      
       ("bpf: add skc_lookup_tcp helper")
      Co-developed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Signed-off-by: default avatarJon Maxwell <jmaxwell37@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarCurtis Taylor <cutaylor-pub@yahoo.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Link: https://lore.kernel.org/bpf/56d6f898-bde0-bb25-3427-12a330b29fb8@iogearbox.net
      Link: https://lore.kernel.org/bpf/20220615011540.813025-1-jmaxwell37@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0360743
    • Jonathan Marek's avatar
      drm/msm: use for_each_sgtable_sg to iterate over scatterlist · 7154e4df
      Jonathan Marek authored
      [ Upstream commit 62b5e322 ]
      
      The dma_map_sgtable() call (used to invalidate cache) overwrites sgt->nents
      with 1, so msm_iommu_pagetable_map maps only the first physical segment.
      
      To fix this problem use for_each_sgtable_sg(), which uses orig_nents.
      
      Fixes: b145c6e6
      
       ("drm/msm: Add support to create a local pagetable")
      Signed-off-by: default avatarJonathan Marek <jonathan@marek.ca>
      Link: https://lore.kernel.org/r/20220613221019.11399-1-jonathan@marek.ca
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7154e4df
    • Ciara Loftus's avatar
      xsk: Fix generic transmit when completion queue reservation fails · 64e6ba7f
      Ciara Loftus authored
      [ Upstream commit a6e944f2 ]
      
      Two points of potential failure in the generic transmit function are:
      
        1. completion queue (cq) reservation failure.
        2. skb allocation failure
      
      Originally the cq reservation was performed first, followed by the skb
      allocation. Commit 67571640 ("xdp: fix possible cq entry leak")
      reversed the order because at the time there was no mechanism available
      to undo the cq reservation which could have led to possible cq entry leaks
      in the event of skb allocation failure. However if the skb allocation is
      performed first and the cq reservation then fails, the xsk skb destructor
      is called which blindly adds the skb address to the already full cq leading
      to undefined behavior.
      
      This commit restores the original order (cq reservation followed by skb
      allocation) and uses the xskq_prod_cancel helper to undo the cq reserve
      in event of skb allocation failure.
      
      Fixes: 67571640
      
       ("xdp: fix possible cq entry leak")
      Signed-off-by: default avatarCiara Loftus <ciara.loftus@intel.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
      Link: https://lore.kernel.org/bpf/20220614070746.8871-1-ciara.loftus@intel.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64e6ba7f
    • Sergey Gorenko's avatar
      scsi: iscsi: Exclude zero from the endpoint ID range · 54abcc52
      Sergey Gorenko authored
      [ Upstream commit f6eed15f ]
      
      The kernel returns an endpoint ID as r.ep_connect_ret.handle in the
      iscsi_uevent. The iscsid validates a received endpoint ID and treats zero
      as an error. The commit referenced in the fixes line changed the endpoint
      ID range, and zero is always assigned to the first endpoint ID.  So, the
      first attempt to create a new iSER connection always fails.
      
      Link: https://lore.kernel.org/r/20220613123854.55073-1-sergeygo@nvidia.com
      Fixes: 3c6ae371
      
       ("scsi: iscsi: Release endpoint ID when its freed")
      Reviewed-by: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
      Reviewed-by: default avatarMike Christie <michael.christie@oracle.com>
      Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
      Signed-off-by: default avatarSergey Gorenko <sergeygo@nvidia.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      54abcc52
    • Rob Clark's avatar
      drm/msm: Switch ordering of runpm put vs devfreq_idle · 0a7a5261
      Rob Clark authored
      [ Upstream commit 49e47761 ]
      
      In msm_devfreq_suspend() we cancel idle_work synchronously so that it
      doesn't run after we power of the hw or in the resume path.  But this
      means that we want to ensure that idle_work is not scheduled *after* we
      no longer hold a runpm ref.  So switch the ordering of pm_runtime_put()
      vs msm_devfreq_idle().
      
      v2. Only move the runpm _put_autosuspend, and not the _mark_last_busy()
      
      Fixes: 9bc95570
      
       ("drm/msm: Devfreq tuning")
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Link: https://lore.kernel.org/r/20210927152928.831245-1-robdclark@gmail.com
      Reviewed-by: default avatarAkhil P Oommen <quic_akhilpo@quicinc.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Link: https://lore.kernel.org/r/20220608161334.2140611-1-robdclark@gmail.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0a7a5261
    • Damien Le Moal's avatar
      scsi: scsi_debug: Fix zone transition to full condition · 7d5fe943
      Damien Le Moal authored
      [ Upstream commit 566d3c57 ]
      
      When a write command to a sequential write required or sequential write
      preferred zone result in the zone write pointer reaching the end of the
      zone, the zone condition must be set to full AND the number of implicitly
      or explicitly open zones updated to have a correct accounting for zone
      resources. However, the function zbc_inc_wp() only sets the zone condition
      to full without updating the open zone counters, resulting in a zone state
      machine breakage.
      
      Introduce the helper function zbc_set_zone_full() and use it in
      zbc_inc_wp() to correctly transition zones to the full condition.
      
      Link: https://lore.kernel.org/r/20220608011302.92061-1-damien.lemoal@opensource.wdc.com
      Fixes: f0d1cf93
      
       ("scsi: scsi_debug: Add ZBC zone commands")
      Reviewed-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7d5fe943
    • Florian Westphal's avatar
      netfilter: use get_random_u32 instead of prandom · d0906b0f
      Florian Westphal authored
      [ Upstream commit b1fd94e7 ]
      
      bh might occur while updating per-cpu rnd_state from user context,
      ie. local_out path.
      
      BUG: using smp_processor_id() in preemptible [00000000] code: nginx/2725
      caller is nft_ng_random_eval+0x24/0x54 [nft_numgen]
      Call Trace:
       check_preemption_disabled+0xde/0xe0
       nft_ng_random_eval+0x24/0x54 [nft_numgen]
      
      Use the random driver instead, this also avoids need for local prandom
      state. Moreover, prandom now uses the random driver since d4150779
      ("random32: use real rng for non-deterministic randomness").
      
      Based on earlier patch from Pablo Neira.
      
      Fixes: 6b2faee0 ("netfilter: nft_meta: place prandom handling in a helper")
      Fixes: 978d8f90
      
       ("netfilter: nft_numgen: add map lookups for numgen random operations")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d0906b0f
    • Maximilian Luz's avatar
      drm/msm: Fix double pm_runtime_disable() call · f7fa3263
      Maximilian Luz authored
      [ Upstream commit ce0db505 ]
      
      Following commit 17e822f7 ("drm/msm: fix unbalanced
      pm_runtime_enable in adreno_gpu_{init, cleanup}"), any call to
      adreno_unbind() will disable runtime PM twice, as indicated by the call
      trees below:
      
        adreno_unbind()
         -> pm_runtime_force_suspend()
         -> pm_runtime_disable()
      
        adreno_unbind()
         -> gpu->funcs->destroy() [= aNxx_destroy()]
         -> adreno_gpu_cleanup()
         -> pm_runtime_disable()
      
      Note that pm_runtime_force_suspend() is called right before
      gpu->funcs->destroy() and both functions are called unconditionally.
      
      With recent addition of the eDP AUX bus code, this problem manifests
      itself when the eDP panel cannot be found yet and probing is deferred.
      On the first probe attempt, we disable runtime PM twice as described
      above. This then causes any later probe attempt to fail with
      
        [drm:adreno_load_gpu [msm]] *ERROR* Couldn't power up the GPU: -13
      
      preventing the driver from loading.
      
      As there seem to be scenarios where the aNxx_destroy() functions are not
      called from adreno_unbind(), simply removing pm_runtime_disable() from
      inside adreno_unbind() does not seem to be the proper fix. This is what
      commit 17e822f7 ("drm/msm: fix unbalanced pm_runtime_enable in
      adreno_gpu_{init, cleanup}") intended to fix. Therefore, instead check
      whether runtime PM is still enabled, and only disable it in that case.
      
      Fixes: 17e822f7
      
       ("drm/msm: fix unbalanced pm_runtime_enable in adreno_gpu_{init, cleanup}")
      Signed-off-by: default avatarMaximilian Luz <luzmaximilian@gmail.com>
      Tested-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
      Link: https://lore.kernel.org/r/20220606211305.189585-1-luzmaximilian@gmail.com
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7fa3263
    • Rob Clark's avatar
      drm/msm: Ensure mmap offset is initialized · c6f6c966
      Rob Clark authored
      [ Upstream commit 036d2072 ]
      
      If a GEM object is allocated, and then exported as a dma-buf fd which is
      mmap'd before or without the GEM buffer being directly mmap'd, the
      vma_node could be unitialized.  This leads to a situation where the CPU
      mapping is not correctly torn down in drm_vma_node_unmap().
      
      Fixes: e5516553
      
       ("drm: call drm_gem_object_funcs.mmap with fake offset")
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Link: https://lore.kernel.org/r/20220531200857.136547-1-robdclark@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c6f6c966