From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762903AbXHXIok (ORCPT ); Fri, 24 Aug 2007 04:44:40 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756076AbXHXIob (ORCPT ); Fri, 24 Aug 2007 04:44:31 -0400 Received: from mailhub.sw.ru ([195.214.233.200]:22515 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755902AbXHXIoa (ORCPT ); Fri, 24 Aug 2007 04:44:30 -0400 Message-ID: <46CE99A6.6060100@openvz.org> Date: Fri, 24 Aug 2007 12:41:10 +0400 From: Pavel Emelyanov User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Andrew Morton CC: Alexey Dobriyan , Linux Containers , Linux Kernel Mailing List , Oleg Nesterov , Sukadev Bhattiprolu Subject: [PATCH] sys_getsid/sys_getpgid return wrong id for task from another ns Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/sys.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/sys.c b/kernel/sys.c index c7c4fa4..c827186 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -993,16 +995,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; @@ -1026,16 +1029,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;