Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ice: use-after-free in ice_vc_fdir_rem_prof() during PF reset
  [1]
--

commit 48401f6c29b813715dc1bcf787d7992e20c344db
Author: Jakub Ramaseuski <[email protected]>

ice: share default RSS hash profiles between PFs

This commit tracks shared RSS hash profile IDs in struct ice_adapter so
that multiple PFs on the same device can reuse firmware profile IDs for
default RSS configurations without exhausting the device-wide pool.

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c 
> b/drivers/net/ethernet/intel/ice/ice_main.c
> index 7a56f1367b01c..e59c02e50429c 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -604,6 +604,9 @@ ice_prepare_for_reset(struct ice_pf *pf, enum 
> ice_reset_req reset_type)
>               ice_fdir_clear_flow_handles(hw);
>       /* clear SW filtering DB */
>       ice_clear_hw_tbls(hw);
> +     /* a CORER, GLOBR or EMPR also clears the profile IDs of the other PFs 
> */
> +     if (reset_type != ICE_RESET_PFR)
> +             ice_flush_shared_profs(hw);
>       /* disable the VSIs and their queues that are not already DOWN */
>       set_bit(ICE_VSI_REBUILD_PENDING, ice_get_main_vsi(pf)->state);
>       ice_pf_dis_all_vsi(pf, false);

[Severity: High]
This problem wasn't introduced by this patch, but can ice_clear_hw_tbls()
here trigger a use-after-free and double free of struct ice_flow_entry in
ice_vc_fdir_rem_prof() during a PF reset [1]?

ice_fdir_clear_flow_handles() clears the PF's cached flow entry handles
before ice_clear_hw_tbls() -> ice_free_flow_profs() frees every profile
and entry in hw->fl_profs[ICE_BLK_FD], but nothing clears the handles
cached by VFs in vf_prof->entry_h:

drivers/net/ethernet/intel/ice/virt/fdir.c:ice_vc_fdir_rem_prof() {
        ...
        for (i = 0; i < fdir->prof_entry_cnt[flow][tun]; i++)
                if (vf_prof->entry_h[i][tun]) {
                        u16 vsi_num = ice_get_hw_vsi_num(hw, vf_prof->vsi_h[i]);

                        ice_rem_prof_id_flow(hw, ICE_BLK_FD, vsi_num, prof_id);
                        ice_flow_rem_entry(hw, ICE_BLK_FD,
                                           vf_prof->entry_h[i][tun]);
                        vf_prof->entry_h[i][tun] = 0;
                }
        ...
}

When the reset later runs ice_reset_all_vfs() -> ice_vf_fdir_exit() ->
ice_vc_fdir_rem_prof_all() -> ice_vc_fdir_rem_prof(), those dangling
vf_prof->entry_h pointers are passed to ice_flow_rem_entry(), which
dereferences and frees the struct ice_flow_entry a second time, and the
stale vf_prof->prof_id is passed to ice_flow_rem_prof(), which can remove
a flow profile reallocated during ice_rebuild().

[1] https://sashiko.dev/#/bug/linux-bf11eccc-e91f-476d-9247-5b7368b4b35b

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to