DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ice: fix illegal pointer access in releasing vsi
@ 2021-04-01 15:06 Wenwu Ma
  0 siblings, 0 replies; 4+ messages in thread
From: Wenwu Ma @ 2021-04-01 15:06 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: dev

From: wenwu ma <wenwux.ma@intel.com>

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 null pointer access.

Signed-off-by: wenwu ma <wenwux.ma@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9c9b84a93..785750d9b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] net/ice: fix illegal pointer access in releasing vsi
@ 2021-04-01 15:14 Wenwu Ma
  2021-04-01 12:02 ` Zhang, Qi Z
  0 siblings, 1 reply; 4+ messages in thread
From: Wenwu Ma @ 2021-04-01 15:14 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: dev

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.

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9c9b84a93..785750d9b 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] net/ice: fix illegal pointer access in releasing vsi
@ 2021-04-01 13:32 Wenwu Ma
  0 siblings, 0 replies; 4+ messages in thread
From: Wenwu Ma @ 2021-04-01 13:32 UTC (permalink / raw)
  To: qiming.yang, qi.z.zhang; +Cc: dev

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.

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 drivers/net/ice/ice_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 9c9b84a93..8cc8d4c7a 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -1094,12 +1094,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 +1111,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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/ice: fix illegal pointer access in releasing vsi
  2021-04-01 15:14 Wenwu Ma
@ 2021-04-01 12:02 ` Zhang, Qi Z
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Qi Z @ 2021-04-01 12:02 UTC (permalink / raw)
  To: Ma, WenwuX, Yang, Qiming; +Cc: dev



> -----Original Message-----
> From: Ma, WenwuX <wenwux.ma@intel.com>
> Sent: Thursday, April 1, 2021 11:14 PM
> To: Yang, Qiming <qiming.yang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH] net/ice: fix illegal pointer access in releasing vsi

Please add fix line and cc stable.

> 
> 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.
> 
> Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
> ---
>  drivers/net/ice/ice_ethdev.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 9c9b84a93..785750d9b 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-01 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 15:06 [dpdk-dev] [PATCH] net/ice: fix illegal pointer access in releasing vsi Wenwu Ma
  -- strict thread matches above, loose matches on Subject: below --
2021-04-01 15:14 Wenwu Ma
2021-04-01 12:02 ` Zhang, Qi Z
2021-04-01 13:32 Wenwu Ma

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git