lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b6cb7905-8906-27eb-60a4-4475cd3f709a@linux.intel.com>
Date: Tue, 19 Aug 2025 13:00:27 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Miguel García <miguelgarciaroman8@...il.com>
cc: platform-driver-x86@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>, 
    krzk@...nel.org
Subject: Re: [PATCH v3] platform/x86: surfacepro3_button: replace deprecated
 strcpy() with strscpy()

On Mon, 28 Jul 2025, Miguel García wrote:

> Replace strcpy() with strscpy() when copying SURFACE_BUTTON_DEVICE_NAME
> into the device’s embedded name buffer returned by acpi_device_name().
> Bound the copy with MAX_ACPI_DEVICE_NAME_LEN to guarantee NUL-termination
> and avoid pointer-sized sizeof() mistakes.
> 
> This is a mechanical safety improvement; functional behavior is unchanged.
> 
> Signed-off-by: Miguel García <miguelgarciaroman8@...il.com>
> ---
> v2:
>  - Use MAX_ACPI_DEVICE_NAME_LEN instead of sizeof(name).
> 
> v3:
>  - Add full commit message (v2 was sent without message).
> 
> Testing:
>  - Build-tested on x86_64 (defconfig, allmodconfig, W=1).
>  - No runtime testing on Surface hardware
> 
>  drivers/platform/surface/surfacepro3_button.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c
> index 2755601f979c..772e107151f6 100644
> --- a/drivers/platform/surface/surfacepro3_button.c
> +++ b/drivers/platform/surface/surfacepro3_button.c
> @@ -211,7 +211,7 @@ static int surface_button_add(struct acpi_device *device)
>  	}
>  
>  	name = acpi_device_name(device);
> -	strcpy(name, SURFACE_BUTTON_DEVICE_NAME);
> +	strscpy(name, SURFACE_BUTTON_DEVICE_NAME, MAX_ACPI_DEVICE_NAME_LEN);

As mentioned earlier, I'd prefer this to use the two argument version of 
strscpy():

	strscpy(acpi_device_name(device), SURFACE_BUTTON_DEVICE_NAME);

...Changing to that may mean changes to name variable as well (remove 
it?).

-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ