ovl: Annotate struct ovl_entry with __counted_by()
authorThorsten Blum <thorsten.blum@linux.dev>
Sat, 3 May 2025 13:25:36 +0000 (15:25 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 5 May 2025 10:49:20 +0000 (12:49 +0200)
Add the __counted_by() compiler attribute to the flexible array member
'__lowerstack' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS
and CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/ovl_entry.h

index cb449ab310a7a89aafa0ee04ee7ff6c8141dd7d5..afb7762f873f66c72cc5aa795a51ab22c15106dc 100644 (file)
@@ -51,7 +51,7 @@ struct ovl_path {
 
 struct ovl_entry {
        unsigned int __numlower;
-       struct ovl_path __lowerstack[];
+       struct ovl_path __lowerstack[] __counted_by(__numlower);
 };
 
 /* private information held for overlayfs's superblock */