]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/xattr: Annotate struct simple_xattr with __counted_by
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 5 Jan 2026 12:20:53 +0000 (13:20 +0100)
committerKees Cook <kees@kernel.org>
Wed, 14 Jan 2026 22:43:18 +0000 (14:43 -0800)
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>
Link: https://patch.msgid.link/20260105122057.2347-2-thorsten.blum@linux.dev
Signed-off-by: Kees Cook <kees@kernel.org>
include/linux/xattr.h

index 64e9afe7d647dc38f686a4b5c6f765e061cde54c..296b5ee5c979ec58c85e5c2c21d62a602f46119a 100644 (file)
@@ -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);