1. 01 10月, 2022 2 次提交
  2. 31 8月, 2022 1 次提交
  3. 30 8月, 2022 2 次提交
  4. 29 8月, 2022 1 次提交
    • J
      genetlink: start to validate reserved header bytes · 9c5d03d3
      Jakub Kicinski 提交于
      We had historically not checked that genlmsghdr.reserved
      is 0 on input which prevents us from using those precious
      bytes in the future.
      
      One use case would be to extend the cmd field, which is
      currently just 8 bits wide and 256 is not a lot of commands
      for some core families.
      
      To make sure that new families do the right thing by default
      put the onus of opting out of validation on existing families.
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      Acked-by: Paul Moore <paul@paul-moore.com> (NetLabel)
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9c5d03d3
  5. 27 8月, 2022 1 次提交
  6. 26 8月, 2022 2 次提交
    • J
      net: devlink: limit flash component name to match version returned by info_get() · f94b6063
      Jiri Pirko 提交于
      Limit the acceptance of component name passed to cmd_flash_update() to
      match one of the versions returned by info_get(), marked by version type.
      This makes things clearer and enforces 1:1 mapping between exposed
      version and accepted flash component.
      
      Check VERSION_TYPE_COMPONENT version type during cmd_flash_update()
      execution by calling info_get() with different "req" context.
      That causes info_get() to lookup the component name instead of
      filling-up the netlink message.
      
      Remove "UPDATE_COMPONENT" flag which becomes used.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      f94b6063
    • J
      net: devlink: extend info_get() version put to indicate a flash component · bb670123
      Jiri Pirko 提交于
      Whenever the driver is called by his info_get() op, it may put multiple
      version names and values to the netlink message. Extend by additional
      helper devlink_info_version_running/stored_put_ext() that allows to
      specify a version type that indicates when particular version name
      represents a flash component.
      
      This is going to be used in follow-up patch calling info_get() during
      flash update command checking if version with this the version type
      exists.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      bb670123
  7. 10 8月, 2022 1 次提交
    • I
      devlink: Fix use-after-free after a failed reload · 6b4db2e5
      Ido Schimmel 提交于
      After a failed devlink reload, devlink parameters are still registered,
      which means user space can set and get their values. In the case of the
      mlxsw "acl_region_rehash_interval" parameter, these operations will
      trigger a use-after-free [1].
      
      Fix this by rejecting set and get operations while in the failed state.
      Return the "-EOPNOTSUPP" error code which does not abort the parameters
      dump, but instead causes it to skip over the problematic parameter.
      
      Another possible fix is to perform these checks in the mlxsw parameter
      callbacks, but other drivers might be affected by the same problem and I
      am not aware of scenarios where these stricter checks will cause a
      regression.
      
      [1]
      mlxsw_spectrum3 0000:00:10.0: Port 125: Failed to register netdev
      mlxsw_spectrum3 0000:00:10.0: Failed to create ports
      
      ==================================================================
      BUG: KASAN: use-after-free in mlxsw_sp_acl_tcam_vregion_rehash_intrvl_get+0xbd/0xd0 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c:904
      Read of size 4 at addr ffff8880099dcfd8 by task kworker/u4:4/777
      
      CPU: 1 PID: 777 Comm: kworker/u4:4 Not tainted 5.19.0-rc7-custom-126601-gfe26f28c586d #1
      Hardware name: QEMU MSN4700, BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      Workqueue: netns cleanup_net
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0x92/0xbd lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:313 [inline]
       print_report.cold+0x5e/0x5cf mm/kasan/report.c:429
       kasan_report+0xb9/0xf0 mm/kasan/report.c:491
       __asan_report_load4_noabort+0x14/0x20 mm/kasan/report_generic.c:306
       mlxsw_sp_acl_tcam_vregion_rehash_intrvl_get+0xbd/0xd0 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_tcam.c:904
       mlxsw_sp_acl_region_rehash_intrvl_get+0x49/0x60 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c:1106
       mlxsw_sp_params_acl_region_rehash_intrvl_get+0x33/0x80 drivers/net/ethernet/mellanox/mlxsw/spectrum.c:3854
       devlink_param_get net/core/devlink.c:4981 [inline]
       devlink_nl_param_fill+0x238/0x12d0 net/core/devlink.c:5089
       devlink_param_notify+0xe5/0x230 net/core/devlink.c:5168
       devlink_ns_change_notify net/core/devlink.c:4417 [inline]
       devlink_ns_change_notify net/core/devlink.c:4396 [inline]
       devlink_reload+0x15f/0x700 net/core/devlink.c:4507
       devlink_pernet_pre_exit+0x112/0x1d0 net/core/devlink.c:12272
       ops_pre_exit_list net/core/net_namespace.c:152 [inline]
       cleanup_net+0x494/0xc00 net/core/net_namespace.c:582
       process_one_work+0x9fc/0x1710 kernel/workqueue.c:2289
       worker_thread+0x675/0x10b0 kernel/workqueue.c:2436
       kthread+0x30c/0x3d0 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
       </TASK>
      
      The buggy address belongs to the physical page:
      page:ffffea0000267700 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x99dc
      flags: 0x100000000000000(node=0|zone=1)
      raw: 0100000000000000 0000000000000000 dead000000000122 0000000000000000
      raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8880099dce80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
       ffff8880099dcf00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      >ffff8880099dcf80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                          ^
       ffff8880099dd000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
       ffff8880099dd080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      ==================================================================
      
      Fixes: 98bbf70c ("mlxsw: spectrum: add "acl_region_rehash_interval" devlink param")
      Signed-off-by: NIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      6b4db2e5
  8. 02 8月, 2022 1 次提交
  9. 01 8月, 2022 4 次提交
  10. 29 7月, 2022 4 次提交
  11. 28 7月, 2022 1 次提交
  12. 27 7月, 2022 3 次提交
  13. 19 7月, 2022 8 次提交
    • J
      net: devlink: remove unused locked functions · f655dacb
      Jiri Pirko 提交于
      Remove locked versions of functions that are no longer used by anyone.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      f655dacb
    • J
      netdevsim: convert driver to use unlocked devlink API during init/fini · 012ec02a
      Jiri Pirko 提交于
      Prepare for devlink reload being called with devlink->lock held and
      convert the netdevsim driver to use unlocked devlink API during init and
      fini flows. Take devl_lock() in reload_down() and reload_up() ops in the
      meantime before reload cmd is converted to take the lock itself.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      012ec02a
    • J
      net: devlink: add unlocked variants of devlink_region_create/destroy() functions · eb0e9fa2
      Jiri Pirko 提交于
      Add unlocked variants of devlink_region_create/destroy() functions
      to be used in drivers called-in with devlink->lock held.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Reviewed-by: NMoshe Shemesh <moshe@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      eb0e9fa2
    • J
      net: devlink: add unlocked variants of devlink_dpipe*() functions · 70a2ff89
      Jiri Pirko 提交于
      Add unlocked variants of devlink_dpipe*() functions to be used
      in drivers called-in with devlink->lock held.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      70a2ff89
    • J
      net: devlink: add unlocked variants of devlink_sb*() functions · 755cfa69
      Jiri Pirko 提交于
      Add unlocked variants of devlink_sb*() functions to be used
      in drivers called-in with devlink->lock held.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      755cfa69
    • J
      net: devlink: add unlocked variants of devlink_resource*() functions · c223d6a4
      Jiri Pirko 提交于
      Add unlocked variants of devlink_resource*() functions to be used
      in drivers called-in with devlink->lock held.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      c223d6a4
    • J
      net: devlink: add unlocked variants of devling_trap*() functions · 852e85a7
      Jiri Pirko 提交于
      Add unlocked variants of devl_trap*() functions to be used in drivers
      called-in with devlink->lock held.
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      852e85a7
    • M
      net: devlink: avoid false DEADLOCK warning reported by lockdep · e26fde2f
      Moshe Shemesh 提交于
      Add a lock_class_key per devlink instance to avoid DEADLOCK warning by
      lockdep, while locking more than one devlink instance in driver code,
      for example in opening VFs flow.
      
      Kernel log:
      [  101.433802] ============================================
      [  101.433803] WARNING: possible recursive locking detected
      [  101.433810] 5.19.0-rc1+ #35 Not tainted
      [  101.433812] --------------------------------------------
      [  101.433813] bash/892 is trying to acquire lock:
      [  101.433815] ffff888127bfc2f8 (&devlink->lock){+.+.}-{3:3}, at: probe_one+0x3c/0x690 [mlx5_core]
      [  101.433909]
                     but task is already holding lock:
      [  101.433910] ffff888118f4c2f8 (&devlink->lock){+.+.}-{3:3}, at: mlx5_core_sriov_configure+0x62/0x280 [mlx5_core]
      [  101.433989]
                     other info that might help us debug this:
      [  101.433990]  Possible unsafe locking scenario:
      
      [  101.433991]        CPU0
      [  101.433991]        ----
      [  101.433992]   lock(&devlink->lock);
      [  101.433993]   lock(&devlink->lock);
      [  101.433995]
                      *** DEADLOCK ***
      
      [  101.433996]  May be due to missing lock nesting notation
      
      [  101.433996] 6 locks held by bash/892:
      [  101.433998]  #0: ffff88810eb50448 (sb_writers#3){.+.+}-{0:0}, at: ksys_write+0xf3/0x1d0
      [  101.434009]  #1: ffff888114777c88 (&of->mutex){+.+.}-{3:3}, at: kernfs_fop_write_iter+0x20d/0x520
      [  101.434017]  #2: ffff888102b58660 (kn->active#231){.+.+}-{0:0}, at: kernfs_fop_write_iter+0x230/0x520
      [  101.434023]  #3: ffff888102d70198 (&dev->mutex){....}-{3:3}, at: sriov_numvfs_store+0x132/0x310
      [  101.434031]  #4: ffff888118f4c2f8 (&devlink->lock){+.+.}-{3:3}, at: mlx5_core_sriov_configure+0x62/0x280 [mlx5_core]
      [  101.434108]  #5: ffff88812adce198 (&dev->mutex){....}-{3:3}, at: __device_attach+0x76/0x430
      [  101.434116]
                     stack backtrace:
      [  101.434118] CPU: 5 PID: 892 Comm: bash Not tainted 5.19.0-rc1+ #35
      [  101.434120] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [  101.434130] Call Trace:
      [  101.434133]  <TASK>
      [  101.434135]  dump_stack_lvl+0x57/0x7d
      [  101.434145]  __lock_acquire.cold+0x1df/0x3e7
      [  101.434151]  ? register_lock_class+0x1880/0x1880
      [  101.434157]  lock_acquire+0x1c1/0x550
      [  101.434160]  ? probe_one+0x3c/0x690 [mlx5_core]
      [  101.434229]  ? lockdep_hardirqs_on_prepare+0x400/0x400
      [  101.434232]  ? __xa_alloc+0x1ed/0x2d0
      [  101.434236]  ? ksys_write+0xf3/0x1d0
      [  101.434239]  __mutex_lock+0x12c/0x14b0
      [  101.434243]  ? probe_one+0x3c/0x690 [mlx5_core]
      [  101.434312]  ? probe_one+0x3c/0x690 [mlx5_core]
      [  101.434380]  ? devlink_alloc_ns+0x11b/0x910
      [  101.434385]  ? mutex_lock_io_nested+0x1320/0x1320
      [  101.434388]  ? lockdep_init_map_type+0x21a/0x7d0
      [  101.434391]  ? lockdep_init_map_type+0x21a/0x7d0
      [  101.434393]  ? __init_swait_queue_head+0x70/0xd0
      [  101.434397]  probe_one+0x3c/0x690 [mlx5_core]
      [  101.434467]  pci_device_probe+0x1b4/0x480
      [  101.434471]  really_probe+0x1e0/0xaa0
      [  101.434474]  __driver_probe_device+0x219/0x480
      [  101.434478]  driver_probe_device+0x49/0x130
      [  101.434481]  __device_attach_driver+0x1b8/0x280
      [  101.434484]  ? driver_allows_async_probing+0x140/0x140
      [  101.434487]  bus_for_each_drv+0x123/0x1a0
      [  101.434489]  ? bus_for_each_dev+0x1a0/0x1a0
      [  101.434491]  ? lockdep_hardirqs_on_prepare+0x286/0x400
      [  101.434494]  ? trace_hardirqs_on+0x2d/0x100
      [  101.434498]  __device_attach+0x1a3/0x430
      [  101.434501]  ? device_driver_attach+0x1e0/0x1e0
      [  101.434503]  ? pci_bridge_d3_possible+0x1e0/0x1e0
      [  101.434506]  ? pci_create_resource_files+0xeb/0x190
      [  101.434511]  pci_bus_add_device+0x6c/0xa0
      [  101.434514]  pci_iov_add_virtfn+0x9e4/0xe00
      [  101.434517]  ? trace_hardirqs_on+0x2d/0x100
      [  101.434521]  sriov_enable+0x64a/0xca0
      [  101.434524]  ? pcibios_sriov_disable+0x10/0x10
      [  101.434528]  mlx5_core_sriov_configure+0xab/0x280 [mlx5_core]
      [  101.434602]  sriov_numvfs_store+0x20a/0x310
      [  101.434605]  ? sriov_totalvfs_show+0xc0/0xc0
      [  101.434608]  ? sysfs_file_ops+0x170/0x170
      [  101.434611]  ? sysfs_file_ops+0x117/0x170
      [  101.434614]  ? sysfs_file_ops+0x170/0x170
      [  101.434616]  kernfs_fop_write_iter+0x348/0x520
      [  101.434619]  new_sync_write+0x2e5/0x520
      [  101.434621]  ? new_sync_read+0x520/0x520
      [  101.434624]  ? lock_acquire+0x1c1/0x550
      [  101.434626]  ? lockdep_hardirqs_on_prepare+0x400/0x400
      [  101.434630]  vfs_write+0x5cb/0x8d0
      [  101.434633]  ksys_write+0xf3/0x1d0
      [  101.434635]  ? __x64_sys_read+0xb0/0xb0
      [  101.434638]  ? lockdep_hardirqs_on_prepare+0x286/0x400
      [  101.434640]  ? syscall_enter_from_user_mode+0x1d/0x50
      [  101.434643]  do_syscall_64+0x3d/0x90
      [  101.434647]  entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  101.434650] RIP: 0033:0x7f5ff536b2f7
      [  101.434658] Code: 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f
      1f 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f
      05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24
      [  101.434661] RSP: 002b:00007ffd9ea85d58 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
      [  101.434664] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f5ff536b2f7
      [  101.434666] RDX: 0000000000000002 RSI: 000055c4c279e230 RDI: 0000000000000001
      [  101.434668] RBP: 000055c4c279e230 R08: 000000000000000a R09: 0000000000000001
      [  101.434669] R10: 000055c4c283cbf0 R11: 0000000000000246 R12: 0000000000000002
      [  101.434670] R13: 00007f5ff543d500 R14: 0000000000000002 R15: 00007f5ff543d700
      [  101.434673]  </TASK>
      Signed-off-by: NMoshe Shemesh <moshe@nvidia.com>
      Signed-off-by: NJiri Pirko <jiri@nvidia.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      e26fde2f
  14. 15 7月, 2022 3 次提交
  15. 13 7月, 2022 2 次提交
  16. 12 7月, 2022 3 次提交
  17. 10 6月, 2022 1 次提交