netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: davem@davemloft.net, kuba@kernel.org
Cc: Michal Maloszewski <michal.maloszewski@intel.com>,
	netdev@vger.kernel.org, anthony.l.nguyen@intel.com,
	sassmann@redhat.com,
	Grzegorz Szczurek <grzegorzx.szczurek@intel.com>,
	Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>,
	Witold Fijalkowski <witoldx.fijalkowski@intel.com>,
	Jaroslaw Gawin <jaroslawx.gawin@intel.com>,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Tony Brelinski <tony.brelinski@intel.com>
Subject: [PATCH net 2/7] i40e: Fix NULL ptr dereference on VSI filter sync
Date: Wed, 17 Nov 2021 16:31:54 -0800	[thread overview]
Message-ID: <20211118003159.245561-3-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20211118003159.245561-1-anthony.l.nguyen@intel.com>

From: Michal Maloszewski <michal.maloszewski@intel.com>

Remove the reason of null pointer dereference in sync VSI filters.
Added new I40E_VSI_RELEASING flag to signalize deleting and releasing
of VSI resources to sync this thread with sync filters subtask.
Without this patch it is possible to start update the VSI filter list
after VSI is removed, that's causing a kernel oops.

Fixes: 41c445ff0f48 ("i40e: main driver core")
Signed-off-by: Grzegorz Szczurek <grzegorzx.szczurek@intel.com>
Signed-off-by: Michal Maloszewski <michal.maloszewski@intel.com>
Reviewed-by: Przemyslaw Patynowski <przemyslawx.patynowski@intel.com>
Reviewed-by: Witold Fijalkowski <witoldx.fijalkowski@intel.com>
Reviewed-by: Jaroslaw Gawin <jaroslawx.gawin@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Tony Brelinski <tony.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e.h      | 1 +
 drivers/net/ethernet/intel/i40e/i40e_main.c | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index 3d528fba754b..35a83a161b6f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -161,6 +161,7 @@ enum i40e_vsi_state_t {
 	__I40E_VSI_OVERFLOW_PROMISC,
 	__I40E_VSI_REINIT_REQUESTED,
 	__I40E_VSI_DOWN_REQUESTED,
+	__I40E_VSI_RELEASING,
 	/* This must be last as it determines the size of the BITMAP */
 	__I40E_VSI_STATE_SIZE__,
 };
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index ba862131b9bd..6e309d6ce37d 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -2623,7 +2623,8 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
 
 	for (v = 0; v < pf->num_alloc_vsi; v++) {
 		if (pf->vsi[v] &&
-		    (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED)) {
+		    (pf->vsi[v]->flags & I40E_VSI_FLAG_FILTER_CHANGED) &&
+		    !test_bit(__I40E_VSI_RELEASING, pf->vsi[v]->state)) {
 			int ret = i40e_sync_vsi_filters(pf->vsi[v]);
 
 			if (ret) {
@@ -13771,7 +13772,7 @@ int i40e_vsi_release(struct i40e_vsi *vsi)
 		dev_info(&pf->pdev->dev, "Can't remove PF VSI\n");
 		return -ENODEV;
 	}
-
+	set_bit(__I40E_VSI_RELEASING, vsi->state);
 	uplink_seid = vsi->uplink_seid;
 	if (vsi->type != I40E_VSI_SRIOV) {
 		if (vsi->netdev_registered) {
-- 
2.31.1


  parent reply	other threads:[~2021-11-18  0:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18  0:31 [PATCH net 0/7][pull request] Intel Wired LAN Driver Updates 2021-11-17 Tony Nguyen
2021-11-18  0:31 ` [PATCH net 1/7] i40e: Fix correct max_pkt_size on VF RX queue Tony Nguyen
2021-11-18  0:31 ` Tony Nguyen [this message]
2021-11-18  0:31 ` [PATCH net 3/7] i40e: Fix changing previously set num_queue_pairs for PFs Tony Nguyen
2021-11-18  0:31 ` [PATCH net 4/7] i40e: Fix ping is lost after configuring ADq on VF Tony Nguyen
2021-11-18  0:31 ` [PATCH net 5/7] i40e: Fix warning message and call stack during rmmod i40e driver Tony Nguyen
2021-11-18  0:31 ` [PATCH net 6/7] i40e: Fix creation of first queue by omitting it if is not power of two Tony Nguyen
2021-11-18  0:31 ` [PATCH net 7/7] i40e: Fix display error code in dmesg Tony Nguyen
2021-11-18 12:00 ` [PATCH net 0/7][pull request] Intel Wired LAN Driver Updates 2021-11-17 patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211118003159.245561-3-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=davem@davemloft.net \
    --cc=grzegorzx.szczurek@intel.com \
    --cc=jaroslawx.gawin@intel.com \
    --cc=kuba@kernel.org \
    --cc=michal.maloszewski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=przemyslawx.patynowski@intel.com \
    --cc=sassmann@redhat.com \
    --cc=tony.brelinski@intel.com \
    --cc=witoldx.fijalkowski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).