[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <75ab6118-6ddd-5ef6-0a12-1d2fd0253f68@linux.intel.com>
Date: Thu, 17 Feb 2022 10:57:10 -0600
From: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Stephen Kitt <steve@....org>
Cc: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Liam Girdwood <lgirdwood@...il.com>,
Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>,
Kai Vehmanen <kai.vehmanen@...ux.intel.com>,
Daniel Baluta <daniel.baluta@....com>,
alsa-devel@...a-project.org, linux-kernel@...r.kernel.org,
sound-open-firmware@...a-project.org,
linux-hardening@...r.kernel.org, Mark Brown <broonie@...nel.org>
Subject: Re: [PATCH] ASoC: SOF: Replace zero-length array with flexible-array
member
On 2/17/22 10:44, Gustavo A. R. Silva wrote:
> 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@...nel.org>
>> Signed-off-by: Stephen Kitt <steve@....org>
>
> Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Thanks for the patch
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
I just realized we have additional cases in this directory (interface
between kernel and firmware), I'll send a follow-up patch a
channel_map.h: int32_t ch_coeffs[0];
channel_map.h: struct sof_ipc_channel_map ch_map[0];
control.h: struct sof_ipc_ctrl_value_chan chanv[0];
control.h: struct sof_ipc_ctrl_value_comp compv[0];
control.h: struct sof_abi_hdr data[0];
control.h: struct sof_abi_hdr data[0];
>
> 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
>>
Powered by blists - more mailing lists