RE: [PATCH] Fix possible strscpy() buffer overflows

"Datta, Shubhrajyoti" <[email protected]>
Newsgroups org.kernel.vger.linux-edac,org.kernel.vger.linux-kernel,org.kernel.vger.linux-sound
Message-ID <LV5PR12MB982875DA2891146C9F7B40E781EB2@LV5PR12MB9828.namprd12.prod.outlook.com>

> -----Original Message-----
> From: David Laight <[email protected]>
> Sent: Tuesday, May 12, 2026 12:46 AM
> To: Borislav Petkov <[email protected]>
> Cc: Andrei Purdea <[email protected]>; Datta, Shubhrajyoti
> <[email protected]>; Geraldo Nascimento
> <[email protected]>; Alexander A. Klimov
> <[email protected]>; Tony Luck <[email protected]>; Kees Cook
> <[email protected]>; Arnd Bergmann <[email protected]>; Greg Kroah-Hartman
> <[email protected]>; Nick Li <[email protected]>; Liam
> Girdwood <[email protected]>; Mark Brown <[email protected]>;
> Jaroslav Kysela <[email protected]>; Takashi Iwai <[email protected]>; linux-
> [email protected]; Linux Kernel Mailing List <linux-
> [email protected]>; [email protected]
> Subject: Re: [PATCH] Fix possible strscpy() buffer overflows
> 

...
> 
> It would be better if amd_rpmsg_id_table[] were 'const' - in that case the
> strscpy() call should 'degenerate' into a memcpy().

Here the channel is error_ipc 
So instead of copying we can initialize the name.

diff --git a/drivers/edac/versalnet_edac.c b/drivers/edac/versalnet_edac.c
index 18284c76651c..161bde2b14ba 100644
--- a/drivers/edac/versalnet_edac.c
+++ b/drivers/edac/versalnet_edac.c
@@ -720,14 +720,14 @@ MODULE_DEVICE_TABLE(rpmsg, amd_rpmsg_id_table);

 static int rpmsg_probe(struct rpmsg_device *rpdev)
 {
-       struct rpmsg_channel_info chinfo;
        struct mc_priv *pg;
+       struct rpmsg_channel_info chinfo = {
+               .src = RPMSG_ADDR_ANY,
+               .dst = rpdev->dst,
+               .name = "error_ipc",
+       };

        pg = (struct mc_priv *)amd_rpmsg_id_table[0].driver_data;
-       chinfo.src = RPMSG_ADDR_ANY;
-       chinfo.dst = rpdev->dst;
-       strscpy(chinfo.name, amd_rpmsg_id_table[0].name,
-               strlen(amd_rpmsg_id_table[0].name));

        pg->ept = rpmsg_create_ept(rpdev, rpmsg_cb, NULL, chinfo);
        if (!pg->ept)
> 
> -- David
> 
> 
> >
> > In case someone goes and changes that amd_rpmsg_id_table[0].name in
> > the future.
> >
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.