* [PATCH] gdrom: use strscpy in probe_gdrom_{setupcd,setupdisk}
@ 2026-04-17 14:03 Thorsten Blum
2026-04-19 17:17 ` Artur Rojek
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-04-17 14:03 UTC (permalink / raw)
To: Kees Cook
Cc: Thorsten Blum, Yoshinori Sato, Rich Felker,
John Paul Adrian Glaubitz, linux-sh, linux-kernel
strcpy() has been deprecated¹ because it performs no bounds checking on
the destination buffer, which can lead to buffer overflows.
While the current code works correctly, replace strcpy() with the safer
strscpy() to follow secure coding best practices.
¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
Compile-tested only. Adding arch/sh/ maintainers since that's the only
platform where this driver can be used.
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: linux-sh@vger.kernel.org
---
drivers/cdrom/gdrom.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
index 4ba4dd06cbf4..5768dc1aebc0 100644
--- a/drivers/cdrom/gdrom.c
+++ b/drivers/cdrom/gdrom.c
@@ -13,6 +13,7 @@
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/dma-mapping.h>
#include <linux/cdrom.h>
#include <linux/bio.h>
@@ -708,7 +709,7 @@ static void probe_gdrom_setupcd(void)
{
gd.cd_info->ops = &gdrom_ops;
gd.cd_info->capacity = 1;
- strcpy(gd.cd_info->name, GDROM_DEV_NAME);
+ strscpy(gd.cd_info->name, GDROM_DEV_NAME);
gd.cd_info->mask = CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|
CDC_SELECT_DISC;
}
@@ -719,7 +720,7 @@ static void probe_gdrom_setupdisk(void)
gd.disk->first_minor = 1;
gd.disk->minors = 1;
gd.disk->flags |= GENHD_FL_NO_PART;
- strcpy(gd.disk->disk_name, GDROM_DEV_NAME);
+ strscpy(gd.disk->disk_name, GDROM_DEV_NAME);
}
static int probe_gdrom_setupqueue(void)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gdrom: use strscpy in probe_gdrom_{setupcd,setupdisk}
2026-04-17 14:03 [PATCH] gdrom: use strscpy in probe_gdrom_{setupcd,setupdisk} Thorsten Blum
@ 2026-04-19 17:17 ` Artur Rojek
0 siblings, 0 replies; 2+ messages in thread
From: Artur Rojek @ 2026-04-19 17:17 UTC (permalink / raw)
To: Thorsten Blum
Cc: Kees Cook, Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
linux-sh, linux-kernel
On 2026-04-17 16:03, Thorsten Blum wrote:
> strcpy() has been deprecated¹ because it performs no bounds checking on
> the destination buffer, which can lead to buffer overflows.
>
> While the current code works correctly, replace strcpy() with the safer
> strscpy() to follow secure coding best practices.
>
> ¹ https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Hey Thorsten,
tested on real hardware. LGTM.
Acked-by: Artur Rojek <contact@artur-rojek.eu>
> ---
> Compile-tested only. Adding arch/sh/ maintainers since that's the only
> platform where this driver can be used.
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Rich Felker <dalias@libc.org>
> Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
> Cc: linux-sh@vger.kernel.org
> ---
> drivers/cdrom/gdrom.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
> index 4ba4dd06cbf4..5768dc1aebc0 100644
> --- a/drivers/cdrom/gdrom.c
> +++ b/drivers/cdrom/gdrom.c
> @@ -13,6 +13,7 @@
> #include <linux/kernel.h>
> #include <linux/list.h>
> #include <linux/slab.h>
> +#include <linux/string.h>
> #include <linux/dma-mapping.h>
> #include <linux/cdrom.h>
> #include <linux/bio.h>
> @@ -708,7 +709,7 @@ static void probe_gdrom_setupcd(void)
> {
> gd.cd_info->ops = &gdrom_ops;
> gd.cd_info->capacity = 1;
> - strcpy(gd.cd_info->name, GDROM_DEV_NAME);
> + strscpy(gd.cd_info->name, GDROM_DEV_NAME);
> gd.cd_info->mask = CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|
> CDC_SELECT_DISC;
> }
> @@ -719,7 +720,7 @@ static void probe_gdrom_setupdisk(void)
> gd.disk->first_minor = 1;
> gd.disk->minors = 1;
> gd.disk->flags |= GENHD_FL_NO_PART;
> - strcpy(gd.disk->disk_name, GDROM_DEV_NAME);
> + strscpy(gd.disk->disk_name, GDROM_DEV_NAME);
> }
>
> static int probe_gdrom_setupqueue(void)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-19 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-17 14:03 [PATCH] gdrom: use strscpy in probe_gdrom_{setupcd,setupdisk} Thorsten Blum
2026-04-19 17:17 ` Artur Rojek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox