mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: hrushirajg23@gmail.com
Cc: linux-kernel@vger.kernel.org, oberpar@linux.ibm.com,
	akpm@linux-foundation.org
Subject: Re: [PATCH] gcov: use strscpy() instead of strcpy() in init_node()
Date: Mon, 31 Aug 2026 17:27:05 +0100	[thread overview]
Message-ID: <CB6CAE4C-7DBD-4C8D-B9A9-C93EB9531FDB@mainlining.org> (raw)
In-Reply-To: <20260831144953.324441-1-hrushirajg23@gmail.com>

On 31 August 2026 15:49:53 BST, Hrushiraj Gandhi <hrushirajg23@gmail.com>
wrote:
>node->name is a flexible array member sized to exactly strlen(name) +
>1 bytes at allocation time in new_node(), so this copy can never
>actually overflow. Still, prefer the bounded strscpy() over strcpy()
>on general principle; pass the same strlen(name) + 1 bound the
>allocation used, since sizeof() cannot be applied to a flexible array
>member.
>
>No functional change.
>
>Signed-off-by: Hrushiraj Gandhi <hrushirajg23@gmail.com>
>---
> kernel/gcov/fs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
>index 1d19b1be207a..764918570de1 100644
>--- a/kernel/gcov/fs.c
>+++ b/kernel/gcov/fs.c
>@@ -529,7 +529,7 @@ static void init_node(struct gcov_node *node, struct gcov_info *info,
> 	}
> 	node->parent = parent;
> 	if (name)
>-		strcpy(node->name, name);
>+		strscpy(node->name, name, strlen(name) + 1);
> }
> 
> /*
>
>
LGTM, thanks.

Reviewed-by: Bradley Morgan <brads@mainlining.org>


Maybe Andrew may like to see this?!
--- Thanks!
https://lore.kernel.org/all/EE579805-42F2-4C58-B752-F28779EEB717@grrlz.net/

      reply	other threads:[~2026-08-31 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 14:49 Hrushiraj Gandhi
2026-08-31 16:27 ` Bradley Morgan [this message]

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=CB6CAE4C-7DBD-4C8D-B9A9-C93EB9531FDB@mainlining.org \
    --to=brads@mainlining.org \
    --cc=akpm@linux-foundation.org \
    --cc=hrushirajg23@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oberpar@linux.ibm.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®