[PATCH] ovl: Annotate struct ovl_entry with __counted_by()

Thorsten Blum posted 1 patch 9 months, 2 weeks ago
fs/overlayfs/ovl_entry.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ovl: Annotate struct ovl_entry with __counted_by()
Posted by Thorsten Blum 9 months, 2 weeks ago
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>
---
 fs/overlayfs/ovl_entry.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index cb449ab310a7..afb7762f873f 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -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 */
-- 
2.49.0
Re: [PATCH] ovl: Annotate struct ovl_entry with __counted_by()
Posted by Miklos Szeredi 9 months, 1 week ago
On Sat, 3 May 2025 at 15:26, Thorsten Blum <thorsten.blum@linux.dev> wrote:
>
> 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>

Applied, thanks.

Miklos