[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxenlight: remove ctx dangerously passed to children
# HG changeset patch # User Keir Fraser <keir.fraser@xxxxxxxxxx> # Date 1263279972 0 # Node ID 675443b02c530f4ddf0da720daa552e023d97f1a # Parent da6cddd200002cd5a3319a5c7b90f48681c3923a libxenlight: remove ctx dangerously passed to children apart from ctx->waitpid, it's potentially harmful to call into logging. Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx> --- tools/libxl/libxl.c | 4 ++-- tools/libxl/libxl_exec.c | 16 ++++++++-------- tools/libxl/libxl_internal.h | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-) diff -r da6cddd20000 -r 675443b02c53 tools/libxl/libxl.c --- a/tools/libxl/libxl.c Tue Jan 12 07:05:22 2010 +0000 +++ b/tools/libxl/libxl.c Tue Jan 12 07:06:12 2010 +0000 @@ -726,8 +726,8 @@ static char ** libxl_build_device_model_ return (char **) flexarray_contents(dm_args); } -void dm_xenstore_record_pid(struct libxl_ctx *ctx, void *for_spawn, - pid_t innerchild) { +void dm_xenstore_record_pid(void *for_spawn, pid_t innerchild) +{ struct libxl_device_model_starting *starting = for_spawn; char *kvs[3]; int rc; diff -r da6cddd20000 -r 675443b02c53 tools/libxl/libxl_exec.c --- a/tools/libxl/libxl_exec.c Tue Jan 12 07:05:22 2010 +0000 +++ b/tools/libxl/libxl_exec.c Tue Jan 12 07:06:12 2010 +0000 @@ -100,8 +100,7 @@ int libxl_spawn_spawn(struct libxl_ctx * int libxl_spawn_spawn(struct libxl_ctx *ctx, libxl_device_model_starting *starting, const char *what, - void (*intermediate_hook)(struct libxl_ctx *ctx, - void *for_spawn, + void (*intermediate_hook)(void *for_spawn, pid_t innerchild)) { pid_t child, got; @@ -127,18 +126,19 @@ int libxl_spawn_spawn(struct libxl_ctx * /* we are now the intermediate process */ - child = libxl_fork(ctx); - if (!child) return 0; /* caller runs child code */ - if (child < 0) exit(255); - - intermediate_hook(ctx, starting, child); + child = fork(); + if (child == -1) + exit(255); + if (!child) + return 0; /* caller runs child code */ + + intermediate_hook(starting, child); if (!for_spawn) _exit(0); /* just detach then */ got = call_waitpid(ctx->waitpid_instead, child, &status, 0); assert(got == child); - libxl_report_child_exitstatus(ctx, what, child, status); _exit(WIFEXITED(status) ? WEXITSTATUS(status) : WIFSIGNALED(status) && WTERMSIG(status) < 127 ? WTERMSIG(status)+128 : -1); diff -r da6cddd20000 -r 675443b02c53 tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Tue Jan 12 07:05:22 2010 +0000 +++ b/tools/libxl/libxl_internal.h Tue Jan 12 07:06:12 2010 +0000 @@ -181,9 +181,7 @@ int libxl_spawn_spawn(struct libxl_ctx * int libxl_spawn_spawn(struct libxl_ctx *ctx, libxl_device_model_starting *starting, const char *what, - void (*intermediate_hook)(struct libxl_ctx *ctx, - void *for_spawn, - pid_t innerchild)); + void (*intermediate_hook)(void *for_spawn, pid_t innerchild)); /* Logs errors. A copy of "what" is taken. Return values: * < 0 error, for_spawn need not be detached * +1 caller is now the inner child, should probably call libxl_exec _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |