Add the '__counted_by_ptr' attribute to the 'regions' field of 'struct
memblock_type'. The 'regions' field is an array of 'struct
memblock_region' and its size is tracked by the 'max' field, which
represents the total number of allocated regions.

This annotation allows the Kernel Address Sanitizer (KASAN) to detect
out-of-bounds accesses to the 'regions' array.

Cc: Kees Cook <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Justin Stitt <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Marc Herbert <[email protected]>
Cc: Uros Bizjak <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Jeff Xu <[email protected]>
Cc: "Michal Koutný" <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: "Thomas Weißschuh" <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Mike Rapoport <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Bill Wendling <[email protected]>
---
 include/linux/memblock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 221118b5a16e..ba7f7c999a45 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -91,7 +91,7 @@ struct memblock_type {
        unsigned long cnt;
        unsigned long max;
        phys_addr_t total_size;
-       struct memblock_region *regions;
+       struct memblock_region *regions __counted_by_ptr(max);
        char *name;
 };
 
-- 
2.52.0.rc2.455.g230fcf2819-goog


Reply via email to