Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S944231AbcJSUvQ (ORCPT ); Wed, 19 Oct 2016 16:51:16 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:33236 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938152AbcJSUvO (ORCPT ); Wed, 19 Oct 2016 16:51:14 -0400 Date: Wed, 19 Oct 2016 16:51:11 -0400 From: Tejun Heo To: Andy Lutomirski Cc: John Stultz , lkml , Li Zefan , Jonathan Corbet , "open list:CONTROL GROUP (CGROUP)" , Android Kernel Team , Rom Lemarchand , Colin Cross , Dmitry Shmidt , Ricky Zhou , Dmitry Torokhov , Todd Kjos , Christian Poetzsch , Amit Pundir , "Serge E . Hallyn" , Linux API Subject: Re: [PATCH] cgroup: Add new capability to allow a process to migrate other tasks between cgroups Message-ID: <20161019205111.GF3044@htj.duckdns.org> References: <1476743724-9104-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1346 Lines: 32 Hello, Andy. On Mon, Oct 17, 2016 at 03:40:37PM -0700, Andy Lutomirski wrote: > > @@ -2856,7 +2856,8 @@ static int cgroup_procs_write_permission(struct task_struct *task, > > */ > > if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) && > > !uid_eq(cred->euid, tcred->uid) && > > - !uid_eq(cred->euid, tcred->suid)) > > + !uid_eq(cred->euid, tcred->suid) && > > + !ns_capable(tcred->user_ns, CAP_CGROUP_MIGRATE)) > > ret = -EACCES; > > This logic seems rather confused to me. Without this patch, a user > can write to procs if it's root *or* it matches the target uid *or* it > matches the target suid. How does this make sense? How about > ptrace_may_access(...) || ns_capable(tcred->user_ns, > CAP_CGROUP_MIGRATE)? Yeah, it's weird. The problem is that there was no delegation model defined on v1 and it used a hybrid of file + ptracey access checks. The goal, I think, was disallowing !root user from pulling in random tasks into a cgroup it has write access to, which was possible because there was no isolation on the delegation boundary. Given how long it has been out in the wild, I don't think changing the logic is a good idea. We should simply replace GLOBAL_ROOT_UID test with CAT_WHATEVER_WE_PICK test and just ignore the whole thing on v2. Thanks. -- tejun