Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754737AbYGAJqZ (ORCPT ); Tue, 1 Jul 2008 05:46:25 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752093AbYGAJqN (ORCPT ); Tue, 1 Jul 2008 05:46:13 -0400 Received: from e28smtp05.in.ibm.com ([59.145.155.5]:42456 "EHLO e28esmtp05.in.ibm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751675AbYGAJqM (ORCPT ); Tue, 1 Jul 2008 05:46:12 -0400 Date: Tue, 1 Jul 2008 15:15:45 +0530 From: Dhaval Giani To: Paul Menage Cc: Andrew Morton , Balbir Singh , Sudhir Kumar , lkml , containers@linux.vnet.ibm.com Subject: Attaching PID 0 to a cgroup Message-ID: <20080701094545.GD3925@linux.vnet.ibm.com> Reply-To: Dhaval Giani MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1868 Lines: 60 Hi Paul, Attaching PID 0 to a cgroup caused the current task to be attached to the cgroup. Looking at the code, if (pid) { rcu_read_lock(); tsk = find_task_by_vpid(pid); if (!tsk || tsk->flags & PF_EXITING) { rcu_read_unlock(); return -ESRCH; } get_task_struct(tsk); rcu_read_unlock(); if ((current->euid) && (current->euid != tsk->uid) && (current->euid != tsk->suid)) { put_task_struct(tsk); return -EACCES; } } else { tsk = current; get_task_struct(tsk); } I was wondering, why this was done. It seems to be unexpected behavior. Wouldn't something like the following be a better response? (I've used EINVAL, but I can change it to ESRCH if that is better.) --- cgroups: Don't allow PID 0 to be attached to a group Currently when one trys to attach PID 0 to a cgroup, it attaches the current task. That is not expected behavior. It should return an error instead. Signed-off-by: Dhaval Giani Index: linux-2.6/kernel/cgroup.c =================================================================== --- linux-2.6.orig/kernel/cgroup.c +++ linux-2.6/kernel/cgroup.c @@ -1309,8 +1309,7 @@ static int attach_task_by_pid(struct cgr return -EACCES; } } else { - tsk = current; - get_task_struct(tsk); + return -EINVAL; } ret = cgroup_attach_task(cgrp, tsk); -- regards, Dhaval -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/