Add the __counted_by compiler attribute to the flexible array member
range to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.b...@linux.dev>
---
 include/linux/hyperv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 22c22fb91042..ec62d625c439 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -643,7 +643,7 @@ struct vmbus_channel_gpadl_header {
        u32 gpadl;
        u16 range_buflen;
        u16 rangecount;
-       struct gpa_range range[];
+       struct gpa_range range[] __counted_by(rangecount);
 } __packed;
 
 /* This is the followup packet that contains more PFNs. */
-- 
2.47.0


Reply via email to