public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Paulo Miguel Almeida" <paulo.miguel.almeida.rodenas@gmail.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Grigory Vasilyev" <h0tc0d3@gmail.com>,
	"Claudio Suarez" <cssk@net-c.es>,
	"Slark Xiao" <slark_xiao@163.com>,
	"Rongguang Wei" <weirongguang@kylinos.cn>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] [next] drm/amdgpu: Replace one-element array with flexible-array member
Date: Fri, 28 Oct 2022 09:18:39 +0200	[thread overview]
Message-ID: <04e37ee1-53b0-97ab-d6d7-a39edfbdc2ea@amd.com> (raw)
In-Reply-To: <Y1tkWdwPUp+UdpM0@mail.google.com>

Am 28.10.22 um 07:10 schrieb Paulo Miguel Almeida:
> One-element arrays are deprecated, and we are replacing them with
> flexible array members instead. So, replace one-element array with
> flexible-array member in struct _ATOM_FAKE_EDID_PATCH_RECORD and
> refactor the rest of the code accordingly.
>
> This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
> routines on memcpy() and help us make progress towards globally
> enabling -fstrict-flex-arrays=3 [1].
>
> Link: https://github.com/KSPP/linux/issues/79
> Link: https://github.com/KSPP/linux/issues/238
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1]

I'm not sure if that's a good idea. We had multiple attempts to refactor 
this now and it always caused a regression.

Additional to that the header in question came from our BIOS team and 
isn't following Linux styles in general.

Alex what do you think?

Regards,
Christian.

>
> Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 10 +++++++---
>   drivers/gpu/drm/amd/include/atombios.h         |  2 +-
>   2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
> index 6be9ac2b9c5b..6b5abf1249db 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
> @@ -2079,10 +2079,14 @@ amdgpu_atombios_encoder_get_lcd_info(struct amdgpu_encoder *encoder)
>   							} else
>   								kfree(edid);
>   						}
> +
> +						record += struct_size(fake_edid_record,
> +								      ucFakeEDIDString,
> +								      fake_edid_record->ucFakeEDIDLength);
> +					} else {
> +						/* empty fake edid record must be 3 bytes long */
> +						record += sizeof(ATOM_FAKE_EDID_PATCH_RECORD) + 1;
>   					}
> -					record += fake_edid_record->ucFakeEDIDLength ?
> -						fake_edid_record->ucFakeEDIDLength + 2 :
> -						sizeof(ATOM_FAKE_EDID_PATCH_RECORD);
>   					break;
>   				case LCD_PANEL_RESOLUTION_RECORD_TYPE:
>   					panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record;
> diff --git a/drivers/gpu/drm/amd/include/atombios.h b/drivers/gpu/drm/amd/include/atombios.h
> index 15943bc21bc5..b5b1d073f8e2 100644
> --- a/drivers/gpu/drm/amd/include/atombios.h
> +++ b/drivers/gpu/drm/amd/include/atombios.h
> @@ -4107,7 +4107,7 @@ typedef struct _ATOM_FAKE_EDID_PATCH_RECORD
>   {
>     UCHAR ucRecordType;
>     UCHAR ucFakeEDIDLength;       // = 128 means EDID length is 128 bytes, otherwise the EDID length = ucFakeEDIDLength*128
> -  UCHAR ucFakeEDIDString[1];    // This actually has ucFakeEdidLength elements.
> +  UCHAR ucFakeEDIDString[];     // This actually has ucFakeEdidLength elements.
>   } ATOM_FAKE_EDID_PATCH_RECORD;
>   
>   typedef struct  _ATOM_PANEL_RESOLUTION_PATCH_RECORD


  reply	other threads:[~2022-10-28  7:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28  5:10 [PATCH] [next] drm/amdgpu: Replace one-element array with flexible-array member Paulo Miguel Almeida
2022-10-28  7:18 ` Christian König [this message]
2022-10-28 16:36   ` Kees Cook
2022-10-28 17:33     ` Christian König
2022-10-29  0:43       ` Paulo Miguel Almeida
2022-10-29  1:30         ` [PATCH v2] " Paulo Miguel Almeida
2022-11-02 16:12           ` Alex Deucher

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=04e37ee1-53b0-97ab-d6d7-a39edfbdc2ea@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=cssk@net-c.es \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=h0tc0d3@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=slark_xiao@163.com \
    --cc=weirongguang@kylinos.cn \
    /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