* [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr
@ 2026-09-22 11:06 Bill Wendling
2026-09-23 5:42 ` Gustavo A. R. Silva
2026-09-23 7:28 ` Kees Cook
0 siblings, 2 replies; 3+ messages in thread
From: Bill Wendling @ 2026-09-22 11:06 UTC (permalink / raw)
To: Thierry Reding, Jonathan Hunter
Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Kees Cook,
Gustavo A. R. Silva, linux-clk, linux-tegra, linux-kernel,
linux-hardening, Bill Wendling, codemender-patching+linux
Annotate the "configs" pointer field of "struct
tegra210_clk_emc_provider" with the "__counted_by_ptr" attribute,
allowing the compiler to perform runtime bounds checking on accesses to
"configs" based on the value of "num_configs".
The "emc->provider.configs = devm_kcalloc(...)" call uses
"emc->num_timings" for the number of elements, which is then assigned to
"emc->provider.num_configs" before any accesses to "configs". The
"num_configs" field isn't modified after assignment.
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
---
include/linux/clk/tegra.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
index 3650e926e93f..f1034e14c1a4 100644
--- a/include/linux/clk/tegra.h
+++ b/include/linux/clk/tegra.h
@@ -170,7 +170,7 @@ struct tegra210_clk_emc_provider {
struct module *owner;
struct device *dev;
- struct tegra210_clk_emc_config *configs;
+ struct tegra210_clk_emc_config *configs __counted_by_ptr(num_configs);
unsigned int num_configs;
int (*set_rate)(struct device *dev,
--
2.55.0.1082.g2b9226bbc0-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr
2026-09-22 11:06 [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr Bill Wendling
@ 2026-09-23 5:42 ` Gustavo A. R. Silva
2026-09-23 7:28 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2026-09-23 5:42 UTC (permalink / raw)
To: Bill Wendling, Thierry Reding, Jonathan Hunter
Cc: Stephen Boyd, Brian Masney, Jerome Brunet, Kees Cook,
Gustavo A. R. Silva, linux-clk, linux-tegra, linux-kernel,
linux-hardening, codemender-patching+linux
On 9/22/26 20:06, Bill Wendling wrote:
> Annotate the "configs" pointer field of "struct
> tegra210_clk_emc_provider" with the "__counted_by_ptr" attribute,
> allowing the compiler to perform runtime bounds checking on accesses to
> "configs" based on the value of "num_configs".
>
> The "emc->provider.configs = devm_kcalloc(...)" call uses
> "emc->num_timings" for the number of elements, which is then assigned to
> "emc->provider.num_configs" before any accesses to "configs". The
> "num_configs" field isn't modified after assignment.
>
> 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/clk/tegra.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
> index 3650e926e93f..f1034e14c1a4 100644
> --- a/include/linux/clk/tegra.h
> +++ b/include/linux/clk/tegra.h
> @@ -170,7 +170,7 @@ struct tegra210_clk_emc_provider {
> struct module *owner;
> struct device *dev;
>
> - struct tegra210_clk_emc_config *configs;
> + struct tegra210_clk_emc_config *configs __counted_by_ptr(num_configs);
> unsigned int num_configs;
>
> int (*set_rate)(struct device *dev,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr
2026-09-22 11:06 [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr Bill Wendling
2026-09-23 5:42 ` Gustavo A. R. Silva
@ 2026-09-23 7:28 ` Kees Cook
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2026-09-23 7:28 UTC (permalink / raw)
To: Bill Wendling
Cc: Thierry Reding, Jonathan Hunter, Stephen Boyd, Brian Masney,
Jerome Brunet, Gustavo A. R. Silva, linux-clk, linux-tegra,
linux-kernel, linux-hardening, codemender-patching+linux
On Tue, Sep 22, 2026 at 11:06:01AM +0000, Bill Wendling wrote:
> Annotate the "configs" pointer field of "struct
> tegra210_clk_emc_provider" with the "__counted_by_ptr" attribute,
> allowing the compiler to perform runtime bounds checking on accesses to
> "configs" based on the value of "num_configs".
>
> The "emc->provider.configs = devm_kcalloc(...)" call uses
> "emc->num_timings" for the number of elements, which is then assigned to
> "emc->provider.num_configs" before any accesses to "configs". The
> "num_configs" field isn't modified after assignment.
Yup, that's the only assignment I can find.
> Cc: codemender-patching+linux@google.com
> Assisted-by: LLM
> Signed-off-by: Bill Wendling <morbo@google.com>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-23 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 11:06 [PATCH] clk: tegra: annotate struct tegra210_clk_emc_provider with __counted_by_ptr Bill Wendling
2026-09-23 5:42 ` Gustavo A. R. Silva
2026-09-23 7:28 ` Kees Cook
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®