]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfs: Annotate struct pnfs_commit_array with __counted_by()
authorThorsten Blum <thorsten.blum@linux.dev>
Tue, 15 Oct 2024 20:27:31 +0000 (22:27 +0200)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Fri, 8 Nov 2024 19:26:20 +0000 (14:26 -0500)
Add the __counted_by compiler attribute to the flexible array member
buckets to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
include/linux/nfs_xdr.h

index 12d8e47bc5a38863b2831fb16056f742fa81612e..559273a0f16d81ef93b66c088cc0c5f86ab3109c 100644 (file)
@@ -1336,7 +1336,7 @@ struct pnfs_commit_array {
        struct rcu_head rcu;
        refcount_t refcount;
        unsigned int nbuckets;
-       struct pnfs_commit_bucket buckets[];
+       struct pnfs_commit_bucket buckets[] __counted_by(nbuckets);
 };
 
 struct pnfs_ds_commit_info {