mcctrl: fix a bunch of -Wframe-larger-than warnings
This commit is contained in:
@@ -75,7 +75,7 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
char buf[32];
|
char buf[32];
|
||||||
int l;
|
int l;
|
||||||
int pass;
|
int pass;
|
||||||
char pbuf[1024];
|
char *pbuf;
|
||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if(bprm->envc == 0)
|
if(bprm->envc == 0)
|
||||||
@@ -88,6 +88,11 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
if(elf_ex->e_ident[EI_CLASS] != ELFCLASS64)
|
if(elf_ex->e_ident[EI_CLASS] != ELFCLASS64)
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
|
pbuf = kmalloc(1024, GFP_ATOMIC);
|
||||||
|
if (!pbuf) {
|
||||||
|
printk("%s: error: allocating pbuf\n", __FUNCTION__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
path = d_path(&bprm->file->f_path, pbuf, 1024);
|
path = d_path(&bprm->file->f_path, pbuf, 1024);
|
||||||
if(!path || IS_ERR(path))
|
if(!path || IS_ERR(path))
|
||||||
path = bprm->interp;
|
path = bprm->interp;
|
||||||
@@ -96,8 +101,10 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
if(!cp ||
|
if(!cp ||
|
||||||
!strcmp(cp, "/mcexec") ||
|
!strcmp(cp, "/mcexec") ||
|
||||||
!strcmp(cp, "/ihkosctl") ||
|
!strcmp(cp, "/ihkosctl") ||
|
||||||
!strcmp(cp, "/ihkconfig"))
|
!strcmp(cp, "/ihkconfig")) {
|
||||||
|
kfree(pbuf);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
cnt[0] = bprm->argc;
|
cnt[0] = bprm->argc;
|
||||||
cnt[1] = bprm->envc;
|
cnt[1] = bprm->envc;
|
||||||
@@ -124,8 +131,10 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
bprm->p, 1, 0, 1,
|
bprm->p, 1, 0, 1,
|
||||||
&page, NULL);
|
&page, NULL);
|
||||||
#endif
|
#endif
|
||||||
if(rc <= 0)
|
if(rc <= 0) {
|
||||||
|
kfree(pbuf);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
}
|
||||||
addr = kmap_atomic(page
|
addr = kmap_atomic(page
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
|
||||||
, KM_USER0
|
, KM_USER0
|
||||||
@@ -199,21 +208,27 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
for(ep = env; ep->name; ep++)
|
for(ep = env; ep->name; ep++)
|
||||||
if(ep->val)
|
if(ep->val)
|
||||||
kfree(ep->val);
|
kfree(ep->val);
|
||||||
if(rc)
|
if(rc) {
|
||||||
|
kfree(pbuf);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
file = open_exec(MCEXEC_PATH);
|
file = open_exec(MCEXEC_PATH);
|
||||||
if (IS_ERR(file))
|
if (IS_ERR(file)) {
|
||||||
|
kfree(pbuf);
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
rc = remove_arg_zero(bprm);
|
rc = remove_arg_zero(bprm);
|
||||||
if (rc){
|
if (rc){
|
||||||
fput(file);
|
fput(file);
|
||||||
|
kfree(pbuf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
rc = copy_strings_kernel(1, &bprm->interp, bprm);
|
rc = copy_strings_kernel(1, &bprm->interp, bprm);
|
||||||
if (rc < 0){
|
if (rc < 0){
|
||||||
fput(file);
|
fput(file);
|
||||||
|
kfree(pbuf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
bprm->argc++;
|
bprm->argc++;
|
||||||
@@ -221,12 +236,14 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
rc = copy_strings_kernel(1, &wp, bprm);
|
rc = copy_strings_kernel(1, &wp, bprm);
|
||||||
if (rc){
|
if (rc){
|
||||||
fput(file);
|
fput(file);
|
||||||
|
kfree(pbuf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
bprm->argc++;
|
bprm->argc++;
|
||||||
rc = bprm_change_interp(MCEXEC_PATH, bprm);
|
rc = bprm_change_interp(MCEXEC_PATH, bprm);
|
||||||
if (rc < 0){
|
if (rc < 0){
|
||||||
fput(file);
|
fput(file);
|
||||||
|
kfree(pbuf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,8 +253,12 @@ static int load_elf(struct linux_binprm *bprm
|
|||||||
|
|
||||||
rc = prepare_binprm(bprm);
|
rc = prepare_binprm(bprm);
|
||||||
if (rc < 0){
|
if (rc < 0){
|
||||||
|
kfree(pbuf);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kfree(pbuf);
|
||||||
|
|
||||||
return search_binary_handler(bprm
|
return search_binary_handler(bprm
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||||
, regs
|
, regs
|
||||||
|
|||||||
@@ -77,32 +77,49 @@ int mcctrl_ikc_set_recv_cpu(ihk_os_t os, int cpu);
|
|||||||
static long mcexec_prepare_image(ihk_os_t os,
|
static long mcexec_prepare_image(ihk_os_t os,
|
||||||
struct program_load_desc * __user udesc)
|
struct program_load_desc * __user udesc)
|
||||||
{
|
{
|
||||||
struct program_load_desc desc, *pdesc;
|
struct program_load_desc *desc, *pdesc;
|
||||||
struct ikc_scd_packet isp;
|
struct ikc_scd_packet isp;
|
||||||
void *args, *envs;
|
void *args, *envs;
|
||||||
long ret = 0;
|
long ret = 0;
|
||||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||||
struct mcctrl_per_proc_data *ppd = NULL;
|
struct mcctrl_per_proc_data *ppd = NULL;
|
||||||
|
int num_sections;
|
||||||
|
|
||||||
if (copy_from_user(&desc, udesc,
|
desc = kmalloc(sizeof(*desc), GFP_KERNEL);
|
||||||
|
if (!desc) {
|
||||||
|
printk("%s: error: allocating program_load_desc\n",
|
||||||
|
__FUNCTION__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy_from_user(desc, udesc,
|
||||||
sizeof(struct program_load_desc))) {
|
sizeof(struct program_load_desc))) {
|
||||||
|
printk("%s: error: copying program_load_desc\n",
|
||||||
|
__FUNCTION__);
|
||||||
|
kfree(desc);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
if (desc.num_sections <= 0 || desc.num_sections > 16) {
|
|
||||||
printk("# of sections: %d\n", desc.num_sections);
|
num_sections = desc->num_sections;
|
||||||
|
|
||||||
|
if (num_sections <= 0 || num_sections > 16) {
|
||||||
|
printk("# of sections: %d\n", num_sections);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
pdesc = kmalloc(sizeof(struct program_load_desc) +
|
pdesc = kmalloc(sizeof(struct program_load_desc) +
|
||||||
sizeof(struct program_image_section)
|
sizeof(struct program_image_section)
|
||||||
* desc.num_sections, GFP_KERNEL);
|
* num_sections, GFP_KERNEL);
|
||||||
memcpy(pdesc, &desc, sizeof(struct program_load_desc));
|
memcpy(pdesc, desc, sizeof(struct program_load_desc));
|
||||||
if (copy_from_user(pdesc->sections, udesc->sections,
|
if (copy_from_user(pdesc->sections, udesc->sections,
|
||||||
sizeof(struct program_image_section)
|
sizeof(struct program_image_section)
|
||||||
* desc.num_sections)) {
|
* num_sections)) {
|
||||||
|
kfree(desc);
|
||||||
kfree(pdesc);
|
kfree(pdesc);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kfree(desc);
|
||||||
|
|
||||||
pdesc->pid = task_tgid_vnr(current);
|
pdesc->pid = task_tgid_vnr(current);
|
||||||
|
|
||||||
if (reserve_user_space(usrdata, &pdesc->user_start, &pdesc->user_end)) {
|
if (reserve_user_space(usrdata, &pdesc->user_start, &pdesc->user_end)) {
|
||||||
@@ -158,7 +175,7 @@ static long mcexec_prepare_image(ihk_os_t os,
|
|||||||
ppd->rpgtable = pdesc->rpgtable;
|
ppd->rpgtable = pdesc->rpgtable;
|
||||||
|
|
||||||
if (copy_to_user(udesc, pdesc, sizeof(struct program_load_desc) +
|
if (copy_to_user(udesc, pdesc, sizeof(struct program_load_desc) +
|
||||||
sizeof(struct program_image_section) * desc.num_sections)) {
|
sizeof(struct program_image_section) * num_sections)) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto free_out;
|
goto free_out;
|
||||||
}
|
}
|
||||||
@@ -315,33 +332,42 @@ static long mcexec_start_image(ihk_os_t os,
|
|||||||
struct program_load_desc * __user udesc,
|
struct program_load_desc * __user udesc,
|
||||||
struct file *file)
|
struct file *file)
|
||||||
{
|
{
|
||||||
struct program_load_desc desc;
|
struct program_load_desc *desc;
|
||||||
struct ikc_scd_packet isp;
|
struct ikc_scd_packet isp;
|
||||||
struct mcctrl_channel *c;
|
struct mcctrl_channel *c;
|
||||||
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
struct mcctrl_usrdata *usrdata = ihk_host_os_get_usrdata(os);
|
||||||
struct handlerinfo *info;
|
struct handlerinfo *info;
|
||||||
|
|
||||||
if (copy_from_user(&desc, udesc,
|
desc = kmalloc(sizeof(*desc), GFP_KERNEL);
|
||||||
|
if (!desc) {
|
||||||
|
printk("%s: error: allocating program_load_desc\n",
|
||||||
|
__FUNCTION__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy_from_user(desc, udesc,
|
||||||
sizeof(struct program_load_desc))) {
|
sizeof(struct program_load_desc))) {
|
||||||
|
kfree(desc);
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
info = kmalloc(sizeof(struct handlerinfo), GFP_KERNEL);
|
info = kmalloc(sizeof(struct handlerinfo), GFP_KERNEL);
|
||||||
info->pid = desc.pid;
|
info->pid = desc->pid;
|
||||||
ihk_os_register_release_handler(file, release_handler, info);
|
ihk_os_register_release_handler(file, release_handler, info);
|
||||||
|
|
||||||
c = usrdata->channels + desc.cpu;
|
c = usrdata->channels + desc->cpu;
|
||||||
|
|
||||||
mcctrl_ikc_set_recv_cpu(os, desc.cpu);
|
mcctrl_ikc_set_recv_cpu(os, desc->cpu);
|
||||||
|
|
||||||
usrdata->last_thread_exec = desc.cpu;
|
usrdata->last_thread_exec = desc->cpu;
|
||||||
|
|
||||||
isp.msg = SCD_MSG_SCHEDULE_PROCESS;
|
isp.msg = SCD_MSG_SCHEDULE_PROCESS;
|
||||||
isp.ref = desc.cpu;
|
isp.ref = desc->cpu;
|
||||||
isp.arg = desc.rprocess;
|
isp.arg = desc->rprocess;
|
||||||
|
|
||||||
mcctrl_ikc_send(os, desc.cpu, &isp);
|
mcctrl_ikc_send(os, desc->cpu, &isp);
|
||||||
|
|
||||||
|
kfree(desc);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +528,7 @@ int mcexec_syscall(struct mcctrl_usrdata *ud, struct ikc_scd_packet *packet)
|
|||||||
|
|
||||||
if (unlikely(!ppd)) {
|
if (unlikely(!ppd)) {
|
||||||
kprintf("%s: ERROR: no per-process structure for PID %d, "
|
kprintf("%s: ERROR: no per-process structure for PID %d, "
|
||||||
"syscall nr: %d\n",
|
"syscall nr: %lu\n",
|
||||||
__FUNCTION__, pid, packet->req.number);
|
__FUNCTION__, pid, packet->req.number);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ inline struct mcctrl_per_thread_data *mcctrl_get_per_thread_data(
|
|||||||
void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet,
|
void __return_syscall(ihk_os_t os, struct ikc_scd_packet *packet,
|
||||||
long ret, int stid);
|
long ret, int stid);
|
||||||
|
|
||||||
#define PROCFS_NAME_MAX 1000
|
#define PROCFS_NAME_MAX 768
|
||||||
|
|
||||||
struct procfs_read {
|
struct procfs_read {
|
||||||
unsigned long pbuf; /* physical address of the host buffer (request) */
|
unsigned long pbuf; /* physical address of the host buffer (request) */
|
||||||
|
|||||||
@@ -331,7 +331,7 @@ void delete_proc_procfs_files(int pid);
|
|||||||
void create_os_procfs_files(void);
|
void create_os_procfs_files(void);
|
||||||
void delete_os_procfs_files(void);
|
void delete_os_procfs_files(void);
|
||||||
|
|
||||||
#define PROCFS_NAME_MAX 1000
|
#define PROCFS_NAME_MAX 768
|
||||||
|
|
||||||
struct procfs_read {
|
struct procfs_read {
|
||||||
unsigned long pbuf; /* physical address of the host buffer (request) */
|
unsigned long pbuf; /* physical address of the host buffer (request) */
|
||||||
|
|||||||
Reference in New Issue
Block a user