Skip to contentSkip to conversation

: xc: fix segfault in pv domain create if kernel is an invalid image

PATCH Applied Gianni Tedesco 2 participants 2 messages Aug 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : xc: fix segfault in pv domain create if kernel is an invalid image

If libelf calls elf_err() or elf_msg() before elf_set_log() has been called then it could potentially read an uninitialised log handling callback function pointer from struct elf_binary. Fix this in libxc by zeroing the structure before calling elf_init().

tools/libxc/xc_hvm_build.c +1 -0
diff -r ac93a1ec290c tools/libxc/xc_hvm_build.c
@@ -141,6 +141,7 @@ static int setup_guest(xc_interface *xch
     if ( memsize > target )
         pod_mode = 1;
 
+    memset(&elf, 0, sizeof(elf));
     if ( elf_init(&elf, image, image_size) != 0 )
         goto error_out;
     elf_parse_binary(&elf);
#1 lore raw
Quoted 12 lines · Gianni Tedesco

If libelf calls elf_err() or elf_msg() before elf_set_log() has been called then it could potentially read an uninitialised log handling callback function pointer from struct elf_binary. Fix this in libxc by zeroing the structure before calling elf_init().

diff -r ac93a1ec290c tools/libxc/xc_hvm_build.c

tools/libxc/xc_hvm_build.c static int setup_guest(xc_interface *xch · line 147

Quoted 7 lines
tools/libxc/xc_hvm_build.c +1 -0
@@ -141,6 +141,7 @@ static int setup_guest(xc_interface *xch
     if ( memsize > target )
         pod_mode = 1;
 
+    memset(&elf, 0, sizeof(elf));
     if ( elf_init(&elf, image, image_size) != 0 )
         goto error_out;
     elf_parse_binary(&elf);

applied, thanks