Updating a vulnerable use of strcpy.
PATCH v2 1/1 Updating a vulnerable use of strcpy.
Replacing strcpy with strscpy and memory bound the copy.
Signed-off-by Muhammad Qasim Abdul Majeed <[email protected]>
--- drivers/acpi/acpi_video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/acpi/acpi_video.c +4 -4
@@ -1128,8 +1128,8 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)return -ENOMEM ; } -strcpy (acpi_device_name (device),ACPI_VIDEO_DEVICE_NAME ); -strcpy (acpi_device_class (device),ACPI_VIDEO_CLASS ); +strscpy (acpi_device_name (device),ACPI_VIDEO_DEVICE_NAME ,strlen (ACPI_VIDEO_DEVICE_NAME )); +strscpy (acpi_device_class (device),ACPI_VIDEO_CLASS ,strlen (ACPI_VIDEO_CLASS )); data->device_id = device_id; data->video = video;
@@ -2010,8 +2010,8 @@ static int acpi_video_bus_add(struct acpi_device *device) } video->device = device; -strcpy (acpi_device_name (device),ACPI_VIDEO_BUS_NAME ); -strcpy (acpi_device_class (device),ACPI_VIDEO_CLASS ); +strscpy (acpi_device_name (device),ACPI_VIDEO_BUS_NAME ,strlen (ACPI_VIDEO_BUS_NAME )); +strscpy (acpi_device_class (device),ACPI_VIDEO_CLASS ,strlen (ACPI_VIDEO_CLASS )); device->driver_data = video;acpi_video_bus_find_cap (video);
Signature · 1 line
2.34.1
Rafael J. Wysocki
maintainerIn what way exactly is it vulnerable?
Both ACPI_VIDEO_DEVICE_NAME and ACPI_VIDEO_CLASS are kernel symbols.
Quoted 13 lines · Muhammad Qasim Abdul Majeed
Replacing strcpy with strscpy and memory bound the copy.
Signed-off-by Muhammad Qasim Abdul Majeed <[email protected]>--- drivers/acpi/acpi_video.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/acpi/acpi_video.c +0
-0
drivers/acpi/acpi_video.c static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg) · line 1132
Quoted 7 lines
drivers/acpi/acpi_video.c +2
-2@@ -1128,8 +1128,8 @@ static int acpi_video_bus_get_one_device(struct acpi_device *device, void *arg)return -ENOMEM ; } -strcpy (acpi_device_name (device),ACPI_VIDEO_DEVICE_NAME ); -strcpy (acpi_device_class (device),ACPI_VIDEO_CLASS ); +strscpy (acpi_device_name (device),ACPI_VIDEO_DEVICE_NAME ,strlen (ACPI_VIDEO_DEVICE_NAME )); +strscpy (acpi_device_class (device),ACPI_VIDEO_CLASS ,strlen (ACPI_VIDEO_CLASS ));
Why is a runtime check needed here if all of the sizes in question are known at compile time?
Quoted 15 lines
drivers/acpi/acpi_video.c +2
-3data->device_id = device_id; data->video = video;@@ -2010,8 +2010,8 @@ static int acpi_video_bus_add(struct acpi_device *device) } video->device = device; -strcpy (acpi_device_name (device),ACPI_VIDEO_BUS_NAME ); -strcpy (acpi_device_class (device),ACPI_VIDEO_CLASS ); +strscpy (acpi_device_name (device),ACPI_VIDEO_BUS_NAME ,strlen (ACPI_VIDEO_BUS_NAME )); +strscpy (acpi_device_class (device),ACPI_VIDEO_CLASS ,strlen (ACPI_VIDEO_CLASS )); device->driver_data = video;acpi_video_bus_find_cap (video); --