fix to compile on CentOS 6
This commit is contained in:
@ -13,7 +13,6 @@
|
|||||||
#include <linux/version.h>
|
#include <linux/version.h>
|
||||||
#include "mcctrl.h"
|
#include "mcctrl.h"
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
|
|
||||||
static int pathcheck(const char *file, const char *list)
|
static int pathcheck(const char *file, const char *list)
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
@ -40,13 +39,20 @@ static int pathcheck(const char *file, const char *list)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_elf(struct linux_binprm *bprm)
|
static int load_elf(struct linux_binprm *bprm
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||||
|
, struct pt_regs *regs
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
const char *i_name;
|
char mcexec[BINPRM_BUF_SIZE];
|
||||||
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
|
||||||
|
const
|
||||||
|
#endif
|
||||||
|
char *wp;
|
||||||
char *cp;
|
char *cp;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
char interp[BINPRM_BUF_SIZE];
|
int rc;
|
||||||
int retval;
|
|
||||||
struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf;
|
struct elfhdr *elf_ex = (struct elfhdr *)bprm->buf;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
@ -106,12 +112,16 @@ static int load_elf(struct linux_binprm *bprm)
|
|||||||
for(i = 0, st = 0; mode != 2;){
|
for(i = 0, st = 0; mode != 2;){
|
||||||
if(st == 0){
|
if(st == 0){
|
||||||
off = p & ~PAGE_MASK;
|
off = p & ~PAGE_MASK;
|
||||||
retval = get_user_pages(current, bprm->mm,
|
rc = get_user_pages(current, bprm->mm,
|
||||||
bprm->p, 1, 0, 1,
|
bprm->p, 1, 0, 1,
|
||||||
&page, NULL);
|
&page, NULL);
|
||||||
if(retval <= 0)
|
if(rc <= 0)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
addr = kmap_atomic(page);
|
addr = kmap_atomic(page
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
|
||||||
|
, KM_USER0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
st = 1;
|
st = 1;
|
||||||
}
|
}
|
||||||
if(addr[off]){
|
if(addr[off]){
|
||||||
@ -161,7 +171,11 @@ static int load_elf(struct linux_binprm *bprm)
|
|||||||
off++;
|
off++;
|
||||||
p++;
|
p++;
|
||||||
if(off == PAGE_SIZE || mode == 2){
|
if(off == PAGE_SIZE || mode == 2){
|
||||||
kunmap_atomic(addr);
|
kunmap_atomic(addr
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
|
||||||
|
, KM_USER0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
put_page(page);
|
put_page(page);
|
||||||
st = 0;
|
st = 0;
|
||||||
}
|
}
|
||||||
@ -169,62 +183,62 @@ static int load_elf(struct linux_binprm *bprm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!env_mcexec || !strcmp(env_mcexec, "0") || !strcmp(env_mcexec, "off"))
|
if(!env_mcexec || !strcmp(env_mcexec, "0") || !strcmp(env_mcexec, "off"))
|
||||||
retval = 1;
|
rc = 1;
|
||||||
else{
|
else{
|
||||||
retval = 0;
|
rc = 0;
|
||||||
if(strchr(env_mcexec, '/') && strlen(env_mcexec) < BINPRM_BUF_SIZE)
|
if(strchr(env_mcexec, '/') && strlen(env_mcexec) < BINPRM_BUF_SIZE)
|
||||||
strcpy(interp, env_mcexec);
|
strcpy(mcexec, env_mcexec);
|
||||||
else
|
else
|
||||||
strcpy(interp, MCEXEC_PATH);
|
strcpy(mcexec, MCEXEC_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(retval);
|
if(rc);
|
||||||
else if(env_mcexec_wl)
|
else if(env_mcexec_wl)
|
||||||
retval = !pathcheck(bprm->interp, env_mcexec_wl);
|
rc = !pathcheck(bprm->interp, env_mcexec_wl);
|
||||||
else if(env_mcexec_bl)
|
else if(env_mcexec_bl)
|
||||||
retval = pathcheck(bprm->interp, env_mcexec_bl);
|
rc = pathcheck(bprm->interp, env_mcexec_bl);
|
||||||
else
|
else
|
||||||
retval = pathcheck(bprm->interp, "/usr:/bin:/sbin:/opt");
|
rc = pathcheck(bprm->interp, "/usr:/bin:/sbin:/opt");
|
||||||
|
|
||||||
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(retval)
|
if(rc)
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
file = open_exec(interp);
|
file = open_exec(mcexec);
|
||||||
if (IS_ERR(file))
|
if (IS_ERR(file))
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
retval = remove_arg_zero(bprm);
|
rc = remove_arg_zero(bprm);
|
||||||
if (retval){
|
if (rc){
|
||||||
fput(file);
|
fput(file);
|
||||||
return retval;
|
return rc;
|
||||||
}
|
}
|
||||||
retval = copy_strings_kernel(1, &bprm->interp, bprm);
|
rc = copy_strings_kernel(1, &bprm->interp, bprm);
|
||||||
if (retval < 0){
|
if (rc < 0){
|
||||||
fput(file);
|
fput(file);
|
||||||
return retval;
|
return rc;
|
||||||
}
|
}
|
||||||
bprm->argc++;
|
bprm->argc++;
|
||||||
i_name = interp;
|
wp = mcexec;
|
||||||
retval = copy_strings_kernel(1, &i_name, bprm);
|
rc = copy_strings_kernel(1, &wp, bprm);
|
||||||
if (retval){
|
if (rc){
|
||||||
fput(file);
|
fput(file);
|
||||||
return retval;
|
return rc;
|
||||||
}
|
}
|
||||||
bprm->argc++;
|
bprm->argc++;
|
||||||
#if 1
|
#if 1
|
||||||
retval = bprm_change_interp(interp, bprm);
|
rc = bprm_change_interp(mcexec, bprm);
|
||||||
if (retval < 0){
|
if (rc < 0){
|
||||||
fput(file);
|
fput(file);
|
||||||
return retval;
|
return rc;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(brpm->interp != bprm->filename)
|
if(brpm->interp != bprm->filename)
|
||||||
kfree(brpm->interp);
|
kfree(brpm->interp);
|
||||||
kfree(brpm->filename);
|
kfree(brpm->filename);
|
||||||
bprm->filename = bprm->interp = kstrdup(interp, GFP_KERNEL);
|
bprm->filename = bprm->interp = kstrdup(mcexec, GFP_KERNEL);
|
||||||
if(!bprm->interp){
|
if(!bprm->interp){
|
||||||
fput(file);
|
fput(file);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -235,11 +249,15 @@ static int load_elf(struct linux_binprm *bprm)
|
|||||||
fput(bprm->file);
|
fput(bprm->file);
|
||||||
bprm->file = file;
|
bprm->file = file;
|
||||||
|
|
||||||
retval = prepare_binprm(bprm);
|
rc = prepare_binprm(bprm);
|
||||||
if (retval < 0){
|
if (rc < 0){
|
||||||
return retval;
|
return rc;
|
||||||
}
|
}
|
||||||
return search_binary_handler(bprm);
|
return search_binary_handler(bprm
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||||
|
, regs
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct linux_binfmt mcexec_format = {
|
static struct linux_binfmt mcexec_format = {
|
||||||
@ -256,12 +274,3 @@ void __exit binfmt_mcexec_exit(void)
|
|||||||
{
|
{
|
||||||
unregister_binfmt(&mcexec_format);
|
unregister_binfmt(&mcexec_format);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void __init binfmt_mcexec_init(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void __exit binfmt_mcexec_exit(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|||||||
Reference in New Issue
Block a user