Line 68... |
Line 68... |
static struct linux_binfmt *formats = (struct linux_binfmt *) NULL;
|
static struct linux_binfmt *formats = (struct linux_binfmt *) NULL;
|
|
|
void binfmt_setup(void)
|
void binfmt_setup(void)
|
{
|
{
|
#ifdef CONFIG_BINFMT_FLAT
|
#ifdef CONFIG_BINFMT_FLAT
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
init_flat_binfmt();
|
init_flat_binfmt();
|
|
|
#endif
|
#endif
|
|
|
#ifdef CONFIG_BINFMT_ELF
|
#ifdef CONFIG_BINFMT_ELF
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
init_elf_binfmt();
|
init_elf_binfmt();
|
#endif
|
#endif
|
|
|
#ifdef CONFIG_BINFMT_AOUT
|
#ifdef CONFIG_BINFMT_AOUT
|
init_aout_binfmt();
|
init_aout_binfmt();
|
Line 93... |
Line 92... |
|
|
int register_binfmt(struct linux_binfmt * fmt)
|
int register_binfmt(struct linux_binfmt * fmt)
|
{
|
{
|
struct linux_binfmt ** tmp = &formats;
|
struct linux_binfmt ** tmp = &formats;
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if (!fmt)
|
if (!fmt)
|
return -EINVAL;
|
return -EINVAL;
|
if (fmt->next)
|
if (fmt->next)
|
return -EBUSY;
|
return -EBUSY;
|
while (*tmp) {
|
while (*tmp) {
|
Line 105... |
Line 103... |
return -EBUSY;
|
return -EBUSY;
|
tmp = &(*tmp)->next;
|
tmp = &(*tmp)->next;
|
}
|
}
|
fmt->next = formats;
|
fmt->next = formats;
|
formats = fmt;
|
formats = fmt;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
#ifdef CONFIG_MODULES
|
#ifdef CONFIG_MODULES
|
int unregister_binfmt(struct linux_binfmt * fmt)
|
int unregister_binfmt(struct linux_binfmt * fmt)
|
Line 673... |
Line 671... |
}
|
}
|
#endif
|
#endif
|
for (try=0; try<2; try++) {
|
for (try=0; try<2; try++) {
|
for (fmt = formats ; fmt ; fmt = fmt->next) {
|
for (fmt = formats ; fmt ; fmt = fmt->next) {
|
int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
|
int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if (!fn)
|
if (!fn)
|
continue;
|
continue;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
retval = fn(bprm, regs);
|
retval = fn(bprm, regs);
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if (retval >= 0) {
|
if (retval >= 0) {
|
if(!bprm->dont_iput)
|
if(!bprm->dont_iput)
|
iput(bprm->inode);
|
iput(bprm->inode);
|
bprm->dont_iput=1;
|
bprm->dont_iput=1;
|
current->did_exec = 1;
|
current->did_exec = 1;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
return retval;
|
return retval;
|
}
|
}
|
if (retval != -ENOEXEC)
|
if (retval != -ENOEXEC)
|
break;
|
break;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if (bprm->dont_iput) /* We don't have the inode anymore*/
|
if (bprm->dont_iput) /* We don't have the inode anymore*/
|
return retval;
|
return retval;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
}
|
}
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if (retval != -ENOEXEC) {
|
if (retval != -ENOEXEC) {
|
break;
|
break;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
#ifdef CONFIG_KERNELD
|
#ifdef CONFIG_KERNELD
|
}else{
|
}else{
|
#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
|
#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
char modname[20];
|
char modname[20];
|
if (printable(bprm->buf[0]) &&
|
if (printable(bprm->buf[0]) &&
|
printable(bprm->buf[1]) &&
|
printable(bprm->buf[1]) &&
|
printable(bprm->buf[2]) &&
|
printable(bprm->buf[2]) &&
|
printable(bprm->buf[3]))
|
printable(bprm->buf[3]))
|
break; /* -ENOEXEC */
|
break; /* -ENOEXEC */
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
sprintf(modname, "binfmt-%hd", *(short*)(&bprm->buf));
|
sprintf(modname, "binfmt-%hd", *(short*)(&bprm->buf));
|
request_module(modname);
|
request_module(modname);
|
#endif
|
#endif
|
}
|
}
|
}
|
}
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
return retval;
|
return retval;
|
}
|
}
|
|
|
|
|
/*
|
/*
|
Line 730... |
Line 724... |
int retval;
|
int retval;
|
#ifndef NO_MM
|
#ifndef NO_MM
|
int i;
|
int i;
|
#endif /* !NO_MM */
|
#endif /* !NO_MM */
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
|
|
#ifndef NO_MM
|
#ifndef NO_MM
|
bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
|
bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
|
for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */
|
for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */
|
bprm.page[i] = 0;
|
bprm.page[i] = 0;
|
#endif /* !NO_MM */
|
#endif /* !NO_MM */
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
retval = open_namei(filename, 0, 0, &bprm.inode, NULL);
|
retval = open_namei(filename, 0, 0, &bprm.inode, NULL);
|
if (retval)
|
if (retval)
|
return retval;
|
return retval;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
bprm.filename = filename;
|
bprm.filename = filename;
|
bprm.sh_bang = 0;
|
bprm.sh_bang = 0;
|
bprm.loader = 0;
|
bprm.loader = 0;
|
bprm.exec = 0;
|
bprm.exec = 0;
|
bprm.dont_iput = 0;
|
bprm.dont_iput = 0;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if ((bprm.argc = count(argv)) < 0)
|
if ((bprm.argc = count(argv)) < 0)
|
return bprm.argc;
|
return bprm.argc;
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if ((bprm.envc = count(envp)) < 0)
|
if ((bprm.envc = count(envp)) < 0)
|
return bprm.envc;
|
return bprm.envc;
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
retval = prepare_binprm(&bprm);
|
retval = prepare_binprm(&bprm);
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
#ifndef NO_MM
|
#ifndef NO_MM
|
if(retval>=0) {
|
if(retval>=0) {
|
bprm.p = copy_strings(1, &bprm.filename, bprm.page, bprm.p, 2);
|
bprm.p = copy_strings(1, &bprm.filename, bprm.page, bprm.p, 2);
|
bprm.exec = bprm.p;
|
bprm.exec = bprm.p;
|
bprm.p = copy_strings(bprm.envc,envp,bprm.page,bprm.p,0);
|
bprm.p = copy_strings(bprm.envc,envp,bprm.page,bprm.p,0);
|
Line 772... |
Line 758... |
#else /* NO_MM */
|
#else /* NO_MM */
|
bprm.envp = envp;
|
bprm.envp = envp;
|
bprm.argv = argv;
|
bprm.argv = argv;
|
#endif /* NO_MM */
|
#endif /* NO_MM */
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if(retval>=0)
|
if(retval>=0)
|
retval = search_binary_handler(&bprm,regs);
|
retval = search_binary_handler(&bprm,regs);
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
if(retval>=0) {
|
if(retval>=0) {
|
#ifdef NO_MM
|
#ifdef NO_MM
|
/* Wake up parent that vforked me */
|
/* Wake up parent that vforked me */
|
wake_up(¤t->p_opptr->mm->vforkwait);
|
wake_up(¤t->p_opptr->mm->vforkwait);
|
#endif /* NO_MM */
|
#endif /* NO_MM */
|
/* execve success */
|
/* execve success */
|
return retval;
|
return retval;
|
}
|
}
|
|
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
/* Something went wrong, return the inode and free the argument pages*/
|
/* Something went wrong, return the inode and free the argument pages*/
|
if(!bprm.dont_iput)
|
if(!bprm.dont_iput)
|
iput(bprm.inode);
|
iput(bprm.inode);
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
#ifndef NO_MM
|
#ifndef NO_MM
|
for (i=0 ; i<MAX_ARG_PAGES ; i++)
|
for (i=0 ; i<MAX_ARG_PAGES ; i++)
|
free_page(bprm.page[i]);
|
free_page(bprm.page[i]);
|
#endif /* !NO_MM */
|
#endif /* !NO_MM */
|
printk("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
|
|
return(retval);
|
return(retval);
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|