* [PATCH] crypto: hisilicon/qm - add __counted_by_ptr to dfx_diff_registers
@ 2026-09-23 6:10 Bill Wendling
2026-09-23 6:12 ` Gustavo A. R. Silva
0 siblings, 1 reply; 2+ messages in thread
From: Bill Wendling @ 2026-09-23 6:10 UTC (permalink / raw)
To: Weili Qian, Zhou Wang
Cc: Kees Cook, Gustavo A. R. Silva, linux-crypto, linux-kernel,
linux-hardening, Bill Wendling, codemender-patching+linux
Annotate the pointer field 'regs' in 'struct dfx_diff_registers' with
the '__counted_by_ptr' attribute, referencing the 'reg_len' member
which holds the element count of the allocated memory.
In 'drivers/crypto/hisilicon/debugfs.c', the 'dfx_regs_init' function
allocates the 'diff_regs' array and initializes each element's 'regs'
pointer after setting its 'reg_len'.
Since 'reg_len' is set before 'regs' is assigned, the compiler's bounds
sanitizer can correctly associate the pointer with its allocated size.
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
---
include/linux/hisi_acc_qm.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h
index 8dc49fa2123b..f2885d60b468 100644
--- a/include/linux/hisi_acc_qm.h
+++ b/include/linux/hisi_acc_qm.h
@@ -196,7 +196,7 @@ struct qm_dev_dfx {
};
struct dfx_diff_registers {
- u32 *regs;
+ u32 *regs __counted_by_ptr(reg_len);
u32 reg_offset;
u32 reg_len;
};
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: hisilicon/qm - add __counted_by_ptr to dfx_diff_registers
2026-09-23 6:10 [PATCH] crypto: hisilicon/qm - add __counted_by_ptr to dfx_diff_registers Bill Wendling
@ 2026-09-23 6:12 ` Gustavo A. R. Silva
0 siblings, 0 replies; 2+ messages in thread
From: Gustavo A. R. Silva @ 2026-09-23 6:12 UTC (permalink / raw)
To: Bill Wendling, Weili Qian, Zhou Wang
Cc: Kees Cook, Gustavo A. R. Silva, linux-crypto, linux-kernel,
linux-hardening, codemender-patching+linux
On 9/23/26 15:10, Bill Wendling wrote:
> Annotate the pointer field 'regs' in 'struct dfx_diff_registers' with
> the '__counted_by_ptr' attribute, referencing the 'reg_len' member
> which holds the element count of the allocated memory.
>
> In 'drivers/crypto/hisilicon/debugfs.c', the 'dfx_regs_init' function
> allocates the 'diff_regs' array and initializes each element's 'regs'
> pointer after setting its 'reg_len'.
>
> Since 'reg_len' is set before 'regs' is assigned, the compiler's bounds
> sanitizer can correctly associate the pointer with its allocated size.
>
> 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>
Thanks
-Gustavo
> ---
> include/linux/hisi_acc_qm.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/hisi_acc_qm.h b/include/linux/hisi_acc_qm.h
> index 8dc49fa2123b..f2885d60b468 100644
> --- a/include/linux/hisi_acc_qm.h
> +++ b/include/linux/hisi_acc_qm.h
> @@ -196,7 +196,7 @@ struct qm_dev_dfx {
> };
>
> struct dfx_diff_registers {
> - u32 *regs;
> + u32 *regs __counted_by_ptr(reg_len);
> u32 reg_offset;
> u32 reg_len;
> };
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-23 6:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-23 6:10 [PATCH] crypto: hisilicon/qm - add __counted_by_ptr to dfx_diff_registers Bill Wendling
2026-09-23 6:12 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®