linux/drivers/net/ethernet/intel/i40e
Aleksandr Loktionov dac6c7b3d3 i40e: Fix macvlan leak by synchronizing access to mac_filter_hash
This patch addresses a macvlan leak issue in the i40e driver caused by
concurrent access to vsi->mac_filter_hash. The leak occurs when multiple
threads attempt to modify the mac_filter_hash simultaneously, leading to
inconsistent state and potential memory leaks.

To fix this, we now wrap the calls to i40e_del_mac_filter() and zeroing
vf->default_lan_addr.addr with spin_lock/unlock_bh(&vsi->mac_filter_hash_lock),
ensuring atomic operations and preventing concurrent access.

Additionally, we add lockdep_assert_held(&vsi->mac_filter_hash_lock) in
i40e_add_mac_filter() to help catch similar issues in the future.

Reproduction steps:
1. Spawn VFs and configure port vlan on them.
2. Trigger concurrent macvlan operations (e.g., adding and deleting
	portvlan and/or mac filters).
3. Observe the potential memory leak and inconsistent state in the
	mac_filter_hash.

This synchronization ensures the integrity of the mac_filter_hash and prevents
the described leak.

Fixes: fed0d9f132 ("i40e: Fix VF's MAC Address change on VM")
Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
2024-10-08 14:39:21 -07:00
..
i40e.h
i40e_adminq.c
i40e_adminq.h
i40e_adminq_cmd.h
i40e_alloc.h
i40e_client.c
i40e_common.c
i40e_dcb.c
i40e_dcb.h
i40e_dcb_nl.c
i40e_ddp.c
i40e_debug.h
i40e_debugfs.c
i40e_devids.h
i40e_devlink.c
i40e_devlink.h
i40e_diag.c
i40e_diag.h
i40e_ethtool.c
i40e_hmc.c
i40e_hmc.h
i40e_io.h
i40e_lan_hmc.c
i40e_lan_hmc.h
i40e_main.c
i40e_nvm.c
i40e_prototype.h
i40e_ptp.c
i40e_register.h
i40e_trace.h
i40e_txrx.c
i40e_txrx.h
i40e_txrx_common.h
i40e_type.h
i40e_virtchnl_pf.c
i40e_virtchnl_pf.h
i40e_xsk.c
i40e_xsk.h
Makefile