linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id
@ 2025-06-10 19:33 kalavakunta.hari.prasad
  2025-06-11  9:09 ` Paul Fertser
  2025-06-13  1:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: kalavakunta.hari.prasad @ 2025-06-10 19:33 UTC (permalink / raw)
  To: sam, fercerpav, davem, edumazet, kuba, pabeni, horms, netdev,
	linux-kernel
  Cc: npeacock, hkalavakunta, Hari Kalavakunta

From: Hari Kalavakunta <kalavakunta.hari.prasad@gmail.com>

In NC-SI spec v1.2 section 8.4.44.2, the firmware name doesn't
need to be null terminated while its size occupies the full size
of the field. Fix the buffer overflow issue by adding one
additional byte for null terminator.

Signed-off-by: Hari Kalavakunta <kalavakunta.hari.prasad@gmail.com>
---
 net/ncsi/internal.h | 2 +-
 net/ncsi/ncsi-rsp.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h
index e76c6de0c784..adee6dcabdc3 100644
--- a/net/ncsi/internal.h
+++ b/net/ncsi/internal.h
@@ -110,7 +110,7 @@ struct ncsi_channel_version {
 	u8   update;		/* NCSI version update */
 	char alpha1;		/* NCSI version alpha1 */
 	char alpha2;		/* NCSI version alpha2 */
-	u8  fw_name[12];	/* Firmware name string                */
+	u8  fw_name[12 + 1];	/* Firmware name string                */
 	u32 fw_version;		/* Firmware version                   */
 	u16 pci_ids[4];		/* PCI identification                 */
 	u32 mf_id;		/* Manufacture ID                     */
diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c
index 472cc68ad86f..271ec6c3929e 100644
--- a/net/ncsi/ncsi-rsp.c
+++ b/net/ncsi/ncsi-rsp.c
@@ -775,6 +775,7 @@ static int ncsi_rsp_handler_gvi(struct ncsi_request *nr)
 	ncv->alpha1 = rsp->alpha1;
 	ncv->alpha2 = rsp->alpha2;
 	memcpy(ncv->fw_name, rsp->fw_name, 12);
+	ncv->fw_name[12] = '\0';
 	ncv->fw_version = ntohl(rsp->fw_version);
 	for (i = 0; i < ARRAY_SIZE(ncv->pci_ids); i++)
 		ncv->pci_ids[i] = ntohs(rsp->pci_ids[i]);
-- 
2.47.1


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

* Re: [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id
  2025-06-10 19:33 [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id kalavakunta.hari.prasad
@ 2025-06-11  9:09 ` Paul Fertser
  2025-06-13  1:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Fertser @ 2025-06-11  9:09 UTC (permalink / raw)
  To: kalavakunta.hari.prasad
  Cc: sam, davem, edumazet, kuba, pabeni, horms, netdev, linux-kernel,
	npeacock, hkalavakunta

Hello Hari,

On Tue, Jun 10, 2025 at 12:33:38PM -0700, kalavakunta.hari.prasad@gmail.com wrote:
> From: Hari Kalavakunta <kalavakunta.hari.prasad@gmail.com>
> 
> In NC-SI spec v1.2 section 8.4.44.2, the firmware name doesn't
> need to be null terminated while its size occupies the full size
> of the field. Fix the buffer overflow issue by adding one
> additional byte for null terminator.
> 
> Signed-off-by: Hari Kalavakunta <kalavakunta.hari.prasad@gmail.com>

You seem to be surprisingly persistent about ignoring my remarks on
your commit message.

So be it, since the code looks correct and reliable, fixes a real life
bug, and actually applies to the right tree now,

Reviewed-by: Paul Fertser <fercerpav@gmail.com>

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

* Re: [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id
  2025-06-10 19:33 [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id kalavakunta.hari.prasad
  2025-06-11  9:09 ` Paul Fertser
@ 2025-06-13  1:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-13  1:30 UTC (permalink / raw)
  To: Hari Kalavakunta
  Cc: sam, fercerpav, davem, edumazet, kuba, pabeni, horms, netdev,
	linux-kernel, npeacock, hkalavakunta

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 10 Jun 2025 12:33:38 -0700 you wrote:
> From: Hari Kalavakunta <kalavakunta.hari.prasad@gmail.com>
> 
> In NC-SI spec v1.2 section 8.4.44.2, the firmware name doesn't
> need to be null terminated while its size occupies the full size
> of the field. Fix the buffer overflow issue by adding one
> additional byte for null terminator.
> 
> [...]

Here is the summary with links:
  - [net-next] net: ncsi: Fix buffer overflow in fetching version id
    https://git.kernel.org/netdev/net-next/c/8e16170ae972

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:[~2025-06-13  1:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 19:33 [PATCH net-next] net: ncsi: Fix buffer overflow in fetching version id kalavakunta.hari.prasad
2025-06-11  9:09 ` Paul Fertser
2025-06-13  1:30 ` 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).