All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH-for-4.17] xen: fix generated code for calling hypercall handlers
@ 2022-11-03 16:36 Juergen Gross
  2022-11-03 16:45 ` Jan Beulich
  2022-11-04  5:01 ` Revert of the 4.17 hypercall handler changes " Andrew Cooper
  0 siblings, 2 replies; 10+ messages in thread
From: Juergen Gross @ 2022-11-03 16:36 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Jan Beulich,
	Julien Grall, Stefano Stabellini, Wei Liu, Henry Wang

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>
---
 xen/scripts/gen_hypercall.awk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/scripts/gen_hypercall.awk b/xen/scripts/gen_hypercall.awk
index 34840c514f..08b2f70bdb 100644
--- a/xen/scripts/gen_hypercall.awk
+++ b/xen/scripts/gen_hypercall.awk
@@ -263,7 +263,7 @@ END {
         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) {
-- 
2.35.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-10  8:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 16:36 [PATCH-for-4.17] xen: fix generated code for calling hypercall handlers Juergen Gross
2022-11-03 16:45 ` Jan Beulich
2022-11-03 16:50   ` Henry Wang
2022-11-04  5:01 ` Revert of the 4.17 hypercall handler changes " Andrew Cooper
2022-11-04  5:26   ` Juergen Gross
2022-11-04  7:36   ` Jan Beulich
2022-11-04 21:04   ` George Dunlap
2022-11-09 20:16   ` George Dunlap
2022-11-10  6:25     ` Juergen Gross
2022-11-10  8:09     ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.