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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 29 Jan 2024 14:54:43 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Mario Limonciello <mario.limonciello@....com>
Cc: amd-gfx@...ts.freedesktop.org, Alex Deucher <alexander.deucher@....com>, 
	Harry Wentland <harry.wentland@....com>, "Rafael J . Wysocki" <rafael@...nel.org>, 
	Hans de Goede <hdegoede@...hat.com>, "open list:ACPI" <linux-acpi@...r.kernel.org>, 
	open list <linux-kernel@...r.kernel.org>, 
	"open list:DRM DRIVERS" <dri-devel@...ts.freedesktop.org>, Melissa Wen <mwen@...lia.com>, 
	Mark Pearson <mpearson-lenovo@...ebb.ca>
Subject: Re: [PATCH 1/2] ACPI: video: Handle fetching EDID that is longer than
 256 bytes

On Fri, Jan 26, 2024 at 7:55 PM Mario Limonciello
<mario.limonciello@....com> wrote:
>
> The ACPI specification allows for an EDID to be up to 512 bytes but
> the _DDC EDID fetching code will only try up to 256 bytes.
>
> Modify the code to instead start at 512 bytes and work it's way
> down instead.
>
> Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/Apx_B_Video_Extensions/output-device-specific-methods.html#ddc-return-the-edid-for-this-device
> Signed-off-by: Mario Limonciello <mario.limonciello@....com>
> ---
>  drivers/acpi/acpi_video.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 62f4364e4460..b3b15dd4755d 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -624,6 +624,10 @@ acpi_video_device_EDID(struct acpi_video_device *device,
>                 arg0.integer.value = 1;
>         else if (length == 256)
>                 arg0.integer.value = 2;
> +       else if (length == 384)
> +               arg0.integer.value = 3;
> +       else if (length == 512)
> +               arg0.integer.value = 4;

It looks like switch () would be somewhat better.

Or maybe even

arg0.integer.value = length / 128;

The validation could be added too:

if (arg0.integer.value > 4 || arg0.integer.value * 128 != length)
        return -EINVAL;

but it is pointless, because the caller is never passing an invalid
number to it AFAICS.

>         else
>                 return -EINVAL;
>
> @@ -1443,7 +1447,7 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
>
>         for (i = 0; i < video->attached_count; i++) {
>                 video_device = video->attached_array[i].bind_info;
> -               length = 256;
> +               length = 512;
>
>                 if (!video_device)
>                         continue;
> @@ -1478,13 +1482,18 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
>
>                 if (ACPI_FAILURE(status) || !buffer ||
>                     buffer->type != ACPI_TYPE_BUFFER) {
> -                       length = 128;
> -                       status = acpi_video_device_EDID(video_device, &buffer,
> -                                                       length);
> -                       if (ACPI_FAILURE(status) || !buffer ||
> -                           buffer->type != ACPI_TYPE_BUFFER) {
> -                               continue;
> +                       while (length) {

I would prefer a do {} while () loop here, which could include the
first invocation of acpi_video_device_EDID() too (and reduce code
duplication a bit).

> +                               length -= 128;
> +                               status = acpi_video_device_EDID(video_device, &buffer,
> +                                                               length);

No line break, please.

> +                               if (ACPI_FAILURE(status) || !buffer ||
> +                                   buffer->type != ACPI_TYPE_BUFFER) {
> +                                       continue;
> +                               }
> +                               break;
>                         }
> +                       if (!length)
> +                               continue;
>                 }
>
>                 *edid = buffer->buffer.pointer;
> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ