Skip to content
  1. May 02, 2024
    • Kees Cook's avatar
      cifs: Replace remaining 1-element arrays · b3686200
      Kees Cook authored
      commit 35235e19 upstream.
      
      The kernel is globally removing the ambiguous 0-length and 1-element
      arrays in favor of flexible arrays, so that we can gain both compile-time
      and run-time array bounds checking[1].
      
      Replace the trailing 1-element array with a flexible array in the
      following structures:
      
      	struct cifs_spnego_msg
      	struct cifs_quota_data
      	struct get_dfs_referral_rsp
      	struct file_alt_name_info
      	NEGOTIATE_RSP
      	SESSION_SETUP_ANDX
      	TCONX_REQ
      	TCONX_RSP
      	TCONX_RSP_EXT
      	ECHO_REQ
      	ECHO_RSP
      	OPEN_REQ
      	OPENX_REQ
      	LOCK_REQ
      	RENAME_REQ
      	COPY_REQ
      	COPY_RSP
      	NT_RENAME_REQ
      	DELETE_FILE_REQ
      	DELETE_DIRECTORY_REQ
      	CREATE_DIRECTORY_REQ
      	QUERY_INFORMATION_REQ
      	SETATTR_REQ
      	TRANSACT_IOCTL_REQ
      	TRANSACT_CHANGE_NOTIFY_REQ
      	TRANSACTION2_QPI_REQ
      	TRANSACTION2_SPI_REQ
      	TRANSACTION2_FFIRST_REQ
      	TRANSACTION2_GET_DFS_REFER_REQ
      	FILE_UNIX_LINK_INFO
      	FILE_DIRECTORY_INFO
      	FILE_FULL_DIRECTORY_INFO
      	SEARCH_ID_FULL_DIR_INFO
      	FILE_BOTH_DIRECTORY_INFO
      	FIND_FILE_STANDARD_INFO
      
      Replace the trailing 1-element array with a flexible array, but leave
      the existing structure padding:
      
      	FILE_ALL_INFO
      	FILE_UNIX_INFO
      
      Remove unused structures:
      
      	struct gea
      	struct gealist
      
      Adjust all related size calculations to match the changes to sizeof().
      
      No machine code output differences are produced after these changes.
      
      [1] For lots of details, see both:
          https://docs.kernel.org/process/deprecated.html#zero-length-and-one-element-arrays
          https://people.kernel.org/kees/bounded-flexible-arrays-in-c
      
      
      
      Cc: Steve French <sfrench@samba.org>
      Cc: Paulo Alcantara <pc@cjr.nz>
      Cc: Ronnie Sahlberg <lsahlber@redhat.com>
      Cc: Shyam Prasad N <sprasad@microsoft.com>
      Cc: linux-cifs@vger.kernel.org
      Cc: samba-technical@lists.samba.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      [ Salvatore Bonaccorso: Patch does not apply cleanly only due to a
        whitespace difference in fs/smb/client/cifspdu.h . Fixed up manually. ]
      Signed-off-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3686200
    • Kuniyuki Iwashima's avatar
      af_unix: Suppress false-positive lockdep splat for spin_lock() in __unix_gc(). · 2ceacda2
      Kuniyuki Iwashima authored
      [ Upstream commit 1971d13f ]
      
      syzbot reported a lockdep splat regarding unix_gc_lock and
      unix_state_lock().
      
      One is called from recvmsg() for a connected socket, and another
      is called from GC for TCP_LISTEN socket.
      
      So, the splat is false-positive.
      
      Let's add a dedicated lock class for the latter to suppress the splat.
      
      Note that this change is not necessary for net-next.git as the issue
      is only applied to the old GC impl.
      
      [0]:
      WARNING: possible circular locking dependency detected
      6.9.0-rc5-syzkaller-00007-g4d2008430ce8 #0 Not tainted
       -----------------------------------------------------
      kworker/u8:1/11 is trying to acquire lock:
      ffff88807cea4e70 (&u->lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
      ffff88807cea4e70 (&u->lock){+.+.}-{2:2}, at: __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
      
      but task is already holding lock:
      ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
      ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: __unix_gc+0x117/0xf70 net/unix/garbage.c:261
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
       -> #1 (unix_gc_lock){+.+.}-{2:2}:
             lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
             __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
             _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
             spin_lock include/linux/spinlock.h:351 [inline]
             unix_notinflight+0x13d/0x390 net/unix/garbage.c:140
             unix_detach_fds net/unix/af_unix.c:1819 [inline]
             unix_destruct_scm+0x221/0x350 net/unix/af_unix.c:1876
             skb_release_head_state+0x100/0x250 net/core/skbuff.c:1188
             skb_release_all net/core/skbuff.c:1200 [inline]
             __kfree_skb net/core/skbuff.c:1216 [inline]
             kfree_skb_reason+0x16d/0x3b0 net/core/skbuff.c:1252
             kfree_skb include/linux/skbuff.h:1262 [inline]
             manage_oob net/unix/af_unix.c:2672 [inline]
             unix_stream_read_generic+0x1125/0x2700 net/unix/af_unix.c:2749
             unix_stream_splice_read+0x239/0x320 net/unix/af_unix.c:2981
             do_splice_read fs/splice.c:985 [inline]
             splice_file_to_pipe+0x299/0x500 fs/splice.c:1295
             do_splice+0xf2d/0x1880 fs/splice.c:1379
             __do_splice fs/splice.c:1436 [inline]
             __do_sys_splice fs/splice.c:1652 [inline]
             __se_sys_splice+0x331/0x4a0 fs/splice.c:1634
             do_syscall_x64 arch/x86/entry/common.c:52 [inline]
             do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
             entry_SYSCALL_64_after_hwframe+0x77/0x7f
      
       -> #0 (&u->lock){+.+.}-{2:2}:
             check_prev_add kernel/locking/lockdep.c:3134 [inline]
             check_prevs_add kernel/locking/lockdep.c:3253 [inline]
             validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
             __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
             lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
             __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
             _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
             spin_lock include/linux/spinlock.h:351 [inline]
             __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
             process_one_work kernel/workqueue.c:3254 [inline]
             process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335
             worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
             kthread+0x2f0/0x390 kernel/kthread.c:388
             ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
             ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
      
      other info that might help us debug this:
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(unix_gc_lock);
                                     lock(&u->lock);
                                     lock(unix_gc_lock);
        lock(&u->lock);
      
       *** DEADLOCK ***
      
      3 locks held by kworker/u8:1/11:
       #0: ffff888015089148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3229 [inline]
       #0: ffff888015089148 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_scheduled_works+0x8e0/0x17c0 kernel/workqueue.c:3335
       #1: ffffc90000107d00 (unix_gc_work){+.+.}-{0:0}, at: process_one_work kernel/workqueue.c:3230 [inline]
       #1: ffffc90000107d00 (unix_gc_work){+.+.}-{0:0}, at: process_scheduled_works+0x91b/0x17c0 kernel/workqueue.c:3335
       #2: ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
       #2: ffffffff8f6ab638 (unix_gc_lock){+.+.}-{2:2}, at: __unix_gc+0x117/0xf70 net/unix/garbage.c:261
      
      stack backtrace:
      CPU: 0 PID: 11 Comm: kworker/u8:1 Not tainted 6.9.0-rc5-syzkaller-00007-g4d2008430ce8 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
      Workqueue: events_unbound __unix_gc
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
       check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       __unix_gc+0x40e/0xf70 net/unix/garbage.c:302
       process_one_work kernel/workqueue.c:3254 [inline]
       process_scheduled_works+0xa10/0x17c0 kernel/workqueue.c:3335
       worker_thread+0x86d/0xd70 kernel/workqueue.c:3416
       kthread+0x2f0/0x390 kernel/kthread.c:388
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
       </TASK>
      
      Fixes: 47d8ac01
      
       ("af_unix: Fix garbage collector racing against connect()")
      Reported-and-tested-by: default avatar <syzbot+fa379358c28cc87cc307@syzkaller.appspotmail.com>
      Closes: https://syzkaller.appspot.com/bug?extid=fa379358c28cc87cc307
      
      
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Link: https://lore.kernel.org/r/20240424170443.9832-1-kuniyu@amazon.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2ceacda2
    • Jason Reeder's avatar
      net: ethernet: ti: am65-cpts: Fix PTPv1 message type on TX packets · f05caed8
      Jason Reeder authored
      [ Upstream commit 1b9e743e
      
       ]
      
      The CPTS, by design, captures the messageType (Sync, Delay_Req, etc.)
      field from the second nibble of the PTP header which is defined in the
      PTPv2 (1588-2008) specification. In the PTPv1 (1588-2002) specification
      the first two bytes of the PTP header are defined as the versionType
      which is always 0x0001. This means that any PTPv1 packets that are
      tagged for TX timestamping by the CPTS will have their messageType set
      to 0x0 which corresponds to a Sync message type. This causes issues
      when a PTPv1 stack is expecting a Delay_Req (messageType: 0x1)
      timestamp that never appears.
      
      Fix this by checking if the ptp_class of the timestamped TX packet is
      PTP_CLASS_V1 and then matching the PTP sequence ID to the stored
      sequence ID in the skb->cb data structure. If the sequence IDs match
      and the packet is of type PTPv1 then there is a chance that the
      messageType has been incorrectly stored by the CPTS so overwrite the
      messageType stored by the CPTS with the messageType from the skb->cb
      data structure. This allows the PTPv1 stack to receive TX timestamps
      for Delay_Req packets which are necessary to lock onto a PTP Leader.
      
      Signed-off-by: default avatarJason Reeder <jreeder@ti.com>
      Signed-off-by: default avatarRavi Gunasekaran <r-gunasekaran@ti.com>
      Tested-by: default avatarEd Trexel <ed.trexel@hp.com>
      Fixes: f6bd5952 ("net: ethernet: ti: introduce am654 common platform time sync driver")
      Link: https://lore.kernel.org/r/20240424071626.32558-1-r-gunasekaran@ti.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f05caed8
    • Sudheer Mogilappagari's avatar
      iavf: Fix TC config comparison with existing adapter TC config · 777d7d00
      Sudheer Mogilappagari authored
      [ Upstream commit 54976cf5 ]
      
      Same number of TCs doesn't imply that underlying TC configs are
      same. The config could be different due to difference in number
      of queues in each TC. Add utility function to determine if TC
      configs are same.
      
      Fixes: d5b33d02
      
       ("i40evf: add ndo_setup_tc callback to i40evf")
      Signed-off-by: default avatarSudheer Mogilappagari <sudheer.mogilappagari@intel.com>
      Tested-by: Mineri Bhange <minerix.bhange@intel.com> (A Contingent Worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Link: https://lore.kernel.org/r/20240423182723.740401-4-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      777d7d00
    • Erwan Velu's avatar
      i40e: Report MFS in decimal base instead of hex · 81ad28ac
      Erwan Velu authored
      [ Upstream commit ef3c3131
      
       ]
      
      If the MFS is set below the default (0x2600), a warning message is
      reported like the following :
      
      	MFS for port 1 has been set below the default: 600
      
      This message is a bit confusing as the number shown here (600) is in
      fact an hexa number: 0x600 = 1536
      
      Without any explicit "0x" prefix, this message is read like the MFS is
      set to 600 bytes.
      
      MFS, as per MTUs, are usually expressed in decimal base.
      
      This commit reports both current and default MFS values in decimal
      so it's less confusing for end-users.
      
      A typical warning message looks like the following :
      
      	MFS for port 1 (1536) has been set below the default (9728)
      
      Signed-off-by: default avatarErwan Velu <e.velu@criteo.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: default avatarTony Brelinski <tony.brelinski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Fixes: 3a2c6ced ("i40e: Add a check to see if MFS is set")
      Link: https://lore.kernel.org/r/20240423182723.740401-3-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81ad28ac
    • Sindhu Devale's avatar
      i40e: Do not use WQ_MEM_RECLAIM flag for workqueue · 152ed360
      Sindhu Devale authored
      [ Upstream commit 2cc7d150 ]
      
      Issue reported by customer during SRIOV testing, call trace:
      When both i40e and the i40iw driver are loaded, a warning
      in check_flush_dependency is being triggered. This seems
      to be because of the i40e driver workqueue is allocated with
      the WQ_MEM_RECLAIM flag, and the i40iw one is not.
      
      Similar error was encountered on ice too and it was fixed by
      removing the flag. Do the same for i40e too.
      
      [Feb 9 09:08] ------------[ cut here ]------------
      [  +0.000004] workqueue: WQ_MEM_RECLAIM i40e:i40e_service_task [i40e] is
      flushing !WQ_MEM_RECLAIM infiniband:0x0
      [  +0.000060] WARNING: CPU: 0 PID: 937 at kernel/workqueue.c:2966
      check_flush_dependency+0x10b/0x120
      [  +0.000007] Modules linked in: snd_seq_dummy snd_hrtimer snd_seq
      snd_timer snd_seq_device snd soundcore nls_utf8 cifs cifs_arc4
      nls_ucs2_utils rdma_cm iw_cm ib_cm cifs_md4 dns_resolver netfs qrtr
      rfkill sunrpc vfat fat intel_rapl_msr intel_rapl_common irdma
      intel_uncore_frequency intel_uncore_frequency_common ice ipmi_ssif
      isst_if_common skx_edac nfit libnvdimm x86_pkg_temp_thermal
      intel_powerclamp gnss coretemp ib_uverbs rapl intel_cstate ib_core
      iTCO_wdt iTCO_vendor_support acpi_ipmi mei_me ipmi_si intel_uncore
      ioatdma i2c_i801 joydev pcspkr mei ipmi_devintf lpc_ich
      intel_pch_thermal i2c_smbus ipmi_msghandler acpi_power_meter acpi_pad
      xfs libcrc32c ast sd_mod drm_shmem_helper t10_pi drm_kms_helper sg ixgbe
      drm i40e ahci crct10dif_pclmul libahci crc32_pclmul igb crc32c_intel
      libata ghash_clmulni_intel i2c_algo_bit mdio dca wmi dm_mirror
      dm_region_hash dm_log dm_mod fuse
      [  +0.000050] CPU: 0 PID: 937 Comm: kworker/0:3 Kdump: loaded Not
      tainted 6.8.0-rc2-Feb-net_dev-Qiueue-00279-gbd43c5687e05 #1
      [  +0.000003] Hardware name: Intel Corporation S2600BPB/S2600BPB, BIOS
      SE5C620.86B.02.01.0013.121520200651 12/15/2020
      [  +0.000001] Workqueue: i40e i40e_service_task [i40e]
      [  +0.000024] RIP: 0010:check_flush_dependency+0x10b/0x120
      [  +0.000003] Code: ff 49 8b 54 24 18 48 8d 8b b0 00 00 00 49 89 e8 48
      81 c6 b0 00 00 00 48 c7 c7 b0 97 fa 9f c6 05 8a cc 1f 02 01 e8 35 b3 fd
      ff <0f> 0b e9 10 ff ff ff 80 3d 78 cc 1f 02 00 75 94 e9 46 ff ff ff 90
      [  +0.000002] RSP: 0018:ffffbd294976bcf8 EFLAGS: 00010282
      [  +0.000002] RAX: 0000000000000000 RBX: ffff94d4c483c000 RCX:
      0000000000000027
      [  +0.000001] RDX: ffff94d47f620bc8 RSI: 0000000000000001 RDI:
      ffff94d47f620bc0
      [  +0.000001] RBP: 0000000000000000 R08: 0000000000000000 R09:
      00000000ffff7fff
      [  +0.000001] R10: ffffbd294976bb98 R11: ffffffffa0be65e8 R12:
      ffff94c5451ea180
      [  +0.000001] R13: ffff94c5ab5e8000 R14: ffff94c5c20b6e05 R15:
      ffff94c5f1330ab0
      [  +0.000001] FS:  0000000000000000(0000) GS:ffff94d47f600000(0000)
      knlGS:0000000000000000
      [  +0.000002] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  +0.000001] CR2: 00007f9e6f1fca70 CR3: 0000000038e20004 CR4:
      00000000007706f0
      [  +0.000000] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
      0000000000000000
      [  +0.000001] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:
      0000000000000400
      [  +0.000001] PKRU: 55555554
      [  +0.000001] Call Trace:
      [  +0.000001]  <TASK>
      [  +0.000002]  ? __warn+0x80/0x130
      [  +0.000003]  ? check_flush_dependency+0x10b/0x120
      [  +0.000002]  ? report_bug+0x195/0x1a0
      [  +0.000005]  ? handle_bug+0x3c/0x70
      [  +0.000003]  ? exc_invalid_op+0x14/0x70
      [  +0.000002]  ? asm_exc_invalid_op+0x16/0x20
      [  +0.000006]  ? check_flush_dependency+0x10b/0x120
      [  +0.000002]  ? check_flush_dependency+0x10b/0x120
      [  +0.000002]  __flush_workqueue+0x126/0x3f0
      [  +0.000015]  ib_cache_cleanup_one+0x1c/0xe0 [ib_core]
      [  +0.000056]  __ib_unregister_device+0x6a/0xb0 [ib_core]
      [  +0.000023]  ib_unregister_device_and_put+0x34/0x50 [ib_core]
      [  +0.000020]  i40iw_close+0x4b/0x90 [irdma]
      [  +0.000022]  i40e_notify_client_of_netdev_close+0x54/0xc0 [i40e]
      [  +0.000035]  i40e_service_task+0x126/0x190 [i40e]
      [  +0.000024]  process_one_work+0x174/0x340
      [  +0.000003]  worker_thread+0x27e/0x390
      [  +0.000001]  ? __pfx_worker_thread+0x10/0x10
      [  +0.000002]  kthread+0xdf/0x110
      [  +0.000002]  ? __pfx_kthread+0x10/0x10
      [  +0.000002]  ret_from_fork+0x2d/0x50
      [  +0.000003]  ? __pfx_kthread+0x10/0x10
      [  +0.000001]  ret_from_fork_asm+0x1b/0x30
      [  +0.000004]  </TASK>
      [  +0.000001] ---[ end trace 0000000000000000 ]---
      
      Fixes: 4d5957cb
      
       ("i40e: remove WQ_UNBOUND and the task limit of our workqueue")
      Signed-off-by: default avatarSindhu Devale <sindhu.devale@intel.com>
      Reviewed-by: default avatarArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
      Reviewed-by: default avatarMateusz Polchlopek <mateusz.polchlopek@intel.com>
      Signed-off-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
      Tested-by: default avatarRobert Ganzynkowicz <robert.ganzynkowicz@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Link: https://lore.kernel.org/r/20240423182723.740401-2-anthony.l.nguyen@intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      152ed360
    • Pablo Neira Ayuso's avatar
      netfilter: nf_tables: honor table dormant flag from netdev release event path · 13ba94f6
      Pablo Neira Ayuso authored
      [ Upstream commit 8e30abc9 ]
      
      Check for table dormant flag otherwise netdev release event path tries
      to unregister an already unregistered hook.
      
      [524854.857999] ------------[ cut here ]------------
      [524854.858010] WARNING: CPU: 0 PID: 3386599 at net/netfilter/core.c:501 __nf_unregister_net_hook+0x21a/0x260
      [...]
      [524854.858848] CPU: 0 PID: 3386599 Comm: kworker/u32:2 Not tainted 6.9.0-rc3+ #365
      [524854.858869] Workqueue: netns cleanup_net
      [524854.858886] RIP: 0010:__nf_unregister_net_hook+0x21a/0x260
      [524854.858903] Code: 24 e8 aa 73 83 ff 48 63 43 1c 83 f8 01 0f 85 3d ff ff ff e8 98 d1 f0 ff 48 8b 3c 24 e8 8f 73 83 ff 48 63 43 1c e9 26 ff ff ff <0f> 0b 48 83 c4 18 48 c7 c7 00 68 e9 82 5b 5d 41 5c 41 5d 41 5e 41
      [524854.858914] RSP: 0018:ffff8881e36d79e0 EFLAGS: 00010246
      [524854.858926] RAX: 0000000000000000 RBX: ffff8881339ae790 RCX: ffffffff81ba524a
      [524854.858936] RDX: dffffc0000000000 RSI: 0000000000000008 RDI: ffff8881c8a16438
      [524854.858945] RBP: ffff8881c8a16438 R08: 0000000000000001 R09: ffffed103c6daf34
      [524854.858954] R10: ffff8881e36d79a7 R11: 0000000000000000 R12: 0000000000000005
      [524854.858962] R13: ffff8881c8a16000 R14: 0000000000000000 R15: ffff8881351b5a00
      [524854.858971] FS:  0000000000000000(0000) GS:ffff888390800000(0000) knlGS:0000000000000000
      [524854.858982] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [524854.858991] CR2: 00007fc9be0f16f4 CR3: 00000001437cc004 CR4: 00000000001706f0
      [524854.859000] Call Trace:
      [524854.859006]  <TASK>
      [524854.859013]  ? __warn+0x9f/0x1a0
      [524854.859027]  ? __nf_unregister_net_hook+0x21a/0x260
      [524854.859044]  ? report_bug+0x1b1/0x1e0
      [524854.859060]  ? handle_bug+0x3c/0x70
      [524854.859071]  ? exc_invalid_op+0x17/0x40
      [524854.859083]  ? asm_exc_invalid_op+0x1a/0x20
      [524854.859100]  ? __nf_unregister_net_hook+0x6a/0x260
      [524854.859116]  ? __nf_unregister_net_hook+0x21a/0x260
      [524854.859135]  nf_tables_netdev_event+0x337/0x390 [nf_tables]
      [524854.859304]  ? __pfx_nf_tables_netdev_event+0x10/0x10 [nf_tables]
      [524854.859461]  ? packet_notifier+0xb3/0x360
      [524854.859476]  ? _raw_spin_unlock_irqrestore+0x11/0x40
      [524854.859489]  ? dcbnl_netdevice_event+0x35/0x140
      [524854.859507]  ? __pfx_nf_tables_netdev_event+0x10/0x10 [nf_tables]
      [524854.859661]  notifier_call_chain+0x7d/0x140
      [524854.859677]  unregister_netdevice_many_notify+0x5e1/0xae0
      
      Fixes: d54725cd
      
       ("netfilter: nf_tables: support for multiple devices per netdev hook")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      13ba94f6
    • Jakub Kicinski's avatar
      eth: bnxt: fix counting packets discarded due to OOM and netpoll · e3253574
      Jakub Kicinski authored
      [ Upstream commit 73011773 ]
      
      I added OOM and netpoll discard counters, naively assuming that
      the cpr pointer is pointing to a common completion ring.
      Turns out that is usually *a* completion ring but not *the*
      completion ring which bnapi->cp_ring points to. bnapi->cp_ring
      is where the stats are read from, so we end up reporting 0
      thru ethtool -S and qstat even though the drop events have happened.
      Make 100% sure we're recording statistics in the correct structure.
      
      Fixes: 907fd4a2
      
       ("bnxt: count discards due to memory allocation errors")
      Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Link: https://lore.kernel.org/r/20240424002148.3937059-1-kuba@kernel.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3253574
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix memory leak when canceling rehash work · 5bfe7bf9
      Ido Schimmel authored
      [ Upstream commit fb4e2b70 ]
      
      The rehash delayed work is rescheduled with a delay if the number of
      credits at end of the work is not negative as supposedly it means that
      the migration ended. Otherwise, it is rescheduled immediately.
      
      After "mlxsw: spectrum_acl_tcam: Fix possible use-after-free during
      rehash" the above is no longer accurate as a non-negative number of
      credits is no longer indicative of the migration being done. It can also
      happen if the work encountered an error in which case the migration will
      resume the next time the work is scheduled.
      
      The significance of the above is that it is possible for the work to be
      pending and associated with hints that were allocated when the migration
      started. This leads to the hints being leaked [1] when the work is
      canceled while pending as part of ACL region dismantle.
      
      Fix by freeing the hints if hints are associated with a work that was
      canceled while pending.
      
      Blame the original commit since the reliance on not having a pending
      work associated with hints is fragile.
      
      [1]
      unreferenced object 0xffff88810e7c3000 (size 256):
        comm "kworker/0:16", pid 176, jiffies 4295460353
        hex dump (first 32 bytes):
          00 30 95 11 81 88 ff ff 61 00 00 00 00 00 00 80  .0......a.......
          00 00 61 00 40 00 00 00 00 00 00 00 04 00 00 00  ..a.@...........
        backtrace (crc 2544ddb9):
          [<00000000cf8cfab3>] kmalloc_trace+0x23f/0x2a0
          [<000000004d9a1ad9>] objagg_hints_get+0x42/0x390
          [<000000000b143cf3>] mlxsw_sp_acl_erp_rehash_hints_get+0xca/0x400
          [<0000000059bdb60a>] mlxsw_sp_acl_tcam_vregion_rehash_work+0x868/0x1160
          [<00000000e81fd734>] process_one_work+0x59c/0xf20
          [<00000000ceee9e81>] worker_thread+0x799/0x12c0
          [<00000000bda6fe39>] kthread+0x246/0x300
          [<0000000070056d23>] ret_from_fork+0x34/0x70
          [<00000000dea2b93e>] ret_from_fork_asm+0x1a/0x30
      
      Fixes: c9c9af91
      
       ("mlxsw: spectrum_acl: Allow to interrupt/continue rehash work")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/0cc12ebb07c4d4c41a1265ee2c28b392ff997a86.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5bfe7bf9
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix incorrect list API usage · 4526a56e
      Ido Schimmel authored
      [ Upstream commit b377add0 ]
      
      Both the function that migrates all the chunks within a region and the
      function that migrates all the entries within a chunk call
      list_first_entry() on the respective lists without checking that the
      lists are not empty. This is incorrect usage of the API, which leads to
      the following warning [1].
      
      Fix by returning if the lists are empty as there is nothing to migrate
      in this case.
      
      [1]
      WARNING: CPU: 0 PID: 6437 at drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c:1266 mlxsw_sp_acl_tcam_vchunk_migrate_all+0x1f1/0>
      Modules linked in:
      CPU: 0 PID: 6437 Comm: kworker/0:37 Not tainted 6.9.0-rc3-custom-00883-g94a65f079ef6 #39
      Hardware name: Mellanox Technologies Ltd. MSN3700/VMOD0005, BIOS 5.11 01/06/2019
      Workqueue: mlxsw_core mlxsw_sp_acl_tcam_vregion_rehash_work
      RIP: 0010:mlxsw_sp_acl_tcam_vchunk_migrate_all+0x1f1/0x2c0
      [...]
      Call Trace:
       <TASK>
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x6c/0x4a0
       process_one_work+0x151/0x370
       worker_thread+0x2cb/0x3e0
       kthread+0xd0/0x100
       ret_from_fork+0x34/0x50
       ret_from_fork_asm+0x1a/0x30
       </TASK>
      
      Fixes: 6f9579d4
      
       ("mlxsw: spectrum_acl: Remember where to continue rehash migration")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/4628e9a22d1d84818e28310abbbc498e7bc31bc9.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4526a56e
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix warning during rehash · 751d3528
      Ido Schimmel authored
      [ Upstream commit 743edc85 ]
      
      As previously explained, the rehash delayed work migrates filters from
      one region to another. This is done by iterating over all chunks (all
      the filters with the same priority) in the region and in each chunk
      iterating over all the filters.
      
      When the work runs out of credits it stores the current chunk and entry
      as markers in the per-work context so that it would know where to resume
      the migration from the next time the work is scheduled.
      
      Upon error, the chunk marker is reset to NULL, but without resetting the
      entry markers despite being relative to it. This can result in migration
      being resumed from an entry that does not belong to the chunk being
      migrated. In turn, this will eventually lead to a chunk being iterated
      over as if it is an entry. Because of how the two structures happen to
      be defined, this does not lead to KASAN splats, but to warnings such as
      [1].
      
      Fix by creating a helper that resets all the markers and call it from
      all the places the currently only reset the chunk marker. For good
      measures also call it when starting a completely new rehash. Add a
      warning to avoid future cases.
      
      [1]
      WARNING: CPU: 7 PID: 1076 at drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_keys.c:407 mlxsw_afk_encode+0x242/0x2f0
      Modules linked in:
      CPU: 7 PID: 1076 Comm: kworker/7:24 Tainted: G        W          6.9.0-rc3-custom-00880-g29e61d91b77b #29
      Hardware name: Mellanox Technologies Ltd. MSN3700/VMOD0005, BIOS 5.11 01/06/2019
      Workqueue: mlxsw_core mlxsw_sp_acl_tcam_vregion_rehash_work
      RIP: 0010:mlxsw_afk_encode+0x242/0x2f0
      [...]
      Call Trace:
       <TASK>
       mlxsw_sp_acl_atcam_entry_add+0xd9/0x3c0
       mlxsw_sp_acl_tcam_entry_create+0x5e/0xa0
       mlxsw_sp_acl_tcam_vchunk_migrate_all+0x109/0x290
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x6c/0x470
       process_one_work+0x151/0x370
       worker_thread+0x2cb/0x3e0
       kthread+0xd0/0x100
       ret_from_fork+0x34/0x50
       </TASK>
      
      Fixes: 6f9579d4
      
       ("mlxsw: spectrum_acl: Remember where to continue rehash migration")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/cc17eed86b41dd829d39b07906fec074a9ce580e.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      751d3528
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix memory leak during rehash · b822644f
      Ido Schimmel authored
      [ Upstream commit 8ca3f7a7 ]
      
      The rehash delayed work migrates filters from one region to another.
      This is done by iterating over all chunks (all the filters with the same
      priority) in the region and in each chunk iterating over all the
      filters.
      
      If the migration fails, the code tries to migrate the filters back to
      the old region. However, the rollback itself can also fail in which case
      another migration will be erroneously performed. Besides the fact that
      this ping pong is not a very good idea, it also creates a problem.
      
      Each virtual chunk references two chunks: The currently used one
      ('vchunk->chunk') and a backup ('vchunk->chunk2'). During migration the
      first holds the chunk we want to migrate filters to and the second holds
      the chunk we are migrating filters from.
      
      The code currently assumes - but does not verify - that the backup chunk
      does not exist (NULL) if the currently used chunk does not reference the
      target region. This assumption breaks when we are trying to rollback a
      rollback, resulting in the backup chunk being overwritten and leaked
      [1].
      
      Fix by not rolling back a failed rollback and add a warning to avoid
      future cases.
      
      [1]
      WARNING: CPU: 5 PID: 1063 at lib/parman.c:291 parman_destroy+0x17/0x20
      Modules linked in:
      CPU: 5 PID: 1063 Comm: kworker/5:11 Tainted: G        W          6.9.0-rc2-custom-00784-gc6a05c468a0b #14
      Hardware name: Mellanox Technologies Ltd. MSN3700/VMOD0005, BIOS 5.11 01/06/2019
      Workqueue: mlxsw_core mlxsw_sp_acl_tcam_vregion_rehash_work
      RIP: 0010:parman_destroy+0x17/0x20
      [...]
      Call Trace:
       <TASK>
       mlxsw_sp_acl_atcam_region_fini+0x19/0x60
       mlxsw_sp_acl_tcam_region_destroy+0x49/0xf0
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x1f1/0x470
       process_one_work+0x151/0x370
       worker_thread+0x2cb/0x3e0
       kthread+0xd0/0x100
       ret_from_fork+0x34/0x50
       ret_from_fork_asm+0x1a/0x30
       </TASK>
      
      Fixes: 84350051
      
       ("mlxsw: spectrum_acl: Do rollback as another call to mlxsw_sp_acl_tcam_vchunk_migrate_all()")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/d5edd4f4503934186ae5cfe268503b16345b4e0f.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b822644f
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Rate limit error message · 78884187
      Ido Schimmel authored
      [ Upstream commit 5bcf9255 ]
      
      In the rare cases when the device resources are exhausted it is likely
      that the rehash delayed work will fail. An error message will be printed
      whenever this happens which can be overwhelming considering the fact
      that the work is per-region and that there can be hundreds of regions.
      
      Fix by rate limiting the error message.
      
      Fixes: e5e7962e
      
       ("mlxsw: spectrum_acl: Implement region migration according to hints")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/c510763b2ebd25e7990d80183feff91cde593145.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      78884187
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix possible use-after-free during rehash · 813e2ab7
      Ido Schimmel authored
      [ Upstream commit 54225988 ]
      
      The rehash delayed work migrates filters from one region to another
      according to the number of available credits.
      
      The migrated from region is destroyed at the end of the work if the
      number of credits is non-negative as the assumption is that this is
      indicative of migration being complete. This assumption is incorrect as
      a non-negative number of credits can also be the result of a failed
      migration.
      
      The destruction of a region that still has filters referencing it can
      result in a use-after-free [1].
      
      Fix by not destroying the region if migration failed.
      
      [1]
      BUG: KASAN: slab-use-after-free in mlxsw_sp_acl_ctcam_region_entry_remove+0x21d/0x230
      Read of size 8 at addr ffff8881735319e8 by task kworker/0:31/3858
      
      CPU: 0 PID: 3858 Comm: kworker/0:31 Tainted: G        W          6.9.0-rc2-custom-00782-gf2275c2157d8 #5
      Hardware name: Mellanox Technologies Ltd. MSN3700/VMOD0005, BIOS 5.11 01/06/2019
      Workqueue: mlxsw_core mlxsw_sp_acl_tcam_vregion_rehash_work
      Call Trace:
       <TASK>
       dump_stack_lvl+0xc6/0x120
       print_report+0xce/0x670
       kasan_report+0xd7/0x110
       mlxsw_sp_acl_ctcam_region_entry_remove+0x21d/0x230
       mlxsw_sp_acl_ctcam_entry_del+0x2e/0x70
       mlxsw_sp_acl_atcam_entry_del+0x81/0x210
       mlxsw_sp_acl_tcam_vchunk_migrate_all+0x3cd/0xb50
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x157/0x1300
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
       </TASK>
      
      Allocated by task 174:
       kasan_save_stack+0x33/0x60
       kasan_save_track+0x14/0x30
       __kasan_kmalloc+0x8f/0xa0
       __kmalloc+0x19c/0x360
       mlxsw_sp_acl_tcam_region_create+0xdf/0x9c0
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x954/0x1300
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
      
      Freed by task 7:
       kasan_save_stack+0x33/0x60
       kasan_save_track+0x14/0x30
       kasan_save_free_info+0x3b/0x60
       poison_slab_object+0x102/0x170
       __kasan_slab_free+0x14/0x30
       kfree+0xc1/0x290
       mlxsw_sp_acl_tcam_region_destroy+0x272/0x310
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x731/0x1300
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
      
      Fixes: c9c9af91
      
       ("mlxsw: spectrum_acl: Allow to interrupt/continue rehash work")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/3e412b5659ec2310c5c615760dfe5eac18dd7ebd.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      813e2ab7
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix possible use-after-free during activity update · b996e869
      Ido Schimmel authored
      [ Upstream commit 79b5b4b1 ]
      
      The rule activity update delayed work periodically traverses the list of
      configured rules and queries their activity from the device.
      
      As part of this task it accesses the entry pointed by 'ventry->entry',
      but this entry can be changed concurrently by the rehash delayed work,
      leading to a use-after-free [1].
      
      Fix by closing the race and perform the activity query under the
      'vregion->lock' mutex.
      
      [1]
      BUG: KASAN: slab-use-after-free in mlxsw_sp_acl_tcam_flower_rule_activity_get+0x121/0x140
      Read of size 8 at addr ffff8881054ed808 by task kworker/0:18/181
      
      CPU: 0 PID: 181 Comm: kworker/0:18 Not tainted 6.9.0-rc2-custom-00781-gd5ab772d32f7 #2
      Hardware name: Mellanox Technologies Ltd. MSN3700/VMOD0005, BIOS 5.11 01/06/2019
      Workqueue: mlxsw_core mlxsw_sp_acl_rule_activity_update_work
      Call Trace:
       <TASK>
       dump_stack_lvl+0xc6/0x120
       print_report+0xce/0x670
       kasan_report+0xd7/0x110
       mlxsw_sp_acl_tcam_flower_rule_activity_get+0x121/0x140
       mlxsw_sp_acl_rule_activity_update_work+0x219/0x400
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
       </TASK>
      
      Allocated by task 1039:
       kasan_save_stack+0x33/0x60
       kasan_save_track+0x14/0x30
       __kasan_kmalloc+0x8f/0xa0
       __kmalloc+0x19c/0x360
       mlxsw_sp_acl_tcam_entry_create+0x7b/0x1f0
       mlxsw_sp_acl_tcam_vchunk_migrate_all+0x30d/0xb50
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x157/0x1300
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
      
      Freed by task 1039:
       kasan_save_stack+0x33/0x60
       kasan_save_track+0x14/0x30
       kasan_save_free_info+0x3b/0x60
       poison_slab_object+0x102/0x170
       __kasan_slab_free+0x14/0x30
       kfree+0xc1/0x290
       mlxsw_sp_acl_tcam_vchunk_migrate_all+0x3d7/0xb50
       mlxsw_sp_acl_tcam_vregion_rehash_work+0x157/0x1300
       process_one_work+0x8eb/0x19b0
       worker_thread+0x6c9/0xf70
       kthread+0x2c9/0x3b0
       ret_from_fork+0x4d/0x80
       ret_from_fork_asm+0x1a/0x30
      
      Fixes: 2bffc532
      
       ("mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/1fcce0a60b231ebeb2515d91022284ba7b4ffe7a.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b996e869
    • Ido Schimmel's avatar
      mlxsw: spectrum_acl_tcam: Fix race during rehash delayed work · 19ebdce6
      Ido Schimmel authored
      [ Upstream commit d90cfe20 ]
      
      The purpose of the rehash delayed work is to reduce the number of masks
      (eRPs) used by an ACL region as the eRP bank is a global and limited
      resource.
      
      This is done in three steps:
      
      1. Creating a new set of masks and a new ACL region which will use the
         new masks and to which the existing filters will be migrated to. The
         new region is assigned to 'vregion->region' and the region from which
         the filters are migrated from is assigned to 'vregion->region2'.
      
      2. Migrating all the filters from the old region to the new region.
      
      3. Destroying the old region and setting 'vregion->region2' to NULL.
      
      Only the second steps is performed under the 'vregion->lock' mutex
      although its comments says that among other things it "Protects
      consistency of region, region2 pointers".
      
      This is problematic as the first step can race with filter insertion
      from user space that uses 'vregion->region', but under the mutex.
      
      Fix by holding the mutex across the entirety of the delayed work and not
      only during the second step.
      
      Fixes: 2bffc532
      
       ("mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()")
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Tested-by: default avatarAlexander Zubkov <green@qrator.net>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/1ec1d54edf2bad0a369e6b4fa030aba64e1f124b.1713797103.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      19ebdce6
    • Hyunwoo Kim's avatar
      net: openvswitch: Fix Use-After-Free in ovs_ct_exit · bca6fa2d
      Hyunwoo Kim authored
      [ Upstream commit 5ea7b72d ]
      
      Since kfree_rcu, which is called in the hlist_for_each_entry_rcu traversal
      of ovs_ct_limit_exit, is not part of the RCU read critical section, it
      is possible that the RCU grace period will pass during the traversal and
      the key will be free.
      
      To prevent this, it should be changed to hlist_for_each_entry_safe.
      
      Fixes: 11efd5cb
      
       ("openvswitch: Support conntrack zone limit")
      Signed-off-by: default avatarHyunwoo Kim <v4bel@theori.io>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Reviewed-by: default avatarAaron Conole <aconole@redhat.com>
      Link: https://lore.kernel.org/r/ZiYvzQN/Ry5oeFQW@v4bel-B760M-AORUS-ELITE-AX
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bca6fa2d
    • Ismael Luceno's avatar
      ipvs: Fix checksumming on GSO of SCTP packets · f4861f05
      Ismael Luceno authored
      [ Upstream commit e10d3ba4 ]
      
      It was observed in the wild that pairs of consecutive packets would leave
      the IPVS with the same wrong checksum, and the issue only went away when
      disabling GSO.
      
      IPVS needs to avoid computing the SCTP checksum when using GSO.
      
      Fixes: 90017acc
      
       ("sctp: Add GSO support")
      Co-developed-by: default avatarFiro Yang <firo.yang@suse.com>
      Signed-off-by: default avatarIsmael Luceno <iluceno@suse.de>
      Tested-by: default avatarAndreas Taschner <andreas.taschner@suse.com>
      Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4861f05
    • Bartosz Golaszewski's avatar
      Bluetooth: qca: set power_ctrl_enabled on NULL returned by gpiod_get_optional() · 4115403d
      Bartosz Golaszewski authored
      [ Upstream commit 3d05fc82 ]
      
      Any return value from gpiod_get_optional() other than a pointer to a
      GPIO descriptor or a NULL-pointer is an error and the driver should
      abort probing. That being said: commit 56d074d2
      
       ("Bluetooth: hci_qca:
      don't use IS_ERR_OR_NULL() with gpiod_get_optional()") no longer sets
      power_ctrl_enabled on NULL-pointer returned by
      devm_gpiod_get_optional(). Restore this behavior but bail-out on errors.
      While at it: also bail-out on error returned when trying to get the
      "swctrl" GPIO.
      
      Reported-by: default avatarWren Turkal <wt@penguintechs.org>
      Reported-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
      Closes: https://lore.kernel.org/linux-bluetooth/1713449192-25926-2-git-send-email-quic_zijuhu@quicinc.com/
      Fixes: 56d074d2
      
       ("Bluetooth: hci_qca: don't use IS_ERR_OR_NULL() with gpiod_get_optional()")
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Tested-by: default avatarWren Turkal <wt@penguintechs.org>
      Reported-by: default avatarWren Turkal <wt@penguintechs.org>
      Reported-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
      Reviewed-by: default avatarKrzysztof <Kozlowski&lt;krzysztof.kozlowski@linaro.org>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4115403d
    • Chun-Yi Lee's avatar
      Bluetooth: hci_sync: Using hci_cmd_sync_submit when removing Adv Monitor · 31f18a1f
      Chun-Yi Lee authored
      [ Upstream commit 88cd6e6b ]
      
      Since the d883a466 be introduced in v6.4, bluetooth daemon
      got the following failed message of MGMT_OP_REMOVE_ADV_MONITOR
      command when controller is power-off:
      
      bluetoothd[20976]:
      src/adapter.c:reset_adv_monitors_complete() Failed to reset Adv
      Monitors: Failed>
      
      Normally this situation is happened when the bluetoothd deamon
      be started manually after system booting. Which means that
      bluetoothd received MGMT_EV_INDEX_ADDED event after kernel
      runs hci_power_off().
      
      Base on doc/mgmt-api.txt, the MGMT_OP_REMOVE_ADV_MONITOR command
      can be used when the controller is not powered. This patch changes
      the code in remove_adv_monitor() to use hci_cmd_sync_submit()
      instead of hci_cmd_sync_queue().
      
      Fixes: d883a466
      
       ("Bluetooth: hci_sync: Only allow hci_cmd_sync_queue if running")
      Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Cc: Manish Mandlik <mmandlik@google.com>
      Cc: Archie Pusaka <apusaka@chromium.org>
      Cc: Miao-chen Chou <mcchou@chromium.org>
      Signed-off-by: default avatarChun-Yi Lee <jlee@suse.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      31f18a1f
    • Luiz Augusto von Dentz's avatar
      Bluetooth: MGMT: Fix failing to MGMT_OP_ADD_UUID/MGMT_OP_REMOVE_UUID · 14051cbc
      Luiz Augusto von Dentz authored
      [ Upstream commit 6eb5fcc4 ]
      
      These commands don't require the adapter to be up and running so don't
      use hci_cmd_sync_queue which would check that flag, instead use
      hci_cmd_sync_submit which would ensure mgmt_class_complete is set
      properly regardless if any command was actually run or not.
      
      Link: https://github.com/bluez/bluez/issues/809
      Fixes: d883a466
      
       ("Bluetooth: hci_sync: Only allow hci_cmd_sync_queue if running")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      14051cbc
    • Hyunwoo Kim's avatar
      net: gtp: Fix Use-After-Free in gtp_dellink · 25a1c2d4
      Hyunwoo Kim authored
      [ Upstream commit f2a90410 ]
      
      Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal
      of gtp_dellink, is not part of the RCU read critical section, it
      is possible that the RCU grace period will pass during the traversal and
      the key will be free.
      
      To prevent this, it should be changed to hlist_for_each_entry_safe.
      
      Fixes: 94dc550a
      
       ("gtp: fix an use-after-free in ipv4_pdp_find()")
      Signed-off-by: default avatarHyunwoo Kim <v4bel@theori.io>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      25a1c2d4
    • Eric Dumazet's avatar
      net: usb: ax88179_178a: stop lying about skb->truesize · 5e5e1865
      Eric Dumazet authored
      [ Upstream commit 4ce62d5b ]
      
      Some usb drivers try to set small skb->truesize and break
      core networking stacks.
      
      In this patch, I removed one of the skb->truesize overide.
      
      I also replaced one skb_clone() by an allocation of a fresh
      and small skb, to get minimally sized skbs, like we did
      in commit 1e2c6117 ("net: cdc_ncm: reduce skb truesize
      in rx path")
      
      Fixes: f8ebb3ac
      
       ("net: usb: ax88179_178a: Fix packet receiving")
      Reported-by: default avatarshironeko <shironeko@tesaguri.club>
      Closes: https://lore.kernel.org/netdev/c110f41a0d2776b525930f213ca9715c@tesaguri.club/
      
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Jose Alonso <joalonsof@gmail.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20240421193828.1966195-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5e5e1865
    • Eric Dumazet's avatar
      ipv4: check for NULL idev in ip_route_use_hint() · 7a25bfd1
      Eric Dumazet authored
      [ Upstream commit 58a4c9b1 ]
      
      syzbot was able to trigger a NULL deref in fib_validate_source()
      in an old tree [1].
      
      It appears the bug exists in latest trees.
      
      All calls to __in_dev_get_rcu() must be checked for a NULL result.
      
      [1]
      general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN
      KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
      CPU: 2 PID: 3257 Comm: syz-executor.3 Not tainted 5.10.0-syzkaller #0
      Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
       RIP: 0010:fib_validate_source+0xbf/0x15a0 net/ipv4/fib_frontend.c:425
      Code: 18 f2 f2 f2 f2 42 c7 44 20 23 f3 f3 f3 f3 48 89 44 24 78 42 c6 44 20 27 f3 e8 5d 88 48 fc 4c 89 e8 48 c1 e8 03 48 89 44 24 18 <42> 80 3c 20 00 74 08 4c 89 ef e8 d2 15 98 fc 48 89 5c 24 10 41 bf
      RSP: 0018:ffffc900015fee40 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: ffff88800f7a4000 RCX: ffff88800f4f90c0
      RDX: 0000000000000000 RSI: 0000000004001eac RDI: ffff8880160c64c0
      RBP: ffffc900015ff060 R08: 0000000000000000 R09: ffff88800f7a4000
      R10: 0000000000000002 R11: ffff88800f4f90c0 R12: dffffc0000000000
      R13: 0000000000000000 R14: 0000000000000000 R15: ffff88800f7a4000
      FS:  00007f938acfe6c0(0000) GS:ffff888058c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f938acddd58 CR3: 000000001248e000 CR4: 0000000000352ef0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
        ip_route_use_hint+0x410/0x9b0 net/ipv4/route.c:2231
        ip_rcv_finish_core+0x2c4/0x1a30 net/ipv4/ip_input.c:327
        ip_list_rcv_finish net/ipv4/ip_input.c:612 [inline]
        ip_sublist_rcv+0x3ed/0xe50 net/ipv4/ip_input.c:638
        ip_list_rcv+0x422/0x470 net/ipv4/ip_input.c:673
        __netif_receive_skb_list_ptype net/core/dev.c:5572 [inline]
        __netif_receive_skb_list_core+0x6b1/0x890 net/core/dev.c:5620
        __netif_receive_skb_list net/core/dev.c:5672 [inline]
        netif_receive_skb_list_internal+0x9f9/0xdc0 net/core/dev.c:5764
        netif_receive_skb_list+0x55/0x3e0 net/core/dev.c:5816
        xdp_recv_frames net/bpf/test_run.c:257 [inline]
        xdp_test_run_batch net/bpf/test_run.c:335 [inline]
        bpf_test_run_xdp_live+0x1818/0x1d00 net/bpf/test_run.c:363
        bpf_prog_test_run_xdp+0x81f/0x1170 net/bpf/test_run.c:1376
        bpf_prog_test_run+0x349/0x3c0 kernel/bpf/syscall.c:3736
        __sys_bpf+0x45c/0x710 kernel/bpf/syscall.c:5115
        __do_sys_bpf kernel/bpf/syscall.c:5201 [inline]
        __se_sys_bpf kernel/bpf/syscall.c:5199 [inline]
        __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5199
      
      Fixes: 02b24941
      
       ("ipv4: use dst hint for ipv4 list receive")
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Link: https://lore.kernel.org/r/20240421184326.1704930-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a25bfd1
    • Eric Dumazet's avatar
      net: fix sk_memory_allocated_{add|sub} vs softirqs · 1e9b6945
      Eric Dumazet authored
      [ Upstream commit 3584718c ]
      
      Jonathan Heathcote reported a regression caused by blamed commit
      on aarch64 architecture.
      
      x86 happens to have irq-safe __this_cpu_add_return()
      and __this_cpu_sub(), but this is not generic.
      
      I think my confusion came from "struct sock" argument,
      because these helpers are called with a locked socket.
      But the memory accounting is per-proto (and per-cpu after
      the blamed commit). We might cleanup these helpers later
      to directly accept a "struct proto *proto" argument.
      
      Switch to this_cpu_add_return() and this_cpu_xchg()
      operations, and get rid of preempt_disable()/preempt_enable() pairs.
      
      Fast path becomes a bit faster as a result :)
      
      Many thanks to Jonathan Heathcote for his awesome report and
      investigations.
      
      Fixes: 3cd3399d
      
       ("net: implement per-cpu reserves for memory_allocated")
      Reported-by: default avatarJonathan Heathcote <jonathan.heathcote@bbc.co.uk>
      Closes: https://lore.kernel.org/netdev/VI1PR01MB42407D7947B2EA448F1E04EFD10D2@VI1PR01MB4240.eurprd01.prod.exchangelabs.com/
      
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Reviewed-by: default avatarShakeel Butt <shakeel.butt@linux.dev>
      Link: https://lore.kernel.org/r/20240421175248.1692552-1-edumazet@google.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e9b6945
    • Adam Li's avatar
      net: make SK_MEMORY_PCPU_RESERV tunable · 82810873
      Adam Li authored
      [ Upstream commit 12a686c2 ]
      
      This patch adds /proc/sys/net/core/mem_pcpu_rsv sysctl file,
      to make SK_MEMORY_PCPU_RESERV tunable.
      
      Commit 3cd3399d
      
       ("net: implement per-cpu reserves for
      memory_allocated") introduced per-cpu forward alloc cache:
      
      "Implement a per-cpu cache of +1/-1 MB, to reduce number
      of changes to sk->sk_prot->memory_allocated, which
      would otherwise be cause of false sharing."
      
      sk_prot->memory_allocated points to global atomic variable:
      atomic_long_t tcp_memory_allocated ____cacheline_aligned_in_smp;
      
      If increasing the per-cpu cache size from 1MB to e.g. 16MB,
      changes to sk->sk_prot->memory_allocated can be further reduced.
      Performance may be improved on system with many cores.
      
      Signed-off-by: default avatarAdam Li <adamli@os.amperecomputing.com>
      Reviewed-by: default avatarChristoph Lameter (Ampere) <cl@linux.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: 3584718c
      
       ("net: fix sk_memory_allocated_{add|sub} vs softirqs")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      82810873
    • Duoming Zhou's avatar
      ax25: Fix netdev refcount issue · 0d14f104
      Duoming Zhou authored
      [ Upstream commit 467324bc ]
      
      The dev_tracker is added to ax25_cb in ax25_bind(). When the
      ax25 device is detaching, the dev_tracker of ax25_cb should be
      deallocated in ax25_kill_by_device() instead of the dev_tracker
      of ax25_dev. The log reported by ref_tracker is shown below:
      
      [   80.884935] ref_tracker: reference already released.
      [   80.885150] ref_tracker: allocated in:
      [   80.885349]  ax25_dev_device_up+0x105/0x540
      [   80.885730]  ax25_device_event+0xa4/0x420
      [   80.885730]  notifier_call_chain+0xc9/0x1e0
      [   80.885730]  __dev_notify_flags+0x138/0x280
      [   80.885730]  dev_change_flags+0xd7/0x180
      [   80.885730]  dev_ifsioc+0x6a9/0xa30
      [   80.885730]  dev_ioctl+0x4d8/0xd90
      [   80.885730]  sock_do_ioctl+0x1c2/0x2d0
      [   80.885730]  sock_ioctl+0x38b/0x4f0
      [   80.885730]  __se_sys_ioctl+0xad/0xf0
      [   80.885730]  do_syscall_64+0xc4/0x1b0
      [   80.885730]  entry_SYSCALL_64_after_hwframe+0x67/0x6f
      [   80.885730] ref_tracker: freed in:
      [   80.885730]  ax25_device_event+0x272/0x420
      [   80.885730]  notifier_call_chain+0xc9/0x1e0
      [   80.885730]  dev_close_many+0x272/0x370
      [   80.885730]  unregister_netdevice_many_notify+0x3b5/0x1180
      [   80.885730]  unregister_netdev+0xcf/0x120
      [   80.885730]  sixpack_close+0x11f/0x1b0
      [   80.885730]  tty_ldisc_kill+0xcb/0x190
      [   80.885730]  tty_ldisc_hangup+0x338/0x3d0
      [   80.885730]  __tty_hangup+0x504/0x740
      [   80.885730]  tty_release+0x46e/0xd80
      [   80.885730]  __fput+0x37f/0x770
      [   80.885730]  __x64_sys_close+0x7b/0xb0
      [   80.885730]  do_syscall_64+0xc4/0x1b0
      [   80.885730]  entry_SYSCALL_64_after_hwframe+0x67/0x6f
      [   80.893739] ------------[ cut here ]------------
      [   80.894030] WARNING: CPU: 2 PID: 140 at lib/ref_tracker.c:255 ref_tracker_free+0x47b/0x6b0
      [   80.894297] Modules linked in:
      [   80.894929] CPU: 2 PID: 140 Comm: ax25_conn_rel_6 Not tainted 6.9.0-rc4-g8cd26fd90c1a #11
      [   80.895190] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qem4
      [   80.895514] RIP: 0010:ref_tracker_free+0x47b/0x6b0
      [   80.895808] Code: 83 c5 18 4c 89 eb 48 c1 eb 03 8a 04 13 84 c0 0f 85 df 01 00 00 41 83 7d 00 00 75 4b 4c 89 ff 9
      [   80.896171] RSP: 0018:ffff888009edf8c0 EFLAGS: 00000286
      [   80.896339] RAX: 1ffff1100141ac00 RBX: 1ffff1100149463b RCX: dffffc0000000000
      [   80.896502] RDX: 0000000000000001 RSI: 0000000000000246 RDI: ffff88800a0d6518
      [   80.896925] RBP: ffff888009edf9b0 R08: ffff88806d3288d3 R09: 1ffff1100da6511a
      [   80.897212] R10: dffffc0000000000 R11: ffffed100da6511b R12: ffff88800a4a31d4
      [   80.897859] R13: ffff88800a4a31d8 R14: dffffc0000000000 R15: ffff88800a0d6518
      [   80.898279] FS:  00007fd88b7fe700(0000) GS:ffff88806d300000(0000) knlGS:0000000000000000
      [   80.899436] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   80.900181] CR2: 00007fd88c001d48 CR3: 000000000993e000 CR4: 00000000000006f0
      ...
      [   80.935774] ref_tracker: sp%d@000000000bb9df3d has 1/1 users at
      [   80.935774]      ax25_bind+0x424/0x4e0
      [   80.935774]      __sys_bind+0x1d9/0x270
      [   80.935774]      __x64_sys_bind+0x75/0x80
      [   80.935774]      do_syscall_64+0xc4/0x1b0
      [   80.935774]      entry_SYSCALL_64_after_hwframe+0x67/0x6f
      
      Change ax25_dev->dev_tracker to the dev_tracker of ax25_cb
      in order to mitigate the bug.
      
      Fixes: feef318c
      
       ("ax25: fix UAF bugs of net_device caused by rebinding operation")
      Signed-off-by: default avatarDuoming Zhou <duoming@zju.edu.cn>
      Link: https://lore.kernel.org/r/20240419020456.29826-1-duoming@zju.edu.cn
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d14f104
    • Paul Geurts's avatar
      NFC: trf7970a: disable all regulators on removal · 424c69db
      Paul Geurts authored
      [ Upstream commit 6bea4f03 ]
      
      During module probe, regulator 'vin' and 'vdd-io' are used and enabled,
      but the vdd-io regulator overwrites the 'vin' regulator pointer. During
      remove, only the vdd-io is disabled, as the vin regulator pointer is not
      available anymore. When regulator_put() is called during resource
      cleanup a kernel warning is given, as the regulator is still enabled.
      
      Store the two regulators in separate pointers and disable both the
      regulators on module remove.
      
      Fixes: 49d22c70
      
       ("NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage")
      Signed-off-by: default avatarPaul Geurts <paul_geurts@live.nl>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Link: https://lore.kernel.org/r/DB7PR09MB26847A4EBF88D9EDFEB1DA0F950E2@DB7PR09MB2684.eurprd09.prod.outlook.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      424c69db
    • Vikas Gupta's avatar
      bnxt_en: Fix the PCI-AER routines · 25a82005
      Vikas Gupta authored
      [ Upstream commit a1acdc22 ]
      
      We do not support two simultaneous recoveries so check for reset
      flag, BNXT_STATE_IN_FW_RESET, and do not proceed with AER further.
      When the pci channel state is pci_channel_io_frozen, the PCIe link
      can not be trusted so we disable the traffic immediately and stop
      BAR access by calling bnxt_fw_fatal_close().  BAR access after
      AER fatal error can cause an NMI.
      
      Fixes: f75d9a0a
      
       ("bnxt_en: Re-write PCI BARs after PCI fatal error.")
      Signed-off-by: default avatarVikas Gupta <vikas.gupta@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      25a82005
    • Vikas Gupta's avatar
      bnxt_en: refactor reset close code · b20beb05
      Vikas Gupta authored
      [ Upstream commit 7474b1c8
      
       ]
      
      Introduce bnxt_fw_fatal_close() API which can be used
      to stop data path and disable device when firmware
      is in fatal state.
      
      Signed-off-by: default avatarVikas Gupta <vikas.gupta@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Stable-dep-of: a1acdc22
      
       ("bnxt_en: Fix the PCI-AER routines")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b20beb05
    • Hangbin Liu's avatar
      bridge/br_netlink.c: no need to return void function · 16be6002
      Hangbin Liu authored
      [ Upstream commit 4fd1edcd ]
      
      br_info_notify is a void function. There is no need to return.
      
      Fixes: b6d0425b
      
       ("bridge: cfm: Netlink Notifications.")
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Acked-by: default avatarNikolay Aleksandrov <razor@blackwall.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      16be6002
    • Eric Dumazet's avatar
      icmp: prevent possible NULL dereferences from icmp_build_probe() · 599c9ad5
      Eric Dumazet authored
      [ Upstream commit c58e88d4 ]
      
      First problem is a double call to __in_dev_get_rcu(), because
      the second one could return NULL.
      
      if (__in_dev_get_rcu(dev) && __in_dev_get_rcu(dev)->ifa_list)
      
      Second problem is a read from dev->ip6_ptr with no NULL check:
      
      if (!list_empty(&rcu_dereference(dev->ip6_ptr)->addr_list))
      
      Use the correct RCU API to fix these.
      
      v2: add missing include <net/addrconf.h>
      
      Fixes: d329ea5b
      
       ("icmp: add response to RFC 8335 PROBE messages")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Andreas Roeseler <andreas.a.roeseler@gmail.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      599c9ad5
    • Andrei Simion's avatar
      ARM: dts: microchip: at91-sama7g5ek: Replace regulator-suspend-voltage with the valid property · d3c4b14c
      Andrei Simion authored
      [ Upstream commit e027b717 ]
      
      By checking the pmic node with microchip,mcp16502.yaml#
      'regulator-suspend-voltage' does not match any of the
      regexes 'pinctrl-[0-9]+' from schema microchip,mcp16502.yaml#
      which inherits regulator.yaml#. So replace regulator-suspend-voltage
      with regulator-suspend-microvolt to avoid the inconsitency.
      
      Fixes: 85b1304b
      
       ("ARM: dts: at91: sama7g5ek: set regulator voltages for standby state")
      Signed-off-by: default avatarAndrei Simion <andrei.simion@microchip.com>
      Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
      Link: https://lore.kernel.org/r/20240404123824.19182-2-andrei.simion@microchip.com
      
      
      [claudiu.beznea: added a dot before starting the last sentence in commit
       description]
      Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea@tuxon.dev>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d3c4b14c
    • Ido Schimmel's avatar
      mlxsw: core: Unregister EMAD trap using FORWARD action · 3f7ecad5
      Ido Schimmel authored
      [ Upstream commit 976c44af ]
      
      The device's manual (PRM - Programmer's Reference Manual) classifies the
      trap that is used to deliver EMAD responses as an "event trap". Among
      other things, it means that the only actions that can be associated with
      the trap are TRAP and FORWARD (NOP).
      
      Currently, during driver de-initialization the driver unregisters the
      trap by setting its action to DISCARD, which violates the above
      guideline. Future firmware versions will prevent such misuses by
      returning an error. This does not prevent the driver from working, but
      an error will be printed to the kernel log during module removal /
      devlink reload:
      
      mlxsw_spectrum 0000:03:00.0: Reg cmd access status failed (status=7(bad parameter))
      mlxsw_spectrum 0000:03:00.0: Reg cmd access failed (reg_id=7003(hpkt),type=write)
      
      Suppress the error message by aligning the driver to the manual and use
      a FORWARD (NOP) action when unregistering the trap.
      
      Fixes: 4ec14b76
      
       ("mlxsw: Add interface to access registers and process events")
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: Amit Cohen <amcohen@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Link: https://lore.kernel.org/r/753a89e14008fde08cb4a2c1e5f537b81d8eb2d6.1713446092.git.petrm@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3f7ecad5
    • David Bauer's avatar
      vxlan: drop packets from invalid src-address · 9064163f
      David Bauer authored
      [ Upstream commit f58f45c1 ]
      
      The VXLAN driver currently does not check if the inner layer2
      source-address is valid.
      
      In case source-address snooping/learning is enabled, a entry in the FDB
      for the invalid address is created with the layer3 address of the tunnel
      endpoint.
      
      If the frame happens to have a non-unicast address set, all this
      non-unicast traffic is subsequently not flooded to the tunnel network
      but sent to the learnt host in the FDB. To make matters worse, this FDB
      entry does not expire.
      
      Apply the same filtering for packets as it is done for bridges. This not
      only drops these invalid packets but avoids them from being learnt into
      the FDB.
      
      Fixes: d342894c
      
       ("vxlan: virtual extensible lan")
      Suggested-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid Bauer <mail@david-bauer.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9064163f
    • Miri Korenblit's avatar
      wifi: iwlwifi: mvm: return uid from iwl_mvm_build_scan_cmd · 9b9c4ada
      Miri Korenblit authored
      [ Upstream commit bada85a3 ]
      
      This function is supposed to return a uid on success, and an errno in
      failure.
      But it currently returns the return value of the specific cmd version
      handler, which in turn returns 0 on success and errno otherwise.
      This means that on success, iwl_mvm_build_scan_cmd will return 0
      regardless if the actual uid.
      Fix this by returning the uid if the handler succeeded.
      
      Fixes: 687db6ff
      
       ("iwlwifi: scan: make new scan req versioning flow")
      Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
      Reviewed-by: default avatarIlan Peer <ilan.peer@intel.com>
      Link: https://msgid.link/20240415114847.5e2d602b3190.I4c4931021be74a67a869384c8f8ee7463e0c7857@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9b9c4ada
    • Avraham Stern's avatar
      wifi: iwlwifi: mvm: remove old PASN station when adding a new one · d20e3beb
      Avraham Stern authored
      [ Upstream commit dbfff5bf ]
      
      If a PASN station is added, and an old PASN station already exists
      for the same mac address, remove the old station before adding the
      new one. Keeping the old station caueses old security context to
      be used in measurements.
      
      Fixes: 0739a7d7
      
       ("iwlwifi: mvm: initiator: add option for adding a PASN responder")
      Signed-off-by: default avatarAvraham Stern <avraham.stern@intel.com>
      Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
      Link: https://msgid.link/20240415114847.ef3544a416f2.I4e8c7c8ca22737f4f908ae5cd4fc0b920c703dd3@changeid
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d20e3beb
    • Alexey Brodkin's avatar
      ARC: [plat-hsdk]: Remove misplaced interrupt-cells property · bab058e3
      Alexey Brodkin authored
      [ Upstream commit 61231eb8
      
       ]
      
      "gmac" node stands for just an ordinary Ethernet controller,
      which is by no means a provider of interrupts, i.e. it doesn't serve
      as an interrupt controller, thus "#interrupt-cells" property doesn't
      belong to it and so we remove it.
      
      Fixes:
      ------------>8------------
        DTC     arch/arc/boot/dts/hsdk.dtb
      arch/arc/boot/dts/hsdk.dts:207.23-235.5: Warning (interrupt_provider): /soc/ethernet@8000: '#interrupt-cells' found, but node is not an interrupt provider
      arch/arc/boot/dts/hsdk.dtb: Warning (interrupt_map): Failed prerequisite 'interrupt_provider'
      ------------>8------------
      
      Reported-by: default avatarVineet Gupta <vgupta@kernel.org>
      Signed-off-by: default avatarAlexey Brodkin <abrodkin@synopsys.com>
      Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bab058e3
    • Jose Ignacio Tornos Martinez's avatar
      arm64: dts: rockchip: regulator for sd needs to be always on for BPI-R2Pro · 0277e73e
      Jose Ignacio Tornos Martinez authored
      [ Upstream commit 433d5481 ]
      
      With default dts configuration for BPI-R2Pro, the regulator for sd card is
      powered off when reboot is commanded, and the only solution to detect the
      sd card again, and therefore, allow rebooting from there, is to do a
      hardware reset.
      
      Configure the regulator for sd to be always on for BPI-R2Pro in order to
      avoid this issue.
      
      Fixes: f901aaad
      
       ("arm64: dts: rockchip: Add Bananapi R2 Pro")
      Signed-off-by: default avatarJose Ignacio Tornos Martinez <jtornosm@redhat.com>
      Link: https://lore.kernel.org/r/20240305143222.189413-1-jtornosm@redhat.com
      
      
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0277e73e
    • Rafał Miłecki's avatar
      arm64: dts: mediatek: mt2712: fix validation errors · af45b5bc
      Rafał Miłecki authored
      [ Upstream commit 3baac729 ]
      
      1. Fixup infracfg clock controller binding
         It also acts as reset controller so #reset-cells is required.
      2. Use -pins suffix for pinctrl
      
      This fixes:
      arch/arm64/boot/dts/mediatek/mt2712-evb.dtb: syscon@10001000: '#reset-cells' is a required property
              from schema $id: http://devicetree.org/schemas/arm/mediatek/mediatek,infracfg.yaml#
      arch/arm64/boot/dts/mediatek/mt2712-evb.dtb: pinctrl@1000b000: 'eth_default', 'eth_sleep', 'usb0_iddig', 'usb1_iddig' do not match any of the regexes: 'pinctrl-[0-9]+', 'pins$'
              from schema $id: http://devicetree.org/schemas/pinctrl/mediatek,mt65xx-pinctrl.yaml#
      
      
      
      Signed-off-by: default avatarRafał Miłecki <rafal@milecki.pl>
      Reviewed-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Link: https://lore.kernel.org/r/20240301074741.8362-1-zajec5@gmail.com
      [Angelo: Added Fixes tags]
      Fixes: 5d483970 ("arm64: dts: mt2712: Add clock controller device nodes")
      Fixes: 1724f4cc
      
       ("arm64: dts: Add USB3 related nodes for MT2712")
      Signed-off-by: default avatarAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      af45b5bc