Skip to content
  1. Feb 09, 2022
    • Dan Carpenter's avatar
      drm/i915/overlay: Prevent divide by zero bugs in scaling · 76aad713
      Dan Carpenter authored
      commit 90a3d22f upstream.
      
      Smatch detected a divide by zero bug in check_overlay_scaling().
      
          drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_height'.
          drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling()
          error: potential divide by zero bug '/ rec->dst_width'.
      
      Prevent this by ensuring that the dst height and width are non-zero.
      
      Fixes: 02e792fb
      
       ("drm/i915: implement drmmode overlay support v4")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@kili
      (cherry picked from commit cf5b64f7
      
      )
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      76aad713
    • Anitha Chrisanthus's avatar
      drm/kmb: Fix for build errors with Warray-bounds · cb64de55
      Anitha Chrisanthus authored
      commit 43f25179 upstream.
      
      This fixes the following build error
      
      drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
      drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
        165 |                 kmb->plane_status[plane_id].ctrl =
        LCD_CTRL_GL2_ENABLE;
        |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
        In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
        drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
        61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
        |                                         ^~~~~~~~~~~~
        drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
        162 |  kmb->plane_status[plane_id].ctrl =  LCD_CTRL_GL1_ENABLE;
        |                 ~~~~~~~~~~~~~~~~~^~~~~~~~~~
        In file included from
        drivers/gpu/drm/kmb/kmb_plane.c:17:
        drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
        61 |         struct layer_status  plane_status[KMB_MAX_PLANES];
        |
        ^~~~~~~~~~~~
      
      Fixes: 7f7b96a8
      
       ("drm/kmb: Add support for KeemBay Display")
      Signed-off-by: default avatarAnitha Chrisanthus <anitha.chrisanthus@intel.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220127194227.2213608-1-anitha.chrisanthus@intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb64de55
    • Alexander Stein's avatar
      drm: mxsfb: Fix NULL pointer dereference · 6f9267e0
      Alexander Stein authored
      commit 622c9a3a upstream.
      
      mxsfb should not ever dereference the NULL pointer which
      drm_atomic_get_new_bridge_state is allowed to return.
      Assume a fixed format instead.
      
      Fixes: b776b0f0
      
       ("drm: mxsfb: Use bus_format from the nearest bridge if present")
      Signed-off-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202081755.145716-3-alexander.stein@ew.tq-group.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6f9267e0
    • Yannick Vignon's avatar
      net: stmmac: ensure PTP time register reads are consistent · c16fb9eb
      Yannick Vignon authored
      commit 80d46090 upstream.
      
      Even if protected from preemption and interrupts, a small time window
      remains when the 2 register reads could return inconsistent values,
      each time the "seconds" register changes. This could lead to an about
      1-second error in the reported time.
      
      Add logic to ensure the "seconds" and "nanoseconds" values are consistent.
      
      Fixes: 92ba6888
      
       ("stmmac: add the support for PTP hw clock driver")
      Signed-off-by: default avatarYannick Vignon <yannick.vignon@nxp.com>
      Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Link: https://lore.kernel.org/r/20220203160025.750632-1-yannick.vignon@oss.nxp.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c16fb9eb
    • Daniel Borkmann's avatar
      net, neigh: Do not trigger immediate probes on NUD_FAILED from neigh_managed_work · 203a35eb
      Daniel Borkmann authored
      commit 4a81f6da upstream.
      
      syzkaller was able to trigger a deadlock for NTF_MANAGED entries [0]:
      
        kworker/0:16/14617 is trying to acquire lock:
        ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: ___neigh_create+0x9e1/0x2990 net/core/neighbour.c:652
        [...]
        but task is already holding lock:
        ffffffff8d4dd370 (&tbl->lock){++-.}-{2:2}, at: neigh_managed_work+0x35/0x250 net/core/neighbour.c:1572
      
      The neighbor entry turned to NUD_FAILED state, where __neigh_event_send()
      triggered an immediate probe as per commit cd28ca0a ("neigh: reduce
      arp latency") via neigh_probe() given table lock was held.
      
      One option to fix this situation is to defer the neigh_probe() back to
      the neigh_timer_handler() similarly as pre cd28ca0a. For the case
      of NTF_MANAGED, this deferral is acceptable given this only happens on
      actual failure state and regular / expected state is NUD_VALID with the
      entry already present.
      
      The fix adds a parameter to __neigh_event_send() in order to communicate
      whether immediate probe is allowed or disallowed. Existing call-sites
      of neigh_event_send() default as-is to immediate probe. However, the
      neigh_managed_work() disables it via use of neigh_event_send_probe().
      
      [0] <TASK>
        __dump_stack lib/dump_stack.c:88 [inline]
        dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
        print_deadlock_bug kernel/locking/lockdep.c:2956 [inline]
        check_deadlock kernel/locking/lockdep.c:2999 [inline]
        validate_chain kernel/locking/lockdep.c:3788 [inline]
        __lock_acquire.cold+0x149/0x3ab kernel/locking/lockdep.c:5027
        lock_acquire kernel/locking/lockdep.c:5639 [inline]
        lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604
        __raw_write_lock_bh include/linux/rwlock_api_smp.h:202 [inline]
        _raw_write_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:334
        ___neigh_create+0x9e1/0x2990 net/core/neighbour.c:652
        ip6_finish_output2+0x1070/0x14f0 net/ipv6/ip6_output.c:123
        __ip6_finish_output net/ipv6/ip6_output.c:191 [inline]
        __ip6_finish_output+0x61e/0xe90 net/ipv6/ip6_output.c:170
        ip6_finish_output+0x32/0x200 net/ipv6/ip6_output.c:201
        NF_HOOK_COND include/linux/netfilter.h:296 [inline]
        ip6_output+0x1e4/0x530 net/ipv6/ip6_output.c:224
        dst_output include/net/dst.h:451 [inline]
        NF_HOOK include/linux/netfilter.h:307 [inline]
        ndisc_send_skb+0xa99/0x17f0 net/ipv6/ndisc.c:508
        ndisc_send_ns+0x3a9/0x840 net/ipv6/ndisc.c:650
        ndisc_solicit+0x2cd/0x4f0 net/ipv6/ndisc.c:742
        neigh_probe+0xc2/0x110 net/core/neighbour.c:1040
        __neigh_event_send+0x37d/0x1570 net/core/neighbour.c:1201
        neigh_event_send include/net/neighbour.h:470 [inline]
        neigh_managed_work+0x162/0x250 net/core/neighbour.c:1574
        process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307
        worker_thread+0x657/0x1110 kernel/workqueue.c:2454
        kthread+0x2e9/0x3a0 kernel/kthread.c:377
        ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
        </TASK>
      
      Fixes: 7482e384
      
       ("net, neigh: Add NTF_MANAGED flag for managed neighbor entries")
      Reported-by: default avatar <syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Roopa Prabhu <roopa@nvidia.com>
      Tested-by: default avatar <syzbot+5239d0e1778a500d477a@syzkaller.appspotmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20220201193942.5055-1-daniel@iogearbox.net
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      203a35eb
    • Camel Guo's avatar
      net: stmmac: dump gmac4 DMA registers correctly · 40d20d9a
      Camel Guo authored
      commit 7af037c3 upstream.
      
      Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are
      located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump
      gmac4 DMA registers correctly, this commit checks if a net_device has
      gmac4 and uses different logic to dump its DMA registers.
      
      This fixes the following KASAN warning, which can normally be triggered
      by a command similar like "ethtool -d eth0":
      
      BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30
      Write of size 4 at addr ffffffc010177100 by task ethtool/1839
       kasan_report+0x200/0x21c
       __asan_report_store4_noabort+0x34/0x60
       dwmac4_dump_dma_regs+0x6d4/0xb30
       stmmac_ethtool_gregs+0x110/0x204
       ethtool_get_regs+0x200/0x4b0
       dev_ethtool+0x1dac/0x3800
       dev_ioctl+0x7c0/0xb50
       sock_ioctl+0x298/0x6c4
       ...
      
      Fixes: fbf68229
      
       ("net: stmmac: unify registers dumps methods")
      Signed-off-by: default avatarCamel Guo <camelg@axis.com>
      Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40d20d9a
    • Lior Nahmanson's avatar
      net: macsec: Verify that send_sci is on when setting Tx sci explicitly · 40c80a3f
      Lior Nahmanson authored
      commit d0cfa548 upstream.
      
      When setting Tx sci explicit, the Rx side is expected to use this
      sci and not recalculate it from the packet.However, in case of Tx sci
      is explicit and send_sci is off, the receiver is wrongly recalculate
      the sci from the source MAC address which most likely be different
      than the explicit sci.
      
      Fix by preventing such configuration when macsec newlink is established
      and return EINVAL error code on such cases.
      
      Fixes: c09440f7
      
       ("macsec: introduce IEEE 802.1AE driver")
      Signed-off-by: default avatarLior Nahmanson <liorna@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarRaed Salem <raeds@nvidia.com>
      Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      40c80a3f
    • Lior Nahmanson's avatar
      net: macsec: Fix offload support for NETDEV_UNREGISTER event · 8299be16
      Lior Nahmanson authored
      commit 9cef24c8 upstream.
      
      Current macsec netdev notify handler handles NETDEV_UNREGISTER event by
      releasing relevant SW resources only, this causes resources leak in case
      of macsec HW offload, as the underlay driver was not notified to clean
      it's macsec offload resources.
      
      Fix by calling the underlay driver to clean it's relevant resources
      by moving offload handling from macsec_dellink() to macsec_common_dellink()
      when handling NETDEV_UNREGISTER event.
      
      Fixes: 3cf3227a
      
       ("net: macsec: hardware offloading infrastructure")
      Signed-off-by: default avatarLior Nahmanson <liorna@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarRaed Salem <raeds@nvidia.com>
      Reviewed-by: default avatarAntoine Tenart <atenart@kernel.org>
      Link: https://lore.kernel.org/r/1643542141-28956-1-git-send-email-raeds@nvidia.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8299be16
    • Jisheng Zhang's avatar
      net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() · 5dc4be3b
      Jisheng Zhang authored
      commit 64495203 upstream.
      
      There are two issues with runtime pm handling in stmmac_dvr_remove():
      
      1. the mac is runtime suspended before stopping dma and rx/tx. We
      need to ensure the device is properly resumed back.
      
      2. the stmmaceth clk enable/disable isn't balanced in both exit and
      error handling code path. Take the exit code path for example, when we
      unbind the driver or rmmod the driver module, the mac is runtime
      suspended as said above, so the stmmaceth clk is disabled, but
      	stmmac_dvr_remove()
      	  stmmac_remove_config_dt()
      	    clk_disable_unprepare()
      CCF will complain this time. The error handling code path suffers
      from the similar situtaion.
      
      Here are kernel warnings in error handling code path on Allwinner D1
      platform:
      
      [    1.604695] ------------[ cut here ]------------
      [    1.609328] bus-emac already disabled
      [    1.613015] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:952 clk_core_disable+0xcc/0xec
      [    1.621039] CPU: 0 PID: 38 Comm: kworker/u2:1 Not tainted 5.14.0-rc4#1
      [    1.627653] Hardware name: Allwinner D1 NeZha (DT)
      [    1.632443] Workqueue: events_unbound deferred_probe_work_func
      [    1.638286] epc : clk_core_disable+0xcc/0xec
      [    1.642561]  ra : clk_core_disable+0xcc/0xec
      [    1.646835] epc : ffffffff8023c2ec ra : ffffffff8023c2ec sp : ffffffd00411bb10
      [    1.654054]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : ffffffff80ed6a6f
      [    1.661272]  t1 : ffffffff80ed6a60 t2 : 0000000000000000 s0 : ffffffe001509e00
      [    1.668489]  s1 : 0000000000000001 a0 : 0000000000000019 a1 : ffffffff80e80bd8
      [    1.675707]  a2 : 00000000ffffefff a3 : 00000000000000f4 a4 : 0000000000000002
      [    1.682924]  a5 : 0000000000000001 a6 : 0000000000000030 a7 : 00000000028f5c29
      [    1.690141]  s2 : 0000000000000800 s3 : ffffffe001375000 s4 : ffffffe01fdf7a80
      [    1.697358]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
      [    1.704577]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
      [    1.711794]  s11: ffffffe001b80760 t3 : 0000000000000062 t4 : ffffffffffffffff
      [    1.719012]  t5 : ffffffff80e0f6d8 t6 : ffffffd00411b8f0
      [    1.724321] status: 8000000201800100 badaddr: 0000000000000000 cause: 0000000000000003
      [    1.732233] [<ffffffff8023c2ec>] clk_core_disable+0xcc/0xec
      [    1.737810] [<ffffffff80240430>] clk_disable+0x38/0x78
      [    1.742956] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    1.748451] [<ffffffff8031a500>] stmmac_remove_config_dt+0x1c/0x4c
      [    1.754646] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
      [    1.760484] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    1.765975] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
      [    1.771382] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
      [    1.777305] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
      [    1.783402] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
      [    1.789324] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
      [    1.795508] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
      [    1.802125] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
      [    1.807701] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
      [    1.813277] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
      [    1.818852] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
      [    1.825122] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
      [    1.830872] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
      [    1.836362] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    1.841335] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    1.846304] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
      [    1.852054] [<ffffffff80026564>] kthread+0x124/0x160
      [    1.857021] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
      [    1.862770] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
      [    1.868956] ---[ end trace 8d5c6046255f84a0 ]---
      [    1.873675] ------------[ cut here ]------------
      [    1.878366] bus-emac already unprepared
      [    1.882378] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:810 clk_core_unprepare+0xe4/0x168
      [    1.890673] CPU: 0 PID: 38 Comm: kworker/u2:1 Tainted: G        W	5.14.0-rc4 #1
      [    1.898674] Hardware name: Allwinner D1 NeZha (DT)
      [    1.903464] Workqueue: events_unbound deferred_probe_work_func
      [    1.909305] epc : clk_core_unprepare+0xe4/0x168
      [    1.913840]  ra : clk_core_unprepare+0xe4/0x168
      [    1.918375] epc : ffffffff8023d6cc ra : ffffffff8023d6cc sp : ffffffd00411bb10
      [    1.925593]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : 0000000000000002
      [    1.932811]  t1 : ffffffe01f743be0 t2 : 0000000000000040 s0 : ffffffe001509e00
      [    1.940029]  s1 : 0000000000000001 a0 : 000000000000001b a1 : ffffffe00143a800
      [    1.947246]  a2 : 0000000000000000 a3 : 00000000000000f4 a4 : 0000000000000001
      [    1.954463]  a5 : 0000000000000000 a6 : 0000000005fce2a5 a7 : 0000000000000001
      [    1.961680]  s2 : 0000000000000800 s3 : ffffffff80afeb90 s4 : ffffffe01fdf7a80
      [    1.968898]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
      [    1.976115]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
      [    1.983333]  s11: ffffffe001b80760 t3 : ffffffff80b39120 t4 : 0000000000000001
      [    1.990550]  t5 : 0000000000000000 t6 : ffffffe001600002
      [    1.995859] status: 8000000201800120 badaddr: 0000000000000000 cause: 0000000000000003
      [    2.003771] [<ffffffff8023d6cc>] clk_core_unprepare+0xe4/0x168
      [    2.009609] [<ffffffff802403a0>] clk_unprepare+0x24/0x3c
      [    2.014929] [<ffffffff8031a508>] stmmac_remove_config_dt+0x24/0x4c
      [    2.021125] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
      [    2.026965] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    2.032463] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
      [    2.037871] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
      [    2.043795] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
      [    2.049892] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
      [    2.055815] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
      [    2.061999] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
      [    2.068616] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
      [    2.074193] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
      [    2.079769] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
      [    2.085345] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
      [    2.091616] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
      [    2.097367] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
      [    2.102858] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    2.107830] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    2.112800] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
      [    2.118551] [<ffffffff80026564>] kthread+0x124/0x160
      [    2.123520] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
      [    2.129268] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
      [    2.135455] ---[ end trace 8d5c6046255f84a1 ]---
      
      Fixes: 5ec55823
      
       ("net: stmmac: add clocks management for gmac driver")
      Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5dc4be3b
    • Yuji Ishikawa's avatar
      net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request. · 262c05aa
      Yuji Ishikawa authored
      commit 928d6fe9
      
       upstream.
      
      Variable clk_sel_val is not initialized in the default case of the first switch statement.
      In that case, the function should return immediately without any changes to the hardware.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Fixes: b38dd98f
      
       ("net: stmmac: Add Toshiba Visconti SoCs glue driver")
      Signed-off-by: default avatarYuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
      Reviewed-by: default avatarNobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      262c05aa
    • Wen Gu's avatar
      net/smc: Forward wakeup to smc socket waitqueue after fallback · 504078fb
      Wen Gu authored
      commit 341adeec upstream.
      
      When we replace TCP with SMC and a fallback occurs, there may be
      some socket waitqueue entries remaining in smc socket->wq, such
      as eppoll_entries inserted by userspace applications.
      
      After the fallback, data flows over TCP/IP and only clcsocket->wq
      will be woken up. Applications can't be notified by the entries
      which were inserted in smc socket->wq before fallback. So we need
      a mechanism to wake up smc socket->wq at the same time if some
      entries remaining in it.
      
      The current workaround is to transfer the entries from smc socket->wq
      to clcsock->wq during the fallback. But this may cause a crash
      like this:
      
       general protection fault, probably for non-canonical address 0xdead000000000100: 0000 [#1] PREEMPT SMP PTI
       CPU: 3 PID: 0 Comm: swapper/3 Kdump: loaded Tainted: G E     5.16.0+ #107
       RIP: 0010:__wake_up_common+0x65/0x170
       Call Trace:
        <IRQ>
        __wake_up_common_lock+0x7a/0xc0
        sock_def_readable+0x3c/0x70
        tcp_data_queue+0x4a7/0xc40
        tcp_rcv_established+0x32f/0x660
        ? sk_filter_trim_cap+0xcb/0x2e0
        tcp_v4_do_rcv+0x10b/0x260
        tcp_v4_rcv+0xd2a/0xde0
        ip_protocol_deliver_rcu+0x3b/0x1d0
        ip_local_deliver_finish+0x54/0x60
        ip_local_deliver+0x6a/0x110
        ? tcp_v4_early_demux+0xa2/0x140
        ? tcp_v4_early_demux+0x10d/0x140
        ip_sublist_rcv_finish+0x49/0x60
        ip_sublist_rcv+0x19d/0x230
        ip_list_rcv+0x13e/0x170
        __netif_receive_skb_list_core+0x1c2/0x240
        netif_receive_skb_list_internal+0x1e6/0x320
        napi_complete_done+0x11d/0x190
        mlx5e_napi_poll+0x163/0x6b0 [mlx5_core]
        __napi_poll+0x3c/0x1b0
        net_rx_action+0x27c/0x300
        __do_softirq+0x114/0x2d2
        irq_exit_rcu+0xb4/0xe0
        common_interrupt+0xba/0xe0
        </IRQ>
        <TASK>
      
      The crash is caused by privately transferring waitqueue entries from
      smc socket->wq to clcsock->wq. The owners of these entries, such as
      epoll, have no idea that the entries have been transferred to a
      different socket wait queue and still use original waitqueue spinlock
      (smc socket->wq.wait.lock) to make the entries operation exclusive,
      but it doesn't work. The operations to the entries, such as removing
      from the waitqueue (now is clcsock->wq after fallback), may cause a
      crash when clcsock waitqueue is being iterated over at the moment.
      
      This patch tries to fix this by no longer transferring wait queue
      entries privately, but introducing own implementations of clcsock's
      callback functions in fallback situation. The callback functions will
      forward the wakeup to smc socket->wq if clcsock->wq is actually woken
      up and smc socket->wq has remaining entries.
      
      Fixes: 2153bd1e
      
       ("net/smc: Transfer remaining wait queue entries during fallback")
      Suggested-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarWen Gu <guwen@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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      504078fb
    • Miquel Raynal's avatar
      net: ieee802154: Return meaningful error codes from the netlink helpers · e2e9d2e7
      Miquel Raynal authored
      commit 79c37ca7 upstream.
      
      Returning -1 does not indicate anything useful.
      
      Use a standard and meaningful error code instead.
      
      Fixes: a26c5fd7
      
       ("nl802154: add support for security layer")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-6-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2e9d2e7
    • Phil Sutter's avatar
      netfilter: nft_reject_bridge: Fix for missing reply from prerouting · d2295407
      Phil Sutter authored
      commit aeac4554 upstream.
      
      Prior to commit fa538f7c ("netfilter: nf_reject: add reject skbuff
      creation helpers"), nft_reject_bridge did not assign to nskb->dev before
      passing nskb on to br_forward(). The shared skbuff creation helpers
      introduced in above commit do which seems to confuse br_forward() as
      reject statements in prerouting hook won't emit a packet anymore.
      
      Fix this by simply passing NULL instead of 'dev' to the helpers - they
      use the pointer for just that assignment, nothing else.
      
      Fixes: fa538f7c
      
       ("netfilter: nf_reject: add reject skbuff creation helpers")
      Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2295407
    • Miquel Raynal's avatar
      net: ieee802154: ca8210: Stop leaking skb's · 21feb6df
      Miquel Raynal authored
      commit 621b24b0 upstream.
      
      Upon error the ieee802154_xmit_complete() helper is not called. Only
      ieee802154_wake_queue() is called manually. We then leak the skb
      structure.
      
      Free the skb structure upon error before returning.
      
      Fixes: ded845a7
      
       ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-5-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21feb6df
    • Miquel Raynal's avatar
      net: ieee802154: mcr20a: Fix lifs/sifs periods · 81704045
      Miquel Raynal authored
      commit d753c400 upstream.
      
      These periods are expressed in time units (microseconds) while 40 and 12
      are the number of symbol durations these periods will last. We need to
      multiply them both with phy->symbol_duration in order to get these
      values in microseconds.
      
      Fixes: 8c6ad9cc
      
       ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-3-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      81704045
    • Miquel Raynal's avatar
      net: ieee802154: hwsim: Ensure proper channel selection at probe time · 03b0f859
      Miquel Raynal authored
      commit 1293fccc upstream.
      
      Drivers are expected to set the PHY current_channel and current_page
      according to their default state. The hwsim driver is advertising being
      configured on channel 13 by default but that is not reflected in its own
      internal pib structure. In order to ensure that this driver consider the
      current channel as being 13 internally, we at least need to set the
      pib->channel field to 13.
      
      Fixes: f25da51f
      
       ("ieee802154: hwsim: add replacement for fakelb")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      [stefan@datenfreihafen.org: fixed assigment from page to channel]
      Acked-by: default avatarAlexander Aring <aahringo@redhat.com>
      Link: https://lore.kernel.org/r/20220125121426.848337-2-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03b0f859
    • Mark Zhang's avatar
      IB/cm: Release previously acquired reference counter in the cm_id_priv · 8e3b022d
      Mark Zhang authored
      commit b856101a upstream.
      
      In failure flow, the reference counter acquired was not released,
      and the following error was reported:
      
        drivers/infiniband/core/cm.c:3373 cm_lap_handler() warn: inconsistent
      			refcounting 'cm_id_priv->refcount.refs.counter':
      
      Fixes: 7345201c
      
       ("IB/cm: Improve the calling of cm_init_av_for_lap and cm_init_av_by_path")
      Link: https://lore.kernel.org/r/7615f23bbb5c5b66d03f6fa13e1c99d51dae6916.1642581448.git.leonro@nvidia.com
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMark Zhang <markzhang@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e3b022d
    • Mike Marciniszyn's avatar
      IB/hfi1: Fix tstats alloc and dealloc · c2f79ff2
      Mike Marciniszyn authored
      commit e5cce44a upstream.
      
      The tstats allocation is done in the accelerated ndo_init function but the
      allocation is not tested to succeed.
      
      The deallocation is not done in the accelerated ndo_uninit function.
      
      Resolve issues by testing for an allocation failure and adding the
      free_percpu in the uninit function.
      
      Fixes: aa0616a9
      
       ("IB/hfi1: switch to core handling of rx/tx byte/packet counters")
      Link: https://lore.kernel.org/r/1642287756-182313-5-git-send-email-mike.marciniszyn@cornelisnetworks.com
      Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2f79ff2
    • Xin Xiong's avatar
      spi: uniphier: fix reference count leak in uniphier_spi_probe() · 447c3d40
      Xin Xiong authored
      commit 37c2c83c
      
       upstream.
      
      The issue happens in several error paths in uniphier_spi_probe().
      When either dma_get_slave_caps() or devm_spi_register_master() returns
      an error code, the function forgets to decrease the refcount of both
      `dma_rx` and `dma_tx` objects, which may lead to refcount leaks.
      
      Fix it by decrementing the reference count of specific objects in
      those error paths.
      
      Signed-off-by: default avatarXin Xiong <xiongx18@fudan.edu.cn>
      Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Reviewed-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
      Fixes: 28d1dddc
      
       ("spi: uniphier: Add DMA transfer mode support")
      Link: https://lore.kernel.org/r/20220125101214.35677-1-xiongx18@fudan.edu.cn
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      447c3d40
    • Miaoqian Lin's avatar
      spi: meson-spicc: add IRQ check in meson_spicc_probe · af6825eb
      Miaoqian Lin authored
      commit e937440f upstream.
      
      This check misses checking for  platform_get_irq()'s call and may passes
      the negative error codes to devm_request_irq(), which takes unsigned IRQ #,
      causing it to fail with -EINVAL, overriding an original error code.
      Stop calling devm_request_irq() with invalid IRQ #s.
      
      Fixes: 454fa271
      
       ("spi: Add Meson SPICC driver")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Link: https://lore.kernel.org/r/20220126110447.24549-1-linmq006@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af6825eb
    • Benjamin Gaignard's avatar
      spi: mediatek: Avoid NULL pointer crash in interrupt · a05b7dff
      Benjamin Gaignard authored
      commit f83a96e5 upstream.
      
      In some case, like after a transfer timeout, master->cur_msg pointer
      is NULL which led to a kernel crash when trying to use master->cur_msg->spi.
      mtk_spi_can_dma(), pointed by master->can_dma, doesn't use this parameter
      avoid the problem by setting NULL as second parameter.
      
      Fixes: a568231f
      
       ("spi: mediatek: Add spi bus for Mediatek MT8173")
      Signed-off-by: default avatarBenjamin Gaignard <benjamin.gaignard@collabora.com>
      Link: https://lore.kernel.org/r/20220131141708.888710-1-benjamin.gaignard@collabora.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a05b7dff
    • Kamal Dasu's avatar
      spi: bcm-qspi: check for valid cs before applying chip select · 6279623e
      Kamal Dasu authored
      commit 2cbd2726 upstream.
      
      Apply only valid chip select value. This change fixes case where chip
      select is set to initial value of '-1' during probe and  PM supend and
      subsequent resume can try to use the value with undefined behaviour.
      Also in case where gpio based chip select, the check in
      bcm_qspi_chip_select() shall prevent undefined behaviour on resume.
      
      Fixes: fa236a7e
      
       ("spi: bcm-qspi: Add Broadcom MSPI driver")
      Signed-off-by: default avatarKamal Dasu <kdasu.kdev@gmail.com>
      Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6279623e
    • Joerg Roedel's avatar
      iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() · 0be365db
      Joerg Roedel authored
      commit 9b45a773 upstream.
      
      The polling loop for the register change in iommu_ga_log_enable() needs
      to have a udelay() in it.  Otherwise the CPU might be faster than the
      IOMMU hardware and wrongly trigger the WARN_ON() further down the code
      stream. Use a 10us for udelay(), has there is some hardware where
      activation of the GA log can take more than a 100ms.
      
      A future optimization should move the activation check of the GA log
      to the point where it gets used for the first time. But that is a
      bigger change and not suitable for a fix.
      
      Fixes: 8bda0cfb
      
       ("iommu/amd: Detect and initialize guest vAPIC log")
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0be365db
    • Guoqing Jiang's avatar
      iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() · b62eceb5
      Guoqing Jiang authored
      commit 99e675d4 upstream.
      
      After commit e3beca48 ("irqdomain/treewide: Keep firmware node
      unconditionally allocated"). For tear down scenario, fn is only freed
      after fail to allocate ir_domain, though it also should be freed in case
      dmar_enable_qi returns error.
      
      Besides free fn, irq_domain and ir_msi_domain need to be removed as well
      if intel_setup_irq_remapping fails to enable queued invalidation.
      
      Improve the rewinding path by add out_free_ir_domain and out_free_fwnode
      lables per Baolu's suggestion.
      
      Fixes: e3beca48
      
       ("irqdomain/treewide: Keep firmware node unconditionally allocated")
      Suggested-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@linux.dev>
      Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.dev
      Signed-off-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
      Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.intel.com
      Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b62eceb5
    • Peter Ujfalusi's avatar
      ALSA: hda: Skip codec shutdown in case the codec is not registered · f2c290e7
      Peter Ujfalusi authored
      commit 1c7f0e34
      
       upstream.
      
      If the codec->registered is not set then it means that pm_runtime is
      not yet enabled and the codec->pcm_list_head has not been initialized.
      
      The access to the not initialized pcm_list_head will lead a kernel crash
      during shutdown.
      
      Reported-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
      Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
      Tested-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
      Fixes: b98444ed
      
       ("ALSA: hda: Suspend codec at shutdown")
      Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux.intel.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2c290e7
    • Takashi Iwai's avatar
      ALSA: hda: Fix signedness of sscanf() arguments · 806943fe
      Takashi Iwai authored
      commit 0444f827 upstream.
      
      The %x format of sscanf() takes an unsigned int pointer, while we pass
      a signed int pointer.  Practically it's OK, but this may result in a
      compile warning.  Let's fix it.
      
      Fixes: a235d5b8
      
       ("ALSA: hda: Allow model option to specify PCI SSID alias")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/r/20220127135717.31751-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      806943fe
    • Tom Rix's avatar
      ALSA: usb-audio: initialize variables that could ignore errors · 95cb3176
      Tom Rix authored
      commit 3da4b740 upstream.
      
      clang static analysis reports this representative issue
      mixer.c:1548:35: warning: Assigned value is garbage or undefined
              ucontrol->value.integer.value[0] = val;
                                               ^ ~~~
      
      The filter_error() macro allows errors to be ignored.
      If errors can be ignored, initialize variables
      so garbage will not be used.
      
      Fixes: 48cc4297
      
       ("ALSA: usb-audio: Filter error from connector kctl ops, too")
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Link: https://lore.kernel.org/r/20220126182142.1184819-1-trix@redhat.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95cb3176
    • Leon Romanovsky's avatar
      RDMA/mlx4: Don't continue event handler after memory allocation failure · 6c6c2b03
      Leon Romanovsky authored
      commit f3136c4c upstream.
      
      The failure to allocate memory during MLX4_DEV_EVENT_PORT_MGMT_CHANGE
      event handler will cause skip the assignment logic, but
      ib_dispatch_event() will be called anyway.
      
      Fix it by calling to return instead of break after memory allocation
      failure.
      
      Fixes: 00f5ce99
      
       ("mlx4: Use port management change event instead of smp_snoop")
      Link: https://lore.kernel.org/r/12a0e83f18cfad4b5f62654f141e240d04915e10.1643622264.git.leonro@nvidia.com
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Reviewed-by: default avatarHåkon Bugge <haakon.bugge@oracle.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c6c2b03
    • Bernard Metzler's avatar
      RDMA/siw: Fix broken RDMA Read Fence/Resume logic. · 2702b466
      Bernard Metzler authored
      commit b43a76f4 upstream.
      
      Code unconditionally resumed fenced SQ processing after next RDMA Read
      completion, even if other RDMA Read responses are still outstanding, or
      ORQ is full. Also adds comments for better readability of fence
      processing, and removes orq_get_tail() helper, which is not needed
      anymore.
      
      Fixes: 8b6a361b ("rdma/siw: receive path")
      Fixes: a5319752
      
       ("rdma/siw: main include file")
      Link: https://lore.kernel.org/r/20220130170815.1940-1-bmt@zurich.ibm.com
      Reported-by: default avatarJared Holzman <jared.holzman@excelero.com>
      Signed-off-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2702b466
    • Mike Marciniszyn's avatar
      IB/rdmavt: Validate remote_addr during loopback atomic tests · 8218ef38
      Mike Marciniszyn authored
      commit 4028bccb upstream.
      
      The rdma-core test suite sends an unaligned remote address and expects a
      failure.
      
      ERROR: test_atomic_non_aligned_addr (tests.test_atomic.AtomicTest)
      
      The qib/hfi1 rc handling validates properly, but the test has the client
      and server on the same system.
      
      The loopback of these operations is a distinct code path.
      
      Fix by syntaxing the proposed remote address in the loopback code path.
      
      Fixes: 15703461
      
       ("IB/{hfi1, qib, rdmavt}: Move ruc_loopback to rdmavt")
      Link: https://lore.kernel.org/r/1642584489-141005-1-git-send-email-mike.marciniszyn@cornelisnetworks.com
      Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
      Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8218ef38
    • Dan Carpenter's avatar
      RDMA/siw: Fix refcounting leak in siw_create_qp() · fa3b844a
      Dan Carpenter authored
      commit a75badeb upstream.
      
      The atomic_inc() needs to be paired with an atomic_dec() on the error
      path.
      
      Fixes: 514aee66
      
       ("RDMA: Globally allocate and release QP memory")
      Link: https://lore.kernel.org/r/20220118091104.GA11671@kili
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Reviewed-by: default avatarBernard Metzler <bmt@zurich.ibm.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa3b844a
    • Leon Romanovsky's avatar
      RDMA/ucma: Protect mc during concurrent multicast leaves · ee2477e8
      Leon Romanovsky authored
      commit 36e8169e upstream.
      
      Partially revert the commit mentioned in the Fixes line to make sure that
      allocation and erasing multicast struct are locked.
      
        BUG: KASAN: use-after-free in ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
        BUG: KASAN: use-after-free in ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
        Read of size 8 at addr ffff88801bb74b00 by task syz-executor.1/25529
        CPU: 0 PID: 25529 Comm: syz-executor.1 Not tainted 5.16.0-rc7-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         __dump_stack lib/dump_stack.c:88 [inline]
         dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
         print_address_description.constprop.0.cold+0x8d/0x320 mm/kasan/report.c:247
         __kasan_report mm/kasan/report.c:433 [inline]
         kasan_report.cold+0x83/0xdf mm/kasan/report.c:450
         ucma_cleanup_multicast drivers/infiniband/core/ucma.c:491 [inline]
         ucma_destroy_private_ctx+0x914/0xb70 drivers/infiniband/core/ucma.c:579
         ucma_destroy_id+0x1e6/0x280 drivers/infiniband/core/ucma.c:614
         ucma_write+0x25c/0x350 drivers/infiniband/core/ucma.c:1732
         vfs_write+0x28e/0xae0 fs/read_write.c:588
         ksys_write+0x1ee/0x250 fs/read_write.c:643
         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
      
      Currently the xarray search can touch a concurrently freeing mc as the
      xa_for_each() is not surrounded by any lock. Rather than hold the lock for
      a full scan hold it only for the effected items, which is usually an empty
      list.
      
      Fixes: 95fe5109
      
       ("RDMA/ucma: Remove mc_list and rely on xarray")
      Link: https://lore.kernel.org/r/1cda5fabb1081e8d16e39a48d3a4f8160cea88b8.1642491047.git.leonro@nvidia.com
      Reported-by: default avatar <syzbot+e3f96c43d19782dd14a7@syzkaller.appspotmail.com>
      Suggested-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee2477e8
    • Maor Gottlieb's avatar
      RDMA/cma: Use correct address when leaving multicast group · 3365f9da
      Maor Gottlieb authored
      commit d9e410eb upstream.
      
      In RoCE we should use cma_iboe_set_mgid() and not cma_set_mgid to generate
      the mgid, otherwise we will generate an IGMP for an incorrect address.
      
      Fixes: b5de0c60
      
       ("RDMA/cma: Fix use after free race in roce multicast join")
      Link: https://lore.kernel.org/r/913bc6783fd7a95fe71ad9454e01653ee6fb4a9a.1642491047.git.leonro@nvidia.com
      Signed-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3365f9da
    • Anshuman Khandual's avatar
      arm64: Add Cortex-A510 CPU part definition · a64abe18
      Anshuman Khandual authored
      commit 53960faf
      
       upstream.
      
      Add the CPU Partnumbers for the new Arm designs.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Suzuki Poulose <suzuki.poulose@arm.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-kernel@vger.kernel.org
      Reviewed-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Link: https://lore.kernel.org/r/1643120437-14352-2-git-send-email-anshuman.khandual@arm.com
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a64abe18
    • James Morse's avatar
      KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs · 50fefe70
      James Morse authored
      commit 1229630a upstream.
      
      Prior to commit defe21f4 ("KVM: arm64: Move PC rollback on SError to
      HYP"), when an SError is synchronised due to another exception, KVM
      handles the SError first. If the guest survives, the instruction that
      triggered the original exception is re-exectued to handle the first
      exception. HVC is treated as a special case as the instruction wouldn't
      normally be re-exectued, as its not a trap.
      
      Commit defe21f4 didn't preserve the behaviour of the 'return 1'
      that skips the rest of handle_exit().
      
      Since commit defe21f4, KVM will try to handle the SError and the
      original exception at the same time. When the exception was an HVC,
      fixup_guest_exit() has already rolled back ELR_EL2, meaning if the
      guest has virtual SError masked, it will execute and handle the HVC
      twice.
      
      Restore the original behaviour.
      
      Fixes: defe21f4
      
       ("KVM: arm64: Move PC rollback on SError to HYP")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220127122052.1584324-4-james.morse@arm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      50fefe70
    • James Morse's avatar
      KVM: arm64: Avoid consuming a stale esr value when SError occur · 57e2986c
      James Morse authored
      commit 1c71dbc8 upstream.
      
      When any exception other than an IRQ occurs, the CPU updates the ESR_EL2
      register with the exception syndrome. An SError may also become pending,
      and will be synchronised by KVM. KVM notes the exception type, and whether
      an SError was synchronised in exit_code.
      
      When an exception other than an IRQ occurs, fixup_guest_exit() updates
      vcpu->arch.fault.esr_el2 from the hardware register. When an SError was
      synchronised, the vcpu esr value is used to determine if the exception
      was due to an HVC. If so, ELR_EL2 is moved back one instruction. This
      is so that KVM can process the SError first, and re-execute the HVC if
      the guest survives the SError.
      
      But if an IRQ synchronises an SError, the vcpu's esr value is stale.
      If the previous non-IRQ exception was an HVC, KVM will corrupt ELR_EL2,
      causing an unrelated guest instruction to be executed twice.
      
      Check ARM_EXCEPTION_CODE() before messing with ELR_EL2, IRQs don't
      update this register so don't need to check.
      
      Fixes: defe21f4
      
       ("KVM: arm64: Move PC rollback on SError to HYP")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarSteven Price <steven.price@arm.com>
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220127122052.1584324-3-james.morse@arm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57e2986c
    • Mayuresh Chitale's avatar
      RISC-V: KVM: make CY, TM, and IR counters accessible in VU mode · 5e7161c9
      Mayuresh Chitale authored
      commit de1d7b6a upstream.
      
      Those applications that run in VU mode and access the time CSR cause
      a virtual instruction trap as Guest kernel currently does not
      initialize the scounteren CSR.
      
      To fix this, we should make CY, TM, and IR counters accessibile
      by default in VU mode (similar to OpenSBI).
      
      Fixes: a33c72fa
      
       ("RISC-V: KVM: Implement VCPU create, init and
      destroy functions")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMayuresh Chitale <mchitale@ventanamicro.com>
      Signed-off-by: default avatarAnup Patel <anup@brainfault.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e7161c9
    • Guenter Roeck's avatar
      Revert "ASoC: mediatek: Check for error clk pointer" · 086daee3
      Guenter Roeck authored
      This reverts commit e0bf3c9e which is
      commit 9de2b928 upstream
      
      With this patch in the tree, Chromebooks running the affected hardware
      no longer boot. Bisect points to this patch, and reverting it fixes
      the problem.
      
      An analysis of the code with this patch applied shows:
      
              ret = init_clks(pdev, clk);
              if (ret)
                      return ERR_PTR(ret);
      ...
                      for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) {
                              struct clk *c = clk[data->clk_id[j]];
      
                              if (IS_ERR(c)) {
                                      dev_err(&pdev->dev, "%s: clk unavailable\n",
                                              data->name);
                                      return ERR_CAST(c);
                              }
      
                              scpd->clk[j] = c;
                      }
      
      Not all clocks in the clk_names array have to be present. Only the clocks
      in the data->clk_id array are actually needed. The code already checks if
      the required clocks are available and bails out if not. The assumption that
      all clocks have to be present is wrong, and commit 9de2b928 needs to be
      reverted.
      
      Fixes: 9de2b928
      
       ("ASoC: mediatek: Check for error clk pointer")
      Cc: Jiasheng Jiang <jiasheng@iscas.ac.cn>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: James Liao <jamesjj.liao@mediatek.com>
      Cc: Kevin Hilman <khilman@baylibre.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com
      Cc: Frank Wunderlich <frank-w@public-files.de>
      Cc: Daniel Golle <daniel@makrotopia.org>
      Link: https://lore.kernel.org/lkml/20220205014755.699603-1-linux@roeck-us.net/
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      086daee3
    • Paolo Abeni's avatar
      mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() · 08906847
      Paolo Abeni authored
      commit 8e9eacad upstream.
      
      The MPTCP endpoint list is under RCU protection, guarded by the
      pernet spinlock. mptcp_nl_cmd_set_flags() traverses the list
      without acquiring the spin-lock nor under the RCU critical section.
      
      This change addresses the issue performing the lookup and the endpoint
      update under the pernet spinlock.
      
      [The upstream commit had to handle a lookup_by_id variable that is only
       present in 5.17. This version of the patch removes that variable, so
       the __lookup_addr() function only handles the lookup as it is
       implemented in 5.15 and 5.16. It also removes one 'const' keyword to
       prevent a warning due to differing const-ness in the 5.17 version of
       addresses_equal().]
      
      Fixes: 0f9f696a
      
       ("mptcp: add set_flags command in PM netlink")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      08906847
    • Helge Deller's avatar
      fbcon: Add option to enable legacy hardware acceleration · 72c4cec1
      Helge Deller authored
      commit a3f781a9
      
       upstream.
      
      Add a config option CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION to
      enable bitblt and fillrect hardware acceleration in the framebuffer
      console. If disabled, such acceleration will not be used, even if it is
      supported by the graphics hardware driver.
      
      If you plan to use DRM as your main graphics output system, you should
      disable this option since it will prevent compiling in code which isn't
      used later on when DRM takes over.
      
      For all other configurations, e.g. if none of your graphic cards support
      DRM (yet), DRM isn't available for your architecture, or you can't be
      sure that the graphic card in the target system will support DRM, you
      most likely want to enable this option.
      
      In the non-accelerated case (e.g. when DRM is used), the inlined
      fb_scrollmode() function is hardcoded to return SCROLL_REDRAW and as such the
      compiler is able to optimize much unneccesary code away.
      
      In this v3 patch version I additionally changed the GETVYRES() and GETVXRES()
      macros to take a pointer to the fbcon_display struct. This fixes the build when
      console rotation is enabled and helps the compiler again to optimize out code.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220202135531.92183-4-deller@gmx.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72c4cec1