netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sfc: extend the locking on mcdi->seqno
@ 2022-03-01 22:28 Niels Dossche
  2022-03-03  8:12 ` Martin Habets
  2022-03-03 14:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Niels Dossche @ 2022-03-01 22:28 UTC (permalink / raw)
  To: netdev
  Cc: Edward Cree, Martin Habets, David S. Miller, Jakub Kicinski,
	Niels Dossche

seqno could be read as a stale value outside of the lock. The lock is
already acquired to protect the modification of seqno against a possible
race condition. Place the reading of this value also inside this locking
to protect it against a possible race condition.

Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
 drivers/net/ethernet/sfc/mcdi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index be6bfd6b7ec7..50baf62b2cbc 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -163,9 +163,9 @@ static void efx_mcdi_send_request(struct efx_nic *efx, unsigned cmd,
 	/* Serialise with efx_mcdi_ev_cpl() and efx_mcdi_ev_death() */
 	spin_lock_bh(&mcdi->iface_lock);
 	++mcdi->seqno;
+	seqno = mcdi->seqno & SEQ_MASK;
 	spin_unlock_bh(&mcdi->iface_lock);
 
-	seqno = mcdi->seqno & SEQ_MASK;
 	xflags = 0;
 	if (mcdi->mode == MCDI_MODE_EVENTS)
 		xflags |= MCDI_HEADER_XFLAGS_EVREQ;
-- 
2.35.1


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

* Re: [PATCH] sfc: extend the locking on mcdi->seqno
  2022-03-01 22:28 [PATCH] sfc: extend the locking on mcdi->seqno Niels Dossche
@ 2022-03-03  8:12 ` Martin Habets
  2022-03-03 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Habets @ 2022-03-03  8:12 UTC (permalink / raw)
  To: Niels Dossche; +Cc: netdev, Edward Cree, David S. Miller, Jakub Kicinski

On Tue, Mar 01, 2022 at 11:28:22PM +0100, Niels Dossche wrote:
> seqno could be read as a stale value outside of the lock. The lock is
> already acquired to protect the modification of seqno against a possible
> race condition. Place the reading of this value also inside this locking
> to protect it against a possible race condition.
> 
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>

Acked-by: Martin Habets <habetsm.xilinx@gmail.com>

> ---
>  drivers/net/ethernet/sfc/mcdi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
> index be6bfd6b7ec7..50baf62b2cbc 100644
> --- a/drivers/net/ethernet/sfc/mcdi.c
> +++ b/drivers/net/ethernet/sfc/mcdi.c
> @@ -163,9 +163,9 @@ static void efx_mcdi_send_request(struct efx_nic *efx, unsigned cmd,
>  	/* Serialise with efx_mcdi_ev_cpl() and efx_mcdi_ev_death() */
>  	spin_lock_bh(&mcdi->iface_lock);
>  	++mcdi->seqno;
> +	seqno = mcdi->seqno & SEQ_MASK;
>  	spin_unlock_bh(&mcdi->iface_lock);
>  
> -	seqno = mcdi->seqno & SEQ_MASK;
>  	xflags = 0;
>  	if (mcdi->mode == MCDI_MODE_EVENTS)
>  		xflags |= MCDI_HEADER_XFLAGS_EVREQ;
> -- 
> 2.35.1

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

* Re: [PATCH] sfc: extend the locking on mcdi->seqno
  2022-03-01 22:28 [PATCH] sfc: extend the locking on mcdi->seqno Niels Dossche
  2022-03-03  8:12 ` Martin Habets
@ 2022-03-03 14:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-03 14:20 UTC (permalink / raw)
  To: Niels Dossche; +Cc: netdev, ecree.xilinx, habetsm.xilinx, davem, kuba

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue,  1 Mar 2022 23:28:22 +0100 you wrote:
> seqno could be read as a stale value outside of the lock. The lock is
> already acquired to protect the modification of seqno against a possible
> race condition. Place the reading of this value also inside this locking
> to protect it against a possible race condition.
> 
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
> 
> [...]

Here is the summary with links:
  - sfc: extend the locking on mcdi->seqno
    https://git.kernel.org/netdev/net/c/f1fb205efb0c

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:[~2022-03-03 14:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 22:28 [PATCH] sfc: extend the locking on mcdi->seqno Niels Dossche
2022-03-03  8:12 ` Martin Habets
2022-03-03 14:20 ` 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).