[PATCH] tools/ocaml: Add misc_flags in the x86 domaininfo arch_config

Julian Vetter posted 1 patch 1 week ago
tools/ocaml/libs/xc/xenctrl_stubs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
[PATCH] tools/ocaml: Add misc_flags in the x86 domaininfo arch_config
Posted by Julian Vetter 1 week ago
The function alloc_domaininfo() allocates the x86 arch_config with a
single field. Trying to access misc_flags after calling domain_getinfo()
therefore results in a read past the end of the block.

Allocate both fields, and convert misc_flags like emulation_flags.
XEN_DOMCTL_getdomaininfo doesn't report misc_flags, so the list is
always empty for now, but the record now matches its OCaml type.

Signed-off-by: Julian Vetter <julian.vetter@vates.tech>
---
 tools/ocaml/libs/xc/xenctrl_stubs.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index c15a3428da..7964f3e1e9 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -440,7 +440,7 @@ CAMLprim value stub_xc_domain_shutdown(value xch_val, value domid, value reason)
 static value alloc_domaininfo(xc_domaininfo_t * info)
 {
 	CAMLparam0();
-	CAMLlocal4(result, tmp, arch_config, emul_list);
+	CAMLlocal5(result, tmp, arch_config, emul_list, misc_list);
 	int tag = -1;
 	int i;
 
@@ -490,9 +490,17 @@ static value alloc_domaininfo(xc_domaininfo_t * info)
 		/* ! x86_arch_emulation_flags */
 		(info->arch_config.emulation_flags);
 
+	/*
+	 * misc_flags: x86_arch_misc_flags list;
+	 */
+	misc_list = c_bitmap_to_ocaml_list
+		/* ! x86_arch_misc_flags */
+		(info->arch_config.misc_flags);
+
 	/* xen_x86_arch_domainconfig */
-	arch_config = caml_alloc_tuple(1);
+	arch_config = caml_alloc_tuple(2);
 	Field(arch_config, 0) = emul_list;
+	Field(arch_config, 1) = misc_list;
 
 #endif
 	if (tag < 0)
-- 
2.53.0



-- 
Julian Vetter | Vates Hypervisor & Kernel Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech