* [PATCH v2 2/6] ACPI: acpi_pad: Use strscpy instead of strcpy.
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
@ 2024-08-04 12:33 ` Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 3/6] ACPI: acpi_processor: " Muhammad Qasim Abdul Majeed
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Muhammad Qasim Abdul Majeed @ 2024-08-04 12:33 UTC (permalink / raw)
To: rafael, lenb, linux-acpi, linux-kernel; +Cc: Muhammad Qasim Abdul Majeed
Replace strcpy() with strscpy() in the ACPI acpi_pad driver.
strcpy() has been deprecated because it is generally unsafe, so help to
eliminate it from the kernel source.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
---
drivers/acpi/acpi_pad.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index bd1ad07f0290..e49f89bbeacf 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -417,8 +417,8 @@ static int acpi_pad_probe(struct platform_device *pdev)
struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
acpi_status status;
- strcpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
- strcpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
+ strscpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
+ strscpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS);
status = acpi_install_notify_handler(adev->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify, adev);
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 3/6] ACPI: acpi_processor: Use strscpy instead of strcpy.
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 2/6] ACPI: acpi_pad: Use strscpy instead of strcpy Muhammad Qasim Abdul Majeed
@ 2024-08-04 12:33 ` Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 4/6] ACPI: battery : " Muhammad Qasim Abdul Majeed
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Muhammad Qasim Abdul Majeed @ 2024-08-04 12:33 UTC (permalink / raw)
To: rafael, lenb, linux-acpi, linux-kernel; +Cc: Muhammad Qasim Abdul Majeed
Replace strcpy() with strscpy() in the ACPI acpi_processor driver.
strcpy() has been deprecated because it is generally unsafe, so help to
eliminate it from the kernel source.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
---
drivers/acpi/acpi_processor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 7a0dd35d62c9..8a8826a2242d 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -394,8 +394,8 @@ static int acpi_processor_add(struct acpi_device *device,
}
pr->handle = device->handle;
- strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
- strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
+ strscpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
+ strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
device->driver_data = pr;
result = acpi_processor_get_info(device);
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 4/6] ACPI: battery : Use strscpy instead of strcpy.
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 2/6] ACPI: acpi_pad: Use strscpy instead of strcpy Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 3/6] ACPI: acpi_processor: " Muhammad Qasim Abdul Majeed
@ 2024-08-04 12:33 ` Muhammad Qasim Abdul Majeed
2024-08-04 12:33 ` [PATCH v2 5/6] ACPI: button: " Muhammad Qasim Abdul Majeed
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Muhammad Qasim Abdul Majeed @ 2024-08-04 12:33 UTC (permalink / raw)
To: rafael, lenb, linux-acpi, linux-kernel; +Cc: Muhammad Qasim Abdul Majeed
Replace strcpy() with strscpy() in the ACPI battery driver.
strcpy() has been deprecated because it is generally unsafe, so help to
eliminate it from the kernel source.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
---
drivers/acpi/battery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b379401ff1c2..784f9234f1a4 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1193,8 +1193,8 @@ static int acpi_battery_add(struct acpi_device *device)
if (!battery)
return -ENOMEM;
battery->device = device;
- strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
- strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
+ strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
+ strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
device->driver_data = battery;
mutex_init(&battery->lock);
mutex_init(&battery->sysfs_lock);
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 5/6] ACPI: button: Use strscpy instead of strcpy.
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
` (2 preceding siblings ...)
2024-08-04 12:33 ` [PATCH v2 4/6] ACPI: battery : " Muhammad Qasim Abdul Majeed
@ 2024-08-04 12:33 ` Muhammad Qasim Abdul Majeed
2024-08-26 17:19 ` Rafael J. Wysocki
2024-08-04 12:33 ` [PATCH v2 6/6] ACPI: bus: Define and use a macro for device and class name length Muhammad Qasim Abdul Majeed
2024-08-26 17:14 ` [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Rafael J. Wysocki
5 siblings, 1 reply; 8+ messages in thread
From: Muhammad Qasim Abdul Majeed @ 2024-08-04 12:33 UTC (permalink / raw)
To: rafael, lenb, linux-acpi, linux-kernel; +Cc: Muhammad Qasim Abdul Majeed
Replace strcpy() with strscpy() in the ACPI button driver.
strcpy() has been deprecated because it is generally unsafe, so help to
eliminate it from the kernel source.
Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
---
drivers/acpi/button.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index cc61020756be..9dda4a3998f8 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -521,7 +521,7 @@ static int acpi_button_add(struct acpi_device *device)
struct input_dev *input;
const char *hid = acpi_device_hid(device);
acpi_status status;
- char *name, *class;
+ char *class;
int error = 0;
if (!strcmp(hid, ACPI_BUTTON_HID_LID) &&
@@ -540,27 +540,26 @@ static int acpi_button_add(struct acpi_device *device)
goto err_free_button;
}
- name = acpi_device_name(device);
class = acpi_device_class(device);
if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
!strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
button->type = ACPI_BUTTON_TYPE_POWER;
handler = acpi_button_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
} else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
button->type = ACPI_BUTTON_TYPE_SLEEP;
handler = acpi_button_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
} else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
button->type = ACPI_BUTTON_TYPE_LID;
handler = acpi_lid_notify;
- strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
+ strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
sprintf(class, "%s/%s",
ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
input->open = acpi_lid_input_open;
@@ -579,7 +578,7 @@ static int acpi_button_add(struct acpi_device *device)
snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
- input->name = name;
+ input->name = acpi_device_name(device);
input->phys = button->phys;
input->id.bustype = BUS_HOST;
input->id.product = button->type;
@@ -636,7 +635,7 @@ static int acpi_button_add(struct acpi_device *device)
}
device_init_wakeup(&device->dev, true);
- pr_info("%s [%s]\n", name, acpi_device_bid(device));
+ pr_info("%s [%s]\n", input->name, acpi_device_bid(device));
return 0;
err_input_unregister:
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 5/6] ACPI: button: Use strscpy instead of strcpy.
2024-08-04 12:33 ` [PATCH v2 5/6] ACPI: button: " Muhammad Qasim Abdul Majeed
@ 2024-08-26 17:19 ` Rafael J. Wysocki
0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2024-08-26 17:19 UTC (permalink / raw)
To: Muhammad Qasim Abdul Majeed; +Cc: rafael, lenb, linux-acpi, linux-kernel
On Sun, Aug 4, 2024 at 2:34 PM Muhammad Qasim Abdul Majeed
<qasim.majeed20@gmail.com> wrote:
>
> Replace strcpy() with strscpy() in the ACPI button driver.
>
> strcpy() has been deprecated because it is generally unsafe, so help to
> eliminate it from the kernel source.
>
> Link: https://github.com/KSPP/linux/issues/88
>
> Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
> ---
> drivers/acpi/button.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
> index cc61020756be..9dda4a3998f8 100644
> --- a/drivers/acpi/button.c
> +++ b/drivers/acpi/button.c
> @@ -521,7 +521,7 @@ static int acpi_button_add(struct acpi_device *device)
> struct input_dev *input;
> const char *hid = acpi_device_hid(device);
> acpi_status status;
> - char *name, *class;
> + char *class;
> int error = 0;
>
> if (!strcmp(hid, ACPI_BUTTON_HID_LID) &&
> @@ -540,27 +540,26 @@ static int acpi_button_add(struct acpi_device *device)
> goto err_free_button;
> }
>
> - name = acpi_device_name(device);
This is more than advertised in the changelog.
Please extend the changelog to explain why this additional change is needed.
> class = acpi_device_class(device);
>
> if (!strcmp(hid, ACPI_BUTTON_HID_POWER) ||
> !strcmp(hid, ACPI_BUTTON_HID_POWERF)) {
> button->type = ACPI_BUTTON_TYPE_POWER;
> handler = acpi_button_notify;
> - strcpy(name, ACPI_BUTTON_DEVICE_NAME_POWER);
> + strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_POWER);
> sprintf(class, "%s/%s",
> ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_POWER);
> } else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEP) ||
> !strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) {
> button->type = ACPI_BUTTON_TYPE_SLEEP;
> handler = acpi_button_notify;
> - strcpy(name, ACPI_BUTTON_DEVICE_NAME_SLEEP);
> + strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_SLEEP);
> sprintf(class, "%s/%s",
> ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_SLEEP);
> } else if (!strcmp(hid, ACPI_BUTTON_HID_LID)) {
> button->type = ACPI_BUTTON_TYPE_LID;
> handler = acpi_lid_notify;
> - strcpy(name, ACPI_BUTTON_DEVICE_NAME_LID);
> + strscpy(acpi_device_name(device), ACPI_BUTTON_DEVICE_NAME_LID);
> sprintf(class, "%s/%s",
> ACPI_BUTTON_CLASS, ACPI_BUTTON_SUBCLASS_LID);
> input->open = acpi_lid_input_open;
> @@ -579,7 +578,7 @@ static int acpi_button_add(struct acpi_device *device)
>
> snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid);
>
> - input->name = name;
> + input->name = acpi_device_name(device);
> input->phys = button->phys;
> input->id.bustype = BUS_HOST;
> input->id.product = button->type;
> @@ -636,7 +635,7 @@ static int acpi_button_add(struct acpi_device *device)
> }
>
> device_init_wakeup(&device->dev, true);
> - pr_info("%s [%s]\n", name, acpi_device_bid(device));
> + pr_info("%s [%s]\n", input->name, acpi_device_bid(device));
> return 0;
>
> err_input_unregister:
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 6/6] ACPI: bus: Define and use a macro for device and class name length.
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
` (3 preceding siblings ...)
2024-08-04 12:33 ` [PATCH v2 5/6] ACPI: button: " Muhammad Qasim Abdul Majeed
@ 2024-08-04 12:33 ` Muhammad Qasim Abdul Majeed
2024-08-26 17:14 ` [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Rafael J. Wysocki
5 siblings, 0 replies; 8+ messages in thread
From: Muhammad Qasim Abdul Majeed @ 2024-08-04 12:33 UTC (permalink / raw)
To: rafael, lenb, linux-acpi, linux-kernel; +Cc: Muhammad Qasim Abdul Majeed
Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
---
include/acpi/acpi_bus.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 1a4dfd7a1c4a..74ed1170fe66 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -226,11 +226,12 @@ struct acpi_device_dir {
#define acpi_device_dir(d) ((d)->dir.entry)
/* Plug and Play */
-
+#define MAX_ACPI_DEVICE_NAME_LEN 40
+#define MAX_ACPI_CLASS_NAME_LEN 20
typedef char acpi_bus_id[8];
typedef u64 acpi_bus_address;
-typedef char acpi_device_name[40];
-typedef char acpi_device_class[20];
+typedef char acpi_device_name[MAX_ACPI_DEVICE_NAME_LEN];
+typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
struct acpi_hardware_id {
struct list_head list;
--
2.34.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy().
2024-08-04 12:33 [PATCH v2 1/6] ACPI: ac: Use strscpy() instead of strcpy() Muhammad Qasim Abdul Majeed
` (4 preceding siblings ...)
2024-08-04 12:33 ` [PATCH v2 6/6] ACPI: bus: Define and use a macro for device and class name length Muhammad Qasim Abdul Majeed
@ 2024-08-26 17:14 ` Rafael J. Wysocki
5 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2024-08-26 17:14 UTC (permalink / raw)
To: Muhammad Qasim Abdul Majeed; +Cc: rafael, lenb, linux-acpi, linux-kernel
On Sun, Aug 4, 2024 at 2:34 PM Muhammad Qasim Abdul Majeed
<qasim.majeed20@gmail.com> wrote:
>
> Replace strcpy() with strscpy() in the ACPI ac driver.
> strcpy() has been deprecated because it is generally unsafe, so help to
> eliminate it from the kernel source.
>
> Link: https://github.com/KSPP/linux/issues/88
>
> Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com>
> ---
> drivers/acpi/ac.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
> index 09a87fa222c7..ad1427a384e4 100644
> --- a/drivers/acpi/ac.c
> +++ b/drivers/acpi/ac.c
> @@ -213,8 +213,8 @@ static int acpi_ac_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> ac->device = adev;
> - strcpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME);
> - strcpy(acpi_device_class(adev), ACPI_AC_CLASS);
> + strscpy(acpi_device_name(adev), ACPI_AC_DEVICE_NAME);
> + strscpy(acpi_device_class(adev), ACPI_AC_CLASS);
>
> platform_set_drvdata(pdev, ac);
>
> --
Applied as 6.12 material with some subject and changelog edits along
with patches [2-4/6] and [6/6].
Patch [6/6] needs more work (I'll send a reply to it directly).
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread