Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755636AbcGTWx5 (ORCPT ); Wed, 20 Jul 2016 18:53:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:37218 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754782AbcGTWxz (ORCPT ); Wed, 20 Jul 2016 18:53:55 -0400 Subject: Re: [PATCH v1 2/3] cgroup: allow for unprivileged subtree management To: Tejun Heo References: <20160718161816.13040-1-asarai@suse.de> <20160718161816.13040-3-asarai@suse.de> <20160720154557.GF4574@htj.duckdns.org> Cc: Greg Kroah-Hartman , Li Zefan , Johannes Weiner , "Serge E. Hallyn" , Aditya Kali , Chris Wilson , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Christian Brauner , dev@opencontainers.org, James Bottomley From: Aleksa Sarai Message-ID: <49c34e82-54a8-642d-18ab-1b876cbe709a@suse.de> Date: Thu, 21 Jul 2016 08:59:12 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <20160720154557.GF4574@htj.duckdns.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> +static int cgroup_permission(struct inode *inode, struct kernfs_node *kn, >> + int mask) >> +{ >> + int ret; >> + struct cgroup *cgroup; >> + struct cgroup_namespace *cgroupns; >> + >> + /* >> + * First, compute the generic_permission return value. In most cases >> + * this will succeed and we can also avoid duplicating this code. >> + */ >> + >> + cgroup = kn->priv; >> + cgroup_get(cgroup); > > This pattern which is repated for cgroupns doesn't make sense. The > code is already assuming that the cgroup is safe to deref. Getting > its reference doesn't do anything. Getting it here would only make > sense if the pointer is passed to an asynchronous context. I'll send out a fixed patchset once we figure out the cgroups_proc_write_permission() stuff. -- Aleksa Sarai Software Engineer (Containers) SUSE Linux GmbH https://www.cyphar.com/