Skip to content

Commit

Permalink
Initial import of the semi-autonomous loader.
Browse files Browse the repository at this point in the history
The previous loader is remotely controlled, as a consequence it is
quite slow.  This new loader tries to solve this issue.  For example,
using this benchmak:

    time proot perl -e 'system("/usr/bin/true") for (1..10000)'

we get these figures:

  ======  ========
          time (s)
  ======  ========
  v4.0.3      9.95
  HEAD^      13.20
  HEAD       11.21
  ======  ========

  ==========  ======  ======  ======
  comparison  v4.0.3   HEAD^    HEAD
  ==========  ======  ======  ======
  v4.0.3                -33%    -13%
  HEAD^         +25%            +15%
  HEAD          +11%    -18%
  ==========  ======  ======  ======

I think it's possible to reduce the overhead by making the
semi-autonomous loader patch the ELF auxiliary vectors.
  • Loading branch information
cedric-vincent committed Oct 1, 2014
1 parent 8d9816a commit 1e9c14f
Show file tree
Hide file tree
Showing 10 changed files with 501 additions and 20 deletions.
29 changes: 22 additions & 7 deletions src/execve/enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ static int add_interp(Tracee *tracee, int fd, LoadInfo *load_info,
if (status < 0)
return status;

load_info->interp->path = talloc_strdup(load_info->interp, host_path);
if (load_info->interp->path == NULL)
load_info->interp->host_path = talloc_strdup(load_info->interp, host_path);
if (load_info->interp->host_path == NULL)
return -ENOMEM;

load_info->interp->user_path = talloc_strdup(load_info->interp, user_path);
if (load_info->interp->user_path == NULL)
return -ENOMEM;

return 0;
Expand All @@ -176,7 +180,7 @@ static int add_interp(Tracee *tracee, int fd, LoadInfo *load_info,
#undef P

/**
* Extract the load info from @load->path. This function returns
* Extract the load info from @load->host_path. This function returns
* -errno if an error occured, otherwise it returns 0.
*
* TODO: factorize with find_program_header()
Expand All @@ -194,9 +198,9 @@ static int extract_load_info(Tracee *tracee, LoadInfo *load_info)
int i;

assert(load_info != NULL);
assert(load_info->path != NULL);
assert(load_info->host_path != NULL);

fd = open_elf(load_info->path, &load_info->elf_header);
fd = open_elf(load_info->host_path, &load_info->elf_header);
if (fd < 0)
return fd;

Expand Down Expand Up @@ -439,16 +443,27 @@ int translate_execve_enter(Tracee *tracee)
}

/* WIP. */
#ifdef LOADER2
status = set_sysarg_path(tracee, "/usr/local/cedric/git/proot/src/execve/loader-x86_64", SYSARG_1);
#else
status = set_sysarg_path(tracee, "/usr/local/cedric/git/proot/src/execve/stub-x86_64", SYSARG_1);
#endif
if (status < 0)
return status;

if (tracee->load_info != NULL)
TALLOC_FREE(tracee->load_info);

tracee->load_info = talloc_zero(tracee, LoadInfo);
if (tracee->load_info == NULL)
return -ENOMEM;

tracee->load_info->path = talloc_strdup(tracee->load_info, host_path);
if (tracee->load_info->path == NULL)
tracee->load_info->host_path = talloc_strdup(tracee->load_info, host_path);
if (tracee->load_info->host_path == NULL)
return -ENOMEM;

tracee->load_info->user_path = talloc_strdup(tracee->load_info, user_path);
if (tracee->load_info->user_path == NULL)
return -ENOMEM;

status = extract_load_info(tracee, tracee->load_info);
Expand Down
1 change: 1 addition & 0 deletions src/execve/execve.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
extern int translate_execve(Tracee *tracee);
extern int translate_execve_enter(Tracee *tracee);
extern int translate_execve_exit(Tracee *tracee);
extern int translate_execve_exit2(Tracee *tracee);
extern int translate_and_check_exec(Tracee *tracee, char host_path[PATH_MAX], const char *user_path);

#endif /* EXECVE_H */

0 comments on commit 1e9c14f

Please sign in to comment.