net/ice: fix illegal pointer access in releasing vsi
PATCH 1/1 net/ice: fix illegal pointer access in releasing vsi
When deleting the mac filter in ice_remove_all_mac_vlan_filters(), TAILQ_FOREACH_SAFE should be used instead of TAILQ_FOREACH, Otherwise, it will result in a illegal pointer access.
--- drivers/net/ice/ice_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/net/ice/ice_ethdev.c +5 -2
@@ -10,6 +10,8 @@#include <sys/stat.h> #include <unistd.h> +#include <rte_tailq.h> +#include "base/ice_sched.h" #include "base/ice_flow.h" #include "base/ice_dcb.h"
@@ -1094,12 +1096,13 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi) {struct ice_mac_filter *m_f;struct ice_vlan_filter *v_f; +void *temp;int ret =0 ;if (!vsi || !vsi->mac_num)return -EINVAL ; - TAILQ_FOREACH(m_f, &vsi->mac_list, next) { + TAILQ_FOREACH_SAFE(m_f, &vsi->mac_list, next, temp) { ret =ice_remove_mac_filter (vsi, &m_f->mac_info.mac_addr);if (ret !=ICE_SUCCESS ) { ret = -EINVAL ;
@@ -1110,7 +1113,7 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi)if (vsi->vlan_num ==0 )return 0 ; - TAILQ_FOREACH(v_f, &vsi->vlan_list, next) { + TAILQ_FOREACH_SAFE(v_f, &vsi->vlan_list, next, temp) { ret =ice_remove_vlan_filter (vsi, &v_f->vlan_info.vlan);if (ret !=ICE_SUCCESS ) { ret = -EINVAL ;
Signature · 1 line
2.25.1
Quoted 9 lines
-----Original Message-----
From: Ma, WenwuX <[email protected]>
Sent: Thursday, April 1, 2021 11:14 PM
To: Yang, Qiming <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]
Subject: [PATCH] net/ice: fix illegal pointer access in releasing vsi
Please add fix line and cc stable.
Quoted 49 lines
When deleting the mac filter in
ice_remove_all_mac_vlan_filters(),TAILQ_FOREACH_SAFEshould be used instead ofTAILQ_FOREACH, Otherwise, it will result in a illegal pointer access.Signed-off-by Wenwu Ma <[email protected]>--- drivers/net/ice/ice_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/net/ice/ice_ethdev.c index renamed from drivers/net/ice/ice_ethdev.c +0
-0
9c9b84a93..785750d9b100644drivers/net/ice/ice_ethdev.c +5
-3@@ -10,6 +10,8 @@#include <sys/stat.h> #include <unistd.h> +#include <rte_tailq.h> +#include "base/ice_sched.h" #include "base/ice_flow.h" #include "base/ice_dcb.h" @@ -1094,12 +1096,13 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi) {struct ice_mac_filter *m_f;struct ice_vlan_filter *v_f; +void *temp;int ret =0 ;if (!vsi || !vsi->mac_num)return -EINVAL ; - TAILQ_FOREACH(m_f, &vsi->mac_list, next) { + TAILQ_FOREACH_SAFE(m_f, &vsi->mac_list, next, temp) { ret =ice_remove_mac_filter (vsi, &m_f->mac_info.mac_addr);if (ret !=ICE_SUCCESS ) { ret = -EINVAL ;@@ -1110,7 +1113,7 @@ ice_remove_all_mac_vlan_filters(struct ice_vsi *vsi)if (vsi->vlan_num ==0 )return 0 ; - TAILQ_FOREACH(v_f, &vsi->vlan_list, next) { + TAILQ_FOREACH_SAFE(v_f, &vsi->vlan_list, next, temp) { ret =ice_remove_vlan_filter (vsi, &v_f->vlan_info.vlan);if (ret !=ICE_SUCCESS ) { ret = -EINVAL ; --2.25.1