mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Subrat Pandey <subratp@marvell.com>
To: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: <pabeni@redhat.com>, <kuba@kernel.org>, <edumazet@google.com>,
	<davem@davemloft.net>, <andrew+netdev@lunn.ch>,
	<sbhatta@marvell.com>, <rkannoth@marvell.com>,
	<gakula@marvell.com>, <sgoutham@marvell.com>
Subject: [PATCH net 1/3] octeontx2-af: Fix mcs string buffer size
Date: Wed, 29 Jul 2026 12:53:35 +0530	[thread overview]
Message-ID: <20260729072337.664479-2-subratp@marvell.com> (raw)
In-Reply-To: <20260729072337.664479-1-subratp@marvell.com>

From: Stefan Wiehler <stefan.wiehler@nokia.com>

The "mcs%d" name is built with the unbounded sprintf(), which writes
without any regard for the size of the destination buffer and can
overrun it. Switch to snprintf() with sizeof() so the formatted write
is always clamped to the buffer. The buffer is also enlarged to
24 bytes to comfortably hold the string for any MCS block index.

Fixes: d06c2aba5163 ("octeontx2-af: cn10k: mcs: Add debugfs support").
Signed-off-by: Stefan Wiehler <stefan.wiehler@nokia.com>
Signed-off-by: Subrat Pandey <subratp@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 3456313d3b3c..a13848f26ae9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -497,7 +497,7 @@ RVU_DEBUG_SEQ_FOPS(mcs_rx_secy_stats, mcs_rx_secy_stats_display, NULL);
 static void rvu_dbg_mcs_init(struct rvu *rvu)
 {
 	struct mcs *mcs;
-	char dname[10];
+	char dname[24];
 	int i;
 
 	if (!rvu->mcs_blk_cnt)
@@ -508,7 +508,7 @@ static void rvu_dbg_mcs_init(struct rvu *rvu)
 	for (i = 0; i < rvu->mcs_blk_cnt; i++) {
 		mcs = mcs_get_pdata(i);
 
-		sprintf(dname, "mcs%d", i);
+		snprintf(dname, sizeof(dname), "mcs%d", i);
 		rvu->rvu_dbg.mcs = debugfs_create_dir(dname,
 						      rvu->rvu_dbg.mcs_root);
 
-- 
2.43.0


  reply	other threads:[~2026-07-29  7:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  7:23 [PATCH net 0/3] octeontx2: Misc fixes for RVU drivers Subrat Pandey
2026-07-29  7:23 ` Subrat Pandey [this message]
2026-07-29 10:47   ` [PATCH net 1/3] octeontx2-af: Fix mcs string buffer size Jagielski, Jedrzej
     [not found]     ` <DM4PR18MB43844B8740DB2D5FFDBCED0FABC92@DM4PR18MB4384.namprd18.prod.outlook.com>
     [not found]       ` <PH0PR11MB5902E826DFB27A4AF57CD173F0C92@PH0PR11MB5902.namprd11.prod.outlook.com>
2026-07-30  8:29         ` Subrat Pandey
2026-07-29  7:23 ` [PATCH net 2/3] octeontx2-pf: Fix aura BPID assignment when CONFIG_DCB is enabled Subrat Pandey
2026-07-29  7:23 ` [PATCH net 3/3] octeontx2-af: mcs: Fix SC resource cleanup loop Subrat Pandey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260729072337.664479-2-subratp@marvell.com \
    --to=subratp@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rkannoth@marvell.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®