netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atm/fore200e: Consolidate available cell rate update to prevent race condition
@ 2024-06-11  3:54 Gui-Dong Han
  2024-06-11  7:39 ` Markus Elfring
  2024-06-14 12:23 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: Gui-Dong Han @ 2024-06-11  3:54 UTC (permalink / raw)
  To: 3chas3; +Cc: linux-atm-general, netdev, linux-kernel, baijiaju1990,
	Gui-Dong Han

In fore200e_change_qos, there is a race condition due to two consecutive
updates to the 'available_cell_rate' variable. If a read operation 
occurs between these updates, an intermediate value might be read, 
leading to potential bugs.

To fix this issue, 'available_cell_rate' should be adjusted in a single 
operation, ensuring consistency and preventing any intermediate states 
from being read.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Gui-Dong Han <hanguidong02@outlook.com>
---
 drivers/atm/fore200e.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index cb00f8244e41..d54e044d7542 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -1906,8 +1906,7 @@ fore200e_change_qos(struct atm_vcc* vcc,struct atm_qos* qos, int flags)
 	    return -EAGAIN;
 	}
 
-	fore200e->available_cell_rate += vcc->qos.txtp.max_pcr;
-	fore200e->available_cell_rate -= qos->txtp.max_pcr;
+	fore200e->available_cell_rate += vcc->qos.txtp.max_pcr - qos->txtp.max_pcr;
 
 	mutex_unlock(&fore200e->rate_mtx);
 	
-- 
2.34.1


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

end of thread, other threads:[~2024-06-14 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11  3:54 [PATCH] atm/fore200e: Consolidate available cell rate update to prevent race condition Gui-Dong Han
2024-06-11  7:39 ` Markus Elfring
2024-06-14 12:23 ` Simon Horman

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