amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Kent Russell <kent.russell@amd.com>
Cc: amd-gfx list <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/amdgpu: Fix FRU data checking
Date: Tue, 24 Mar 2020 11:34:24 -0400	[thread overview]
Message-ID: <CADnq5_PnQVcx-bzVkK-yWSJ_J4OR0TgpNZxL4B24jiPcg68vug@mail.gmail.com> (raw)
In-Reply-To: <20200324114937.23299-1-kent.russell@amd.com>

On Tue, Mar 24, 2020 at 7:49 AM Kent Russell <kent.russell@amd.com> wrote:
>
> Ensure that when we memcpy, we don't end up copying more data than
> the struct supports. For now, this is 16 characters for product number
> and serial number, and 32 chars for product name
>
> Signed-off-by: Kent Russell <kent.russell@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  .../gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c    | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
> index 6f5e98fda181..bfe4259f9508 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c
> @@ -116,6 +116,13 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
>                 return size;
>         }
>
> +       /* Product name should only be 32 characters. Any more,
> +        * and something could be wrong. Cap it at 32 to be safe
> +        */
> +       if (size > 32) {
> +               DRM_WARN("FRU Product Number is larger than 32 characters. This is likely a mistake");
> +               size = 32;
> +       }
>         /* Start at 2 due to buff using fields 0 and 1 for the address */
>         memcpy(adev->product_name, &buff[2], size);
>         adev->product_name[size] = '\0';
> @@ -127,6 +134,13 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
>                 return size;
>         }
>
> +       /* Product number should only be 16 characters. Any more,
> +        * and something could be wrong. Cap it at 16 to be safe
> +        */
> +       if (size > 16) {
> +               DRM_WARN("FRU Product Number is larger than 16 characters. This is likely a mistake");
> +               size = 16;
> +       }
>         memcpy(adev->product_number, &buff[2], size);
>         adev->product_number[size] = '\0';
>
> @@ -146,6 +160,13 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
>                 return size;
>         }
>
> +       /* Serial number should only be 16 characters. Any more,
> +        * and something could be wrong. Cap it at 16 to be safe
> +        */
> +       if (size > 16) {
> +               DRM_WARN("FRU Serial Number is larger than 16 characters. This is likely a mistake");
> +               size = 16;
> +       }
>         memcpy(adev->serial, &buff[2], size);
>         adev->serial[size] = '\0';
>
> --
> 2.17.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      reply	other threads:[~2020-03-24 15:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 11:49 [PATCH] drm/amdgpu: Fix FRU data checking Kent Russell
2020-03-24 15:34 ` Alex Deucher [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADnq5_PnQVcx-bzVkK-yWSJ_J4OR0TgpNZxL4B24jiPcg68vug@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=kent.russell@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).