|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen stable-4.22] tools/ocaml: Fix crash in Xenctrl.domain_getinfo{,list}() on ARM
commit cd29f1c5dd84957683a8eae7fac019c83355c6d6
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Tue Jul 28 10:52:49 2026 +0100
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Wed Jul 29 13:41:28 2026 +0100
tools/ocaml: Fix crash in Xenctrl.domain_getinfo{,list}() on ARM
The Store_field(result, 16, arch_config) sits inside an #ifdef x86, meaning
that on other architectures the pointer is not filled in. Ocaml code then
falls over a NULL(ish) pointer (really the Val_unit used to initialise
'result') when the layout in the heap doesn't match the type system.
Rearrange alloc_domaininfo() to avoid this. Similarly to
physinfo_arch_caps(), raise an exception if the architecture code hasn't
filled in an appropriate tag. Move the setup of arch_domainconfig to be
common logic.
In order to simplify the addition of other architectures, remove the
arch_config variable (reusing tmp as it's touched exactly once), and rename
x86_arch_config to be arch_config so each architecture can fill in a
suitable
one without needing more local variables.
Fixes: 9d683b5e375d ("tools/ocaml: Expose arch_config in domaininfo")
Fixes: 81838c9067ab ("ocaml: fix arm build")
Reported-by: Julian Vetter <julian.vetter@xxxxxxxxxx>
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
(cherry picked from commit 365d2a5be3fa34b22c37ef4b6ff3efd3ce05b387)
---
tools/ocaml/libs/xc/xenctrl_stubs.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c
b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 7f6381cdd2..de66f5989a 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -414,7 +414,8 @@ CAMLprim value stub_xc_domain_shutdown(value xch_val, value
domid, value reason)
static value alloc_domaininfo(xc_domaininfo_t * info)
{
CAMLparam0();
- CAMLlocal5(result, tmp, arch_config, x86_arch_config, emul_list);
+ CAMLlocal4(result, tmp, arch_config, emul_list);
+ int tag = -1;
int i;
result = caml_alloc_tuple(17);
@@ -444,6 +445,9 @@ static value alloc_domaininfo(xc_domaininfo_t * info)
Store_field(result, 15, tmp);
#if defined(__i386__) || defined(__x86_64__)
+
+ tag = 1; /* tag x86 */
+
/*
* emulation_flags: x86_arch_emulation_flags list;
*/
@@ -452,16 +456,17 @@ static value alloc_domaininfo(xc_domaininfo_t * info)
(info->arch_config.emulation_flags);
/* xen_x86_arch_domainconfig */
- x86_arch_config = caml_alloc_tuple(1);
- Store_field(x86_arch_config, 0, emul_list);
+ arch_config = caml_alloc_tuple(1);
+ Field(arch_config, 0) = emul_list;
- /* arch_config: arch_domainconfig */
- arch_config = caml_alloc_small(1, 1);
-
- Store_field(arch_config, 0, x86_arch_config);
-
- Store_field(result, 16, arch_config);
#endif
+ if (tag < 0)
+ caml_failwith("Unimplemented architecture in
alloc_domaininfo()");
+
+ /* arch_config: arch_domainconfig */
+ tmp = caml_alloc_small(1, tag);
+ Field(tmp, 0) = arch_config;
+ Field(result, 16) = tmp;
CAMLreturn(result);
}
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.22
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |