diff mbox series

btrfs: Annotate struct name_cache_entry with __counted_by()

Message ID 20240813105314.58484-2-thorsten.blum@toblux.com (mailing list archive)
State Mainlined
Commit c0247d289e73e18f6ddb0895de30c09770fbed95
Headers show
Series btrfs: Annotate struct name_cache_entry with __counted_by() | expand

Commit Message

Thorsten Blum Aug. 13, 2024, 10:53 a.m. UTC
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(-)

Comments

David Sterba Aug. 13, 2024, 12:57 p.m. UTC | #1
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>
diff mbox series

Patch

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. */