From: Pavel Emelyanov When calling the sys_getsid/sys_getpgid for task, that actually lives in another namespace (sub-namespace) the return value should be not the id as this task sees it, but the id as the caller does. Signed-off-by: Pavel Emelyanov Signed-off-by: Andrew Morton --- kernel/sys.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff -puN kernel/sys.c~pid-namespaces-changes-to-show-virtual-ids-to-user-sys_getsid-sys_getpgid-return-wrong-id-for-task-from-another kernel/sys.c --- a/kernel/sys.c~pid-namespaces-changes-to-show-virtual-ids-to-user-sys_getsid-sys_getpgid-return-wrong-id-for-task-from-another +++ a/kernel/sys.c @@ -992,16 +992,17 @@ asmlinkage long sys_getpgid(pid_t pid) else { int retval; struct task_struct *p; + struct pid_namespace *ns; - read_lock(&tasklist_lock); - p = find_task_by_pid_ns(pid, - current->nsproxy->pid_ns); + ns = current->nsproxy->pid_ns; + read_lock(&tasklist_lock); + p = find_task_by_pid_ns(pid, ns); retval = -ESRCH; if (p) { retval = security_task_getpgid(p); if (!retval) - retval = task_pgrp_vnr(p); + retval = task_pgrp_nr_ns(p, ns); } read_unlock(&tasklist_lock); return retval; @@ -1025,16 +1026,17 @@ asmlinkage long sys_getsid(pid_t pid) else { int retval; struct task_struct *p; + struct pid_namespace *ns; - read_lock(&tasklist_lock); - p = find_task_by_pid_ns(pid, - current->nsproxy->pid_ns); + ns = current->nsproxy->pid_ns; + read_lock(&tasklist_lock); + p = find_task_by_pid_ns(pid, ns); retval = -ESRCH; if (p) { retval = security_task_getsid(p); if (!retval) - retval = task_session_vnr(p); + retval = task_session_nr_ns(p, ns); } read_unlock(&tasklist_lock); return retval; _