execve():

- COKERNEL_PATH and COKERNEL_EXEC_ROOT support for co-kernels with different architecture than the host (i.e., Xeon Phi).
- fix various error codes: ENAMETOOLONG, ENOENT, ENOTDIR, EACCES, ENOEXEC, EFAULT.
- support for shell code execution.
This commit is contained in:
Balazs Gerofi bgerofi@riken.jp
2014-09-03 18:15:43 +09:00
parent 308987c1ee
commit cd366de097
6 changed files with 224 additions and 92 deletions

View File

@@ -103,6 +103,8 @@ struct program_image_section {
void *fp;
};
#define SHELL_PATH_MAX_LEN 1024
struct program_load_desc {
int num_sections;
int status;
@@ -128,6 +130,7 @@ struct program_load_desc {
unsigned long rlimit_stack_cur;
unsigned long rlimit_stack_max;
unsigned long interp_align;
char shell_path[SHELL_PATH_MAX_LEN];
struct program_image_section sections[0];
};

View File

@@ -1245,15 +1245,20 @@ SYSCALL_DECLARE(execve)
dkprintf("execve(): ELF desc received, num sections: %d\n",
desc->num_sections);
if (desc->shell_path[0]) {
dkprintf("execve(): shell interpreter: %s\n", desc->shell_path);
}
/* Flatten argv and envp into kernel-space buffers */
argv_flat_len = flatten_strings(-1, argv, &argv_flat);
argv_flat_len = flatten_strings(-1, (desc->shell_path[0] ?
desc->shell_path : NULL), argv, &argv_flat);
if (argv_flat_len == 0) {
kprintf("ERROR: no argv for executable: %s?\n", filename);
return -EINVAL;
}
envp_flat_len = flatten_strings(-1, envp, &envp_flat);
envp_flat_len = flatten_strings(-1, NULL, envp, &envp_flat);
if (envp_flat_len == 0) {
kprintf("ERROR: no envp for executable: %s?\n", filename);
return -EINVAL;