summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorBill Wendling <morbo@google.com>2026-09-23 06:01:14 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2026-10-02 18:12:43 +1000
commit973eb89550d347aa4bc4e58452cf7a0d13fde29e (patch)
treed6e9ea1c90936cb59f17902ca4e3e1a0c33af8bf /include/linux
parent780cd10c8e78f97ed768be229acff0ffd5483477 (diff)
downloadlinux-next-973eb89550d347aa4bc4e58452cf7a0d13fde29e.tar.gz
linux-next-973eb89550d347aa4bc4e58452cf7a0d13fde29e.zip
crypto: hisilicon/qm - annotate cap_tables with __counted_by_ptr
Annotate the 'qm_cap_table' and 'dev_cap_table' pointer fields in 'struct hisi_qm_cap_tables' with the '__counted_by_ptr' attribute. This improves bounds checking via CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE, allowing KASAN and compiler diagnostics to detect out-of-bounds accesses. The 'qm_cap_table' pointer is associated with 'qm_cap_size' which specifies its element count. Similarly, 'dev_cap_table' is associated with 'dev_cap_size'. To ensure safety under compiler instrumentation, the assignments in the initialization paths have been updated to set the 'size'/'count' fields prior to setting the pointer fields. This prevents any transient state where the pointer is valid but the count is 0 (or uninitialized), ensuring that subsequent accesses to these tables do not trigger false-positive bounds check panics. Cc: codemender-patching+linux@google.com Assisted-by: LLM Signed-off-by: Bill Wendling <morbo@google.com> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Longfang Liu <liulongfang@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hisi_acc_qm.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h
index f7570a409905..8dc49fa2123b 100644
--- a/include/linux/hisi_acc_qm.h
+++ b/include/linux/hisi_acc_qm.h
@@ -332,9 +332,9 @@ struct hisi_qm_cap_record {
struct hisi_qm_cap_tables {
u32 qm_cap_size;
- struct hisi_qm_cap_record *qm_cap_table;
+ struct hisi_qm_cap_record *qm_cap_table __counted_by_ptr(qm_cap_size);
u32 dev_cap_size;
- struct hisi_qm_cap_record *dev_cap_table;
+ struct hisi_qm_cap_record *dev_cap_table __counted_by_ptr(dev_cap_size);
};
struct hisi_qm_list {