Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751301AbaKDAuG (ORCPT ); Mon, 3 Nov 2014 19:50:06 -0500 Received: from mail-ob0-f176.google.com ([209.85.214.176]:43268 "EHLO mail-ob0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750905AbaKDAuD (ORCPT ); Mon, 3 Nov 2014 19:50:03 -0500 MIME-Version: 1.0 In-Reply-To: References: <1414783141-6947-1-git-send-email-adityakali@google.com> <1414783141-6947-8-git-send-email-adityakali@google.com> From: Aditya Kali Date: Mon, 3 Nov 2014 16:49:41 -0800 Message-ID: Subject: Re: [PATCHv2 7/7] cgroup: mount cgroupns-root when inside non-init cgroupns To: Andy Lutomirski Cc: Tejun Heo , Li Zefan , Serge Hallyn , "Eric W. Biederman" , cgroups@vger.kernel.org, "linux-kernel@vger.kernel.org" , Linux API , Ingo Molnar , Linux Containers , Rohit Jnagal Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 3, 2014 at 4:17 PM, Andy Lutomirski wrote: > On Mon, Nov 3, 2014 at 4:12 PM, Aditya Kali wrote: >> On Mon, Nov 3, 2014 at 3:48 PM, Andy Lutomirski wrote: >>> On Mon, Nov 3, 2014 at 3:23 PM, Aditya Kali wrote: >>>> On Mon, Nov 3, 2014 at 3:15 PM, Andy Lutomirski wrote: >>>>> On Mon, Nov 3, 2014 at 3:12 PM, Aditya Kali wrote: >>>>>> On Fri, Oct 31, 2014 at 5:07 PM, Andy Lutomirski wrote: >>>>>>> On Fri, Oct 31, 2014 at 12:19 PM, Aditya Kali wrote: >>>>>>>> if (opts->flags & CGRP_ROOT_SANE_BEHAVIOR) { >>>>>>>> pr_warn("sane_behavior: this is still under development and its behaviors will change, proceed at your own risk\n"); >>>>>>>> - if (nr_opts != 1) { >>>>>>>> + if (nr_opts > 1) { >>>>>>>> pr_err("sane_behavior: no other mount options allowed\n"); >>>>>>>> return -EINVAL; >>>>>>> >>>>>>> This looks wrong. But, if you make the change above, then it'll be right. >>>>>>> >>>>>> >>>>>> It would have been nice if simple 'mount -t cgroup cgroup ' from >>>>>> cgroupns does the right thing automatically. >>>>>> >>>>> >>>>> This is a debatable point, but it's not what I meant. Won't your code >>>>> let 'mount -t cgroup -o one_evil_flag cgroup mountpoint' through? >>>>> >>>> >>>> I don't think so. This check "if (nr_opts > 1)" is nested under "if >>>> (opts->flags & CGRP_ROOT_SANE_BEHAVIOR)". So we know that there is >>>> atleast 1 option ('__DEVEL__sane_behavior') present (implicit or not). >>>> Addition of 'one_evil_flag' will make nr_opts = 2 and result in EINVAL >>>> here. >>> >>> But the implicit __DEVEL__sane_behavior doesn't increment nr_opts, right? >>> >> >> Yes. Hence this change makes sure that we don't return EINVAL when >> nr_opts == 0 or nr_opts == 1 :) >> That way, both of the following are equivalent when inside non-init cgroupns: >> >> (1) $ mount -t cgroup -o __DEVEL__sane_behavior cgroup mountpoint >> (2) $ mount -t cgroup cgroup mountpoint >> >> Any other mount option will trigger the error here. > > I still don't get it. Can you walk me through why mount -o > some_other_option -t cgroup cgroup mountpoint causes -EINVAL? > Argh! You are right. I was totally convinced that this works. But it clearly doesn't if you specify 1 legit mount option. I wanted to make it work for both cases (1) and (2) above. But then this check will have to be changed :( Sorry about the back and forth. I am just going to make it return EINVAL if __DEVEL_sane_behavior is not specified as suggested in the beginning. > --Andy -- Aditya -- 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/