1. 27 Apr, 2022 40 commits
    • Atish Patra's avatar
      RISC-V: KVM: Restrict the extensions that can be disabled · 3d34be2a
      Atish Patra authored
      [ Upstream commit 38d9a4ac
      
       ]
      
      Currently, the config isa register allows us to disable all allowed
      single letter ISA extensions. It shouldn't be the case as vmm shouldn't
      be able to disable base extensions (imac).
      
      These extensions should always be enabled as long as they are enabled
      in the host ISA.
      Signed-off-by: default avatarAtish Patra <atishp@rivosinc.com>
      Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
      Fixes: 92ad8200
      
       ("RISC-V: KVM: Implement
      KVM_GET_ONE_REG/KVM_SET_ONE_REG ioctls")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d34be2a
    • Atish Patra's avatar
      RISC-V: KVM: Remove 's' & 'u' as valid ISA extension · 69a8ee12
      Atish Patra authored
      [ Upstream commit 3ab75a79 ]
      
      There are no ISA extension defined as 's' & 'u' in RISC-V specifications.
      The misa register defines 's' & 'u' bit as Supervisor/User privilege mode
      enabled. But it should not appear in the ISA extension in the device tree.
      
      Remove those from the allowed ISA extension for kvm.
      
      Fixes: a33c72fa
      
       ("RISC-V: KVM: Implement VCPU create, init and
      destroy functions")
      Signed-off-by: default avatarAtish Patra <atishp@rivosinc.com>
      Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      69a8ee12
    • José Roberto de Souza's avatar
      drm/i915/display/psr: Unset enable_psr2_sel_fetch if other checks in... · 18201136
      José Roberto de Souza authored
      drm/i915/display/psr: Unset enable_psr2_sel_fetch if other checks in intel_psr2_config_valid() fails
      
      [ Upstream commit bb023304 ]
      
      If any of the PSR2 checks after intel_psr2_sel_fetch_config_valid()
      fails, enable_psr2_sel_fetch will be kept enabled causing problems
      in the functions that only checks for it and not for has_psr2.
      
      So here moving the check that do not depend on enable_psr2_sel_fetch
      and for the remaning ones jumping to a section that unset
      enable_psr2_sel_fetch in case of failure to support PSR2.
      
      Fixes: 6e43e276
      
       ("drm/i915: Initial implementation of PSR2 selective fetch")
      Cc: Jouni Högander <jouni.hogander@intel.com>
      Reviewed-by: default avatarJouni Högander <jouni.hogander@intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220414151118.21980-1-jose.souza@intel.com
      (cherry picked from commit 554ae8dc
      
      )
      Signed-off-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18201136
    • Eric Dumazet's avatar
      netlink: reset network and mac headers in netlink_dump() · 3711c189
      Eric Dumazet authored
      [ Upstream commit 99c07327 ]
      
      netlink_dump() is allocating an skb, reserves space in it
      but forgets to reset network header.
      
      This allows a BPF program, invoked later from sk_filter()
      to access uninitialized kernel memory from the reserved
      space.
      
      Theorically mac header reset could be omitted, because
      it is set to a special initial value.
      bpf_internal_load_pointer_neg_helper calls skb_mac_header()
      without checking skb_mac_header_was_set().
      Relying on skb->len not being too big seems fragile.
      We also could add a sanity check in bpf_internal_load_pointer_neg_helper()
      to avoid surprises in the future.
      
      syzbot report was:
      
      BUG: KMSAN: uninit-value in ___bpf_prog_run+0xa22b/0xb420 kernel/bpf/core.c:1637
       ___bpf_prog_run+0xa22b/0xb420 kernel/bpf/core.c:1637
       __bpf_prog_run32+0x121/0x180 kernel/bpf/core.c:1796
       bpf_dispatcher_nop_func include/linux/bpf.h:784 [inline]
       __bpf_prog_run include/linux/filter.h:626 [inline]
       bpf_prog_run include/linux/filter.h:633 [inline]
       __bpf_prog_run_save_cb+0x168/0x580 include/linux/filter.h:756
       bpf_prog_run_save_cb include/linux/filter.h:770 [inline]
       sk_filter_trim_cap+0x3bc/0x8c0 net/core/filter.c:150
       sk_filter include/linux/filter.h:905 [inline]
       netlink_dump+0xe0c/0x16c0 net/netlink/af_netlink.c:2276
       netlink_recvmsg+0x1129/0x1c80 net/netlink/af_netlink.c:2002
       sock_recvmsg_nosec net/socket.c:948 [inline]
       sock_recvmsg net/socket.c:966 [inline]
       sock_read_iter+0x5a9/0x630 net/socket.c:1039
       do_iter_readv_writev+0xa7f/0xc70
       do_iter_read+0x52c/0x14c0 fs/read_write.c:786
       vfs_readv fs/read_write.c:906 [inline]
       do_readv+0x432/0x800 fs/read_write.c:943
       __do_sys_readv fs/read_write.c:1034 [inline]
       __se_sys_readv fs/read_write.c:1031 [inline]
       __x64_sys_readv+0xe5/0x120 fs/read_write.c:1031
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Uninit was stored to memory at:
       ___bpf_prog_run+0x96c/0xb420 kernel/bpf/core.c:1558
       __bpf_prog_run32+0x121/0x180 kernel/bpf/core.c:1796
       bpf_dispatcher_nop_func include/linux/bpf.h:784 [inline]
       __bpf_prog_run include/linux/filter.h:626 [inline]
       bpf_prog_run include/linux/filter.h:633 [inline]
       __bpf_prog_run_save_cb+0x168/0x580 include/linux/filter.h:756
       bpf_prog_run_save_cb include/linux/filter.h:770 [inline]
       sk_filter_trim_cap+0x3bc/0x8c0 net/core/filter.c:150
       sk_filter include/linux/filter.h:905 [inline]
       netlink_dump+0xe0c/0x16c0 net/netlink/af_netlink.c:2276
       netlink_recvmsg+0x1129/0x1c80 net/netlink/af_netlink.c:2002
       sock_recvmsg_nosec net/socket.c:948 [inline]
       sock_recvmsg net/socket.c:966 [inline]
       sock_read_iter+0x5a9/0x630 net/socket.c:1039
       do_iter_readv_writev+0xa7f/0xc70
       do_iter_read+0x52c/0x14c0 fs/read_write.c:786
       vfs_readv fs/read_write.c:906 [inline]
       do_readv+0x432/0x800 fs/read_write.c:943
       __do_sys_readv fs/read_write.c:1034 [inline]
       __se_sys_readv fs/read_write.c:1031 [inline]
       __x64_sys_readv+0xe5/0x120 fs/read_write.c:1031
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:81
       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:3244 [inline]
       __kmalloc_node_track_caller+0xde3/0x14f0 mm/slub.c:4972
       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+0x30f/0x16c0 net/netlink/af_netlink.c:2242
       netlink_recvmsg+0x1129/0x1c80 net/netlink/af_netlink.c:2002
       sock_recvmsg_nosec net/socket.c:948 [inline]
       sock_recvmsg net/socket.c:966 [inline]
       sock_read_iter+0x5a9/0x630 net/socket.c:1039
       do_iter_readv_writev+0xa7f/0xc70
       do_iter_read+0x52c/0x14c0 fs/read_write.c:786
       vfs_readv fs/read_write.c:906 [inline]
       do_readv+0x432/0x800 fs/read_write.c:943
       __do_sys_readv fs/read_write.c:1034 [inline]
       __se_sys_readv fs/read_write.c:1031 [inline]
       __x64_sys_readv+0xe5/0x120 fs/read_write.c:1031
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x54/0xd0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      CPU: 0 PID: 3470 Comm: syz-executor751 Not tainted 5.17.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: db65a3aa ("netlink: Trim skb to alloc size to avoid MSG_TRUNC")
      Fixes: 9063e21f
      
       ("netlink: autosize skb lengthes")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20220415181442.551228-1-eric.dumazet@gmail.com
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3711c189
    • Vladimir Oltean's avatar
      net: mscc: ocelot: fix broken IP multicast flooding · 09ea4db1
      Vladimir Oltean authored
      [ Upstream commit 4cf35a2b ]
      
      When the user runs:
      bridge link set dev $br_port mcast_flood on
      
      this command should affect not only L2 multicast, but also IPv4 and IPv6
      multicast.
      
      In the Ocelot switch, unknown multicast gets flooded according to
      different PGIDs according to its type, and PGID_MC only handles L2
      multicast. Therefore, by leaving PGID_MCIPV4 and PGID_MCIPV6 at their
      default value of 0, unknown IP multicast traffic is never flooded.
      
      Fixes: 421741ea
      
       ("net: mscc: ocelot: offload bridge port flags to device")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/20220415151950.219660-1-vladimir.oltean@nxp.com
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      09ea4db1
    • Kurt Kanzenbach's avatar
      net: dsa: hellcreek: Calculate checksums in tagger · 465e7756
      Kurt Kanzenbach authored
      [ Upstream commit 0763120b ]
      
      In case the checksum calculation is offloaded to the DSA master network
      interface, it will include the switch trailing tag. As soon as the switch strips
      that tag on egress, the calculated checksum is wrong.
      
      Therefore, add the checksum calculation to the tagger (if required) before
      adding the switch tag. This way, the hellcreek code works with all DSA master
      interfaces regardless of their declared feature set.
      
      Fixes: 01ef09ca
      
       ("net: dsa: Add tag handling for Hirschmann Hellcreek switches")
      Signed-off-by: default avatarKurt Kanzenbach <kurt@linutronix.de>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220415103320.90657-1-kurt@linutronix.de
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      465e7756
    • Oliver Hartkopp's avatar
      can: isotp: stop timeout monitoring when no first frame was sent · f4f1c8f9
      Oliver Hartkopp authored
      [ Upstream commit d7349708 ]
      
      The first attempt to fix a the 'impossible' WARN_ON_ONCE(1) in
      isotp_tx_timer_handler() focussed on the identical CAN IDs created by
      the syzbot reproducer and lead to upstream fix/commit 3ea56642
      ("can: isotp: sanitize CAN ID checks in isotp_bind()"). But this did
      not catch the root cause of the wrong tx.state in the tx_timer handler.
      
      In the isotp 'first frame' case a timeout monitoring needs to be started
      before the 'first frame' is send. But when this sending failed the timeout
      monitoring for this specific frame has to be disabled too.
      
      Otherwise the tx_timer is fired with the 'warn me' tx.state of ISOTP_IDLE.
      
      Fixes: e057dd3f ("can: add ISO 15765-2:2016 transport protocol")
      Link: https://lore.kernel.org/all/20220405175112.2682-1-socketcan@hartkopp.net
      
      
      Reported-by: syzbot+2339c27f5c66c652843e@syzkaller.appspotmail.com
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4f1c8f9
    • Eric Dumazet's avatar
      ipv6: make ip6_rt_gc_expire an atomic_t · cd69bf33
      Eric Dumazet authored
      [ Upstream commit 9cb7c013 ]
      
      Reads and Writes to ip6_rt_gc_expire always have been racy,
      as syzbot reported lately [1]
      
      There is a possible risk of under-flow, leading
      to unexpected high value passed to fib6_run_gc(),
      although I have not observed this in the field.
      
      Hosts hitting ip6_dst_gc() very hard are under pretty bad
      state anyway.
      
      [1]
      BUG: KCSAN: data-race in ip6_dst_gc / ip6_dst_gc
      
      read-write to 0xffff888102110744 of 4 bytes by task 13165 on cpu 1:
       ip6_dst_gc+0x1f3/0x220 net/ipv6/route.c:3311
       dst_alloc+0x9b/0x160 net/core/dst.c:86
       ip6_dst_alloc net/ipv6/route.c:344 [inline]
       icmp6_dst_alloc+0xb2/0x360 net/ipv6/route.c:3261
       mld_sendpack+0x2b9/0x580 net/ipv6/mcast.c:1807
       mld_send_cr net/ipv6/mcast.c:2119 [inline]
       mld_ifc_work+0x576/0x800 net/ipv6/mcast.c:2651
       process_one_work+0x3d3/0x720 kernel/workqueue.c:2289
       worker_thread+0x618/0xa70 kernel/workqueue.c:2436
       kthread+0x1a9/0x1e0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30
      
      read-write to 0xffff888102110744 of 4 bytes by task 11607 on cpu 0:
       ip6_dst_gc+0x1f3/0x220 net/ipv6/route.c:3311
       dst_alloc+0x9b/0x160 net/core/dst.c:86
       ip6_dst_alloc net/ipv6/route.c:344 [inline]
       icmp6_dst_alloc+0xb2/0x360 net/ipv6/route.c:3261
       mld_sendpack+0x2b9/0x580 net/ipv6/mcast.c:1807
       mld_send_cr net/ipv6/mcast.c:2119 [inline]
       mld_ifc_work+0x576/0x800 net/ipv6/mcast.c:2651
       process_one_work+0x3d3/0x720 kernel/workqueue.c:2289
       worker_thread+0x618/0xa70 kernel/workqueue.c:2436
       kthread+0x1a9/0x1e0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30
      
      value changed: 0x00000bb3 -> 0x00000ba9
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 0 PID: 11607 Comm: kworker/0:21 Not tainted 5.18.0-rc1-syzkaller-00037-g42e7a03d-dirty #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: mld mld_ifc_work
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20220413181333.649424-1-eric.dumazet@gmail.com
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd69bf33
    • David Ahern's avatar
      l3mdev: l3mdev_master_upper_ifindex_by_index_rcu should be using netdev_master_upper_dev_get_rcu · ac4fb5ac
      David Ahern authored
      [ Upstream commit 83daab06 ]
      
      Next patch uses l3mdev_master_upper_ifindex_by_index_rcu which throws
      a splat with debug kernels:
      
      [13783.087570] ------------[ cut here ]------------
      [13783.093974] RTNL: assertion failed at net/core/dev.c (6702)
      [13783.100761] WARNING: CPU: 3 PID: 51132 at net/core/dev.c:6702 netdev_master_upper_dev_get+0x16a/0x1a0
      
      [13783.184226] CPU: 3 PID: 51132 Comm: kworker/3:3 Not tainted 5.17.0-custom-100090-g6f963aafb1cc #682
      [13783.194788] Hardware name: Mellanox Technologies Ltd. MSN2010/SA002610, BIOS 5.6.5 08/24/2017
      [13783.204755] Workqueue: mld mld_ifc_work [ipv6]
      [13783.210338] RIP: 0010:netdev_master_upper_dev_get+0x16a/0x1a0
      [13783.217209] Code: 0f 85 e3 fe ff ff e8 65 ac ec fe ba 2e 1a 00 00 48 c7 c6 60 6f 38 83 48 c7 c7 c0 70 38 83 c6 05 5e b5 d7 01 01 e8 c6 29 52 00 <0f> 0b e9 b8 fe ff ff e8 5a 6c 35 ff e9 1c ff ff ff 48 89 ef e8 7d
      [13783.238659] RSP: 0018:ffffc9000b37f5a8 EFLAGS: 00010286
      [13783.244995] RAX: 0000000000000000 RBX: ffff88812ee5c000 RCX: 0000000000000000
      [13783.253379] RDX: ffff88811ce09d40 RSI: ffffffff812d0fcd RDI: fffff5200166fea7
      [13783.261769] RBP: 0000000000000000 R08: 0000000000000001 R09: ffff8882375f4287
      [13783.270138] R10: ffffed1046ebe850 R11: 0000000000000001 R12: dffffc0000000000
      [13783.278510] R13: 0000000000000275 R14: ffffc9000b37f688 R15: ffff8881273b4af8
      [13783.286870] FS:  0000000000000000(0000) GS:ffff888237400000(0000) knlGS:0000000000000000
      [13783.296352] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [13783.303177] CR2: 00007ff25fc9b2e8 CR3: 0000000174d23000 CR4: 00000000001006e0
      [13783.311546] Call Trace:
      [13783.314660]  <TASK>
      [13783.317553]  l3mdev_master_upper_ifindex_by_index_rcu+0x43/0xe0
      ...
      
      Change l3mdev_master_upper_ifindex_by_index_rcu to use
      netdev_master_upper_dev_get_rcu.
      
      Fixes: 6a6d6681
      
       ("l3mdev: add function to retreive upper master")
      Signed-off-by: default avatarIdo Schimmel <idosch@idosch.org>
      Signed-off-by: default avatarDavid Ahern <dsahern@kernel.org>
      Cc: Alexis Bauvin <abauvin@scaleway.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ac4fb5ac
    • Eric Dumazet's avatar
      net/sched: cls_u32: fix possible leak in u32_init_knode() · e133a07e
      Eric Dumazet authored
      [ Upstream commit ec5b0f60 ]
      
      While investigating a related syzbot report,
      I found that whenever call to tcf_exts_init()
      from u32_init_knode() is failing, we end up
      with an elevated refcount on ht->refcnt
      
      To avoid that, only increase the refcount after
      all possible errors have been evaluated.
      
      Fixes: b9a24bb7
      
       ("net_sched: properly handle failure case of tcf_exts_init()")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e133a07e
    • Stephen Hemminger's avatar
      net: restore alpha order to Ethernet devices in config · 7146f83a
      Stephen Hemminger authored
      [ Upstream commit da367ac7 ]
      
      The displayed list of Ethernet devices in make menuconfig
      has gotten out of order. This is mostly due to changes in vendor
      names etc, but also because of new Microsoft entry in wrong place.
      
      This restores so that the display is in order even if the names
      of the sub directories are not.
      
      Fixes: ca9c54d2
      
       ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)")
      Signed-off-by: default avatarStephen Hemminger <stephen@networkplumber.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7146f83a
    • Peilin Ye's avatar
      ip6_gre: Fix skb_under_panic in __gre6_xmit() · 909be893
      Peilin Ye authored
      [ Upstream commit ab198e1d ]
      
      Feng reported an skb_under_panic BUG triggered by running
      test_ip6gretap() in tools/testing/selftests/bpf/test_tunnel.sh:
      
      [   82.492551] skbuff: skb_under_panic: text:ffffffffb268bb8e len:403 put:12 head:ffff9997c5480000 data:ffff9997c547fff8 tail:0x18b end:0x2c0 dev:ip6gretap11
      <...>
      [   82.607380] Call Trace:
      [   82.609389]  <TASK>
      [   82.611136]  skb_push.cold.109+0x10/0x10
      [   82.614289]  __gre6_xmit+0x41e/0x590
      [   82.617169]  ip6gre_tunnel_xmit+0x344/0x3f0
      [   82.620526]  dev_hard_start_xmit+0xf1/0x330
      [   82.623882]  sch_direct_xmit+0xe4/0x250
      [   82.626961]  __dev_queue_xmit+0x720/0xfe0
      <...>
      [   82.633431]  packet_sendmsg+0x96a/0x1cb0
      [   82.636568]  sock_sendmsg+0x30/0x40
      <...>
      
      The following sequence of events caused the BUG:
      
      1. During ip6gretap device initialization, tunnel->tun_hlen (e.g. 4) is
         calculated based on old flags (see ip6gre_calc_hlen());
      2. packet_snd() reserves header room for skb A, assuming
         tunnel->tun_hlen is 4;
      3. Later (in clsact Qdisc), the eBPF program sets a new tunnel key for
         skb A using bpf_skb_set_tunnel_key() (see _ip6gretap_set_tunnel());
      4. __gre6_xmit() detects the new tunnel key, and recalculates
         "tun_hlen" (e.g. 12) based on new flags (e.g. TUNNEL_KEY and
         TUNNEL_SEQ);
      5. gre_build_header() calls skb_push() with insufficient reserved header
         room, triggering the BUG.
      
      As sugguested by Cong, fix it by moving the call to skb_cow_head() after
      the recalculation of tun_hlen.
      
      Reproducer:
      
        OBJ=$LINUX/tools/testing/selftests/bpf/test_tunnel_kern.o
      
        ip netns add at_ns0
        ip link add veth0 type veth peer name veth1
        ip link set veth0 netns at_ns0
        ip netns exec at_ns0 ip addr add 172.16.1.100/24 dev veth0
        ip netns exec at_ns0 ip link set dev veth0 up
        ip link set dev veth1 up mtu 1500
        ip addr add dev veth1 172.16.1.200/24
      
        ip netns exec at_ns0 ip addr add ::11/96 dev veth0
        ip netns exec at_ns0 ip link set dev veth0 up
        ip addr add dev veth1 ::22/96
        ip link set dev veth1 up
      
        ip netns exec at_ns0 \
        	ip link add dev ip6gretap00 type ip6gretap seq flowlabel 0xbcdef key 2 \
        	local ::11 remote ::22
      
        ip netns exec at_ns0 ip addr add dev ip6gretap00 10.1.1.100/24
        ip netns exec at_ns0 ip addr add dev ip6gretap00 fc80::100/96
        ip netns exec at_ns0 ip link set dev ip6gretap00 up
      
        ip link add dev ip6gretap11 type ip6gretap external
        ip addr add dev ip6gretap11 10.1.1.200/24
        ip addr add dev ip6gretap11 fc80::200/24
        ip link set dev ip6gretap11 up
      
        tc qdisc add dev ip6gretap11 clsact
        tc filter add dev ip6gretap11 egress bpf da obj $OBJ sec ip6gretap_set_tunnel
        tc filter add dev ip6gretap11 ingress bpf da obj $OBJ sec ip6gretap_get_tunnel
      
        ping6 -c 3 -w 10 -q ::11
      
      Fixes: 6712abc1
      
       ("ip6_gre: add ip6 gre and gretap collect_md mode")
      Reported-by: default avatarFeng Zhou <zhoufeng.zf@bytedance.com>
      Co-developed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      909be893
    • Peilin Ye's avatar
      ip6_gre: Avoid updating tunnel->tun_hlen in __gre6_xmit() · ff2d7065
      Peilin Ye authored
      [ Upstream commit f40c064e
      
       ]
      
      Do not update tunnel->tun_hlen in data plane code.  Use a local variable
      instead, just like "tunnel_hlen" in net/ipv4/ip_gre.c:gre_fb_xmit().
      Co-developed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ff2d7065
    • Hangbin Liu's avatar
      net/packet: fix packet_sock xmit return value checking · 766df17f
      Hangbin Liu authored
      [ Upstream commit 29e8e659 ]
      
      packet_sock xmit could be dev_queue_xmit, which also returns negative
      errors. So only checking positive errors is not enough, or userspace
      sendmsg may return success while packet is not send out.
      
      Move the net_xmit_errno() assignment in the braces as checkpatch.pl said
      do not use assignment in if condition.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarFlavio Leitner <fbl@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      766df17f
    • Tony Lu's avatar
      net/smc: Fix sock leak when release after smc_shutdown() · fe45368d
      Tony Lu authored
      [ Upstream commit 1a74e993 ]
      
      Since commit e5d5aadc ("net/smc: fix sk_refcnt underflow on linkdown
      and fallback"), for a fallback connection, __smc_release() does not call
      sock_put() if its state is already SMC_CLOSED.
      
      When calling smc_shutdown() after falling back, its state is set to
      SMC_CLOSED but does not call sock_put(), so this patch calls it.
      
      Reported-and-tested-by: syzbot+6e29a053eb165bd50de5@syzkaller.appspotmail.com
      Fixes: e5d5aadc
      
       ("net/smc: fix sk_refcnt underflow on linkdown and fallback")
      Signed-off-by: default avatarTony Lu <tonylu@linux.alibaba.com>
      Acked-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fe45368d
    • David Howells's avatar
      rxrpc: Restore removed timer deletion · be52402f
      David Howells authored
      [ Upstream commit ee3b0826 ]
      
      A recent patch[1] from Eric Dumazet flipped the order in which the
      keepalive timer and the keepalive worker were cancelled in order to fix a
      syzbot reported issue[2].  Unfortunately, this enables the mirror image bug
      whereby the timer races with rxrpc_exit_net(), restarting the worker after
      it has been cancelled:
      
      	CPU 1		CPU 2
      	===============	=====================
      			if (rxnet->live)
      			<INTERRUPT>
      	rxnet->live = false;
       	cancel_work_sync(&rxnet->peer_keepalive_work);
      			rxrpc_queue_work(&rxnet->peer_keepalive_work);
      	del_timer_sync(&rxnet->peer_keepalive_timer);
      
      Fix this by restoring the removed del_timer_sync() so that we try to remove
      the timer twice.  If the timer runs again, it should see ->live == false
      and not restart the worker.
      
      Fixes: 1946014c
      
       ("rxrpc: fix a race in rxrpc_exit_net()")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: Eric Dumazet <edumazet@google.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Link: https://lore.kernel.org/r/20220404183439.3537837-1-eric.dumazet@gmail.com/ [1]
      Link: https://syzkaller.appspot.com/bug?extid=724378c4bb58f703b09a
      
       [2]
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      be52402f
    • Kai Vehmanen's avatar
      ALSA: hda/hdmi: fix warning about PCM count when used with SOF · 77b01d1c
      Kai Vehmanen authored
      [ Upstream commit c7419378 ]
      
      With commit 13046370 ("ALSA: hda/hdmi: let new platforms assign the
      pcm slot dynamically"), old behaviour to consider the HDA pin number,
      when choosing PCM to assign, was dropped.
      
      Build on this change and limit the number of PCMs created to number of
      converters (= maximum number of concurrent display/receivers) when
      "mst_no_extra_pcms" and "dyn_pcm_no_legacy" quirks are both set.
      
      Fix the check in hdmi_find_pcm_slot() to ensure only spec->pcm_used
      entries are considered in the search. Elsewhere in the driver
      spec->pcm_used is already checked properly.
      
      Doing this avoids following warning at SOF driver probe for multiple
      machine drivers:
      
      [  112.425297] sof_sdw sof_sdw: hda_dsp_hdmi_build_controls: no
      PCM in topology for HDMI converter 4
      [  112.425298] sof_sdw sof_sdw: hda_dsp_hdmi_build_controls: no
      PCM in topology for HDMI converter 5
      [  112.425299] sof_sdw sof_sdw: hda_dsp_hdmi_build_controls: no
      PCM in topology for HDMI converter 6
      
      Fixes: 13046370 ("ALSA: hda/hdmi: let new platforms assign the pcm slot dynamically")
      BugLink: https://github.com/thesofproject/linux/issues/2573
      
      Signed-off-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
      Link: https://lore.kernel.org/r/20220414150516.3638283-1-kai.vehmanen@linux.intel.com
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      77b01d1c
    • Jianglei Nie's avatar
      ice: Fix memory leak in ice_get_orom_civd_data() · c7cde701
      Jianglei Nie authored
      [ Upstream commit 7c8881b7 ]
      
      A memory chunk was allocated for orom_data in ice_get_orom_civd_data()
      by vzmalloc(). But when ice_read_flash_module() fails, the allocated
      memory is not freed, which will lead to a memory leak.
      
      We can fix it by freeing the orom_data when ce_read_flash_module() fails.
      
      Fixes: af18d886
      
       ("ice: reduce time to read Option ROM CIVD data")
      Signed-off-by: default avatarJianglei Nie <niejianglei2021@163.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>
      c7cde701
    • Wojciech Drewek's avatar
      ice: fix crash in switchdev mode · 91d47fd5
      Wojciech Drewek authored
      [ Upstream commit d2016651 ]
      
      Below steps end up with crash:
      - modprobe ice
      - devlink dev eswitch set $PF1_PCI mode switchdev
      - echo 64 > /sys/class/net/$PF1/device/sriov_numvfs
      - rmmod ice
      
      Calling ice_eswitch_port_start_xmit while the process of removing
      VFs is in progress ends up with NULL pointer dereference.
      That's because PR netdev is not released but some resources
      are already freed. Fix it by checking if ICE_VF_DIS bit is set.
      
      Call trace:
      [ 1379.595146] BUG: kernel NULL pointer dereference, address: 0000000000000040
      [ 1379.595284] #PF: supervisor read access in kernel mode
      [ 1379.595410] #PF: error_code(0x0000) - not-present page
      [ 1379.595535] PGD 0 P4D 0
      [ 1379.595657] Oops: 0000 [#1] PREEMPT SMP PTI
      [ 1379.595783] CPU: 4 PID: 974 Comm: NetworkManager Kdump: loaded Tainted: G           OE     5.17.0-rc8_mrq_dev-queue+ #12
      [ 1379.595926] Hardware name: Intel Corporation S1200SP/S1200SP, BIOS S1200SP.86B.03.01.0042.013020190050 01/30/2019
      [ 1379.596063] RIP: 0010:ice_eswitch_port_start_xmit+0x46/0xd0 [ice]
      [ 1379.596292] Code: c7 c8 09 00 00 e8 9a c9 fc ff 84 c0 0f 85 82 00 00 00 4c 89 e7 e8 ca 70 fe ff 48 8b 7d 58 48 89 c3 48 85 ff 75 5e 48 8b 53 20 <8b> 42 40 85 c0 74 78 8d 48 01 f0 0f b1 4a 40 75 f2 0f b6 95 84 00
      [ 1379.596456] RSP: 0018:ffffaba0c0d7bad0 EFLAGS: 00010246
      [ 1379.596584] RAX: ffff969c14c71680 RBX: ffff969c14c71680 RCX: 000100107a0f0000
      [ 1379.596715] RDX: 0000000000000000 RSI: ffff969b9d631000 RDI: 0000000000000000
      [ 1379.596846] RBP: ffff969c07b46500 R08: ffff969becfca8ac R09: 0000000000000001
      [ 1379.596977] R10: 0000000000000004 R11: ffffaba0c0d7bbec R12: ffff969b9d631000
      [ 1379.597106] R13: ffffffffc08357a0 R14: ffff969c07b46500 R15: ffff969b9d631000
      [ 1379.597237] FS:  00007f72c0e25c80(0000) GS:ffff969f13500000(0000) knlGS:0000000000000000
      [ 1379.597414] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1379.597562] CR2: 0000000000000040 CR3: 000000012b316006 CR4: 00000000003706e0
      [ 1379.597713] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 1379.597863] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [ 1379.598015] Call Trace:
      [ 1379.598153]  <TASK>
      [ 1379.598294]  dev_hard_start_xmit+0xd9/0x220
      [ 1379.598444]  sch_direct_xmit+0x8a/0x340
      [ 1379.598592]  __dev_queue_xmit+0xa3c/0xd30
      [ 1379.598739]  ? packet_parse_headers+0xb4/0xf0
      [ 1379.598890]  packet_sendmsg+0xa15/0x1620
      [ 1379.599038]  ? __check_object_size+0x46/0x140
      [ 1379.599186]  sock_sendmsg+0x5e/0x60
      [ 1379.599330]  ____sys_sendmsg+0x22c/0x270
      [ 1379.599474]  ? import_iovec+0x17/0x20
      [ 1379.599622]  ? sendmsg_copy_msghdr+0x59/0x90
      [ 1379.599771]  ___sys_sendmsg+0x81/0xc0
      [ 1379.599917]  ? __pollwait+0xd0/0xd0
      [ 1379.600061]  ? preempt_count_add+0x68/0xa0
      [ 1379.600210]  ? _raw_write_lock_irq+0x1a/0x40
      [ 1379.600369]  ? ep_done_scan+0xc9/0x110
      [ 1379.600494]  ? _raw_spin_unlock_irqrestore+0x25/0x40
      [ 1379.600622]  ? preempt_count_add+0x68/0xa0
      [ 1379.600747]  ? _raw_spin_lock_irq+0x1a/0x40
      [ 1379.600899]  ? __fget_light+0x8f/0x110
      [ 1379.601024]  __sys_sendmsg+0x49/0x80
      [ 1379.601148]  ? release_ds_buffers+0x50/0xe0
      [ 1379.601274]  do_syscall_64+0x3b/0x90
      [ 1379.601399]  entry_SYSCALL_64_after_hwframe+0x44/0xae
      [ 1379.601525] RIP: 0033:0x7f72c1e2e35d
      
      Fixes: f5396b8a
      
       ("ice: switchdev slow path")
      Signed-off-by: default avatarWojciech Drewek <wojciech.drewek@intel.com>
      Reported-by: default avatarMarcin Szycik <marcin.szycik@linux.intel.com>
      Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
      Tested-by: default avatarSandeep Penigalapati <sandeep.penigalapati@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      91d47fd5
    • Maciej Fijalkowski's avatar
      ice: allow creating VFs for !CONFIG_NET_SWITCHDEV · 9f58527f
      Maciej Fijalkowski authored
      [ Upstream commit aacca7a8 ]
      
      Currently for !CONFIG_NET_SWITCHDEV kernel builds it is not possible to
      create VFs properly as call to ice_eswitch_configure() returns
      -EOPNOTSUPP for us. This is because CONFIG_ICE_SWITCHDEV depends on
      CONFIG_NET_SWITCHDEV.
      
      Change the ice_eswitch_configure() implementation for
      !CONFIG_ICE_SWITCHDEV to return 0 instead -EOPNOTSUPP and let
      ice_ena_vfs() finish its work properly.
      
      CC: Grzegorz Nitka <grzegorz.nitka@intel.com>
      Fixes: 1a1c40df
      
       ("ice: set and release switchdev environment")
      Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Signed-off-by: default avatarMichal Swiatkowski <michal.swiatkowski@intel.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f58527f
    • Vinicius Costa Gomes's avatar
      igc: Fix suspending when PTM is active · cd1c31eb
      Vinicius Costa Gomes authored
      [ Upstream commit 822f52e7 ]
      
      Some mainboard/CPU combinations, in particular, Alder Lake-S with a
      W680 mainboard, have shown problems (system hangs usually, no kernel
      logs) with suspend/resume when PCIe PTM is enabled and active. In some
      cases, it could be reproduced when removing the igc module.
      
      The best we can do is to stop PTM dialogs from the downstream/device
      side before the interface is brought down. PCIe PTM will be re-enabled
      when the interface is being brought up.
      
      Fixes: a90ec848
      
       ("igc: Add support for PTP getcrosststamp()")
      Signed-off-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Acked-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd1c31eb
    • Sasha Neftin's avatar
      igc: Fix BUG: scheduling while atomic · d7809f64
      Sasha Neftin authored
      [ Upstream commit c80a29f0 ]
      
      Replace usleep_range() method with udelay() method to allow atomic contexts
      in low-level MDIO access functions.
      
      The following issue can be seen by doing the following:
      $ modprobe -r bonding
      $ modprobe -v bonding max_bonds=1 mode=1 miimon=100 use_carrier=0
      $ ip link set bond0 up
      $ ifenslave bond0 eth0 eth1
      
      [  982.357308] BUG: scheduling while atomic: kworker/u64:0/9/0x00000002
      [  982.364431] INFO: lockdep is turned off.
      [  982.368824] Modules linked in: bonding sctp ip6_udp_tunnel udp_tunnel mlx4_ib ib_uverbs ib_core mlx4_en mlx4_core nfp tls sunrpc intel_rapl_msr iTCO_wdt iTCO_vendor_support mxm_wmi dcdbas intel_rapl_common sb_edac x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel rapl intel_cstate intel_uncore pcspkr lpc_ich mei_me ipmi_ssif mei ipmi_si ipmi_devintf ipmi_msghandler wmi acpi_power_meter xfs libcrc32c sr_mod cdrom sd_mod t10_pi sg mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm ahci libahci crc32c_intel libata i2c_algo_bit tg3 megaraid_sas igc dm_mirror dm_region_hash dm_log dm_mod [last unloaded: bonding]
      [  982.437941] CPU: 25 PID: 9 Comm: kworker/u64:0 Kdump: loaded Tainted: G        W        --------- -  - 4.18.0-348.el8.x86_64+debug #1
      [  982.451333] Hardware name: Dell Inc. PowerEdge R730/0H21J3, BIOS 2.7.0 12/005/2017
      [  982.459791] Workqueue: bond0 bond_mii_monitor [bonding]
      [  982.465622] Call Trace:
      [  982.468355]  dump_stack+0x8e/0xd0
      [  982.472056]  __schedule_bug.cold.60+0x3a/0x60
      [  982.476919]  __schedule+0x147b/0x1bc0
      [  982.481007]  ? firmware_map_remove+0x16b/0x16b
      [  982.485967]  ? hrtimer_fixup_init+0x40/0x40
      [  982.490625]  schedule+0xd9/0x250
      [  982.494227]  schedule_hrtimeout_range_clock+0x10d/0x2c0
      [  982.500058]  ? hrtimer_nanosleep_restart+0x130/0x130
      [  982.505598]  ? hrtimer_init_sleeper_on_stack+0x90/0x90
      [  982.511332]  ? usleep_range+0x88/0x130
      [  982.515514]  ? recalibrate_cpu_khz+0x10/0x10
      [  982.520279]  ? ktime_get+0xab/0x1c0
      [  982.524175]  ? usleep_range+0x88/0x130
      [  982.528355]  usleep_range+0xdd/0x130
      [  982.532344]  ? console_conditional_schedule+0x30/0x30
      [  982.537987]  ? igc_put_hw_semaphore+0x17/0x60 [igc]
      [  982.543432]  igc_read_phy_reg_gpy+0x111/0x2b0 [igc]
      [  982.548887]  igc_phy_has_link+0xfa/0x260 [igc]
      [  982.553847]  ? igc_get_phy_id+0x210/0x210 [igc]
      [  982.558894]  ? lock_acquire+0x34d/0x890
      [  982.563187]  ? lock_downgrade+0x710/0x710
      [  982.567659]  ? rcu_read_unlock+0x50/0x50
      [  982.572039]  igc_check_for_copper_link+0x106/0x210 [igc]
      [  982.577970]  ? igc_config_fc_after_link_up+0x840/0x840 [igc]
      [  982.584286]  ? rcu_read_unlock+0x50/0x50
      [  982.588661]  ? lock_release+0x591/0xb80
      [  982.592939]  ? lock_release+0x591/0xb80
      [  982.597220]  igc_has_link+0x113/0x330 [igc]
      [  982.601887]  ? lock_downgrade+0x710/0x710
      [  982.606362]  igc_ethtool_get_link+0x6d/0x90 [igc]
      [  982.611614]  bond_check_dev_link+0x131/0x2c0 [bonding]
      [  982.617350]  ? bond_time_in_interval+0xd0/0xd0 [bonding]
      [  982.623277]  ? rcu_read_lock_held+0x62/0xc0
      [  982.627944]  ? rcu_read_lock_sched_held+0xe0/0xe0
      [  982.633198]  bond_mii_monitor+0x314/0x2500 [bonding]
      [  982.638738]  ? lock_contended+0x880/0x880
      [  982.643214]  ? bond_miimon_link_change+0xa0/0xa0 [bonding]
      [  982.649336]  ? lock_acquire+0x34d/0x890
      [  982.653615]  ? lock_downgrade+0x710/0x710
      [  982.658089]  ? debug_object_deactivate+0x221/0x340
      [  982.663436]  ? rcu_read_unlock+0x50/0x50
      [  982.667811]  ? debug_print_object+0x2b0/0x2b0
      [  982.672672]  ? __switch_to_asm+0x41/0x70
      [  982.677049]  ? __switch_to_asm+0x35/0x70
      [  982.681426]  ? _raw_spin_unlock_irq+0x24/0x40
      [  982.686288]  ? trace_hardirqs_on+0x20/0x195
      [  982.690956]  ? _raw_spin_unlock_irq+0x24/0x40
      [  982.695818]  process_one_work+0x8f0/0x1770
      [  982.700390]  ? pwq_dec_nr_in_flight+0x320/0x320
      [  982.705443]  ? debug_show_held_locks+0x50/0x50
      [  982.710403]  worker_thread+0x87/0xb40
      [  982.714489]  ? process_one_work+0x1770/0x1770
      [  982.719349]  kthread+0x344/0x410
      [  982.722950]  ? kthread_insert_work_sanity_check+0xd0/0xd0
      [  982.728975]  ret_from_fork+0x3a/0x50
      
      Fixes: 5586838f
      
       ("igc: Add code for PHY support")
      Reported-by: default avatarCorinna Vinschen <vinschen@redhat.com>
      Suggested-by: default avatarDima Ruinskiy <dima.ruinskiy@intel.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarCorinna Vinschen <vinschen@redhat.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d7809f64
    • Sasha Neftin's avatar
      igc: Fix infinite loop in release_swfw_sync · 8c785214
      Sasha Neftin authored
      [ Upstream commit 907862e9 ]
      
      An infinite loop may occur if we fail to acquire the HW semaphore,
      which is needed for resource release.
      This will typically happen if the hardware is surprise-removed.
      At this stage there is nothing to do, except log an error and quit.
      
      Fixes: c0071c7a
      
       ("igc: Add HW initialization code")
      Suggested-by: default avatarDima Ruinskiy <dima.ruinskiy@intel.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8c785214
    • Matthias Schiffer's avatar
      spi: cadence-quadspi: fix incorrect supports_op() return value · c222c929
      Matthias Schiffer authored
      [ Upstream commit f1d388f2 ]
      
      Since the conversion to spi-mem, the driver advertised support for
      various operations that cqspi_set_protocol() was never expected to handle
      correctly - in particuar all non-DTR operations with command or address
      buswidth > 1. For DTR, all operations except for 8-8-8 would fail, as
      cqspi_set_protocol() returns -EINVAL.
      
      In non-DTR mode, this resulted in data corruption for SPI-NOR flashes that
      support such operations. As a minimal fix that can be backported to stable
      kernels, simply disallow the unsupported operations again to avoid this
      issue.
      
      Fixes: a314f636
      
       ("mtd: spi-nor: Convert cadence-quadspi to use spi-mem framework")
      Signed-off-by: default avatarMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
      Link: https://lore.kernel.org/r/20220406132832.199777-1-matthias.schiffer@ew.tq-group.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c222c929
    • Sabrina Dubroca's avatar
      esp: limit skb_page_frag_refill use to a single page · b6570308
      Sabrina Dubroca authored
      [ Upstream commit 5bd8baab ]
      
      Commit ebe48d36 ("esp: Fix possible buffer overflow in ESP
      transformation") tried to fix skb_page_frag_refill usage in ESP by
      capping allocsize to 32k, but that doesn't completely solve the issue,
      as skb_page_frag_refill may return a single page. If that happens, we
      will write out of bounds, despite the check introduced in the previous
      patch.
      
      This patch forces COW in cases where we would end up calling
      skb_page_frag_refill with a size larger than a page (first in
      esp_output_head with tailen, then in esp_output_tail with
      skb->data_len).
      
      Fixes: cac2661c ("esp4: Avoid skb_cow_data whenever possible")
      Fixes: 03e2a30f
      
       ("esp6: Avoid skb_cow_data whenever possible")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b6570308
    • Richard Fitzgerald's avatar
      firmware: cs_dsp: Fix overrun of unterminated control name string · 07ab8ba8
      Richard Fitzgerald authored
      [ Upstream commit 5b933c72
      
       ]
      
      For wmfw format v2 and later the coefficient name strings have a length
      field and are NOT null-terminated. Use kasprintf() to convert the
      unterminated string into a null-terminated string in an allocated buffer.
      
      The previous code handled this duplication incorrectly using kmemdup()
      and getting the length from a strlen() of the (unterminated) source string.
      This resulted in creating a string that continued up to the next byte in
      the firmware file that just happened to be 0x00.
      Signed-off-by: default avatarRichard Fitzgerald <rf@opensource.cirrus.com>
      Fixes: f6bc909e ("firmware: cs_dsp: add driver to support firmware loading on Cirrus Logic DSPs")
      Link: https://lore.kernel.org/r/20220412163927.1303470-1-rf@opensource.cirrus.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      07ab8ba8
    • Allen-KH Cheng's avatar
      spi: spi-mtk-nor: initialize spi controller after resume · 71fbe889
      Allen-KH Cheng authored
      [ Upstream commit 317c2045 ]
      
      After system resumes, the registers of nor controller are
      initialized with default values. The nor controller will
      not function properly.
      
      To handle both issues above, we add mtk_nor_init() in
      mtk_nor_resume after pm_runtime_force_resume().
      
      Fixes: 3bfd9103
      
       ("spi: spi-mtk-nor: Add power management support")
      Signed-off-by: default avatarAllen-KH Cheng <allen-kh.cheng@mediatek.com>
      Reviewed-by: default avatarRex-BC Chen <rex-bc.chen@mediatek.com>
      Link: https://lore.kernel.org/r/20220412115743.22641-1-allen-kh.cheng@mediatek.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      71fbe889
    • Herve Codina's avatar
      dmaengine: dw-edma: Fix unaligned 64bit access · 6c7f5be4
      Herve Codina authored
      [ Upstream commit 8fc5133d ]
      
      On some arch (ie aarch64 iMX8MM) unaligned PCIe accesses are
      not allowed and lead to a kernel Oops.
        [ 1911.668835] Unable to handle kernel paging request at virtual address ffff80001bc00a8c
        [ 1911.668841] Mem abort info:
        [ 1911.668844]   ESR = 0x96000061
        [ 1911.668847]   EC = 0x25: DABT (current EL), IL = 32 bits
        [ 1911.668850]   SET = 0, FnV = 0
        [ 1911.668852]   EA = 0, S1PTW = 0
        [ 1911.668853] Data abort info:
        [ 1911.668855]   ISV = 0, ISS = 0x00000061
        [ 1911.668857]   CM = 0, WnR = 1
        [ 1911.668861] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000040ff4000
        [ 1911.668864] [ffff80001bc00a8c] pgd=00000000bffff003, pud=00000000bfffe003, pmd=0068000018400705
        [ 1911.668872] Internal error: Oops: 96000061 [#1] PREEMPT SMP
        ...
      
      The llp register present in the channel group registers is not
      aligned on 64bit.
      
      Fix unaligned 64bit access using two 32bit accesses
      
      Fixes: 04e0a39f
      
       ("dmaengine: dw-edma: Add writeq() and readq() for 64 bits architectures")
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Link: https://lore.kernel.org/r/20220225120252.309404-1-herve.codina@bootlin.com
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6c7f5be4
    • zhangqilong's avatar
      dmaengine: mediatek:Fix PM usage reference leak of mtk_uart_apdma_alloc_chan_resources · 6db48966
      zhangqilong authored
      [ Upstream commit 545b2baa ]
      
      pm_runtime_get_sync will increment pm usage counter even it failed.
      Forgetting to putting operation will result in reference leak here.
      We fix it:
      1) Replacing it with pm_runtime_resume_and_get to keep usage counter
         balanced.
      2) Add putting operation before returning error.
      
      Fixes:9135408c
      
       ("dmaengine: mediatek: Add MediaTek UART APDMA support")
      Signed-off-by: default avatarZhang Qilong <zhangqilong3@huawei.com>
      Link: https://lore.kernel.org/r/20220319022142.142709-1-zhangqilong3@huawei.com
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6db48966
    • Miaoqian Lin's avatar
      dmaengine: imx-sdma: Fix error checking in sdma_event_remap · cd9464a4
      Miaoqian Lin authored
      [ Upstream commit 7104b9cb ]
      
      of_parse_phandle() returns NULL on errors, rather than error
      pointers. Using NULL check on grp_np to fix this.
      
      Fixes: d078cd1b
      
       ("dmaengine: imx-sdma: Add imx6sx platform support")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220308064952.15743-1-linmq006@gmail.com
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd9464a4
    • Dave Jiang's avatar
      dmaengine: idxd: fix device cleanup on disable · 19f4f7df
      Dave Jiang authored
      [ Upstream commit 12e45e89 ]
      
      There are certain parts of WQ that needs to be cleaned up even after WQ is
      disabled during the device disable. Those are the unchangeable parts for a
      WQ when the device is still enabled. Move the cleanup outside of WQ state
      check. Remove idxd_wq_disable_cleanup() inside idxd_wq_device_reset_cleanup()
      since only the unchangeable parts need to be cleared.
      
      Fixes: 0f225705
      
       ("dmaengine: idxd: fix wq settings post wq disable")
      Reported-by: default avatarTony Zhu <tony.zhu@intel.com>
      Tested-by: default avatarTony Zhu <tony.zhu@intel.com>
      Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
      Link: https://lore.kernel.org/r/164919561905.1455025.13542366389944678346.stgit@djiang5-desk3.ch.intel.com
      
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19f4f7df
    • Srinivas Kandagatla's avatar
      ASoC: codecs: wcd934x: do not switch off SIDO Buck when codec is in use · b0b52fe6
      Srinivas Kandagatla authored
      [ Upstream commit db6dd1be
      
       ]
      
      SIDO(Single-Inductor Dual-Ouput) Buck powers up both analog and digital
      circuits along with internal memory, powering off this is the last thing
      that codec should do when going to very low power.
      
      Current code was powering off this Buck if there are no users of sysclk,
      which is not correct. Powering off this buck will result in no register access.
      This code path was never tested until recently after adding pm support
      in SoundWire controller. Fix this by removing the buck poweroff when the
      codec is active and also the code that is not used.
      
      Without this patch all the read/write transactions will never complete and
      results in SLIMBus Errors like:
      
      qcom,slim-ngd qcom,slim-ngd.1: Tx:MT:0x0, MC:0x60, LA:0xcf failed:-110
      wcd934x-codec wcd934x-codec.1.auto: ASoC: error at soc_component_read_no_lock
      	on wcd934x-codec.1.auto for register: [0x00000d05] -110
      qcom,slim-ngd-ctrl 171c0000.slim: Error Interrupt received 0x82000000
      Reported-by: default avatarAmit Pundir <amit.pundir@linaro.org>
      Fixes: a61f3b4f
      
       ("ASoC: wcd934x: add support to wcd9340/wcd9341 codec")
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Tested-by: default avatarAmit Pundir <amit.pundir@linaro.org>
      Link: https://lore.kernel.org/r/20220407094313.2880-1-srinivas.kandagatla@linaro.org
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0b52fe6
    • Miaoqian Lin's avatar
      ASoC: msm8916-wcd-digital: Check failure for devm_snd_soc_register_component · d460550c
      Miaoqian Lin authored
      [ Upstream commit e927b05f ]
      
      devm_snd_soc_register_component() may fails, we should check the error
      and do the corresponding error handling.
      
      Fixes: 150db8c5
      
       ("ASoC: codecs: Add msm8916-wcd digital codec")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220403115239.30140-1-linmq006@gmail.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d460550c
    • Miaoqian Lin's avatar
      ASoC: rk817: Use devm_clk_get() in rk817_platform_probe · cede0aaa
      Miaoqian Lin authored
      [ Upstream commit 8ba08d3a ]
      
      We need to call clk_put() to undo clk_get() in the error path.
      Use devm_clk_get() to obtain a reference to the clock, It has
      the benefit that clk_put() is no longer required.
      
      Fixes: 0d6a04da
      
       ("ASoC: Add Rockchip rk817 audio CODEC support")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220404090753.17940-1-linmq006@gmail.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cede0aaa
    • Peter Ujfalusi's avatar
      ASoC: topology: Correct error handling in soc_tplg_dapm_widget_create() · 1aaf9ffe
      Peter Ujfalusi authored
      [ Upstream commit 9c363532 ]
      
      Academic correction of error handling:
      In case the allocation of kc or kcontrol_type fails the correct label to
      jump is hdr_err since the template.sname has been also allocated at this
      point.
      
      Fixes: d29d41e2
      
       ("ASoC: topology: Add support for multiple kcontrol types to a widget")
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
      Reviewed-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
      Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20220331114957.519-1-peter.ujfalusi@linux.intel.com
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1aaf9ffe
    • Mark Brown's avatar
      ASoC: atmel: Remove system clock tree configuration for at91sam9g20ek · 2b251625
      Mark Brown authored
      [ Upstream commit c775cbf6 ]
      
      The MCLK of the WM8731 on the AT91SAM9G20-EK board is connected to the
      PCK0 output of the SoC, intended in the reference software to be supplied
      using PLLB and programmed to 12MHz. As originally written for use with a
      board file the audio driver was responsible for configuring the entire tree
      but in the conversion to the common clock framework the registration of
      the named pck0 and pllb clocks was removed so the driver has failed to
      instantiate ever since.
      
      Since the WM8731 driver has had support for managing a MCLK provided via
      the common clock framework for some time we can simply drop all the clock
      management code from the machine driver other than configuration of the
      sysclk rate, the CODEC driver still respects that configuration from the
      machine driver.
      
      Fixes: ff78a189
      
       ("ARM: at91: remove old at91-specific clock driver")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarCodrin Ciubotariu <codrin.ciubotariu@microchip.com>
      Link: https://lore.kernel.org/r/20220325154241.1600757-2-broonie@kernel.org
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b251625
    • Tim Crawford's avatar
      ALSA: hda/realtek: Add quirk for Clevo NP70PNP · 5fa01191
      Tim Crawford authored
      commit 86222af0
      
       upstream.
      
      Fixes headset detection on Clevo NP70PNP.
      Signed-off-by: default avatarTim Crawford <tcrawford@system76.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220421170412.3697-1-tcrawford@system76.com
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5fa01191
    • Maurizio Avogadro's avatar
      ALSA: usb-audio: add mapping for MSI MAG X570S Torpedo MAX. · 7bb2f387
      Maurizio Avogadro authored
      commit 4ddef9c4
      
       upstream.
      
      The USB audio device 0db0:a073 based on the Realtek ALC4080 chipset
      exposes all playback volume controls as "PCM". This makes
      distinguishing the individual functions hard.
      The mapping already adopted for device 0db0:419c based on the same
      chipset fixes the issue, apply it for this device too.
      Signed-off-by: default avatarMaurizio Avogadro <mavoga@gmail.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/Yl1ykPaGgsFf3SnW@ryzen
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7bb2f387
    • Takashi Iwai's avatar
      ALSA: usb-audio: Clear MIDI port active flag after draining · c142ff11
      Takashi Iwai authored
      commit 0665886a upstream.
      
      When a rawmidi output stream is closed, it calls the drain at first,
      then does trigger-off only when the drain returns -ERESTARTSYS as a
      fallback.  It implies that each driver should turn off the stream
      properly after the drain.  Meanwhile, USB-audio MIDI interface didn't
      change the port->active flag after the drain.  This may leave the
      output work picking up the port that is closed right now, which
      eventually leads to a use-after-free for the already released rawmidi
      object.
      
      This patch fixes the bug by properly clearing the port->active flag
      after the output drain.
      
      Reported-by: syzbot+70e777a39907d6d5fd0a@syzkaller.appspotmail.com
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/00000000000011555605dceaff03@google.com
      Link: https://lore.kernel.org/r/20220420130247.22062-1-tiwai@suse.de
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c142ff11
    • Eric Dumazet's avatar
      net/sched: cls_u32: fix netns refcount changes in u32_change() · 64c87076
      Eric Dumazet authored
      commit 3db09e76 upstream.
      
      We are now able to detect extra put_net() at the moment
      they happen, instead of much later in correct code paths.
      
      u32_init_knode() / tcf_exts_init() populates the ->exts.net
      pointer, but as mentioned in tcf_exts_init(),
      the refcount on netns has not been elevated yet.
      
      The refcount is taken only once tcf_exts_get_net()
      is called.
      
      So the two u32_destroy_key() calls from u32_change()
      are attempting to release an invalid reference on the netns.
      
      syzbot report:
      
      refcount_t: decrement hit 0; leaking memory.
      WARNING: CPU: 0 PID: 21708 at lib/refcount.c:31 refcount_warn_saturate+0xbf/0x1e0 lib/refcount.c:31
      Modules linked in:
      CPU: 0 PID: 21708 Comm: syz-executor.5 Not tainted 5.18.0-rc2-next-20220412-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:refcount_warn_saturate+0xbf/0x1e0 lib/refcount.c:31
      Code: 1d 14 b6 b2 09 31 ff 89 de e8 6d e9 89 fd 84 db 75 e0 e8 84 e5 89 fd 48 c7 c7 40 aa 26 8a c6 05 f4 b5 b2 09 01 e8 e5 81 2e 05 <0f> 0b eb c4 e8 68 e5 89 fd 0f b6 1d e3 b5 b2 09 31 ff 89 de e8 38
      RSP: 0018:ffffc900051af1b0 EFLAGS: 00010286
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: 0000000000040000 RSI: ffffffff8160a0c8 RDI: fffff52000a35e28
      RBP: 0000000000000004 R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffff81604a9e R11: 0000000000000000 R12: 1ffff92000a35e3b
      R13: 00000000ffffffef R14: ffff8880211a0194 R15: ffff8880577d0a00
      FS:  00007f25d183e700(0000) GS:ffff8880b9c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f19c859c028 CR3: 0000000051009000 CR4: 00000000003506f0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       __refcount_dec include/linux/refcount.h:344 [inline]
       refcount_dec include/linux/refcount.h:359 [inline]
       ref_tracker_free+0x535/0x6b0 lib/ref_tracker.c:118
       netns_tracker_free include/net/net_namespace.h:327 [inline]
       put_net_track include/net/net_namespace.h:341 [inline]
       tcf_exts_put_net include/net/pkt_cls.h:255 [inline]
       u32_destroy_key.isra.0+0xa7/0x2b0 net/sched/cls_u32.c:394
       u32_change+0xe01/0x3140 net/sched/cls_u32.c:909
       tc_new_tfilter+0x98d/0x2200 net/sched/cls_api.c:2148
       rtnetlink_rcv_msg+0x80d/0xb80 net/core/rtnetlink.c:6016
       netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2495
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:725
       ____sys_sendmsg+0x6e2/0x800 net/socket.c:2413
       ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
       __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f25d0689049
      Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f25d183e168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
      RAX: ffffffffffffffda RBX: 00007f25d079c030 RCX: 00007f25d0689049
      RDX: 0000000000000000 RSI: 0000000020000340 RDI: 0000000000000005
      RBP: 00007f25d06e308d R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
      R13: 00007ffd0b752e3f R14: 00007f25d183e300 R15: 0000000000022000
       </TASK>
      
      Fixes: 35c55fc1
      
       ("cls_u32: use tcf_exts_get_net() before call_rcu()")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64c87076