Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: alx: fix possible buffer overflow
@ 2026-05-20 18:01 Alexander A. Klimov
  2026-05-21  2:18 ` kernel test robot
  2026-05-21  4:29 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander A. Klimov @ 2026-05-20 18:01 UTC (permalink / raw)
  To: Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Kees Cook, Alexander A. Klimov,
	Tobias Regnery, open list:ATLX ETHERNET DRIVERS, open list

In alx_request_msix(), use snprintf(DST, sizeof(DST), ...)
and not sprintf(DST, ...) to never write more than sizeof(DST) bytes.

Fixes: e0eac2546090 ("alx: prepare interrupt functions for multiple queues")
Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
---
 drivers/net/ethernet/atheros/alx/main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index ab262e66f986..d2697d9eacfa 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -865,16 +865,17 @@ static int alx_request_msix(struct alx_priv *alx)
 		vector++;
 
 		if (np->txq && np->rxq)
-			sprintf(np->irq_lbl, "%s-TxRx-%u", netdev->name,
-				np->txq->queue_idx);
+			snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-TxRx-%u",
+				 netdev->name, np->txq->queue_idx);
 		else if (np->txq)
-			sprintf(np->irq_lbl, "%s-tx-%u", netdev->name,
-				np->txq->queue_idx);
+			snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-tx-%u",
+				 netdev->name, np->txq->queue_idx);
 		else if (np->rxq)
-			sprintf(np->irq_lbl, "%s-rx-%u", netdev->name,
-				np->rxq->queue_idx);
+			snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-rx-%u",
+				 netdev->name, np->rxq->queue_idx);
 		else
-			sprintf(np->irq_lbl, "%s-unused", netdev->name);
+			snprintf(np->irq_lbl, sizeof(np->irq_lbl), "%s-unused",
+				 netdev->name);
 
 		np->vec_idx = vector;
 		err = request_irq(pci_irq_vector(alx->hw.pdev, vector),
-- 
2.54.0


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

end of thread, other threads:[~2026-05-21  4:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 18:01 [PATCH] net: alx: fix possible buffer overflow Alexander A. Klimov
2026-05-21  2:18 ` kernel test robot
2026-05-21  4:29 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox