netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf)
@ 2023-07-21 15:58 Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir() Tony Nguyen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tony Nguyen @ 2023-07-21 15:58 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev; +Cc: Tony Nguyen

This series contains updates to i40e and iavf drivers.

Wang Ming corrects an error check on i40e.

Jake unlocks crit_lock on allocation failure to prevent deadlock and
stops re-enabling of interrupts when it's not intended for iavf.

The following are changes since commit 57f1f9dd3abea322173ea75a15887ccf14bbbe51:
  Merge tag 'net-6.5-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 40GbE

Jacob Keller (2):
  iavf: fix potential deadlock on allocation failure
  iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED

Wang Ming (1):
  i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir()

 drivers/net/ethernet/intel/i40e/i40e_debugfs.c |  2 +-
 drivers/net/ethernet/intel/iavf/iavf_main.c    | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

-- 
2.38.1


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

* [PATCH net 1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir()
  2023-07-21 15:58 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) Tony Nguyen
@ 2023-07-21 15:58 ` Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 2/3] iavf: fix potential deadlock on allocation failure Tony Nguyen
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2023-07-21 15:58 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Wang Ming, anthony.l.nguyen, shannon.nelson,
	Pucha Himasekhar Reddy

From: Wang Ming <machel@vivo.com>

The debugfs_create_dir() function returns error pointers.
It never returns NULL. Most incorrect error checks were fixed,
but the one in i40e_dbg_init() was forgotten.

Fix the remaining error check.

Fixes: 02e9c290814c ("i40e: debugfs interface")
Signed-off-by: Wang Ming <machel@vivo.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index 9954493cd448..62497f5565c5 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -1839,7 +1839,7 @@ void i40e_dbg_pf_exit(struct i40e_pf *pf)
 void i40e_dbg_init(void)
 {
 	i40e_dbg_root = debugfs_create_dir(i40e_driver_name, NULL);
-	if (!i40e_dbg_root)
+	if (IS_ERR(i40e_dbg_root))
 		pr_info("init of debugfs failed\n");
 }
 
-- 
2.38.1


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

* [PATCH net 2/3] iavf: fix potential deadlock on allocation failure
  2023-07-21 15:58 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir() Tony Nguyen
@ 2023-07-21 15:58 ` Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 3/3] iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED Tony Nguyen
  2023-07-25  0:20 ` [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2023-07-21 15:58 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Jacob Keller, anthony.l.nguyen, Rafal Romanowski

From: Jacob Keller <jacob.e.keller@intel.com>

In iavf_adminq_task(), if kzalloc() fails to allocate the event.msg_buf,
the function will exit without releasing the adapter->crit_lock.

This is unlikely, but if it happens, the next access to that mutex will
deadlock.

Fix this by moving the unlock to the end of the function, and adding a new
label to allow jumping to the unlock portion of the function exit flow.

Fixes: fc2e6b3b132a ("iavf: Rework mutexes for better synchronisation")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 3a88d413ddee..939c8126eb43 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -3264,7 +3264,7 @@ static void iavf_adminq_task(struct work_struct *work)
 	event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
 	event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
 	if (!event.msg_buf)
-		goto out;
+		goto unlock;
 
 	do {
 		ret = iavf_clean_arq_element(hw, &event, &pending);
@@ -3279,7 +3279,6 @@ static void iavf_adminq_task(struct work_struct *work)
 		if (pending != 0)
 			memset(event.msg_buf, 0, IAVF_MAX_AQ_BUF_SIZE);
 	} while (pending);
-	mutex_unlock(&adapter->crit_lock);
 
 	if (iavf_is_reset_in_progress(adapter))
 		goto freedom;
@@ -3323,6 +3322,8 @@ static void iavf_adminq_task(struct work_struct *work)
 
 freedom:
 	kfree(event.msg_buf);
+unlock:
+	mutex_unlock(&adapter->crit_lock);
 out:
 	/* re-enable Admin queue interrupt cause */
 	iavf_misc_irq_enable(adapter);
-- 
2.38.1


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

* [PATCH net 3/3] iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED
  2023-07-21 15:58 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir() Tony Nguyen
  2023-07-21 15:58 ` [PATCH net 2/3] iavf: fix potential deadlock on allocation failure Tony Nguyen
@ 2023-07-21 15:58 ` Tony Nguyen
  2023-07-25  0:20 ` [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Tony Nguyen @ 2023-07-21 15:58 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev
  Cc: Jacob Keller, anthony.l.nguyen, Rafal Romanowski

From: Jacob Keller <jacob.e.keller@intel.com>

In iavf_adminq_task(), if the function can't acquire the
adapter->crit_lock, it checks if the driver is removing. If so, it simply
exits without re-enabling the interrupt. This is done to ensure that the
task stops processing as soon as possible once the driver is being removed.

However, if the IAVF_FLAG_PF_COMMS_FAILED is set, the function checks this
before attempting to acquire the lock. In this case, the function exits
early and re-enables the interrupt. This will happen even if the driver is
already removing.

Avoid this, by moving the check to after the adapter->crit_lock is
acquired. This way, if the driver is removing, we will not re-enable the
interrupt.

Fixes: fc2e6b3b132a ("iavf: Rework mutexes for better synchronisation")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 939c8126eb43..9610ca770349 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -3250,9 +3250,6 @@ static void iavf_adminq_task(struct work_struct *work)
 	u32 val, oldval;
 	u16 pending;
 
-	if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
-		goto out;
-
 	if (!mutex_trylock(&adapter->crit_lock)) {
 		if (adapter->state == __IAVF_REMOVE)
 			return;
@@ -3261,6 +3258,9 @@ static void iavf_adminq_task(struct work_struct *work)
 		goto out;
 	}
 
+	if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED)
+		goto unlock;
+
 	event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
 	event.msg_buf = kzalloc(event.buf_len, GFP_KERNEL);
 	if (!event.msg_buf)
-- 
2.38.1


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

* Re: [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf)
  2023-07-21 15:58 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) Tony Nguyen
                   ` (2 preceding siblings ...)
  2023-07-21 15:58 ` [PATCH net 3/3] iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED Tony Nguyen
@ 2023-07-25  0:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-07-25  0:20 UTC (permalink / raw)
  To: Tony Nguyen; +Cc: davem, kuba, pabeni, edumazet, netdev

Hello:

This series was applied to netdev/net.git (main)
by Tony Nguyen <anthony.l.nguyen@intel.com>:

On Fri, 21 Jul 2023 08:58:09 -0700 you wrote:
> This series contains updates to i40e and iavf drivers.
> 
> Wang Ming corrects an error check on i40e.
> 
> Jake unlocks crit_lock on allocation failure to prevent deadlock and
> stops re-enabling of interrupts when it's not intended for iavf.
> 
> [...]

Here is the summary with links:
  - [net,1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir()
    https://git.kernel.org/netdev/net/c/043b1f185fb0
  - [net,2/3] iavf: fix potential deadlock on allocation failure
    https://git.kernel.org/netdev/net/c/a2f054c10bef
  - [net,3/3] iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED
    https://git.kernel.org/netdev/net/c/91896c8acce2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-07-25  0:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 15:58 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) Tony Nguyen
2023-07-21 15:58 ` [PATCH net 1/3] i40e: Fix an NULL vs IS_ERR() bug for debugfs_create_dir() Tony Nguyen
2023-07-21 15:58 ` [PATCH net 2/3] iavf: fix potential deadlock on allocation failure Tony Nguyen
2023-07-21 15:58 ` [PATCH net 3/3] iavf: check for removal state before IAVF_FLAG_PF_COMMS_FAILED Tony Nguyen
2023-07-25  0:20 ` [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2023-07-21 (i40e, iavf) patchwork-bot+netdevbpf

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).