mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] btrfs: Annotate structs with __counted_by()
@ 2024-08-12 10:36 Thorsten Blum
  2024-08-12 10:54 ` Johannes Thumshirn
  2024-08-12 11:31 ` David Sterba
  0 siblings, 2 replies; 7+ messages in thread
From: Thorsten Blum @ 2024-08-12 10:36 UTC (permalink / raw)
  To: clm, josef, dsterba, kees, gustavoars
  Cc: linux-btrfs, linux-kernel, linux-hardening, Thorsten Blum

Add the __counted_by compiler attribute to the flexible array member
stripes to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/btrfs/volumes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 37a09ebb34dd..f28fa318036b 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -551,7 +551,7 @@ struct btrfs_io_context {
 	 * stripes[data_stripes + 1]:	The Q stripe (only for RAID6).
 	 */
 	u64 full_stripe_logical;
-	struct btrfs_io_stripe stripes[];
+	struct btrfs_io_stripe stripes[] __counted_by(num_stripes);
 };
 
 struct btrfs_device_info {
@@ -591,7 +591,7 @@ struct btrfs_chunk_map {
 	int io_width;
 	int num_stripes;
 	int sub_stripes;
-	struct btrfs_io_stripe stripes[];
+	struct btrfs_io_stripe stripes[] __counted_by(num_stripes);
 };
 
 #define btrfs_chunk_map_size(n) (sizeof(struct btrfs_chunk_map) + \
-- 
2.46.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-14 19:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-12 10:36 [PATCH] btrfs: Annotate structs with __counted_by() Thorsten Blum
2024-08-12 10:54 ` Johannes Thumshirn
2024-08-12 12:03   ` Thorsten Blum
2024-08-14 18:02     ` Nathan Chancellor
2024-08-14 19:01       ` Thorsten Blum
2024-08-14 19:26         ` David Sterba
2024-08-12 11:31 ` David Sterba

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®