* [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy()
@ 2025-02-25 20:39 Thorsten Blum
2025-03-03 18:47 ` Kees Cook
2025-03-06 9:37 ` Patrik Jakobsson
0 siblings, 2 replies; 3+ messages in thread
From: Thorsten Blum @ 2025-02-25 20:39 UTC (permalink / raw)
To: Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: Thorsten Blum, linux-hardening, dri-devel, linux-kernel
strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.
Compile-tested only.
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c
index cc2ed9b3fd2d..ca7f59ff1fda 100644
--- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
+++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
@@ -855,8 +855,7 @@ cdv_intel_dp_i2c_init(struct gma_connector *connector,
memset(&intel_dp->adapter, '\0', sizeof (intel_dp->adapter));
intel_dp->adapter.owner = THIS_MODULE;
- strncpy (intel_dp->adapter.name, name, sizeof(intel_dp->adapter.name) - 1);
- intel_dp->adapter.name[sizeof(intel_dp->adapter.name) - 1] = '\0';
+ strscpy(intel_dp->adapter.name, name);
intel_dp->adapter.algo_data = &intel_dp->algo;
intel_dp->adapter.dev.parent = connector->base.kdev;
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy()
2025-02-25 20:39 [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy() Thorsten Blum
@ 2025-03-03 18:47 ` Kees Cook
2025-03-06 9:37 ` Patrik Jakobsson
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2025-03-03 18:47 UTC (permalink / raw)
To: Thorsten Blum
Cc: Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, linux-hardening,
dri-devel, linux-kernel
On Tue, Feb 25, 2025 at 09:39:32PM +0100, Thorsten Blum wrote:
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Compile-tested only.
>
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Yup, the adapter var is already zeroed out, so even if NUL padding is
needed, it is already present.
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy()
2025-02-25 20:39 [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-03-03 18:47 ` Kees Cook
@ 2025-03-06 9:37 ` Patrik Jakobsson
1 sibling, 0 replies; 3+ messages in thread
From: Patrik Jakobsson @ 2025-03-06 9:37 UTC (permalink / raw)
To: Thorsten Blum
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, linux-hardening, dri-devel, linux-kernel
On Tue, Feb 25, 2025 at 9:39 PM Thorsten Blum <thorsten.blum@linux.dev> wrote:
>
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Compile-tested only.
>
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Thanks for the patch.
Applied to drm-misc-next
-Patrik
> ---
> drivers/gpu/drm/gma500/cdv_intel_dp.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/cdv_intel_dp.c b/drivers/gpu/drm/gma500/cdv_intel_dp.c
> index cc2ed9b3fd2d..ca7f59ff1fda 100644
> --- a/drivers/gpu/drm/gma500/cdv_intel_dp.c
> +++ b/drivers/gpu/drm/gma500/cdv_intel_dp.c
> @@ -855,8 +855,7 @@ cdv_intel_dp_i2c_init(struct gma_connector *connector,
>
> memset(&intel_dp->adapter, '\0', sizeof (intel_dp->adapter));
> intel_dp->adapter.owner = THIS_MODULE;
> - strncpy (intel_dp->adapter.name, name, sizeof(intel_dp->adapter.name) - 1);
> - intel_dp->adapter.name[sizeof(intel_dp->adapter.name) - 1] = '\0';
> + strscpy(intel_dp->adapter.name, name);
> intel_dp->adapter.algo_data = &intel_dp->algo;
> intel_dp->adapter.dev.parent = connector->base.kdev;
>
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-06 9:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25 20:39 [PATCH] drm/gma500: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-03-03 18:47 ` Kees Cook
2025-03-06 9:37 ` Patrik Jakobsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox