From: Jacob Keller <jacob.e.keller@intel.com> mainline inclusion from mainline-v6.5 commit 4fe193cc9dd09565b61de2bf3dd62924443929dd category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBP3Y9 CVE: CVE-2022-49722 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... ---------------------- The ice_reset_vf function returns a boolean value indicating whether or not the VF reset. This is a bit confusing since it means that callers need to know how to interpret the return value when needing to indicate an error. Refactor the function and call sites to report a regular error code. We still report success (i.e. return 0) in cases where the reset is in progress or is disabled. Existing callers don't care because they do not check the return value. We keep the error code anyways instead of a void return because we expect future code which may care about or at least report the error value. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Conflicts: drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h drivers/net/ethernet/intel/ice/ice_vf_lib.c drivers/net/ethernet/intel/ice/ice_vf_lib.h [Context conflicts] Signed-off-by: Liu Chuang <liuchuang40@huawei.com> Signed-off-by: Xiaomeng Zhang <zhangxiaomeng13@huawei.com> --- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 15 ++++++++------- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index a980d337861d..f6ccc99fb2d7 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -1266,10 +1266,11 @@ static bool ice_is_vf_disabled(struct ice_vf *vf) * @vf: pointer to the VF structure * @is_vflr: true if VFLR was issued, false if not * - * Returns true if the VF is currently in reset, resets successfully, or resets - * are disabled and false otherwise. + * Returns 0 if the VF is currently in reset, if the resets are disabled, or + * if the VF resets successfully. Returns an error code if the VF fails to + * rebuild. */ -bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) +int ice_reset_vf(struct ice_vf *vf, bool is_vflr) { struct ice_pf *pf = vf->pf; struct ice_vsi *vsi; @@ -1287,13 +1288,13 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) if (test_bit(__ICE_VF_RESETS_DISABLED, pf->state)) { dev_dbg(dev, "Trying to reset VF %d, but all VF resets are disabled\n", vf->vf_id); - return true; + return 0; } if (ice_is_vf_disabled(vf)) { dev_dbg(dev, "VF is already disabled, there is no need for resetting it, telling VM, all is fine %d\n", vf->vf_id); - return true; + return 0; } /* Set VF disable bit state here, before triggering reset */ @@ -1354,12 +1355,12 @@ bool ice_reset_vf(struct ice_vf *vf, bool is_vflr) if (ice_vf_rebuild_vsi_with_release(vf)) { dev_err(dev, "Failed to release and setup the VF%u's VSI\n", vf->vf_id); - return false; + return -EFAULT; } ice_vf_post_vsi_rebuild(vf); - return true; + return 0; } /** diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h index d2e935c678a1..86f82493841d 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h @@ -116,7 +116,7 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event); void ice_vc_notify_link_state(struct ice_pf *pf); void ice_vc_notify_reset(struct ice_pf *pf); bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr); -bool ice_reset_vf(struct ice_vf *vf, bool is_vflr); +int ice_reset_vf(struct ice_vf *vf, bool is_vflr); void ice_restore_all_vfs_msi_state(struct pci_dev *pdev); int @@ -159,10 +159,10 @@ ice_reset_all_vfs(struct ice_pf __always_unused *pf, return true; } -static inline bool +static inline int ice_reset_vf(struct ice_vf __always_unused *vf, bool __always_unused is_vflr) { - return true; + return 0; } static inline int -- 2.34.1