* [PATCH] fujitsu-laptop: replace strcpy -> strscpy
[not found] <20241127203710.36425-1-abdul.rahim.ref@myyahoo.com>
@ 2024-11-27 20:37 ` Abdul Rahim
2024-11-28 2:39 ` Jonathan Woithe
2024-12-02 17:12 ` Ilpo Järvinen
0 siblings, 2 replies; 3+ messages in thread
From: Abdul Rahim @ 2024-11-27 20:37 UTC (permalink / raw)
To: Jonathan Woithe, Hans de Goede, Ilpo Järvinen
Cc: Abdul Rahim, platform-driver-x86, linux-kernel
strcpy() 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.[1]
[1]: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>
---
drivers/platform/x86/fujitsu-laptop.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
index ae992ac1ab4a..a0eae24ca9e6 100644
--- a/drivers/platform/x86/fujitsu-laptop.c
+++ b/drivers/platform/x86/fujitsu-laptop.c
@@ -505,8 +505,8 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device)
return -ENOMEM;
fujitsu_bl = priv;
- strcpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
- strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
+ strscpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
+ strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
device->driver_data = priv;
pr_info("ACPI: %s [%s]\n",
@@ -891,8 +891,8 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended.");
fext = device;
- strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
- strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
+ strscpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
+ strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
device->driver_data = priv;
/* kfifo */
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fujitsu-laptop: replace strcpy -> strscpy
2024-11-27 20:37 ` [PATCH] fujitsu-laptop: replace strcpy -> strscpy Abdul Rahim
@ 2024-11-28 2:39 ` Jonathan Woithe
2024-12-02 17:12 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Woithe @ 2024-11-28 2:39 UTC (permalink / raw)
To: Abdul Rahim
Cc: Hans de Goede, Ilpo Järvinen, platform-driver-x86, linux-kernel
On Thu, Nov 28, 2024 at 02:07:07AM +0530, Abdul Rahim wrote:
> strcpy() 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.[1]
>
> [1]: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
> Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>
> ---
> drivers/platform/x86/fujitsu-laptop.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index ae992ac1ab4a..a0eae24ca9e6 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -505,8 +505,8 @@ static int acpi_fujitsu_bl_add(struct acpi_device *device)
> return -ENOMEM;
>
> fujitsu_bl = priv;
> - strcpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
> - strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
> + strscpy(acpi_device_name(device), ACPI_FUJITSU_BL_DEVICE_NAME);
> + strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
> device->driver_data = priv;
>
> pr_info("ACPI: %s [%s]\n",
> @@ -891,8 +891,8 @@ static int acpi_fujitsu_laptop_add(struct acpi_device *device)
> WARN_ONCE(fext, "More than one FUJ02E3 ACPI device was found. Driver may not work as intended.");
> fext = device;
>
> - strcpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
> - strcpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
> + strscpy(acpi_device_name(device), ACPI_FUJITSU_LAPTOP_DEVICE_NAME);
> + strscpy(acpi_device_class(device), ACPI_FUJITSU_CLASS);
> device->driver_data = priv;
>
> /* kfifo */
This looks good to me and is a useful improvement. Thanks!
Acked-by: Jonathan Woithe <jwoithe@just42.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fujitsu-laptop: replace strcpy -> strscpy
2024-11-27 20:37 ` [PATCH] fujitsu-laptop: replace strcpy -> strscpy Abdul Rahim
2024-11-28 2:39 ` Jonathan Woithe
@ 2024-12-02 17:12 ` Ilpo Järvinen
1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2024-12-02 17:12 UTC (permalink / raw)
To: Jonathan Woithe, Hans de Goede, Abdul Rahim
Cc: platform-driver-x86, linux-kernel
On Thu, 28 Nov 2024 02:07:07 +0530, Abdul Rahim wrote:
> strcpy() 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.[1]
>
> [1]: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
>
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] fujitsu-laptop: replace strcpy -> strscpy
commit: 0ffafd4a3b39b341a4d7d73df34ab3b2c07a26c0
--
i.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-02 17:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20241127203710.36425-1-abdul.rahim.ref@myyahoo.com>
2024-11-27 20:37 ` [PATCH] fujitsu-laptop: replace strcpy -> strscpy Abdul Rahim
2024-11-28 2:39 ` Jonathan Woithe
2024-12-02 17:12 ` 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®