From: Kees Cook <kees@kernel.org>
To: Thorsten Blum <thorsten.blum@toblux.com>
Cc: kent.overstreet@linux.dev, gustavoars@kernel.org,
linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] bcachefs: Annotate struct bucket_array with __counted_by()
Date: Thu, 22 Aug 2024 10:35:57 -0700 [thread overview]
Message-ID: <202408221035.5464B1E0@keescook> (raw)
In-Reply-To: <20240821162921.86767-2-thorsten.blum@toblux.com>
On Wed, Aug 21, 2024 at 06:29:22PM +0200, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> bucket to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
> fs/bcachefs/buckets_types.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/buckets_types.h b/fs/bcachefs/buckets_types.h
> index c9698cdf866f..a19460a1bb7c 100644
> --- a/fs/bcachefs/buckets_types.h
> +++ b/fs/bcachefs/buckets_types.h
> @@ -24,7 +24,7 @@ struct bucket_array {
> u16 first_bucket;
> size_t nbuckets;
> size_t nbuckets_minus_first;
> - struct bucket b[];
> + struct bucket b[] __counted_by(nbuckets);
> };
>
> struct bucket_gens {
I only see this being allocated in one place and nbuckets is immediately
assigned to the count of "b" elements, so this looks correct to me.
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
prev parent reply other threads:[~2024-08-22 17:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 16:29 [PATCH] bcachefs: Annotate struct bucket_array with __counted_by() Thorsten Blum
2024-08-22 17:35 ` Kees Cook [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=202408221035.5464B1E0@keescook \
--to=kees@kernel.org \
--cc=gustavoars@kernel.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thorsten.blum@toblux.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