summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorThorsten Blum <thorsten.blum@linux.dev>2024-10-18 14:14:21 +0200
committerChristian Brauner <brauner@kernel.org>2024-10-22 11:16:59 +0200
commit8c6e03ffedc5463d1aa1ba89f6ceb082518a3520 (patch)
tree0ca5dd6c019d96f55cfd7ff9ec1cc0369f1c5460 /include/linux
parent99bdadbde9c418f29b78b7241732268dbc0a05cc (diff)
acl: Annotate struct posix_acl with __counted_by()
Add the __counted_by compiler attribute to the flexible array member a_entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE. Use struct_size() to calculate the number of bytes to allocate for new and cloned acls and remove the local size variables. Change the posix_acl_alloc() function parameter count from int to unsigned int to match posix_acl's a_count data type. Add identifier names to the function definition to silence two checkpatch warnings. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20241018121426.155247-2-thorsten.blum@linux.dev Cc: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/posix_acl.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 2d6a4badd306..e2d47eb1a7f3 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -30,7 +30,7 @@ struct posix_acl {
refcount_t a_refcount;
unsigned int a_count;
struct rcu_head a_rcu;
- struct posix_acl_entry a_entries[];
+ struct posix_acl_entry a_entries[] __counted_by(a_count);
};
#define FOREACH_ACL_ENTRY(pa, acl, pe) \
@@ -62,7 +62,7 @@ posix_acl_release(struct posix_acl *acl)
/* posix_acl.c */
extern void posix_acl_init(struct posix_acl *, int);
-extern struct posix_acl *posix_acl_alloc(int, gfp_t);
+extern struct posix_acl *posix_acl_alloc(unsigned int count, gfp_t flags);
extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);