When the PF rejects a cloud filter add request it may include a diagnostic string in the virtchnl response. Use dev_info() to log it so operators can diagnose offload failures without enabling verbose tracing.
Use %.*s with an explicit length bound to avoid reading past the end of the message buffer when the PF fills all 4096 bytes and leaves no NUL terminator. Add the missing cloud_filter_list_lock around both the VIRTCHNL_OP_ADD_CLOUD_FILTER and VIRTCHNL_OP_DEL_CLOUD_FILTER error paths to close a pre-existing race against iavf_add_cloud_filter() and iavf_del_cloud_filter(). Apply the same %.*s fix to the equivalent VIRTCHNL_OP_ADD_FDIR_FILTER error path which carried the same bug. Suggested-by: Grzegorz Szczurek <[email protected]> Signed-off-by: Aleksandr Loktionov <[email protected]> --- drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c index 4f2defd..146fc680 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c @@ -2388,6 +2388,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, case VIRTCHNL_OP_ADD_CLOUD_FILTER: { struct iavf_cloud_filter *cf, *cftmp; + spin_lock_bh(&adapter->cloud_filter_list_lock); list_for_each_entry_safe(cf, cftmp, &adapter->cloud_filter_list, list) { @@ -2398,16 +2399,23 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, v_retval)); iavf_print_cloud_filter(adapter, &cf->f); + if (msglen) + dev_info(&adapter->pdev->dev, + "%.*s\n", + (int)msglen, + (const char *)msg); list_del(&cf->list); kfree(cf); adapter->num_cloud_filters--; } } + spin_unlock_bh(&adapter->cloud_filter_list_lock); } break; case VIRTCHNL_OP_DEL_CLOUD_FILTER: { struct iavf_cloud_filter *cf; + spin_lock_bh(&adapter->cloud_filter_list_lock); list_for_each_entry(cf, &adapter->cloud_filter_list, list) { if (cf->state == __IAVF_CF_DEL_PENDING) { @@ -2419,6 +2427,7 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, &cf->f); } } + spin_unlock_bh(&adapter->cloud_filter_list_lock); } break; case VIRTCHNL_OP_ADD_FDIR_FILTER: { @@ -2434,8 +2443,10 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter, v_retval)); iavf_print_fdir_fltr(adapter, fdir); if (msglen) - dev_err(&adapter->pdev->dev, - "%s\n", msg); + dev_info(&adapter->pdev->dev, + "%.*s\n", + (int)msglen, + (const char *)msg); list_del(&fdir->list); iavf_dec_fdir_active_fltr(adapter, fdir); kfree(fdir); -- 2.52.0
