mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] asus-laptop: prefer strscpy() over strcpy()
       [not found] <20241009230558.51892-1-abdul.rahim.ref@myyahoo.com>
@ 2024-10-09 23:05 ` Abdul Rahim
  2024-10-09 23:10   ` Luke Jones
                     ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Abdul Rahim @ 2024-10-09 23:05 UTC (permalink / raw)
  To: corentin.chary, luke, hdegoede, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel, Abdul Rahim

The function strcpy() is depreciated and potentially unsafe. It performs
no bounds checking on the destination buffer. This could result in
linear overflows beyond the end of the buffer, leading to all kinds of
misbehaviors. The safe replacement is strscpy() [1].

this fixes checkpatch warning:
    WARNING: Prefer strscpy over strcpy

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>
---
 drivers/platform/x86/asus-laptop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 9d7e6b712abf..d460dd194f19 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device *device)
 	if (!asus)
 		return -ENOMEM;
 	asus->handle = device->handle;
-	strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
-	strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
+	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
+	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
 	device->driver_data = asus;
 	asus->device = device;
 
-- 
2.43.0


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

* Re: [PATCH] asus-laptop: prefer strscpy() over strcpy()
  2024-10-09 23:05 ` [PATCH] asus-laptop: prefer strscpy() over strcpy() Abdul Rahim
@ 2024-10-09 23:10   ` Luke Jones
  2024-10-10  9:40   ` Hans de Goede
  2024-10-10 12:25   ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Luke Jones @ 2024-10-09 23:10 UTC (permalink / raw)
  To: Abdul Rahim, corentin.chary, Hans de Goede, Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel

On Thu, 10 Oct 2024, at 12:05 PM, Abdul Rahim wrote:
> The function strcpy() is depreciated and potentially unsafe. It performs
> no bounds checking on the destination buffer. This could result in
> linear overflows beyond the end of the buffer, leading to all kinds of
> misbehaviors. The safe replacement is strscpy() [1].
>
> this fixes checkpatch warning:
>     WARNING: Prefer strscpy over strcpy
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>
> ---
>  drivers/platform/x86/asus-laptop.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c 
> b/drivers/platform/x86/asus-laptop.c
> index 9d7e6b712abf..d460dd194f19 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device 
> *device)
>  	if (!asus)
>  		return -ENOMEM;
>  	asus->handle = device->handle;
> -	strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> -	strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> +	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> +	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
>  	device->driver_data = asus;
>  	asus->device = device;
> 
> -- 
> 2.43.0

Looks good, thank you for doing this.

Reviewed-by: Luke D. Jones <luke@ljones.dev>

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

* Re: [PATCH] asus-laptop: prefer strscpy() over strcpy()
  2024-10-09 23:05 ` [PATCH] asus-laptop: prefer strscpy() over strcpy() Abdul Rahim
  2024-10-09 23:10   ` Luke Jones
@ 2024-10-10  9:40   ` Hans de Goede
  2024-10-10 12:25   ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2024-10-10  9:40 UTC (permalink / raw)
  To: Abdul Rahim, corentin.chary, luke, ilpo.jarvinen
  Cc: platform-driver-x86, linux-kernel

Hi,

On 10-Oct-24 1:05 AM, Abdul Rahim wrote:
> The function strcpy() is depreciated and potentially unsafe. It performs
> no bounds checking on the destination buffer. This could result in
> linear overflows beyond the end of the buffer, leading to all kinds of
> misbehaviors. The safe replacement is strscpy() [1].
> 
> this fixes checkpatch warning:
>     WARNING: Prefer strscpy over strcpy
> 
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans



> ---
>  drivers/platform/x86/asus-laptop.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index 9d7e6b712abf..d460dd194f19 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device *device)
>  	if (!asus)
>  		return -ENOMEM;
>  	asus->handle = device->handle;
> -	strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> -	strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> +	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> +	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
>  	device->driver_data = asus;
>  	asus->device = device;
>  


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

* Re: [PATCH] asus-laptop: prefer strscpy() over strcpy()
  2024-10-09 23:05 ` [PATCH] asus-laptop: prefer strscpy() over strcpy() Abdul Rahim
  2024-10-09 23:10   ` Luke Jones
  2024-10-10  9:40   ` Hans de Goede
@ 2024-10-10 12:25   ` Ilpo Järvinen
  2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2024-10-10 12:25 UTC (permalink / raw)
  To: corentin.chary, luke, hdegoede, Abdul Rahim
  Cc: platform-driver-x86, linux-kernel

On Thu, 10 Oct 2024 04:35:58 +0530, Abdul Rahim wrote:

> The function strcpy() is depreciated and potentially unsafe. It performs
> no bounds checking on the destination buffer. This could result in
> linear overflows beyond the end of the buffer, leading to all kinds of
> misbehaviors. The safe replacement is strscpy() [1].
> 
> this fixes checkpatch warning:
>     WARNING: Prefer strscpy over strcpy
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] asus-laptop: prefer strscpy() over strcpy()
      commit: 8150408bfdb2f9c17970295427cf91470189e6d0

--
 i.


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

end of thread, other threads:[~2024-10-10 12:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20241009230558.51892-1-abdul.rahim.ref@myyahoo.com>
2024-10-09 23:05 ` [PATCH] asus-laptop: prefer strscpy() over strcpy() Abdul Rahim
2024-10-09 23:10   ` Luke Jones
2024-10-10  9:40   ` Hans de Goede
2024-10-10 12:25   ` Ilpo Järvinen

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®