[PATCH RESEND] fs/xattr: Annotate struct simple_xattr with __counted_by

Thorsten Blum posted 1 patch 1 month ago
include/linux/xattr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH RESEND] fs/xattr: Annotate struct simple_xattr with __counted_by
Posted by Thorsten Blum 1 month ago
Add the __counted_by() compiler attribute to the flexible array member
'value' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 include/linux/xattr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 64e9afe7d647..296b5ee5c979 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -114,7 +114,7 @@ struct simple_xattr {
 	struct rb_node rb_node;
 	char *name;
 	size_t size;
-	char value[];
+	char value[] __counted_by(size);
 };
 
 void simple_xattrs_init(struct simple_xattrs *xattrs);
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Re: [PATCH RESEND] fs/xattr: Annotate struct simple_xattr with __counted_by
Posted by Kees Cook 3 weeks, 4 days ago
On Mon, 05 Jan 2026 13:20:53 +0100, Thorsten Blum wrote:
> Add the __counted_by() compiler attribute to the flexible array member
> 'value' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
> 
> 

Applied to for-next/hardening, thanks!

[1/1] fs/xattr: Annotate struct simple_xattr with __counted_by
      https://git.kernel.org/kees/c/f2c5457dadec

Take care,

-- 
Kees Cook