From 325c38b94e41faea3f2ba8eccbd7d9257efe5b0c Mon Sep 17 00:00:00 2001 From: brooks Date: Wed, 6 Nov 2019 19:44:44 +0000 Subject: [PATCH] libstats: Improve ABI assertion. On platforms where pointers are larger than 64-bits, struct statsblob may be harmlessly padded out such that opaque[] always has some included space. Make the assertion more general by comparing to the offset of opaque rather than the size of struct statsblob. Discussed with: jhb, James Clarke Reviewed by: trasz, lstewart Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22188 --- sys/kern/subr_stats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/subr_stats.c b/sys/kern/subr_stats.c index 10e5eaef4e27..bbdc1039237e 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -124,7 +124,8 @@ struct statsblobv1 { struct voi vois[]; /* Array indexed by [voi_id]. */ } __aligned(sizeof(void *)); _Static_assert(offsetof(struct statsblobv1, cursz) + - SIZEOF_MEMBER(struct statsblobv1, cursz) == sizeof(struct statsblob), + SIZEOF_MEMBER(struct statsblobv1, cursz) == + offsetof(struct statsblob, opaque), "statsblobv1 ABI mismatch"); struct statsblobv1_tpl {