1. 22 Nov, 2022 14 commits
    • Emeel Hakim's avatar
      net/mlx5e: Fix possible race condition in macsec extended packet number update routine · 8514e325
      Emeel Hakim authored
      Currenty extended packet number (EPN) update routine is accessing
      macsec object without holding the general macsec lock hence facing
      a possible race condition when an EPN update occurs while updating
      or deleting the SA.
      Fix by holding the general macsec lock before accessing the object.
      
      Fixes: 4411a6c0 ("net/mlx5e: Support MACsec offload extended packet number (EPN)")
      Signed-off-by: default avatarEmeel Hakim <ehakim@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      8514e325
    • Emeel Hakim's avatar
      net/mlx5e: Fix MACsec update SecY · 94ffd6e0
      Emeel Hakim authored
      Currently updating SecY destroys and re-creates RX SA objects,
      the re-created RX SA objects are not identical to the destroyed
      objects and it disagree on the encryption enabled property which
      holds the value false after recreation, this value is not
      supported with offload which leads to no traffic after an update.
      Fix by recreating an identical objects.
      
      Fixes: 5a39816a ("net/mlx5e: Add MACsec offload SecY support")
      Signed-off-by: default avatarEmeel Hakim <ehakim@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      94ffd6e0
    • Emeel Hakim's avatar
      net/mlx5e: Fix MACsec SA initialization routine · d20a56b0
      Emeel Hakim authored
      Currently as part of MACsec SA initialization routine
      extended packet number (EPN) object attribute is always
      being set without checking if EPN is actually enabled,
      the above could lead to a NULL dereference.
      Fix by adding such a check.
      
      Fixes: 4411a6c0 ("net/mlx5e: Support MACsec offload extended packet number (EPN)")
      Signed-off-by: default avatarEmeel Hakim <ehakim@nvidia.com>
      Reviewed-by: default avatarRaed Salem <raeds@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      d20a56b0
    • Tariq Toukan's avatar
      net/mlx5e: Remove leftovers from old XSK queues enumeration · 11abca03
      Tariq Toukan authored
      Before the cited commit, for N channels, a dedicated set of N queues was
      created to support XSK, in indices [N, 2N-1], doubling the number of
      queues.
      
      In addition, changing the number of channels was prohibited, as it would
      shift the indices.
      
      Remove these two leftovers, as we moved XSK to a new queueing scheme,
      starting from index 0.
      
      Fixes: 3db4c85c ("net/mlx5e: xsk: Use queue indices starting from 0 for XSK queues")
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      11abca03
    • Chris Mi's avatar
      net/mlx5e: Offload rule only when all encaps are valid · f3774220
      Chris Mi authored
      The cited commit adds a for loop to support multiple encapsulations.
      But it only checks if the last encap is valid.
      
      Fix it by setting slow path flag when one of the encap is invalid.
      
      Fixes: f493f155 ("net/mlx5e: Move flow attr reformat action bit to per dest flags")
      Signed-off-by: default avatarChris Mi <cmi@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      f3774220
    • Tariq Toukan's avatar
      net/mlx5e: Fix missing alignment in size of MTT/KLM entries · 3e874cb1
      Tariq Toukan authored
      In the cited patch, an alignment required by the HW spec was mistakenly
      dropped. Bring it back to fix error completions like the below:
      
      mlx5_core 0000:00:08.0 eth2: Error cqe on cqn 0x40b, ci 0x0, qn 0x104f, opcode 0xd, syndrome 0x2, vendor syndrome 0x68
      00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000030: 00 00 00 00 86 00 68 02 25 00 10 4f 00 00 bb d2
      WQE DUMP: WQ size 1024 WQ cur size 0, WQE index 0x0, len: 192
      00000000: 00 00 00 25 00 10 4f 0c 00 00 00 00 00 18 2e 00
      00000010: 90 00 00 00 00 02 00 00 00 00 00 00 20 00 00 00
      00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      00000080: 08 00 00 00 48 6a 00 02 08 00 00 00 0e 10 00 02
      00000090: 08 00 00 00 0c db 00 02 08 00 00 00 0e 82 00 02
      000000a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      000000b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      
      Fixes: 9f123f74 ("net/mlx5e: Improve MTT/KSM alignment")
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      3e874cb1
    • Moshe Shemesh's avatar
      net/mlx5: Fix sync reset event handler error flow · e1ad07b9
      Moshe Shemesh authored
      When sync reset now event handling fails on mlx5_pci_link_toggle() then
      no reset was done. However, since mlx5_cmd_fast_teardown_hca() was
      already done, the firmware function is closed and the driver is left
      without firmware functionality.
      
      Fix it by setting device error state and reopen the firmware resources.
      Reopening is done by the thread that was called for devlink reload
      fw_activate as it already holds the devlink lock.
      
      Fixes: 5ec69744 ("net/mlx5: Add support for devlink reload action fw activate")
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarAya Levin <ayal@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      e1ad07b9
    • Roi Dayan's avatar
      net/mlx5: E-Switch, Set correctly vport destination · 6d942e40
      Roi Dayan authored
      The cited commit moved from using reformat_id integer to packet_reformat
      pointer which introduced the possibility to null pointer dereference.
      When setting packet reformat flag and pkt_reformat pointer must
      exists so checking MLX5_ESW_DEST_ENCAP is not enough, we need
      to make sure the pkt_reformat is valid and check for MLX5_ESW_DEST_ENCAP_VALID.
      If the dest encap valid flag does not exists then pkt_reformat can be
      either invalid address or null.
      Also, to make sure we don't try to access invalid pkt_reformat set it to
      null when invalidated and invalidate it before calling add flow code as
      its logically more correct and to be safe.
      
      Fixes: 2b688ea5 ("net/mlx5: Add flow steering actions to fs_cmd shim layer")
      Signed-off-by: default avatarRoi Dayan <roid@nvidia.com>
      Reviewed-by: default avatarChris Mi <cmi@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      6d942e40
    • Eli Cohen's avatar
      net/mlx5: Lag, avoid lockdep warnings · 0d4e8ed1
      Eli Cohen authored
      ldev->lock is used to serialize lag change operations. Since multiport
      eswtich functionality was added, we now change the mode dynamically.
      However, acquiring ldev->lock is not allowed as it could possibly lead
      to a deadlock as reported by the lockdep mechanism.
      
      [  836.154963] WARNING: possible circular locking dependency detected
      [  836.155850] 5.19.0-rc5_net_56b7df2 #1 Not tainted
      [  836.156549] ------------------------------------------------------
      [  836.157418] handler1/12198 is trying to acquire lock:
      [  836.158178] ffff888187d52b58 (&ldev->lock){+.+.}-{3:3}, at: mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.159575]
      [  836.159575] but task is already holding lock:
      [  836.160474] ffff8881d4de2930 (&block->cb_lock){++++}-{3:3}, at: tc_setup_cb_add+0x5b/0x200
      [  836.161669] which lock already depends on the new lock.
      [  836.162905]
      [  836.162905] the existing dependency chain (in reverse order) is:
      [  836.164008] -> #3 (&block->cb_lock){++++}-{3:3}:
      [  836.164946]        down_write+0x25/0x60
      [  836.165548]        tcf_block_get_ext+0x1c6/0x5d0
      [  836.166253]        ingress_init+0x74/0xa0 [sch_ingress]
      [  836.167028]        qdisc_create.constprop.0+0x130/0x5e0
      [  836.167805]        tc_modify_qdisc+0x481/0x9f0
      [  836.168490]        rtnetlink_rcv_msg+0x16e/0x5a0
      [  836.169189]        netlink_rcv_skb+0x4e/0xf0
      [  836.169861]        netlink_unicast+0x190/0x250
      [  836.170543]        netlink_sendmsg+0x243/0x4b0
      [  836.171226]        sock_sendmsg+0x33/0x40
      [  836.171860]        ____sys_sendmsg+0x1d1/0x1f0
      [  836.172535]        ___sys_sendmsg+0xab/0xf0
      [  836.173183]        __sys_sendmsg+0x51/0x90
      [  836.173836]        do_syscall_64+0x3d/0x90
      [  836.174471]        entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  836.175282]
      
      [  836.175282] -> #2 (rtnl_mutex){+.+.}-{3:3}:
      [  836.176190]        __mutex_lock+0x6b/0xf80
      [  836.176830]        register_netdevice_notifier+0x21/0x120
      [  836.177631]        rtnetlink_init+0x2d/0x1e9
      [  836.178289]        netlink_proto_init+0x163/0x179
      [  836.178994]        do_one_initcall+0x63/0x300
      [  836.179672]        kernel_init_freeable+0x2cb/0x31b
      [  836.180403]        kernel_init+0x17/0x140
      [  836.181035]        ret_from_fork+0x1f/0x30
      
       [  836.181687] -> #1 (pernet_ops_rwsem){+.+.}-{3:3}:
      [  836.182628]        down_write+0x25/0x60
      [  836.183235]        unregister_netdevice_notifier+0x1c/0xb0
      [  836.184029]        mlx5_ib_roce_cleanup+0x94/0x120 [mlx5_ib]
      [  836.184855]        __mlx5_ib_remove+0x35/0x60 [mlx5_ib]
      [  836.185637]        mlx5_eswitch_unregister_vport_reps+0x22f/0x440 [mlx5_core]
      [  836.186698]        auxiliary_bus_remove+0x18/0x30
      [  836.187409]        device_release_driver_internal+0x1f6/0x270
      [  836.188253]        bus_remove_device+0xef/0x160
      [  836.188939]        device_del+0x18b/0x3f0
      [  836.189562]        mlx5_rescan_drivers_locked+0xd6/0x2d0 [mlx5_core]
      [  836.190516]        mlx5_lag_remove_devices+0x69/0xe0 [mlx5_core]
      [  836.191414]        mlx5_do_bond_work+0x441/0x620 [mlx5_core]
      [  836.192278]        process_one_work+0x25c/0x590
      [  836.192963]        worker_thread+0x4f/0x3d0
      [  836.193609]        kthread+0xcb/0xf0
      [  836.194189]        ret_from_fork+0x1f/0x30
      
      [  836.194826] -> #0 (&ldev->lock){+.+.}-{3:3}:
      [  836.195734]        __lock_acquire+0x15b8/0x2a10
      [  836.196426]        lock_acquire+0xce/0x2d0
      [  836.197057]        __mutex_lock+0x6b/0xf80
      [  836.197708]        mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.198575]        tc_act_parse_mirred+0x25b/0x800 [mlx5_core]
      [  836.199467]        parse_tc_actions+0x168/0x5a0 [mlx5_core]
      [  836.200340]        __mlx5e_add_fdb_flow+0x263/0x480 [mlx5_core]
      [  836.201241]        mlx5e_configure_flower+0x8a0/0x1820 [mlx5_core]
      [  836.202187]        tc_setup_cb_add+0xd7/0x200
      [  836.202856]        fl_hw_replace_filter+0x14c/0x1f0 [cls_flower]
      [  836.203739]        fl_change+0xbbe/0x1730 [cls_flower]
      [  836.204501]        tc_new_tfilter+0x407/0xd90
      [  836.205168]        rtnetlink_rcv_msg+0x406/0x5a0
      [  836.205877]        netlink_rcv_skb+0x4e/0xf0
      [  836.206535]        netlink_unicast+0x190/0x250
      [  836.207217]        netlink_sendmsg+0x243/0x4b0
      [  836.207915]        sock_sendmsg+0x33/0x40
      [  836.208538]        ____sys_sendmsg+0x1d1/0x1f0
      [  836.209219]        ___sys_sendmsg+0xab/0xf0
      [  836.209878]        __sys_sendmsg+0x51/0x90
      [  836.210510]        do_syscall_64+0x3d/0x90
      [  836.211137]        entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      [  836.211954] other info that might help us debug this:
      [  836.213174] Chain exists of:
      [  836.213174]   &ldev->lock --> rtnl_mutex --> &block->cb_lock
         836.214650]  Possible unsafe locking scenario:
      [  836.214650]
      [  836.215574]        CPU0                    CPU1
      [  836.216255]        ----                    ----
      [  836.216943]   lock(&block->cb_lock);
      [  836.217518]                                lock(rtnl_mutex);
      [  836.218348]                                lock(&block->cb_lock);
      [  836.219212]   lock(&ldev->lock);
      [  836.219758]
      [  836.219758]  *** DEADLOCK ***
      [  836.219758]
       [  836.220747] 2 locks held by handler1/12198:
      [  836.221390]  #0: ffff8881d4de2930 (&block->cb_lock){++++}-{3:3}, at: tc_setup_cb_add+0x5b/0x200
      [  836.222646]  #1: ffff88810c9a92c0 (&esw->mode_lock){++++}-{3:3}, at: mlx5_esw_hold+0x39/0x50 [mlx5_core]
      
      [  836.224063] stack backtrace:
      [  836.224799] CPU: 6 PID: 12198 Comm: handler1 Not tainted 5.19.0-rc5_net_56b7df2 #1
      [  836.225923] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
      [  836.227476] Call Trace:
      [  836.227929]  <TASK>
      [  836.228332]  dump_stack_lvl+0x57/0x7d
      [  836.228924]  check_noncircular+0x104/0x120
      [  836.229562]  __lock_acquire+0x15b8/0x2a10
      [  836.230201]  lock_acquire+0xce/0x2d0
      [  836.230776]  ? mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.231614]  ? find_held_lock+0x2b/0x80
      [  836.232221]  __mutex_lock+0x6b/0xf80
      [  836.232799]  ? mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.233636]  ? mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.234451]  ? xa_load+0xc3/0x190
      [  836.234995]  mlx5_lag_do_mirred+0x3b/0x70 [mlx5_core]
      [  836.235803]  tc_act_parse_mirred+0x25b/0x800 [mlx5_core]
      [  836.236636]  ? tc_act_can_offload_mirred+0x135/0x210 [mlx5_core]
      [  836.237550]  parse_tc_actions+0x168/0x5a0 [mlx5_core]
      [  836.238364]  __mlx5e_add_fdb_flow+0x263/0x480 [mlx5_core]
      [  836.239202]  mlx5e_configure_flower+0x8a0/0x1820 [mlx5_core]
      [  836.240076]  ? lock_acquire+0xce/0x2d0
      [  836.240668]  ? tc_setup_cb_add+0x5b/0x200
      [  836.241294]  tc_setup_cb_add+0xd7/0x200
      [  836.241917]  fl_hw_replace_filter+0x14c/0x1f0 [cls_flower]
      [  836.242709]  fl_change+0xbbe/0x1730 [cls_flower]
      [  836.243408]  tc_new_tfilter+0x407/0xd90
      [  836.244043]  ? tc_del_tfilter+0x880/0x880
      [  836.244672]  rtnetlink_rcv_msg+0x406/0x5a0
      [  836.245310]  ? netlink_deliver_tap+0x7a/0x4b0
      [  836.245991]  ? if_nlmsg_stats_size+0x2b0/0x2b0
      [  836.246675]  netlink_rcv_skb+0x4e/0xf0
      [  836.258046]  netlink_unicast+0x190/0x250
      [  836.258669]  netlink_sendmsg+0x243/0x4b0
      [  836.259288]  sock_sendmsg+0x33/0x40
      [  836.259857]  ____sys_sendmsg+0x1d1/0x1f0
      [  836.260473]  ___sys_sendmsg+0xab/0xf0
      [  836.261064]  ? lock_acquire+0xce/0x2d0
      [  836.261669]  ? find_held_lock+0x2b/0x80
      [  836.262272]  ? __fget_files+0xb9/0x190
      [  836.262871]  ? __fget_files+0xd3/0x190
      [  836.263462]  __sys_sendmsg+0x51/0x90
      [  836.264064]  do_syscall_64+0x3d/0x90
      [  836.264652]  entry_SYSCALL_64_after_hwframe+0x46/0xb0
      [  836.265425] RIP: 0033:0x7fdbe5e2677d
      
      [  836.266012] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 ba ee
      ff ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f
      05 <48> 3d 00 f0 ff ff 77 33 44 89 c7 48 89 44 24 08 e8 ee ee ff ff 48
      [  836.268485] RSP: 002b:00007fdbe48a75a0 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
      [  836.269598] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007fdbe5e2677d
      [  836.270576] RDX: 0000000000000000 RSI: 00007fdbe48a7640 RDI: 000000000000003c
      [  836.271565] RBP: 00007fdbe48a8368 R08: 0000000000000000 R09: 0000000000000000
      [  836.272546] R10: 00007fdbe48a84b0 R11: 0000000000000293 R12: 0000557bd17dc860
      [  836.273527] R13: 0000000000000000 R14: 0000557bd17dc860 R15: 00007fdbe48a7640
      
      [  836.274521]  </TASK>
      
      To avoid using mode holding ldev->lock in the configure flow, we queue a
      work to the lag workqueue and cease wait on a completion object.
      
      In addition, we remove the lock from mlx5_lag_do_mirred() since it is
      not really protecting anything.
      
      It should be noted that an actual deadlock has not been observed.
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Reviewed-by: default avatarMark Bloch <mbloch@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      0d4e8ed1
    • Moshe Shemesh's avatar
      net/mlx5: Fix handling of entry refcount when command is not issued to FW · aaf2e65c
      Moshe Shemesh authored
      In case command interface is down, or the command is not allowed, driver
      did not increment the entry refcount, but might have decrement as part
      of forced completion handling.
      
      Fix that by always increment and decrement the refcount to make it
      symmetric for all flows.
      
      Fixes: 50b2412b ("net/mlx5: Avoid possible free of command entry while timeout comp handler")
      Signed-off-by: default avatarEran Ben Elisha <eranbe@nvidia.com>
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reported-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Tested-by: default avatarJack Wang <jinpu.wang@ionos.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      aaf2e65c
    • Moshe Shemesh's avatar
      net/mlx5: cmdif, Print info on any firmware cmd failure to tracepoint · 870c2481
      Moshe Shemesh authored
      While moving to new CMD API (quiet API), some pre-existing flows may call the new API
      function that in case of error, returns the error instead of printing it as previously done.
      For such flows we bring back the print but to tracepoint this time for sys admins to
      have the ability to check for errors especially for commands using the new quiet API.
      
      Tracepoint output example:
               devlink-1333    [001] .....   822.746922: mlx5_cmd: ACCESS_REG(0x805) op_mod(0x0) failed, status bad resource(0x5), syndrome (0xb06e1f), err(-22)
      
      Fixes: f23519e5 ("net/mlx5: cmdif, Add new api for command execution")
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      870c2481
    • Shay Drory's avatar
      net/mlx5: SF: Fix probing active SFs during driver probe phase · 4f57332d
      Shay Drory authored
      When SF devices and SF port representors are located on different
      functions, unloading and reloading of SF parent driver doesn't recreate
      the existing SF present in the device.
      Fix it by querying SFs and probe active SFs during driver probe phase.
      
      Fixes: 90d010b8 ("net/mlx5: SF, Add auxiliary device support")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarParav Pandit <parav@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      4f57332d
    • Moshe Shemesh's avatar
      net/mlx5: Fix FW tracer timestamp calculation · 61db3d7b
      Moshe Shemesh authored
      Fix a bug in calculation of FW tracer timestamp. Decreasing one in the
      calculation should effect only bits 52_7 and not effect bits 6_0 of the
      timestamp, otherwise bits 6_0 are always set in this calculation.
      
      Fixes: 70dd6fdb ("net/mlx5: FW tracer, parse traces and kernel tracing support")
      Signed-off-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarFeras Daoud <ferasda@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      61db3d7b
    • Roy Novich's avatar
      net/mlx5: Do not query pci info while pci disabled · 394164f9
      Roy Novich authored
      The driver should not interact with PCI while PCI is disabled. Trying to
      do so may result in being unable to get vital signs during PCI reset,
      driver gets timed out and fails to recover.
      
      Fixes: fad1783a ("net/mlx5: Print more info on pci error handlers")
      Signed-off-by: default avatarRoy Novich <royno@nvidia.com>
      Reviewed-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Reviewed-by: default avatarAya Levin <ayal@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      394164f9
  2. 21 Nov, 2022 9 commits
  3. 19 Nov, 2022 11 commits
  4. 18 Nov, 2022 6 commits
    • Pablo Neira Ayuso's avatar
      netfilter: nf_tables: do not set up extensions for end interval · 33c7aba0
      Pablo Neira Ayuso authored
      Elements with an end interval flag set on do not store extensions. The
      global set definition is currently setting on the timeout and stateful
      expression for end interval elements.
      
      This leads to skipping end interval elements from the set->ops->walk()
      path as the expired check bogusly reports true.
      
      Moreover, do not set up stateful expressions for elements with end
      interval flag set on since this is never used.
      
      Fixes: 65038428 ("netfilter: nf_tables: allow to specify stateful expression in set definition")
      Fixes: 8d8540c4 ("netfilter: nft_set_rbtree: add timeout support")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      33c7aba0
    • Daniel Xu's avatar
      netfilter: conntrack: Fix data-races around ct mark · 52d1aa8b
      Daniel Xu authored
      nf_conn:mark can be read from and written to in parallel. Use
      READ_ONCE()/WRITE_ONCE() for reads and writes to prevent unwanted
      compiler optimizations.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarDaniel Xu <dxu@dxuuu.xyz>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      52d1aa8b
    • Wang Hai's avatar
      net: pch_gbe: fix potential memleak in pch_gbe_tx_queue() · 2360f9b8
      Wang Hai authored
      In pch_gbe_xmit_frame(), NETDEV_TX_OK will be returned whether
      pch_gbe_tx_queue() sends data successfully or not, so pch_gbe_tx_queue()
      needs to free skb before returning. But pch_gbe_tx_queue() returns without
      freeing skb in case of dma_map_single() fails. Add dev_kfree_skb_any()
      to fix it.
      
      Fixes: 77555ee7 ("net: Add Gigabit Ethernet driver of Topcliff PCH")
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2360f9b8
    • Lin Ma's avatar
      nfc/nci: fix race with opening and closing · 0ad6bded
      Lin Ma authored
      Previously we leverage NCI_UNREG and the lock inside nci_close_device to
      prevent the race condition between opening a device and closing a
      device. However, it still has problem because a failed opening command
      will erase the NCI_UNREG flag and allow another opening command to
      bypass the status checking.
      
      This fix corrects that by making sure the NCI_UNREG is held.
      
      Reported-by: syzbot+43475bf3cfbd6e41f5b7@syzkaller.appspotmail.com
      Fixes: 48b71a9e ("NFC: add NCI_UNREG flag to eliminate the race")
      Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0ad6bded
    • Vladimir Oltean's avatar
      net: dsa: sja1105: disallow C45 transactions on the BASE-TX MDIO bus · 24deec6b
      Vladimir Oltean authored
      You'd think people know that the internal 100BASE-TX PHY on the SJA1110
      responds only to clause 22 MDIO transactions, but they don't :)
      
      When a clause 45 transaction is attempted, sja1105_base_tx_mdio_read()
      and sja1105_base_tx_mdio_write() don't expect "reg" to contain bit 30
      set (MII_ADDR_C45) and pack this value into the SPI transaction buffer.
      
      But the field in the SPI buffer has a width smaller than 30 bits, so we
      see this confusing message from the packing() API rather than a proper
      rejection of C45 transactions:
      
      Call trace:
       dump_stack+0x1c/0x38
       sja1105_pack+0xbc/0xc0 [sja1105]
       sja1105_xfer+0x114/0x2b0 [sja1105]
       sja1105_xfer_u32+0x44/0xf4 [sja1105]
       sja1105_base_tx_mdio_read+0x44/0x7c [sja1105]
       mdiobus_read+0x44/0x80
       get_phy_c45_ids+0x70/0x234
       get_phy_device+0x68/0x15c
       fwnode_mdiobus_register_phy+0x74/0x240
       of_mdiobus_register+0x13c/0x380
       sja1105_mdiobus_register+0x368/0x490 [sja1105]
       sja1105_setup+0x94/0x119c [sja1105]
      Cannot store 401d2405 inside bits 24-4 (would truncate)
      
      Fixes: 5a8f0974 ("net: dsa: sja1105: register the MDIO buses for 100base-T1 and 100base-TX")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      24deec6b
    • David Howells's avatar
      rxrpc: Fix race between conn bundle lookup and bundle removal [ZDI-CAN-15975] · 3bcd6c7e
      David Howells authored
      After rxrpc_unbundle_conn() has removed a connection from a bundle, it
      checks to see if there are any conns with available channels and, if not,
      removes and attempts to destroy the bundle.
      
      Whilst it does check after grabbing client_bundles_lock that there are no
      connections attached, this races with rxrpc_look_up_bundle() retrieving the
      bundle, but not attaching a connection for the connection to be attached
      later.
      
      There is therefore a window in which the bundle can get destroyed before we
      manage to attach a new connection to it.
      
      Fix this by adding an "active" counter to struct rxrpc_bundle:
      
       (1) rxrpc_connect_call() obtains an active count by prepping/looking up a
           bundle and ditches it before returning.
      
       (2) If, during rxrpc_connect_call(), a connection is added to the bundle,
           this obtains an active count, which is held until the connection is
           discarded.
      
       (3) rxrpc_deactivate_bundle() is created to drop an active count on a
           bundle and destroy it when the active count reaches 0.  The active
           count is checked inside client_bundles_lock() to prevent a race with
           rxrpc_look_up_bundle().
      
       (4) rxrpc_unbundle_conn() then calls rxrpc_deactivate_bundle().
      
      Fixes: 245500d8 ("rxrpc: Rewrite the client connection manager")
      Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-15975
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: zdi-disclosures@trendmicro.com
      cc: Marc Dionne <marc.dionne@auristor.com>
      cc: linux-afs@lists.infradead.org
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3bcd6c7e