Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


small updates to GEARS utilities (for use with v3_ctrl lib)
Kyle Hale [Wed, 22 Aug 2012 06:53:11 +0000 (01:53 -0500)]
linux_usr/v3_env_inject.c
linux_usr/v3_syscall.c
linux_usr/v3_top_inject.c

index f9eb854..4fc80b1 100644 (file)
 #include <sys/ioctl.h>
 
 #include "iface-env-inject.h"
+#include "v3_ctrl.h"
 
 
-static void usage (char* bin) {
-       fprintf(stderr, "usage: %s /dev/v3-vm<N> env-file inject-point-exe\n", bin);
-}
-
 int main (int argc, char **argv) {
        char *vm_dev, *env_file, *bin_name;
-       int vm_fd, err, bytes_read, num_strings;
+       int err, bytes_read, num_strings;
     struct stat t_stat;
     struct env_data env;
     char * strings[MAX_NUM_STRINGS];
@@ -32,7 +29,10 @@ int main (int argc, char **argv) {
     FILE * t_fd;
 
        if (argc < 4) {
-               usage(argv[0]);
+               v3_usage("<vm device> <env-file> <inject-point-exe>\n\n"
+                         "\tenv-file : file containing a list of new-line separated env vars\n\n"
+                         "\tinject-point-exe : if this is an exec-hooked inject, use this executable name\n");
+                         
                return -1;
        }
 
@@ -72,20 +72,13 @@ int main (int argc, char **argv) {
 
     strncpy(env.bin_name, bin_name, MAX_STRING_LEN);
 
-       vm_fd = open(vm_dev, O_RDONLY);
-       if (vm_fd == -1) {
-               fprintf(stderr, "Error opening VM device: %s\n", vm_dev);
-               return -1;
-       }
-
     printf("Transferring control to Palacios\n");
-       err = ioctl(vm_fd, V3_VM_ENV_INJECT, &env);
+       err = v3_vm_ioctl(vm_dev, V3_VM_ENV_INJECT, &env);
        if (err < 0) {
                fprintf(stderr, "Error providing env var data to palacios\n");
                return -1;
        }
     
        close(t_fd);
-       close(vm_fd);
        return 0;
 }
index feead06..149e644 100644 (file)
 #include <string.h>
 
 #include "iface-syscall.h"
+#include "v3_ctrl.h"
 
 #define CMD_MAX 10
 #define SYSCALL_MAX 256
 
-static void usage () {
-       fprintf(stderr, "\nusage: v3_syscall <vm device> <syscall_nr> <on|off|status>\n");
-       exit(0);
+static void usage (char * argv[]) {
+        v3_usage("<vm device> <syscall_nr> <on|off|status>\n");
 }
 
-
 int main (int argc, char * argv[]) {
 
-       int vm_fd, ret, syscall_nr;
+       int ret, syscall_nr;
        char * vm_dev = NULL;
        struct v3_syscall_cmd syscall_cmd;
 
        if (argc < 4 || argc > 4) {
                fprintf(stderr, "Invalid number of arguments.\n");
-               usage();
+                usage(argv);
        }
 
        vm_dev = argv[1];
@@ -46,7 +45,7 @@ int main (int argc, char * argv[]) {
                syscall_cmd.cmd = SYSCALL_STAT;
        } else {
                fprintf(stderr, "Invalid command.\n");
-               usage();
+               usage(argv);
        }
 
     if (syscall_nr < 0 || syscall_nr > SYSCALL_MAX) {
@@ -56,14 +55,7 @@ int main (int argc, char * argv[]) {
 
     syscall_cmd.syscall_nr = syscall_nr;
 
-       vm_fd = open(vm_dev, O_RDONLY);
-
-       if (vm_fd < 0) { 
-               fprintf(stderr, "Error opening VM device: %s\n", vm_dev);
-               return -1;
-       }
-
-       ret = ioctl(vm_fd, V3_VM_SYSCALL_CTRL, &syscall_cmd);
+        ret = v3_vm_ioctl(vm_dev, V3_VM_SYSCALL_CTRL, &syscall_cmd);
 
     if (ret < 0) {
         fprintf(stderr, "Error with syscall control\n");
index 5758cc8..6252b91 100644 (file)
@@ -17,6 +17,7 @@
 #include <sys/ioctl.h>
 
 #include "iface-code-inject.h"
+#include "v3_ctrl.h"
 
 #define __ELF_INJECT_CLASS 32
 
 #define _ElfW_1(e,w,t) e##w##t
 
 
-static void usage (char* bin) {
-       fprintf(stderr, "usage: %s /dev/v3-vm<N> <inject-code> <code-entry-offset> [inject-point-exe]\n", bin);
-}
-
-
 /* look for PT_DYNAMIC to see if it's dynamically linked */
 static int is_dynamic (ElfW(Ehdr) * ehdr) {
     int i;
@@ -51,13 +47,17 @@ int main (int argc, char **argv) {
        char *vm_dev = NULL;
        char *top_half = NULL;
     char *bin_file = NULL;
-       int vm_fd, t_fd, err, bytes_read, entry;
+       int t_fd, err, bytes_read, entry;
     struct stat t_stat;
     struct top_half_data elf;
     ElfW(Ehdr) * elf_hdr;
 
        if (argc < 4 || argc > 5) {
-               usage(argv[0]);
+                // TODO: add a better explanation here
+               v3_usage("/dev/v3-vm<N> <inject-code> <code-entry-offset> [inject-point-exe]\n\n"
+                          "\tinject-code       : the binary file to be injected\n\n"
+                          "\tcode-entry-offset : offset in the binary to .text\n\n"
+                          "\tinject-point-exe  : if exec-hooked injection is used, use this exec name\n");
                return -1;
        }
 
@@ -129,14 +129,9 @@ int main (int argc, char **argv) {
     /* is it a dynamically linked executable? */
     elf.is_dyn = is_dynamic(elf_hdr);
 
-       vm_fd = open(vm_dev, O_RDONLY);
-       if (vm_fd == -1) {
-               fprintf(stderr, "Error opening VM device: %s\n", vm_dev);
-               return -1;
-       }
 
     printf("Transferring control to Palacios\n");
-       err = ioctl(vm_fd, V3_VM_TOPHALF_INJECT, &elf);
+       err = v3_vm_ioctl(vm_dev, V3_VM_TOPHALF_INJECT, &elf);
        if (err < 0) {
                fprintf(stderr, "Error providing top half to palacios: %s\n", top_half);
                return -1;
@@ -144,7 +139,6 @@ int main (int argc, char **argv) {
     
     free(elf.elf_data);
        close(t_fd);
-       close(vm_fd);
 
        return 0;
 }