Revert "mcexec_open_exec: guard fput and add to mckernel_exec_files with spin_lock_irqsave"
This reverts commit cba263ff12.
Change-Id: Ifcd03a2048a3f9d6c155dd8ecd522081b5dde276
This commit is contained in:
@ -1799,7 +1799,8 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
LIST_HEAD(mckernel_exec_files);
|
LIST_HEAD(mckernel_exec_files);
|
||||||
static DEFINE_SPINLOCK(mckernel_exec_file_lock);
|
DEFINE_SEMAPHORE(mckernel_exec_file_lock);
|
||||||
|
|
||||||
|
|
||||||
struct mckernel_exec_file {
|
struct mckernel_exec_file {
|
||||||
ihk_os_t os;
|
ihk_os_t os;
|
||||||
@ -1976,7 +1977,6 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
|||||||
char *fullpath = NULL;
|
char *fullpath = NULL;
|
||||||
char *kfilename = NULL;
|
char *kfilename = NULL;
|
||||||
int len;
|
int len;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (os_ind < 0) {
|
if (os_ind < 0) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -1991,39 +1991,38 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
|||||||
kfilename = kmalloc(PATH_MAX, GFP_KERNEL);
|
kfilename = kmalloc(PATH_MAX, GFP_KERNEL);
|
||||||
if (!kfilename) {
|
if (!kfilename) {
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
|
kfree(pathbuf);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strncpy_from_user(kfilename, filename, PATH_MAX);
|
len = strncpy_from_user(kfilename, filename, PATH_MAX);
|
||||||
if (unlikely(len < 0)) {
|
if (unlikely(len < 0)) {
|
||||||
retval = -EINVAL;
|
retval = -EINVAL;
|
||||||
goto out;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fget and list_add should not be interrupted by hardware interrupt */
|
/* fget and list_add should be atomic */
|
||||||
spin_lock_irqsave(&mckernel_exec_file_lock, flags);
|
down(&mckernel_exec_file_lock);
|
||||||
|
|
||||||
file = open_exec(kfilename);
|
file = open_exec(kfilename);
|
||||||
retval = PTR_ERR(file);
|
retval = PTR_ERR(file);
|
||||||
if (IS_ERR(file)) {
|
if (IS_ERR(file)) {
|
||||||
spin_unlock_irqrestore(&mckernel_exec_file_lock, flags);
|
up(&mckernel_exec_file_lock);
|
||||||
goto out;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
fullpath = d_path(&file->f_path, pathbuf, PATH_MAX);
|
||||||
if (IS_ERR(fullpath)) {
|
if (IS_ERR(fullpath)) {
|
||||||
fput(file);
|
up(&mckernel_exec_file_lock);
|
||||||
spin_unlock_irqrestore(&mckernel_exec_file_lock, flags);
|
|
||||||
retval = PTR_ERR(fullpath);
|
retval = PTR_ERR(fullpath);
|
||||||
goto out;
|
goto out_put_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcef = kmalloc(sizeof(*mcef), GFP_KERNEL);
|
mcef = kmalloc(sizeof(*mcef), GFP_KERNEL);
|
||||||
if (!mcef) {
|
if (!mcef) {
|
||||||
fput(file);
|
up(&mckernel_exec_file_lock);
|
||||||
spin_unlock_irqrestore(&mckernel_exec_file_lock, flags);
|
|
||||||
retval = -ENOMEM;
|
retval = -ENOMEM;
|
||||||
goto out;
|
goto out_put_file;
|
||||||
}
|
}
|
||||||
memset(mcef, 0, sizeof(struct mckernel_exec_file)); /* debug */
|
memset(mcef, 0, sizeof(struct mckernel_exec_file)); /* debug */
|
||||||
|
|
||||||
@ -2047,15 +2046,22 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename)
|
|||||||
/* Create /proc/self/exe entry */
|
/* Create /proc/self/exe entry */
|
||||||
add_pid_entry(os_ind, task_tgid_vnr(current));
|
add_pid_entry(os_ind, task_tgid_vnr(current));
|
||||||
proc_exe_link(os_ind, task_tgid_vnr(current), fullpath);
|
proc_exe_link(os_ind, task_tgid_vnr(current), fullpath);
|
||||||
spin_unlock_irqrestore(&mckernel_exec_file_lock, flags);
|
up(&mckernel_exec_file_lock);
|
||||||
|
|
||||||
dprintk("%d open_exec and holding file: %s\n", (int)task_tgid_vnr(current),
|
dprintk("%d open_exec and holding file: %s\n", (int)task_tgid_vnr(current),
|
||||||
kfilename);
|
kfilename);
|
||||||
|
|
||||||
retval = 0;
|
kfree(kfilename);
|
||||||
out:
|
kfree(pathbuf);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
out_put_file:
|
||||||
|
fput(file);
|
||||||
|
out_free:
|
||||||
kfree(pathbuf);
|
kfree(pathbuf);
|
||||||
kfree(kfilename);
|
kfree(kfilename);
|
||||||
|
out:
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2063,14 +2069,13 @@ int mcexec_close_exec(ihk_os_t os, int pid)
|
|||||||
{
|
{
|
||||||
struct mckernel_exec_file *mcef = NULL;
|
struct mckernel_exec_file *mcef = NULL;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
int os_ind = ihk_host_os_get_index(os);
|
int os_ind = ihk_host_os_get_index(os);
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (os_ind < 0) {
|
if (os_ind < 0) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&mckernel_exec_file_lock, flags);
|
down(&mckernel_exec_file_lock);
|
||||||
list_for_each_entry(mcef, &mckernel_exec_files, list) {
|
list_for_each_entry(mcef, &mckernel_exec_files, list) {
|
||||||
if (mcef->os == os && mcef->pid == pid) {
|
if (mcef->os == os && mcef->pid == pid) {
|
||||||
allow_write_access(mcef->fp);
|
allow_write_access(mcef->fp);
|
||||||
@ -2083,7 +2088,7 @@ int mcexec_close_exec(ihk_os_t os, int pid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&mckernel_exec_file_lock, flags);
|
up(&mckernel_exec_file_lock);
|
||||||
|
|
||||||
return (found ? 0 : EINVAL);
|
return (found ? 0 : EINVAL);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user