The code generated for the call_handlers_*() macros needs to avoid
undefined behavior when multiple handlers share the same priority.
The issue is the hypercall number being unverified fed into the macros
and then used to set a mask via "mask = 1ULL << <hypercall-number>".
Avoid a shift amount of more than 63 by setting mask to zero in case
the hypercall number is too large.
Fixes: eca1f00d0227 ("xen: generate hypercall interface related code")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
printf("#define call_handlers_%s(num, ret, a1, a2, a3, a4, a5) \\\n", ca);
printf("({ \\\n");
if (need_mask)
- printf(" uint64_t mask = 1ULL << num; \\\n");
+ printf(" uint64_t mask = (num) > 63 ? 0 : 1ULL << (num); \\\n");
printf(" ");
for (pl = 1; pl <= n_prios[ca]; pl++) {
if (prios[ca, p_list[pl]] > 1) {