Skip to content
  1. Mar 27, 2024
    • Felix Maurer's avatar
      hsr: Handle failures in module init · 5deee0f7
      Felix Maurer authored
      [ Upstream commit 3cf28cd4 ]
      
      A failure during registration of the netdev notifier was not handled at
      all. A failure during netlink initialization did not unregister the netdev
      notifier.
      
      Handle failures of netdev notifier registration and netlink initialization.
      Both functions should only return negative values on failure and thereby
      lead to the hsr module not being loaded.
      
      Fixes: f421436a
      
       ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarFelix Maurer <fmaurer@redhat.com>
      Reviewed-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Reviewed-by: default avatarBreno Leitao <leitao@debian.org>
      Link: https://lore.kernel.org/r/3ce097c15e3f7ace98fc7fd9bcbf299f092e63d1.1710504184.git.fmaurer@redhat.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5deee0f7
    • Yewon Choi's avatar
      rds: introduce acquire/release ordering in acquire/release_in_xmit() · 8c378cc5
      Yewon Choi authored
      [ Upstream commit 1422f288 ]
      
      acquire/release_in_xmit() work as bit lock in rds_send_xmit(), so they
      are expected to ensure acquire/release memory ordering semantics.
      However, test_and_set_bit/clear_bit() don't imply such semantics, on
      top of this, following smp_mb__after_atomic() does not guarantee release
      ordering (memory barrier actually should be placed before clear_bit()).
      
      Instead, we use clear_bit_unlock/test_and_set_bit_lock() here.
      
      Fixes: 0f4b1c7e ("rds: fix rds_send_xmit() serialization")
      Fixes: 1f9ecd7e
      
       ("RDS: Pass rds_conn_path to rds_send_xmit()")
      Signed-off-by: default avatarYewon Choi <woni9911@gmail.com>
      Reviewed-by: default avatarMichal Kubiak <michal.kubiak@intel.com>
      Link: https://lore.kernel.org/r/ZfQUxnNTO9AJmzwc@libra05
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8c378cc5
    • Nikita Zhandarovich's avatar
      wireguard: receive: annotate data-race around receiving_counter.counter · d691be84
      Nikita Zhandarovich authored
      [ Upstream commit bba045dc ]
      
      Syzkaller with KCSAN identified a data-race issue when accessing
      keypair->receiving_counter.counter. Use READ_ONCE() and WRITE_ONCE()
      annotations to mark the data race as intentional.
      
          BUG: KCSAN: data-race in wg_packet_decrypt_worker / wg_packet_rx_poll
      
          write to 0xffff888107765888 of 8 bytes by interrupt on cpu 0:
           counter_validate drivers/net/wireguard/receive.c:321 [inline]
           wg_packet_rx_poll+0x3ac/0xf00 drivers/net/wireguard/receive.c:461
           __napi_poll+0x60/0x3b0 net/core/dev.c:6536
           napi_poll net/core/dev.c:6605 [inline]
           net_rx_action+0x32b/0x750 net/core/dev.c:6738
           __do_softirq+0xc4/0x279 kernel/softirq.c:553
           do_softirq+0x5e/0x90 kernel/softirq.c:454
           __local_bh_enable_ip+0x64/0x70 kernel/softirq.c:381
           __raw_spin_unlock_bh include/linux/spinlock_api_smp.h:167 [inline]
           _raw_spin_unlock_bh+0x36/0x40 kernel/locking/spinlock.c:210
           spin_unlock_bh include/linux/spinlock.h:396 [inline]
           ptr_ring_consume_bh include/linux/ptr_ring.h:367 [inline]
           wg_packet_decrypt_worker+0x6c5/0x700 drivers/net/wireguard/receive.c:499
           process_one_work kernel/workqueue.c:2633 [inline]
           ...
      
          read to 0xffff888107765888 of 8 bytes by task 3196 on cpu 1:
           decrypt_packet drivers/net/wireguard/receive.c:252 [inline]
           wg_packet_decrypt_worker+0x220/0x700 drivers/net/wireguard/receive.c:501
           process_one_work kernel/workqueue.c:2633 [inline]
           process_scheduled_works+0x5b8/0xa30 kernel/workqueue.c:2706
           worker_thread+0x525/0x730 kernel/workqueue.c:2787
           ...
      
      Fixes: a9e90d99
      
       ("wireguard: noise: separate receive counter from send counter")
      Reported-by: default avatar <syzbot+d1de830e4ecdaac83d89@syzkaller.appspotmail.com>
      Signed-off-by: default avatarNikita Zhandarovich <n.zhandarovich@fintech.ru>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d691be84
    • Jonah Palmer's avatar
      vdpa/mlx5: Allow CVQ size changes · 2b2f8d16
      Jonah Palmer authored
      [ Upstream commit 749a4016
      
       ]
      
      The MLX driver was not updating its control virtqueue size at set_vq_num
      and instead always initialized to MLX5_CVQ_MAX_ENT (16) at
      setup_cvq_vring.
      
      Qemu would try to set the size to 64 by default, however, because the
      CVQ size always was initialized to 16, an error would be thrown when
      sending >16 control messages (as used-ring entry 17 is initialized to 0).
      For example, starting a guest with x-svq=on and then executing the
      following command would produce the error below:
      
       # for i in {1..20}; do ifconfig eth0 hw ether XX:xx:XX:xx:XX:XX; done
      
       qemu-system-x86_64: Insufficient written data (0)
       [  435.331223] virtio_net virtio0: Failed to set mac address by vq command.
       SIOCSIFHWADDR: Invalid argument
      
      Acked-by: default avatarDragos Tatulea <dtatulea@nvidia.com>
      Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
      Signed-off-by: default avatarJonah Palmer <jonah.palmer@oracle.com>
      Message-Id: <20240216142502.78095-1-jonah.palmer@oracle.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Tested-by: default avatarLei Yang <leiyang@redhat.com>
      Fixes: 5262912e
      
       ("vdpa/mlx5: Add support for control VQ and MAC setting")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b2f8d16
    • Arınç ÜNAL's avatar
      net: dsa: mt7530: prevent possible incorrect XTAL frequency selection · 4d61084c
      Arınç ÜNAL authored
      [ Upstream commit f490c492 ]
      
      On MT7530, the HT_XTAL_FSEL field of the HWTRAP register stores a 2-bit
      value that represents the frequency of the crystal oscillator connected to
      the switch IC. The field is populated by the state of the ESW_P4_LED_0 and
      ESW_P4_LED_0 pins, which is done right after reset is deasserted.
      
        ESW_P4_LED_0    ESW_P3_LED_0    Frequency
        -----------------------------------------
        0               0               Reserved
        0               1               20MHz
        1               0               40MHz
        1               1               25MHz
      
      On MT7531, the XTAL25 bit of the STRAP register stores this. The LAN0LED0
      pin is used to populate the bit. 25MHz when the pin is high, 40MHz when
      it's low.
      
      These pins are also used with LEDs, therefore, their state can be set to
      something other than the bootstrapping configuration. For example, a link
      may be established on port 3 before the DSA subdriver takes control of the
      switch which would set ESW_P3_LED_0 to high.
      
      Currently on mt7530_setup() and mt7531_setup(), 1000 - 1100 usec delay is
      described between reset assertion and deassertion. Some switch ICs in real
      life conditions cannot always have these pins set back to the bootstrapping
      configuration before reset deassertion in this amount of delay. This causes
      wrong crystal frequency to be selected which puts the switch in a
      nonfunctional state after reset deassertion.
      
      The tests below are conducted on an MT7530 with a 40MHz crystal oscillator
      by Justin Swartz.
      
      With a cable from an active peer connected to port 3 before reset, an
      incorrect crystal frequency (0b11 = 25MHz) is selected:
      
                            [1]                  [3]     [5]
                            :                    :       :
                    _____________________________         __________________
      ESW_P4_LED_0                               |_______|
                    _____________________________
      ESW_P3_LED_0                               |__________________________
      
                             :                  : :     :
                             :                  : [4]...:
                             :                  :
                             [2]................:
      
      [1] Reset is asserted.
      [2] Period of 1000 - 1100 usec.
      [3] Reset is deasserted.
      [4] Period of 315 usec. HWTRAP register is populated with incorrect
          XTAL frequency.
      [5] Signals reflect the bootstrapped configuration.
      
      Increase the delay between reset_control_assert() and
      reset_control_deassert(), and gpiod_set_value_cansleep(priv->reset, 0) and
      gpiod_set_value_cansleep(priv->reset, 1) to 5000 - 5100 usec. This amount
      ensures a higher possibility that the switch IC will have these pins back
      to the bootstrapping configuration before reset deassertion.
      
      With a cable from an active peer connected to port 3 before reset, the
      correct crystal frequency (0b10 = 40MHz) is selected:
      
                            [1]        [2-1]     [3]     [5]
                            :          :         :       :
                    _____________________________         __________________
      ESW_P4_LED_0                               |_______|
                    ___________________           _______
      ESW_P3_LED_0                     |_________|       |__________________
      
                             :          :       : :     :
                             :          [2-2]...: [4]...:
                             [2]................:
      
      [1] Reset is asserted.
      [2] Period of 5000 - 5100 usec.
      [2-1] ESW_P3_LED_0 goes low.
      [2-2] Remaining period of 5000 - 5100 usec.
      [3] Reset is deasserted.
      [4] Period of 310 usec. HWTRAP register is populated with bootstrapped
          XTAL frequency.
      [5] Signals reflect the bootstrapped configuration.
      
      ESW_P3_LED_0 low period before reset deassertion:
      
                    5000 usec
                  - 5100 usec
          TEST     RESET HOLD
             #         (usec)
        ---------------------
             1           5410
             2           5440
             3           4375
             4           5490
             5           5475
             6           4335
             7           4370
             8           5435
             9           4205
            10           4335
            11           3750
            12           3170
            13           4395
            14           4375
            15           3515
            16           4335
            17           4220
            18           4175
            19           4175
            20           4350
      
           Min           3170
           Max           5490
      
        Median       4342.500
           Avg       4466.500
      
      Revert commit 2920dd92 ("net: dsa: mt7530: disable LEDs before reset").
      Changing the state of pins via reset assertion is simpler and more
      efficient than doing so by setting the LED controller off.
      
      Fixes: b8f126a8 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
      Fixes: c288575f
      
       ("net: dsa: mt7530: Add the support of MT7531 switch")
      Co-developed-by: default avatarJustin Swartz <justin.swartz@risingedge.co.za>
      Signed-off-by: default avatarJustin Swartz <justin.swartz@risingedge.co.za>
      Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4d61084c
    • Ignat Korchagin's avatar
      net: veth: do not manipulate GRO when using XDP · f85c87a8
      Ignat Korchagin authored
      [ Upstream commit d7db7775 ]
      
      Commit d3256efd ("veth: allow enabling NAPI even without XDP") tried to fix
      the fact that GRO was not possible without XDP, because veth did not use NAPI
      without XDP. However, it also introduced the behaviour that GRO is always
      enabled, when XDP is enabled.
      
      While it might be desired for most cases, it is confusing for the user at best
      as the GRO flag suddenly changes, when an XDP program is attached. It also
      introduces some complexities in state management as was partially addressed in
      commit fe9f8013 ("net: veth: clear GRO when clearing XDP even when down").
      
      But the biggest problem is that it is not possible to disable GRO at all, when
      an XDP program is attached, which might be needed for some use cases.
      
      Fix this by not touching the GRO flag on XDP enable/disable as the code already
      supports switching to NAPI if either GRO or XDP is requested.
      
      Link: https://lore.kernel.org/lkml/20240311124015.38106-1-ignat@cloudflare.com/
      Fixes: d3256efd ("veth: allow enabling NAPI even without XDP")
      Fixes: fe9f8013
      
       ("net: veth: clear GRO when clearing XDP even when down")
      Signed-off-by: default avatarIgnat Korchagin <ignat@cloudflare.com>
      Reviewed-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f85c87a8
    • Eric Dumazet's avatar
      packet: annotate data-races around ignore_outgoing · d35b62c2
      Eric Dumazet authored
      [ Upstream commit 6ebfad33 ]
      
      ignore_outgoing is read locklessly from dev_queue_xmit_nit()
      and packet_getsockopt()
      
      Add appropriate READ_ONCE()/WRITE_ONCE() annotations.
      
      syzbot reported:
      
      BUG: KCSAN: data-race in dev_queue_xmit_nit / packet_setsockopt
      
      write to 0xffff888107804542 of 1 bytes by task 22618 on cpu 0:
       packet_setsockopt+0xd83/0xfd0 net/packet/af_packet.c:4003
       do_sock_setsockopt net/socket.c:2311 [inline]
       __sys_setsockopt+0x1d8/0x250 net/socket.c:2334
       __do_sys_setsockopt net/socket.c:2343 [inline]
       __se_sys_setsockopt net/socket.c:2340 [inline]
       __x64_sys_setsockopt+0x66/0x80 net/socket.c:2340
       do_syscall_64+0xd3/0x1d0
       entry_SYSCALL_64_after_hwframe+0x6d/0x75
      
      read to 0xffff888107804542 of 1 bytes by task 27 on cpu 1:
       dev_queue_xmit_nit+0x82/0x620 net/core/dev.c:2248
       xmit_one net/core/dev.c:3527 [inline]
       dev_hard_start_xmit+0xcc/0x3f0 net/core/dev.c:3547
       __dev_queue_xmit+0xf24/0x1dd0 net/core/dev.c:4335
       dev_queue_xmit include/linux/netdevice.h:3091 [inline]
       batadv_send_skb_packet+0x264/0x300 net/batman-adv/send.c:108
       batadv_send_broadcast_skb+0x24/0x30 net/batman-adv/send.c:127
       batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:392 [inline]
       batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:420 [inline]
       batadv_iv_send_outstanding_bat_ogm_packet+0x3f0/0x4b0 net/batman-adv/bat_iv_ogm.c:1700
       process_one_work kernel/workqueue.c:3254 [inline]
       process_scheduled_works+0x465/0x990 kernel/workqueue.c:3335
       worker_thread+0x526/0x730 kernel/workqueue.c:3416
       kthread+0x1d1/0x210 kernel/kthread.c:388
       ret_from_fork+0x4b/0x60 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:243
      
      value changed: 0x00 -> 0x01
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 27 Comm: kworker/u8:1 Tainted: G        W          6.8.0-syzkaller-08073-g480e035fc4c7 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
      Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
      
      Fixes: fa788d98
      
       ("packet: add sockopt to ignore outgoing packets")
      Reported-by: default avatar <syzbot+c669c1136495a2e7c31f@syzkaller.appspotmail.com>
      Closes: https://lore.kernel.org/netdev/CANn89i+Z7MfbkBLOv=p7KZ7=K1rKHO4P1OL5LYDCtBiyqsa9oQ@mail.gmail.com/T/#t
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
      Reviewed-by: default avatarWillem de Bruijn <willemb@google.com>
      Reviewed-by: default avatarJason Xing <kerneljasonxing@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d35b62c2
    • Daniel Golle's avatar
      net: ethernet: mtk_eth_soc: fix PPE hanging issue · 9fcadd12
      Daniel Golle authored
      [ Upstream commit ea80e3ed ]
      
      A patch to resolve an issue was found in MediaTek's GPL-licensed SDK:
      In the mtk_ppe_stop() function, the PPE scan mode is not disabled before
      disabling the PPE. This can potentially lead to a hang during the process
      of disabling the PPE.
      
      Without this patch, the PPE may experience a hang during the reboot test.
      
      Link: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/b40da332dfe763932a82f9f62a4709457a15dd6c
      Fixes: ba37b7ca
      
       ("net: ethernet: mtk_eth_soc: add support for initializing the PPE")
      Suggested-by: default avatarBc-bocun Chen <bc-bocun.chen@mediatek.com>
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9fcadd12
    • Daniel Golle's avatar
      net: mediatek: mtk_eth_soc: clear MAC_MCR_FORCE_LINK only when MAC is up · 448cc8b5
      Daniel Golle authored
      [ Upstream commit f1b85ef1 ]
      
      Clearing bit MAC_MCR_FORCE_LINK which forces the link down too early
      can result in MAC ending up in a broken/blocked state.
      
      Fix this by handling this bit in the .mac_link_up and .mac_link_down
      calls instead of in .mac_finish.
      
      Fixes: b8fc9f30
      
       ("net: ethernet: mediatek: Add basic PHYLINK support")
      Suggested-by: default avatarMason-cw Chang <Mason-cw.Chang@mediatek.com>
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      448cc8b5
    • Russell King (Oracle)'s avatar
      net: mtk_eth_soc: move MAC_MCR setting to mac_finish() · c5c0760a
      Russell King (Oracle) authored
      [ Upstream commit 0e37ad71
      
       ]
      
      Move the setting of the MTK_MAC_MCR register from the end of mac_config
      into the phylink mac_finish() method, to keep it as the very last write
      that is done during configuration.
      
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Stable-dep-of: f1b85ef1
      
       ("net: mediatek: mtk_eth_soc: clear MAC_MCR_FORCE_LINK only when MAC is up")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c5c0760a
    • Shigeru Yoshida's avatar
      hsr: Fix uninit-value access in hsr_get_node() · a809bbfd
      Shigeru Yoshida authored
      [ Upstream commit ddbec99f ]
      
      KMSAN reported the following uninit-value access issue [1]:
      
      =====================================================
      BUG: KMSAN: uninit-value in hsr_get_node+0xa2e/0xa40 net/hsr/hsr_framereg.c:246
       hsr_get_node+0xa2e/0xa40 net/hsr/hsr_framereg.c:246
       fill_frame_info net/hsr/hsr_forward.c:577 [inline]
       hsr_forward_skb+0xe12/0x30e0 net/hsr/hsr_forward.c:615
       hsr_dev_xmit+0x1a1/0x270 net/hsr/hsr_device.c:223
       __netdev_start_xmit include/linux/netdevice.h:4940 [inline]
       netdev_start_xmit include/linux/netdevice.h:4954 [inline]
       xmit_one net/core/dev.c:3548 [inline]
       dev_hard_start_xmit+0x247/0xa10 net/core/dev.c:3564
       __dev_queue_xmit+0x33b8/0x5130 net/core/dev.c:4349
       dev_queue_xmit include/linux/netdevice.h:3134 [inline]
       packet_xmit+0x9c/0x6b0 net/packet/af_packet.c:276
       packet_snd net/packet/af_packet.c:3087 [inline]
       packet_sendmsg+0x8b1d/0x9f30 net/packet/af_packet.c:3119
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg net/socket.c:745 [inline]
       __sys_sendto+0x735/0xa10 net/socket.c:2191
       __do_sys_sendto net/socket.c:2203 [inline]
       __se_sys_sendto net/socket.c:2199 [inline]
       __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      Uninit was created at:
       slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
       slab_alloc_node mm/slub.c:3478 [inline]
       kmem_cache_alloc_node+0x5e9/0xb10 mm/slub.c:3523
       kmalloc_reserve+0x13d/0x4a0 net/core/skbuff.c:560
       __alloc_skb+0x318/0x740 net/core/skbuff.c:651
       alloc_skb include/linux/skbuff.h:1286 [inline]
       alloc_skb_with_frags+0xc8/0xbd0 net/core/skbuff.c:6334
       sock_alloc_send_pskb+0xa80/0xbf0 net/core/sock.c:2787
       packet_alloc_skb net/packet/af_packet.c:2936 [inline]
       packet_snd net/packet/af_packet.c:3030 [inline]
       packet_sendmsg+0x70e8/0x9f30 net/packet/af_packet.c:3119
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg net/socket.c:745 [inline]
       __sys_sendto+0x735/0xa10 net/socket.c:2191
       __do_sys_sendto net/socket.c:2203 [inline]
       __se_sys_sendto net/socket.c:2199 [inline]
       __x64_sys_sendto+0x125/0x1c0 net/socket.c:2199
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0x6d/0x140 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x63/0x6b
      
      CPU: 1 PID: 5033 Comm: syz-executor334 Not tainted 6.7.0-syzkaller-00562-g9f8413c4a66f #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
      =====================================================
      
      If the packet type ID field in the Ethernet header is either ETH_P_PRP or
      ETH_P_HSR, but it is not followed by an HSR tag, hsr_get_skb_sequence_nr()
      reads an invalid value as a sequence number. This causes the above issue.
      
      This patch fixes the issue by returning NULL if the Ethernet header is not
      followed by an HSR tag.
      
      Fixes: f266a683
      
       ("net/hsr: Better frame dispatch")
      Reported-and-tested-by: default avatar <syzbot+2ef3a8ce8e91b5a50098@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=2ef3a8ce8e91b5a50098 [1]
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Link: https://lore.kernel.org/r/20240312152719.724530-1-syoshida@redhat.com
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a809bbfd
    • Arnd Bergmann's avatar
      soc: fsl: dpio: fix kcalloc() argument order · ccafa081
      Arnd Bergmann authored
      [ Upstream commit 72ebb41b ]
      
      A previous bugfix added a call to kcalloc(), which starting in gcc-14
      causes a harmless warning about the argument order:
      
      drivers/soc/fsl/dpio/dpio-service.c: In function 'dpaa2_io_service_enqueue_multiple_desc_fq':
      drivers/soc/fsl/dpio/dpio-service.c:526:29: error: 'kcalloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
        526 |         ed = kcalloc(sizeof(struct qbman_eq_desc), 32, GFP_KERNEL);
            |                             ^~~~~~
      drivers/soc/fsl/dpio/dpio-service.c:526:29: note: earlier argument should specify number of elements, later size of each element
      
      Since the two are only multiplied, the order does not change the
      behavior, so just fix it now to shut up the compiler warning.
      
      Dmity independently came up with the same fix.
      
      Fixes: 5c4a5999
      
       ("soc: fsl: dpio: avoid stack usage warning")
      Reported-by: default avatarDmitry Antipov <dmantipov@yandex.ru>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ccafa081
    • Mete Durlu's avatar
      s390/vtime: fix average steal time calculation · 4b9d7249
      Mete Durlu authored
      [ Upstream commit 367c50f7 ]
      
      Current average steal timer calculation produces volatile and inflated
      values. The only user of this value is KVM so far and it uses that to
      decide whether or not to yield the vCPU which is seeing steal time.
      KVM compares average steal timer to a threshold and if the threshold
      is past then it does not allow CPU polling and yields it to host, else
      it keeps the CPU by polling.
      Since KVM's steal time threshold is very low by default (%10) it most
      likely is not effected much by the bloated average steal timer values
      because the operating region is pretty small. However there might be
      new users in the future who might rely on this number. Fix average
      steal timer calculation by changing the formula from:
      
      	avg_steal_timer = avg_steal_timer / 2 + steal_timer;
      
      to the following:
      
      	avg_steal_timer = (avg_steal_timer + steal_timer) / 2;
      
      This ensures that avg_steal_timer is actually a naive average of steal
      timer values. It now closely follows steal timer values but of course
      in a smoother manner.
      
      Fixes: 152e9b86
      
       ("s390/vtime: steal time exponential moving average")
      Signed-off-by: default avatarMete Durlu <meted@linux.ibm.com>
      Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Acked-by: default avatarChristian Borntraeger <borntraeger@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b9d7249
    • Linu Cherian's avatar
      octeontx2-af: Use matching wake_up API variant in CGX command interface · 8fdc7b40
      Linu Cherian authored
      [ Upstream commit e642921d ]
      
      Use wake_up API instead of wake_up_interruptible, since
      wait_event_timeout API is used for waiting on command completion.
      
      Fixes: 1463f382
      
       ("octeontx2-af: Add support for CGX link management")
      Signed-off-by: default avatarLinu Cherian <lcherian@marvell.com>
      Signed-off-by: default avatarSunil Goutham <sgoutham@marvell.com>
      Signed-off-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8fdc7b40
    • Dave Airlie's avatar
      nouveau: reset the bo resource bus info after an eviction · aa5ab5ce
      Dave Airlie authored
      [ Upstream commit f35c9af4 ]
      
      Later attempts to refault the bo won't happen and the whole
      GPU does to lunch. I think Christian's refactoring of this
      code out to the driver broke this not very well tested path.
      
      Fixes: 141b15e5
      
       ("drm/nouveau: move io_reserve_lru handling into the driver v5")
      Cc: Christian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDanilo Krummrich <dakr@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240311072037.287905-1-airlied@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aa5ab5ce
    • Jens Axboe's avatar
      io_uring: don't save/restore iowait state · deb59462
      Jens Axboe authored
      [ Upstream commit 6f0974ec ]
      
      This kind of state is per-syscall, and since we're doing the waiting off
      entering the io_uring_enter(2) syscall, there's no way that iowait can
      already be set for this case. Simplify it by setting it if we need to,
      and always clearing it to 0 when done.
      
      Fixes: 7b72d661
      
       ("io_uring: gate iowait schedule on having pending requests")
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      deb59462
    • Colin Ian King's avatar
      usb: gadget: net2272: Use irqflags in the call to net2272_probe_fin · 1049fa4d
      Colin Ian King authored
      [ Upstream commit 60055680 ]
      
      Currently the variable irqflags is being set but is not being used,
      it appears it should be used in the call to net2272_probe_fin
      rather than IRQF_TRIGGER_LOW being used. Kudos to Uwe Kleine-König
      for suggesting the fix.
      
      Cleans up clang scan build warning:
      drivers/usb/gadget/udc/net2272.c:2610:15: warning: variable 'irqflags'
      set but not used [-Wunused-but-set-variable]
      
      Fixes: ceb80363
      
       ("USB: net2272: driver for PLX NET2272 USB device controller")
      Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20240307181734.2034407-1-colin.i.king@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1049fa4d
    • Dan Carpenter's avatar
      staging: greybus: fix get_channel_from_mode() failure path · 463c429b
      Dan Carpenter authored
      [ Upstream commit 34164202 ]
      
      The get_channel_from_mode() function is supposed to return the channel
      which matches the mode.  But it has a bug where if it doesn't find a
      matching channel then it returns the last channel.  It should return
      NULL instead.
      
      Also remove an unnecessary NULL check on "channel".
      
      Fixes: 2870b52b
      
       ("greybus: lights: add lights implementation")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
      Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
      Reviewed-by: default avatarAlex Elder <elder@linaro.org>
      Link: https://lore.kernel.org/r/379c0cb4-39e0-4293-8a18-c7b1298e5420@moroto.mountain
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      463c429b
    • Andy Shevchenko's avatar
      serial: 8250_exar: Don't remove GPIO device on suspend · 6c619223
      Andy Shevchenko authored
      [ Upstream commit 73b5a5c0 ]
      
      It seems a copy&paste mistake that suspend callback removes the GPIO
      device. There is no counterpart of this action, means once suspended
      there is no more GPIO device available untile full unbind-bind cycle
      is performed. Remove suspicious GPIO device removal in suspend.
      
      Fixes: d0aeaa83
      
       ("serial: exar: split out the exar code from 8250_pci")
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Link: https://lore.kernel.org/r/20240219150627.2101198-2-andriy.shevchenko@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6c619223
    • Randy Dunlap's avatar
      rtc: mt6397: select IRQ_DOMAIN instead of depending on it · f867ba8e
      Randy Dunlap authored
      [ Upstream commit 544c42f7 ]
      
      IRQ_DOMAIN is a hidden (not user visible) symbol. Users cannot set
      it directly thru "make *config", so drivers should select it instead
      of depending on it if they need it.
      Relying on it being set for a dependency is risky.
      
      Consistently using "select" or "depends on" can also help reduce
      Kconfig circular dependency issues.
      
      Therefore, change the use of "depends on" for IRQ_DOMAIN to
      "select" for RTC_DRV_MT6397.
      
      Fixes: 04d3ba70
      
       ("rtc: mt6397: add IRQ domain dependency")
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Eddie Huang <eddie.huang@mediatek.com>
      Cc: Sean Wang <sean.wang@mediatek.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: linux-mediatek@lists.infradead.org
      Cc: Alessandro Zummo <a.zummo@towertech.it>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: linux-rtc@vger.kernel.org
      Cc: Marc Zyngier <maz@kernel.org>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Peter Rosin <peda@axentia.se>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Link: https://lore.kernel.org/r/20240213050258.6167-1-rdunlap@infradead.org
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f867ba8e
    • Masahiro Yamada's avatar
      kconfig: fix infinite loop when expanding a macro at the end of file · 04dd6133
      Masahiro Yamada authored
      [ Upstream commit af8bbce9 ]
      
      A macro placed at the end of a file with no newline causes an infinite
      loop.
      
      [Test Kconfig]
        $(info,hello)
        \ No newline at end of file
      
      I realized that flex-provided input() returns 0 instead of EOF when it
      reaches the end of a file.
      
      Fixes: 104daea1
      
       ("kconfig: reference environment variables directly and remove 'option env='")
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04dd6133
    • Rafał Miłecki's avatar
      arm64: dts: broadcom: bcmbca: bcm4908: drop invalid switch cells · 3019ad4a
      Rafał Miłecki authored
      [ Upstream commit 27058b95 ]
      
      Ethernet switch does not have addressable subnodes.
      
      This fixes:
      arch/arm64/boot/dts/broadcom/bcmbca/bcm4908-asus-gt-ac5300.dtb: ethernet-switch@0: '#address-cells', '#size-cells' do not match any of the regexes: 'pinctrl-[0-9]+'
              from schema $id: http://devicetree.org/schemas/net/dsa/brcm,sf2.yaml#
      
      Fixes: 527a3ac9
      
       ("arm64: dts: broadcom: bcm4908: describe internal switch")
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Link: https://lore.kernel.org/r/20240111115636.12095-1-zajec5@gmail.com
      Signed-off-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3019ad4a
    • Tudor Ambarus's avatar
      tty: serial: samsung: fix tx_empty() to return TIOCSER_TEMT · c2203780
      Tudor Ambarus authored
      [ Upstream commit 314c2b39 ]
      
      The core expects for tx_empty() either TIOCSER_TEMT when the tx is
      empty or 0 otherwise. s3c24xx_serial_txempty_nofifo() might return
      0x4, and at least uart_get_lsr_info() tries to clear exactly
      TIOCSER_TEMT (BIT(1)). Fix tx_empty() to return TIOCSER_TEMT.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Reviewed-by: default avatarSam Protsenko <semen.protsenko@linaro.org>
      Link: https://lore.kernel.org/r/20240119104526.1221243-2-tudor.ambarus@linaro.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c2203780
    • Hugo Villeneuve's avatar
      serial: max310x: fix syntax error in IRQ error message · e6011abe
      Hugo Villeneuve authored
      [ Upstream commit 8ede8c6f ]
      
      Replace g with q.
      
      Helpful when grepping thru source code or logs for
      "request" keyword.
      
      Fixes: f6544418
      
       ("serial: New serial driver MAX310X")
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarHugo Villeneuve <hvilleneuve@dimonoff.com>
      Link: https://lore.kernel.org/r/20240118152213.2644269-6-hugo@hugovil.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6011abe
    • Jiri Slaby (SUSE)'s avatar
      tty: vt: fix 20 vs 0x20 typo in EScsiignore · 19b21318
      Jiri Slaby (SUSE) authored
      [ Upstream commit 0e6a92f6 ]
      
      The if (c >= 20 && c <= 0x3f) test added in commit 7a99565f
      
       is
      wrong.  20 is DC4 in ascii and it makes no sense to consider that as the
      bottom limit. Instead, it should be 0x20 as in the other test in
      the commit above. This is supposed to NOT change anything as we handle
      interesting 20-0x20 asciis far before this if.
      
      So for sakeness, change to 0x20 (which is SPACE).
      
      Signed-off-by: default avatar"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
      Fixes: 7a99565f
      
       ("vt: ignore csi sequences with intermediate characters.")
      Cc: Martin Hostettler <textshell@uchuujin.de>
      Link: https://lore.kernel.org/all/ZaP45QY2WEsDqoxg@neutronstar.dyndns.org/
      Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
      Link: https://lore.kernel.org/r/20240122110401.7289-4-jirislaby@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19b21318
    • Arnaud Pouliquen's avatar
      remoteproc: stm32: Fix incorrect type assignment returned by stm32_rproc_get_loaded_rsc_tablef · ea34c1c1
      Arnaud Pouliquen authored
      [ Upstream commit c77b35ce ]
      
      The sparse tool complains about the remove of the _iomem attribute.
      
      stm32_rproc.c:660:17: warning: cast removes address space '__iomem' of expression
      
      Add '__force' to explicitly specify that the cast is intentional.
      This conversion is necessary to cast to addresses pointer,
      which are then managed by the remoteproc core as a pointer to a
      resource_table structure.
      
      Fixes: 8a471396
      
       ("remoteproc: stm32: Move resource table setup to rproc_ops")
      Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
      Link: https://lore.kernel.org/r/20240117135312.3381936-3-arnaud.pouliquen@foss.st.com
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ea34c1c1
    • Arnaud Pouliquen's avatar
      remoteproc: stm32: Fix incorrect type in assignment for va · dd68756a
      Arnaud Pouliquen authored
      [ Upstream commit 32381bbc
      
       ]
      
      The sparse tool complains about the attribute conversion between
      a _iomem void * and a void *:
      
      stm32_rproc.c:122:12: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *va @@     got void [noderef] __iomem * @@
      stm32_rproc.c:122:12: sparse:     expected void *va
      stm32_rproc.c:122:12: sparse:     got void [noderef] __iomem *
      
      Add '__force' to explicitly specify that the cast is intentional.
      This conversion is necessary to cast to virtual addresses pointer,used,
      by the remoteproc core.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Closes: https://lore.kernel.org/oe-kbuild-all/202312150052.HCiNKlqB-lkp@intel.com/
      Fixes: 13140de0
      
       ("remoteproc: stm32: add an ST stm32_rproc driver")
      Signed-off-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
      Link: https://lore.kernel.org/r/20240117135312.3381936-2-arnaud.pouliquen@foss.st.com
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd68756a
    • Arnd Bergmann's avatar
      remoteproc: stm32: use correct format strings on 64-bit · a48c24cc
      Arnd Bergmann authored
      [ Upstream commit 03bd158e
      
       ]
      
      With CONFIG_ARCH_STM32 making it into arch/arm64, a couple of format
      strings no longer work, since they rely on size_t being compatible
      with %x, or they print an 'int' using %z:
      
      drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_mem_alloc':
      drivers/remoteproc/stm32_rproc.c:122:22: error: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
      drivers/remoteproc/stm32_rproc.c:122:40: note: format string is defined here
        122 |         dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len);
            |                                       ~^
            |                                        |
            |                                        unsigned int
            |                                       %lx
      drivers/remoteproc/stm32_rproc.c:125:30: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=]
      drivers/remoteproc/stm32_rproc.c:125:65: note: format string is defined here
        125 |                 dev_err(dev, "Unable to map memory region: %pa+%x\n",
            |                                                                ~^
            |                                                                 |
            |                                                                 unsigned int
            |                                                                %lx
      drivers/remoteproc/stm32_rproc.c: In function 'stm32_rproc_get_loaded_rsc_table':
      drivers/remoteproc/stm32_rproc.c:646:30: error: format '%zx' expects argument of type 'size_t', but argument 4 has type 'int' [-Werror=format=]
      drivers/remoteproc/stm32_rproc.c:646:66: note: format string is defined here
        646 |                 dev_err(dev, "Unable to map memory region: %pa+%zx\n",
            |                                                                ~~^
            |                                                                  |
            |                                                                  long unsigned int
            |                                                                %x
      
      Fix up all three instances to work across architectures, and enable
      compile testing for this driver to ensure it builds everywhere.
      
      Reviewed-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Stable-dep-of: 32381bbc
      
       ("remoteproc: stm32: Fix incorrect type in assignment for va")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a48c24cc
    • Ian Abbott's avatar
      comedi: comedi_test: Prevent timers rescheduling during deletion · da0ad1bd
      Ian Abbott authored
      commit f53641a6 upstream.
      
      The comedi_test devices have a couple of timers (ai_timer and ao_timer)
      that can be started to simulate hardware interrupts.  Their expiry
      functions normally reschedule the timer.  The driver code calls either
      del_timer_sync() or del_timer() to delete the timers from the queue, but
      does not currently prevent the timers from rescheduling themselves so
      synchronized deletion may be ineffective.
      
      Add a couple of boolean members (one for each timer: ai_timer_enable and
      ao_timer_enable) to the device private data structure to indicate
      whether the timers are allowed to reschedule themselves.  Set the member
      to true when adding the timer to the queue, and to false when deleting
      the timer from the queue in the waveform_ai_cancel() and
      waveform_ao_cancel() functions.
      
      The del_timer_sync() function is also called from the waveform_detach()
      function, but the timer enable members will already be set to false when
      that function is called, so no change is needed there.
      
      Fixes: 403fe7f3
      
       ("staging: comedi: comedi_test: fix timer race conditions")
      Cc: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Link: https://lore.kernel.org/r/20240214100747.16203-1-abbotti@mev.co.uk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da0ad1bd
    • David Howells's avatar
      afs: Revert "afs: Hide silly-rename files from userspace" · a6ffae61
      David Howells authored
      [ Upstream commit 0aec3847 ]
      
      This reverts commit 57e9d49c.
      
      This undoes the hiding of .__afsXXXX silly-rename files.  The problem with
      hiding them is that rm can't then manually delete them.
      
      This also reverts commit 5f7a0764 ("afs: Fix
      endless loop in directory parsing") as that's a bugfix for the above.
      
      Fixes: 57e9d49c
      
       ("afs: Hide silly-rename files from userspace")
      Reported-by: default avatarMarkus Suvanto <markus.suvanto@gmail.com>
      Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008102.html
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Link: https://lore.kernel.org/r/3085695.1710328121@warthog.procyon.org.uk
      Reviewed-by: default avatarJeffrey E Altman <jaltman@auristor.com>
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a6ffae61
    • Xiuhong Wang's avatar
      f2fs: compress: fix reserve_cblocks counting error when out of space · fa3ac8b1
      Xiuhong Wang authored
      [ Upstream commit 2f6d721e ]
      
      When a file only needs one direct_node, performing the following
      operations will cause the file to be unrepairable:
      
      unisoc # ./f2fs_io compress test.apk
      unisoc #df -h | grep dm-48
      /dev/block/dm-48 112G 112G 1.2M 100% /data
      
      unisoc # ./f2fs_io release_cblocks test.apk
      924
      unisoc # df -h | grep dm-48
      /dev/block/dm-48 112G 112G 4.8M 100% /data
      
      unisoc # dd if=/dev/random of=file4 bs=1M count=3
      3145728 bytes (3.0 M) copied, 0.025 s, 120 M/s
      unisoc # df -h | grep dm-48
      /dev/block/dm-48 112G 112G 1.8M 100% /data
      
      unisoc # ./f2fs_io reserve_cblocks test.apk
      F2FS_IOC_RESERVE_COMPRESS_BLOCKS failed: No space left on device
      
      adb reboot
      unisoc # df -h  | grep dm-48
      /dev/block/dm-48             112G 112G   11M 100% /data
      unisoc # ./f2fs_io reserve_cblocks test.apk
      0
      
      This is because the file has only one direct_node. After returning
      to -ENOSPC, reserved_blocks += ret will not be executed. As a result,
      the reserved_blocks at this time is still 0, which is not the real
      number of reserved blocks. Therefore, fsck cannot be set to repair
      the file.
      
      After this patch, the fsck flag will be set to fix this problem.
      
      unisoc # df -h | grep dm-48
      /dev/block/dm-48             112G 112G  1.8M 100% /data
      unisoc # ./f2fs_io reserve_cblocks test.apk
      F2FS_IOC_RESERVE_COMPRESS_BLOCKS failed: No space left on device
      
      adb reboot then fsck will be executed
      unisoc # df -h  | grep dm-48
      /dev/block/dm-48             112G 112G   11M 100% /data
      unisoc # ./f2fs_io reserve_cblocks test.apk
      924
      
      Fixes: c75488fb
      
       ("f2fs: introduce F2FS_IOC_RESERVE_COMPRESS_BLOCKS")
      Signed-off-by: default avatarXiuhong Wang <xiuhong.wang@unisoc.com>
      Signed-off-by: default avatarZhiguo Niu <zhiguo.niu@unisoc.com>
      Reviewed-by: default avatarChao Yu <chao@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fa3ac8b1
    • Christophe JAILLET's avatar
      NFS: Fix an off by one in root_nfs_cat() · 6ca2ea69
      Christophe JAILLET authored
      [ Upstream commit 698ad1a5 ]
      
      The intent is to check if 'dest' is truncated or not. So, >= should be
      used instead of >, because strlcat() returns the length of 'dest' and 'src'
      excluding the trailing NULL.
      
      Fixes: 56463e50
      
       ("NFS: Use super.c for NFSROOT mount option parsing")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6ca2ea69
    • Ben Wolsieffer's avatar
      watchdog: stm32_iwdg: initialize default timeout · 704dc013
      Ben Wolsieffer authored
      [ Upstream commit dbd7c008 ]
      
      The driver never sets a default timeout value, therefore it is
      initialized to zero. When CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is
      enabled, the watchdog is started during probe. The kernel is supposed to
      automatically ping the watchdog from this point until userspace takes
      over, but this does not happen if the configured timeout is zero. A zero
      timeout causes watchdog_need_worker() to return false, so the heartbeat
      worker does not run and the system therefore resets soon after the
      driver is probed.
      
      This patch fixes this by setting an arbitrary non-zero default timeout.
      The default could be read from the hardware instead, but I didn't see
      any reason to add this complexity.
      
      This has been tested on an STM32F746.
      
      Fixes: 85fdc63f
      
       ("drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe")
      Signed-off-by: default avatarBen Wolsieffer <ben.wolsieffer@hefring.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20240228182723.12855-1-ben.wolsieffer@hefring.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      704dc013
    • Jorge Mora's avatar
      NFSv4.2: fix listxattr maximum XDR buffer size · 446f55d0
      Jorge Mora authored
      [ Upstream commit bcac8bff ]
      
      Switch order of operations to avoid creating a short XDR buffer:
      e.g., buflen = 12, old xdrlen = 12, new xdrlen = 20.
      
      Having a short XDR buffer leads to lxa_maxcount be a few bytes
      less than what is needed to retrieve the whole list when using
      a buflen as returned by a call with size = 0:
          buflen = listxattr(path, NULL, 0);
          buf = malloc(buflen);
          buflen = listxattr(path, buf, buflen);
      
      For a file with one attribute (name = '123456'), the first call
      with size = 0 will return buflen = 12 ('user.123456\x00').
      The second call with size = 12, sends LISTXATTRS with
      lxa_maxcount = 12 + 8 (cookie) + 4 (array count) = 24. The
      XDR buffer needs 8 (cookie) + 4 (array count) + 4 (name count)
      + 6 (name len) + 2 (padding) + 4 (eof) = 28 which is 4 bytes
      shorter than the lxa_maxcount provided in the call.
      
      Fixes: 04a5da69
      
       ("NFSv4.2: define limits and sizes for user xattr handling")
      Signed-off-by: default avatarJorge Mora <mora@netapp.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      446f55d0
    • Jorge Mora's avatar
      NFSv4.2: fix nfs4_listxattr kernel BUG at mm/usercopy.c:102 · 9d52865f
      Jorge Mora authored
      [ Upstream commit 251a658b ]
      
      A call to listxattr() with a buffer size = 0 returns the actual
      size of the buffer needed for a subsequent call. When size > 0,
      nfs4_listxattr() does not return an error because either
      generic_listxattr() or nfs4_listxattr_nfs4_label() consumes
      exactly all the bytes then size is 0 when calling
      nfs4_listxattr_nfs4_user() which then triggers the following
      kernel BUG:
      
        [   99.403778] kernel BUG at mm/usercopy.c:102!
        [   99.404063] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
        [   99.408463] CPU: 0 PID: 3310 Comm: python3 Not tainted 6.6.0-61.fc40.aarch64 #1
        [   99.415827] Call trace:
        [   99.415985]  usercopy_abort+0x70/0xa0
        [   99.416227]  __check_heap_object+0x134/0x158
        [   99.416505]  check_heap_object+0x150/0x188
        [   99.416696]  __check_object_size.part.0+0x78/0x168
        [   99.416886]  __check_object_size+0x28/0x40
        [   99.417078]  listxattr+0x8c/0x120
        [   99.417252]  path_listxattr+0x78/0xe0
        [   99.417476]  __arm64_sys_listxattr+0x28/0x40
        [   99.417723]  invoke_syscall+0x78/0x100
        [   99.417929]  el0_svc_common.constprop.0+0x48/0xf0
        [   99.418186]  do_el0_svc+0x24/0x38
        [   99.418376]  el0_svc+0x3c/0x110
        [   99.418554]  el0t_64_sync_handler+0x120/0x130
        [   99.418788]  el0t_64_sync+0x194/0x198
        [   99.418994] Code: aa0003e3 d000a3e0 91310000 97f49bdb (d4210000)
      
      Issue is reproduced when generic_listxattr() returns 'system.nfs4_acl',
      thus calling lisxattr() with size = 16 will trigger the bug.
      
      Add check on nfs4_listxattr() to return ERANGE error when it is
      called with size > 0 and the return value is greater than size.
      
      Fixes: 012a211a
      
       ("NFSv4.2: hook in the user extended attribute handlers")
      Signed-off-by: default avatarJorge Mora <mora@netapp.com>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d52865f
    • Christophe JAILLET's avatar
      net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() · 6233dbe9
      Christophe JAILLET authored
      [ Upstream commit d6f4de70 ]
      
      The intent is to check if the strings' are truncated or not. So, >= should
      be used instead of >, because strlcat() and snprintf() return the length of
      the output, excluding the trailing NULL.
      
      Fixes: a02d6926
      
       ("SUNRPC: Provide functions for managing universal addresses")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarBenjamin Coddington <bcodding@redhat.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6233dbe9
    • Arnd Bergmann's avatar
      scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn · 83edcda1
      Arnd Bergmann authored
      [ Upstream commit b6960023 ]
      
      Some callback functions used here take a boolean argument, others take a
      status argument. This breaks KCFI type checking, so clang now warns about
      the function pointer cast:
      
      drivers/scsi/bfa/bfad_bsg.c:2138:29: error: cast from 'void (*)(void *, enum bfa_status)' to 'bfa_cb_cbfn_t' (aka 'void (*)(void *, enum bfa_boolean)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
      
      Assuming the code is actually correct here and the callers always match the
      argument types of the callee, rework this to replace the explicit cast with
      a union of the two pointer types. This does not change the behavior of the
      code, so if something is actually broken here, a larger rework may be
      necessary.
      
      Fixes: 37ea0558 ("[SCSI] bfa: Added support to collect and reset fcport stats")
      Fixes: 3ec4f2c8
      
       ("[SCSI] bfa: Added support to configure QOS and collect stats.")
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20240222124433.2046570-1-arnd@kernel.org
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      83edcda1
    • Alexey Kodanev's avatar
      RDMA/rtrs-clt: Check strnlen return len in sysfs mpath_policy_store() · 16a5bed6
      Alexey Kodanev authored
      [ Upstream commit 7a7b7f57 ]
      
      strnlen() may return 0 (e.g. for "\0\n" string), it's better to
      check the result of strnlen() before using 'len - 1' expression
      for the 'buf' array index.
      
      Detected using the static analysis tool - Svace.
      
      Fixes: dc3b66a0
      
       ("RDMA/rtrs-clt: Add a minimum latency multipath policy")
      Signed-off-by: default avatarAlexey Kodanev <aleksei.kodanev@bell-sw.com>
      Link: https://lore.kernel.org/r/20240221113204.147478-1-aleksei.kodanev@bell-sw.com
      Acked-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      16a5bed6
    • Shifeng Li's avatar
      RDMA/device: Fix a race between mad_client and cm_client init · ed3e66d8
      Shifeng Li authored
      [ Upstream commit 7a8bccd8 ]
      
      The mad_client will be initialized in enable_device_and_get(), while the
      devices_rwsem will be downgraded to a read semaphore. There is a window
      that leads to the failed initialization for cm_client, since it can not
      get matched mad port from ib_mad_port_list, and the matched mad port will
      be added to the list after that.
      
          mad_client    |                       cm_client
      ------------------|--------------------------------------------------------
      ib_register_device|
      enable_device_and_get
      down_write(&devices_rwsem)
      xa_set_mark(&devices, DEVICE_REGISTERED)
      downgrade_write(&devices_rwsem)
                        |
                        |ib_cm_init
                        |ib_register_client(&cm_client)
                        |down_read(&devices_rwsem)
                        |xa_for_each_marked (&devices, DEVICE_REGISTERED)
                        |add_client_context
                        |cm_add_one
                        |ib_register_mad_agent
                        |ib_get_mad_port
                        |__ib_get_mad_port
                        |list_for_each_entry(entry, &ib_mad_port_list, port_list)
                        |return NULL
                        |up_read(&devices_rwsem)
                        |
      add_client_context|
      ib_mad_init_device|
      ib_mad_port_open  |
      list_add_tail(&port_priv->port_list, &ib_mad_port_list)
      up_read(&devices_rwsem)
                        |
      
      Fix it by using down_write(&devices_rwsem) in ib_register_client().
      
      Fixes: d0899892
      
       ("RDMA/device: Provide APIs from the core code to help unregistration")
      Link: https://lore.kernel.org/r/20240203035313.98991-1-lishifeng@sangfor.com.cn
      Suggested-by: default avatarJason Gunthorpe <jgg@ziepe.ca>
      Signed-off-by: default avatarShifeng Li <lishifeng@sangfor.com.cn>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ed3e66d8
    • Arnd Bergmann's avatar
      scsi: csiostor: Avoid function pointer casts · a27984f6
      Arnd Bergmann authored
      [ Upstream commit 9f3dbcb5 ]
      
      csiostor uses function pointer casts to keep the csio_ln_ev state machine
      hidden, but this causes warnings about control flow integrity (KCFI)
      violations in clang-16 and higher:
      
      drivers/scsi/csiostor/csio_lnode.c:1098:33: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
       1098 |         return (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready));
            |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/scsi/csiostor/csio_lnode.c:1369:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
       1369 |         if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_uninit)) {
            |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/scsi/csiostor/csio_lnode.c:1373:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
       1373 |         if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_ready)) {
            |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/scsi/csiostor/csio_lnode.c:1377:29: error: cast from 'void (*)(struct csio_lnode *, enum csio_ln_ev)' to 'csio_sm_state_t' (aka 'void (*)(void *, unsigned int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
       1377 |         if (csio_get_state(ln) == ((csio_sm_state_t)csio_lns_offline)) {
            |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Move the enum into a shared header so the correct types can be used without
      the need for casts.
      
      Fixes: a3667aae
      
       ("[SCSI] csiostor: Chelsio FCoE offload driver")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20240213100518.457623-1-arnd@kernel.org
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a27984f6