From: Mark Greer <mgreer@animalcreek.com>
To: Alex Elder <elder@ieee.org>
Cc: Erick Archer <erick.archer@gmx.com>,
Vaibhav Agarwal <vaibhav.sr@gmail.com>,
Mark Greer <mgreer@animalcreek.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Kees Cook <keescook@chromium.org>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] greybus: audio: apbridgea: Remove flexible array from struct audio_apbridgea_hdr
Date: Tue, 27 Feb 2024 08:25:11 -0700 [thread overview]
Message-ID: <Zd3+1xJnl7d22xIb@animalcreek.com> (raw)
In-Reply-To: <02cf87a3-4e92-4f6d-98f6-dfc0e198d462@ieee.org>
On Sat, Feb 17, 2024 at 03:18:59PM -0600, Alex Elder wrote:
> On 2/17/24 9:47 AM, Erick Archer wrote:
> > When a struct containing a flexible array is included in another struct,
> > and there is a member after the struct-with-flex-array, there is a
> > possibility of memory overlap. These cases must be audited [1]. See:
> >
> > struct inner {
> > ...
> > int flex[];
> > };
> >
> > struct outer {
> > ...
> > struct inner header;
> > int overlap;
> > ...
> > };
> >
> > This is the scenario for the "struct audio_apbridgea_hdr" structure
> > that is included in the following "struct audio_apbridgea_*_request"
> > structures:
>
> Yeah this was not a very good way to define these header
> structures, but I'm glad to hear the flexible array at the
> end was never used. I don't know why it was there; maybe
> it's an artifact from some other information that got removed.
>
> If the code compiles with your change, it ought to be fine.
> (It compiles for me.)
>
> It would be good for Vaibhav or Mark to comment though, maybe
> they can provide some context.
Sorry for the delay guys.
The way this was done comes from associated firmware that ran on the
APBridge. This goes back a while but I think the packet headers may have
been in flux at the time and this was a convenient way to change all of
the packets if & when it changed. Anyway, it doesn't seem so convenient
now. :)
So, yeah, getting rid of it sounds like a good thing to do to me.
> I'd like to hear from these others, but otherwise this change
> looks good to me.
>
> Reviewed-by: Alex Elder <elder@linaro.org>
> > diff --git a/drivers/staging/greybus/audio_apbridgea.h b/drivers/staging/greybus/audio_apbridgea.h
> > index efec0f815efd..ab707d310129 100644
> > --- a/drivers/staging/greybus/audio_apbridgea.h
> > +++ b/drivers/staging/greybus/audio_apbridgea.h
> > @@ -65,7 +65,6 @@
> > struct audio_apbridgea_hdr {
> > __u8 type;
> > __le16 i2s_port;
> > - __u8 data[];
> > } __packed;
> >
> > struct audio_apbridgea_set_config_request {
> > --
> > 2.25.1
Acked-by: Mark Greer <mgreer@animalcreek.com>
prev parent reply other threads:[~2024-02-27 15:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-17 15:47 [PATCH] greybus: audio: apbridgea: Remove flexible array from struct audio_apbridgea_hdr Erick Archer
2024-02-17 21:18 ` Alex Elder
2024-02-27 15:25 ` Mark Greer [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=Zd3+1xJnl7d22xIb@animalcreek.com \
--to=mgreer@animalcreek.com \
--cc=elder@ieee.org \
--cc=elder@kernel.org \
--cc=erick.archer@gmx.com \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=gustavoars@kernel.org \
--cc=johan@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=vaibhav.sr@gmail.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