From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Alex Deucher" <alexdeucher@gmail.com>,
"Ricardo Cañuelo" <ricardo.canuelo@collabora.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Paulo Miguel Almeida" <paulo.miguel.almeida.rodenas@gmail.com>
Cc: alexander.deucher@amd.com, kernel@collabora.com,
linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu: replace 1-element arrays with flexible arrays
Date: Fri, 14 Jul 2023 12:13:28 -0600 [thread overview]
Message-ID: <442403e3-317e-8744-3348-dc9823c22074@embeddedor.com> (raw)
In-Reply-To: <CADnq5_OUS=JDfCdrCsuzTB0xD5yeX7piEDEqkRO-ffPTFVYs3g@mail.gmail.com>
On 7/12/23 08:12, Alex Deucher wrote:
> On Wed, Jul 12, 2023 at 8:04 AM Ricardo Cañuelo
> <ricardo.canuelo@collabora.com> wrote:
>>
>> UBSAN complains about out-of-bounds array indexes on all 1-element
>> arrays defined on this driver:
>>
>> UBSAN: array-index-out-of-bounds in /home/rcn/work/repos/kernelci/kernelci-core/linux_kernel_mainline/drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/processpptables.c:1249:61
>>
>> Substitute them with proper flexible arrays.
>
> + Gustavo, Paulo
>
> I haven't kept up with the flexible arrays stuff. Is this equivalent
> to a zero sized array? We've been bitten by these kind of changes in
In terms of size, yes: the size of each array declaration does not
contribute to the overall size of its containing structure.
However, in these cases, using the DECLARE_FLEX_ARRAY() helper is not
required. Simply removing the '1' from the array declaration will suffice.
This helper was created to declare flex-array members in unions, as well
as in structs that contain no other members aside from the array.
In any case, these changes are not complete, as they're only modifying
the struct declaration, hence the size of the struct is affected. Now
the rest of the code where these structs are involved should be audited
and adjusted to accommodate the change in the sizes of the structs.
> the past. These structures define the layout of data in a rom image
> on the board. If the struct size changes, that could lead to errors
> in the code that deals with these structures.
>
> Alex
>
Thanks
--
Gustavo
prev parent reply other threads:[~2023-07-14 18:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 8:31 [PATCH] drm/amdgpu: replace 1-element arrays with flexible arrays Ricardo Cañuelo
2023-07-12 14:12 ` Alex Deucher
2023-07-14 10:40 ` Paulo Miguel Almeida
2023-07-14 12:20 ` Ricardo Cañuelo
2023-07-14 18:13 ` Gustavo A. R. Silva [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=442403e3-317e-8744-3348-dc9823c22074@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=alexander.deucher@amd.com \
--cc=alexdeucher@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=gustavoars@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulo.miguel.almeida.rodenas@gmail.com \
--cc=ricardo.canuelo@collabora.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