From 921280f85c8f444490e550c8115d92ea1e967028 Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Thu, 21 Apr 2016 09:59:49 -0700 Subject: [PATCH] Docker support: use task_XX_vnr() functions for accessing correct namespace --- executer/kernel/mcctrl/control.c | 20 ++++++++++---------- executer/kernel/mcctrl/syscall.c | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/executer/kernel/mcctrl/control.c b/executer/kernel/mcctrl/control.c index 944b1bf0..cd300625 100644 --- a/executer/kernel/mcctrl/control.c +++ b/executer/kernel/mcctrl/control.c @@ -505,7 +505,7 @@ retry_alloc: irqflags = ihk_ikc_spinlock_lock(&c->wq_list_lock); /* First see if there is one wait queue already */ list_for_each_entry(wqhln_iter, &c->wq_list, list) { - if (wqhln_iter->pid == current->tgid) { + if (wqhln_iter->pid == task_tgid_vnr(current)) { kfree(wqhln); wqhln = wqhln_iter; list_del(&wqhln->list); @@ -532,8 +532,8 @@ retry_alloc: c->param.request_va->args[0] == swd.pid) { dprintk("pid: %d, tid: %d: SC %d, swd.cpu: %d, WARNING: wait4() for self?\n", - current->tgid, - current->pid, + task_tgid_vnr(current), + task_pid_vnr(current); c->param.request_va->number, swd.cpu); @@ -892,7 +892,7 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename) spin_lock_irq(&mckernel_exec_file_lock); /* Find previous file (if exists) and drop it */ list_for_each_entry(mcef_iter, &mckernel_exec_files, list) { - if (mcef_iter->os == os && mcef_iter->pid == current->tgid) { + if (mcef_iter->os == os && mcef_iter->pid == task_tgid_vnr(current)) { allow_write_access(mcef_iter->fp); fput(mcef_iter->fp); list_del(&mcef_iter->list); @@ -903,16 +903,16 @@ int mcexec_open_exec(ihk_os_t os, char * __user filename) /* Add new exec file to the list */ mcef->os = os; - mcef->pid = current->tgid; + mcef->pid = task_tgid_vnr(current); mcef->fp = file; list_add_tail(&mcef->list, &mckernel_exec_files); /* Create /proc/self/exe entry */ - add_pid_entry(os_ind, current->tgid); - proc_exe_link(os_ind, current->tgid, fullpath); + add_pid_entry(os_ind, task_tgid_vnr(current)); + proc_exe_link(os_ind, task_tgid_vnr(current), fullpath); spin_unlock(&mckernel_exec_file_lock); - dprintk("%d open_exec and holding file: %s\n", (int)current->tgid, filename); + dprintk("%d open_exec and holding file: %s\n", (int)task_tgid_vnr(current), filename); kfree(pathbuf); @@ -939,13 +939,13 @@ int mcexec_close_exec(ihk_os_t os) spin_lock_irq(&mckernel_exec_file_lock); list_for_each_entry(mcef, &mckernel_exec_files, list) { - if (mcef->os == os && mcef->pid == current->tgid) { + if (mcef->os == os && mcef->pid == task_tgid_vnr(current)) { allow_write_access(mcef->fp); fput(mcef->fp); list_del(&mcef->list); kfree(mcef); found = 1; - dprintk("%d close_exec dropped executable \n", (int)current->tgid); + dprintk("%d close_exec dropped executable \n", (int)task_tgid_vnr(current)); break; } } diff --git a/executer/kernel/mcctrl/syscall.c b/executer/kernel/mcctrl/syscall.c index 8bf13beb..bb5c3a81 100644 --- a/executer/kernel/mcctrl/syscall.c +++ b/executer/kernel/mcctrl/syscall.c @@ -276,14 +276,14 @@ retry_alloc: } /* Prepare per-process wait queue head */ - wqhln->pid = current->tgid; + wqhln->pid = task_tgid_vnr(current); wqhln->req = 0; init_waitqueue_head(&wqhln->wq_syscall); irqflags = ihk_ikc_spinlock_lock(&channel->wq_list_lock); /* First see if there is a wait queue already */ list_for_each_entry(wqhln_iter, &channel->wq_list, list) { - if (wqhln_iter->pid == current->tgid) { + if (wqhln_iter->pid == task_tgid_vnr(current)) { kfree(wqhln); wqhln = wqhln_iter; list_del(&wqhln->list); @@ -482,7 +482,7 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) flags = ihk_ikc_spinlock_lock(&usrdata->per_proc_list_lock); list_for_each_entry(ppd_iter, &usrdata->per_proc_list, list) { - if (ppd_iter->pid == current->tgid) { + if (ppd_iter->pid == task_tgid_vnr(current)) { ppd = ppd_iter; break; } @@ -490,7 +490,7 @@ static int rus_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) ihk_ikc_spinlock_unlock(&usrdata->per_proc_list_lock, flags); if (!ppd) { - printk("ERROR: no per process data for pid %d\n", current->tgid); + printk("ERROR: no per process data for pid %d\n", task_tgid_vnr(current)); return VM_FAULT_SIGBUS; } @@ -1653,7 +1653,7 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall goto out; } - ppd->pid = current->tgid; + ppd->pid = task_tgid_vnr(current); ppd->rpgtable = sc->args[2]; flags = ihk_ikc_spinlock_lock(&usrdata->per_proc_list_lock); @@ -1679,7 +1679,7 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall flags = ihk_ikc_spinlock_lock(&usrdata->per_proc_list_lock); list_for_each_entry(ppd_iter, &usrdata->per_proc_list, list) { - if (ppd_iter->pid == current->tgid) { + if (ppd_iter->pid == task_tgid_vnr(current)) { ppd = ppd_iter; break; } @@ -1689,13 +1689,13 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall list_del(&ppd->list); dprintk("pid: %d, tid: %d: rpgtable for %d (0x%lx) removed\n", - current->tgid, current->pid, ppd->pid, ppd->rpgtable); + task_tgid_vnr(current), current->pid, ppd->pid, ppd->rpgtable); kfree(ppd); } else { printk("WARNING: no per process data for pid %d ?\n", - current->tgid); + task_tgid_vnr(current)); } ihk_ikc_spinlock_unlock(&usrdata->per_proc_list_lock, flags);