[PATCH] btrfs: Annotate struct name_cache_entry with __counted_by()

Thorsten Blum posted 1 patch 1 year, 5 months ago
fs/btrfs/send.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] btrfs: Annotate struct name_cache_entry with __counted_by()
Posted by Thorsten Blum 1 year, 5 months ago
Add the __counted_by compiler attribute to the flexible array member
name to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/btrfs/send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 4ca711a773ef..de185b23cfd0 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -347,7 +347,7 @@ struct name_cache_entry {
 	int ret;
 	int need_later_update;
 	int name_len;
-	char name[];
+	char name[] __counted_by(name_len);
 };
 
 /* See the comment at lru_cache.h about struct btrfs_lru_cache_entry. */
-- 
2.46.0
Re: [PATCH] btrfs: Annotate struct name_cache_entry with __counted_by()
Posted by David Sterba 1 year, 5 months ago
On Tue, Aug 13, 2024 at 12:53:15PM +0200, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> name to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>

Thanks,

Reviewed-by: David Sterba <dsterba@suse.com>