[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen: fix generated code for calling hypercall handlers



commit 9f3e585ff5ecc606e386057f5cfa66b22fea2b93
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Fri Nov 4 08:54:57 2022 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Fri Nov 4 08:54:57 2022 +0100

    xen: fix generated code for calling hypercall handlers
    
    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@xxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
---
 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..9f7cfa298a 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) {
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.