All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qede: Fix memset corruption
@ 2021-08-24 16:52 Shai Malin
  2021-08-25  2:19 ` Kees Cook
  2021-08-25 10:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Shai Malin @ 2021-08-24 16:52 UTC (permalink / raw)
  To: netdev, davem, kuba, keescook
  Cc: aelior, smalin, malin1024, Prabhakar Kushwaha

Thanks to Kees Cook who detected the problem of memset that starting
from not the first member, but sized for the whole struct.
The better change will be to remove the redundant memset and to clear
only the msix_cnt member.

Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
Signed-off-by: Ariel Elior <aelior@marvell.com>
Signed-off-by: Shai Malin <smalin@marvell.com>
---
 drivers/net/ethernet/qlogic/qede/qede_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index d400e9b235bf..a0f20c5337d0 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -1866,6 +1866,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
 	}
 
 	edev->int_info.used_cnt = 0;
+	edev->int_info.msix_cnt = 0;
 }
 
 static int qede_req_msix_irqs(struct qede_dev *edev)
@@ -2419,7 +2420,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
 	goto out;
 err4:
 	qede_sync_free_irqs(edev);
-	memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
 err3:
 	qede_napi_disable_remove(edev);
 err2:
-- 
2.22.0


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

* Re: [PATCH] qede: Fix memset corruption
  2021-08-24 16:52 [PATCH] qede: Fix memset corruption Shai Malin
@ 2021-08-25  2:19 ` Kees Cook
  2021-08-25 10:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2021-08-25  2:19 UTC (permalink / raw)
  To: Shai Malin; +Cc: netdev, davem, kuba, aelior, malin1024, Prabhakar Kushwaha

On Tue, Aug 24, 2021 at 07:52:49PM +0300, Shai Malin wrote:
> Thanks to Kees Cook who detected the problem of memset that starting
> from not the first member, but sized for the whole struct.
> The better change will be to remove the redundant memset and to clear
> only the msix_cnt member.

Okay, thanks. It wasn't clear if this needs to be _only_ the msix_cnt
member or something else.

> 
> Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> Signed-off-by: Ariel Elior <aelior@marvell.com>
> Signed-off-by: Shai Malin <smalin@marvell.com>

Reported-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  drivers/net/ethernet/qlogic/qede/qede_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
> index d400e9b235bf..a0f20c5337d0 100644
> --- a/drivers/net/ethernet/qlogic/qede/qede_main.c
> +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
> @@ -1866,6 +1866,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
>  	}
>  
>  	edev->int_info.used_cnt = 0;
> +	edev->int_info.msix_cnt = 0;
>  }
>  
>  static int qede_req_msix_irqs(struct qede_dev *edev)
> @@ -2419,7 +2420,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
>  	goto out;
>  err4:
>  	qede_sync_free_irqs(edev);
> -	memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
>  err3:
>  	qede_napi_disable_remove(edev);
>  err2:
> -- 
> 2.22.0
> 

-- 
Kees Cook

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

* Re: [PATCH] qede: Fix memset corruption
  2021-08-24 16:52 [PATCH] qede: Fix memset corruption Shai Malin
  2021-08-25  2:19 ` Kees Cook
@ 2021-08-25 10:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-08-25 10:10 UTC (permalink / raw)
  To: Shai Malin; +Cc: netdev, davem, kuba, keescook, aelior, malin1024, pkushwaha

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 24 Aug 2021 19:52:49 +0300 you wrote:
> Thanks to Kees Cook who detected the problem of memset that starting
> from not the first member, but sized for the whole struct.
> The better change will be to remove the redundant memset and to clear
> only the msix_cnt member.
> 
> Signed-off-by: Prabhakar Kushwaha <pkushwaha@marvell.com>
> Signed-off-by: Ariel Elior <aelior@marvell.com>
> Signed-off-by: Shai Malin <smalin@marvell.com>
> 
> [...]

Here is the summary with links:
  - qede: Fix memset corruption
    https://git.kernel.org/netdev/net/c/e543468869e2

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] 3+ messages in thread

end of thread, other threads:[~2021-08-25 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 16:52 [PATCH] qede: Fix memset corruption Shai Malin
2021-08-25  2:19 ` Kees Cook
2021-08-25 10:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.