From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: Thorsten Blum <thorsten.blum@linux.dev>,
David Rhodes <david.rhodes@cirrus.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-sound@vger.kernel.org, patches@opensource.cirrus.com,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] ASoC: cs-amp-lib: Annotate struct cirrus_amp_efi_data with __counted_by()
Date: Tue, 15 Apr 2025 10:24:49 +0100 [thread overview]
Message-ID: <e16b42f3-cc78-49fd-9850-d59a59b5b8e8@opensource.cirrus.com> (raw)
In-Reply-To: <20250415090354.92211-2-thorsten.blum@linux.dev>
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@linux.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@opensource.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.)
next prev parent reply other threads:[~2025-04-15 9:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 9:03 Thorsten Blum
2025-04-15 9:24 ` Richard Fitzgerald [this message]
2025-04-15 10:56 ` Mark Brown
2025-04-15 11:51 ` Thorsten Blum
2025-04-15 12:03 ` Richard Fitzgerald
2025-04-15 12:07 ` Takashi Iwai
2025-04-15 14:36 ` Mark Brown
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=e16b42f3-cc78-49fd-9850-d59a59b5b8e8@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=david.rhodes@cirrus.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=thorsten.blum@linux.dev \
--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
all inboxes | Powered by JetHome®