From: Bill Wendling Date: Fri, 24 Apr 2026 14:13:03 +0000 (+0200) Subject: xfs: annotate struct xfs_attr_list_context with __counted_by_ptr X-Git-Tag: v7.0.0~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df91bc3bdc9b814006cb0247aba1e5a6bfd43341;p=xfsprogs-dev.git xfs: annotate struct xfs_attr_list_context with __counted_by_ptr Source kernel commit: e5966096d0856d071269cb5928d6bc33342d2dfd Add the `__counted_by_ptr` attribute to the `buffer` field of `struct xfs_attr_list_context`. This field is used to point to a buffer of size `bufsize`. The `buffer` field is assigned in: 1. `xfs_ioc_attr_list` in `fs/xfs/xfs_handle.c` 2. `xfs_xattr_list` in `fs/xfs/xfs_xattr.c` 3. `xfs_getparents` in `fs/xfs/xfs_handle.c` (implicitly initialized to NULL) In `xfs_ioc_attr_list`, `buffer` was assigned before `bufsize`. Reorder them to ensure `bufsize` is set before `buffer` is assigned, although no access happens between them. In `xfs_xattr_list`, `buffer` was assigned before `bufsize`. Reorder them to ensure `bufsize` is set before `buffer` is assigned. In `xfs_getparents`, `buffer` is NULL (from zero initialization) and remains NULL. `bufsize` is set to a non-zero value, but since `buffer` is NULL, no access occurs. In all cases, the pointer `buffer` is not accessed before `bufsize` is set. This patch was generated by CodeMender and reviewed by Bill Wendling. Tested by running xfstests. Signed-off-by: Bill Wendling Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Carlos Maiolino Signed-off-by: Andrey Albershteyn --- diff --git a/include/platform_defs.h b/include/platform_defs.h index b2d80597..5a829db6 100644 --- a/include/platform_defs.h +++ b/include/platform_defs.h @@ -330,4 +330,7 @@ struct kvec { #define BLK_ZONE_COND_ACTIVE 0xff #endif +/* xfs_attr.h */ +#define __counted_by_ptr(member) + #endif /* __XFS_PLATFORM_DEFS_H__ */ diff --git a/libxfs/xfs_attr.h b/libxfs/xfs_attr.h index 82443059..67fd9c75 100644 --- a/libxfs/xfs_attr.h +++ b/libxfs/xfs_attr.h @@ -55,7 +55,8 @@ struct xfs_attr_list_context { struct xfs_trans *tp; struct xfs_inode *dp; /* inode */ struct xfs_attrlist_cursor_kern cursor; /* position in list */ - void *buffer; /* output buffer */ + /* output buffer */ + void *buffer __counted_by_ptr(bufsize); /* * Abort attribute list iteration if non-zero. Can be used to pass