[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e16b42f3-cc78-49fd-9850-d59a59b5b8e8@opensource.cirrus.com>
Date: Tue, 15 Apr 2025 10:24:49 +0100
From: Richard Fitzgerald <rf@...nsource.cirrus.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>,
David Rhodes <david.rhodes@...rus.com>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>,
Kees Cook <kees@...nel.org>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc: linux-sound@...r.kernel.org, patches@...nsource.cirrus.com,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] ASoC: cs-amp-lib: Annotate struct cirrus_amp_efi_data
with __counted_by()
On 15/04/2025 10:03 am, Thorsten Blum wrote:
> Add the __counted_by() compiler attribute to the flexible array member
> 'data' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> No functional changes intended.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
> include/sound/cs-amp-lib.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/sound/cs-amp-lib.h b/include/sound/cs-amp-lib.h
> index f481148735e1..5459c221badf 100644
> --- a/include/sound/cs-amp-lib.h
> +++ b/include/sound/cs-amp-lib.h
> @@ -23,7 +23,7 @@ struct cirrus_amp_cal_data {
> struct cirrus_amp_efi_data {
> u32 size;
> u32 count;
> - struct cirrus_amp_cal_data data[];
> + struct cirrus_amp_cal_data data[] __counted_by(count);
> } __packed;
>
> /**
I wrote a patch to do exactly the same, but you got your patch out
first! It is identical to my patch so:
Reviewed-by: Richard Fitzgerald <rf@...nsource.cirrus.com>
(Note that I did some testing with Clang-19 and the __counted_by() seems
to only be checked in certain functions, like memcpy() and memset(). The
get_random_bytes() used in the KUnit test can overrun the array without
triggering any warning.)
Powered by blists - more mailing lists