From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Stephen Kitt <steve@sk2.org>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
Kai Vehmanen <kai.vehmanen@linux.intel.com>,
Daniel Baluta <daniel.baluta@nxp.com>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
sound-open-firmware@alsa-project.org,
linux-hardening@vger.kernel.org, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] ASoC: SOF: Replace zero-length array with flexible-array member
Date: Thu, 17 Feb 2022 10:44:58 -0600 [thread overview]
Message-ID: <20220217164458.GA932472@embeddedor> (raw)
In-Reply-To: <20220217132755.1786130-1-steve@sk2.org>
On Thu, Feb 17, 2022 at 02:27:55PM +0100, Stephen Kitt wrote:
> There is a regular need in the kernel to provide a way to declare having
> a dynamically sized set of trailing elements in a structure. Kernel code
> should always use "flexible array members"[1] for these cases. The older
> style of one-element or zero-length arrays should no longer be used[2].
>
> This helps with the ongoing efforts to globally enable -Warray-bounds
> and get us closer to being able to tighten the FORTIFY_SOURCE routines
> on memcpy().
>
> [1] https://en.wikipedia.org/wiki/Flexible_array_member
> [2] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Link: https://github.com/KSPP/linux/issues/78
> Link: https://github.com/KSPP/linux/issues/180
> Suggested-by: Gustavo A. R. Silva <gustavoars@kernel.org>
> Signed-off-by: Stephen Kitt <steve@sk2.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks!
--
Gustavo
> ---
> include/sound/sof/topology.h | 2 +-
> sound/soc/sof/topology.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/sound/sof/topology.h b/include/sound/sof/topology.h
> index d12736e14b69..adee6afd1490 100644
> --- a/include/sound/sof/topology.h
> +++ b/include/sound/sof/topology.h
> @@ -237,7 +237,7 @@ struct sof_ipc_comp_process {
> /* reserved for future use */
> uint32_t reserved[7];
>
> - uint8_t data[0];
> + uint8_t data[];
> } __packed;
>
> /* frees components, buffers and pipelines
> diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
> index e72dcae5e7ee..1d119d1dd69d 100644
> --- a/sound/soc/sof/topology.c
> +++ b/sound/soc/sof/topology.c
> @@ -2164,7 +2164,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index,
> */
> if (ipc_data_size) {
> for (i = 0; i < widget->num_kcontrols; i++) {
> - memcpy(&process->data + offset,
> + memcpy(&process->data[offset],
> wdata[i].pdata->data,
> wdata[i].pdata->size);
> offset += wdata[i].pdata->size;
>
> base-commit: f71077a4d84bbe8c7b91b7db7c4ef815755ac5e3
> --
> 2.27.0
>
next parent reply other threads:[~2022-02-17 16:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220217132755.1786130-1-steve@sk2.org>
2022-02-17 16:44 ` Gustavo A. R. Silva [this message]
2022-02-17 16:57 ` [PATCH] ASoC: SOF: Replace zero-length array with flexible-array member Pierre-Louis Bossart
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=20220217164458.GA932472@embeddedor \
--to=gustavoars@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
--cc=steve@sk2.org \
--cc=tiwai@suse.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).