public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
From: Serge Hallyn <serge.hallyn@canonical.com>
To: Aristeu Rozanski <aris@redhat.com>
Cc: linux-kernel@vger.kernel.org, Dave Jones <davej@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>, Li Zefan <lizefan@huawei.com>,
	James Morris <jmorris@namei.org>,
	Pavel Emelyanov <xemul@openvz.org>, Jiri Slaby <jslaby@suse.cz>,
	cgroups@vger.kernel.org
Subject: Re: [PATCH 2/4] device_cgroup: rename deny_all to behavior
Date: Mon, 22 Oct 2012 11:12:57 -0500	[thread overview]
Message-ID: <20121022161257.GB23199@sergelap> (raw)
In-Reply-To: <20121022134536.839559616@napanee.usersys.redhat.com>

Quoting Aristeu Rozanski (aris@redhat.com):
> This was done in a v2 patch but v1 ended up being committed. The variable name
> is less confusing and stores the default behavior when no matching exception
> exists.
> 
> 
> Cc: Dave Jones <davej@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Tejun Heo <tj@kernel.org>
> Cc: Li Zefan <lizefan@huawei.com>
> Cc: James Morris <jmorris@namei.org>
> Cc: Pavel Emelyanov <xemul@openvz.org>
> Cc: Serge Hallyn <serge.hallyn@canonical.com>

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>

> Cc: Jiri Slaby <jslaby@suse.cz>
> Signed-off-by: Aristeu Rozanski <aris@redhat.com>
> 
> ---
>  security/device_cgroup.c |   25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> --- github.orig/security/device_cgroup.c	2012-10-19 16:35:37.936804289 -0400
> +++ github/security/device_cgroup.c	2012-10-19 16:35:46.366102913 -0400
> @@ -42,7 +42,10 @@ struct dev_exception_item {
>  struct dev_cgroup {
>  	struct cgroup_subsys_state css;
>  	struct list_head exceptions;
> -	bool deny_all;
> +	enum {
> +		DEVCG_DEFAULT_ALLOW,
> +		DEVCG_DEFAULT_DENY,
> +	} behavior;
>  };
>  
>  static inline struct dev_cgroup *css_to_devcgroup(struct cgroup_subsys_state *s)
> @@ -182,13 +185,13 @@ static struct cgroup_subsys_state *devcg
>  	parent_cgroup = cgroup->parent;
>  
>  	if (parent_cgroup == NULL)
> -		dev_cgroup->deny_all = false;
> +		dev_cgroup->behavior = DEVCG_DEFAULT_ALLOW;
>  	else {
>  		parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup);
>  		mutex_lock(&devcgroup_mutex);
>  		ret = dev_exceptions_copy(&dev_cgroup->exceptions,
>  					  &parent_dev_cgroup->exceptions);
> -		dev_cgroup->deny_all = parent_dev_cgroup->deny_all;
> +		dev_cgroup->behavior = parent_dev_cgroup->behavior;
>  		mutex_unlock(&devcgroup_mutex);
>  		if (ret) {
>  			kfree(dev_cgroup);
> @@ -260,7 +263,7 @@ static int devcgroup_seq_read(struct cgr
>  	 * - List the exceptions in case the default policy is to deny
>  	 * This way, the file remains as a "whitelist of devices"
>  	 */
> -	if (devcgroup->deny_all == false) {
> +	if (devcgroup->behavior == DEVCG_DEFAULT_ALLOW) {
>  		set_access(acc, ACC_MASK);
>  		set_majmin(maj, ~0);
>  		set_majmin(min, ~0);
> @@ -314,12 +317,12 @@ 		if (ex->minor != ~0 && ex->minor != re
>  	 * In two cases we'll consider this new exception valid:
>  	 * - the dev cgroup has its default policy to allow + exception list:
>  	 *   the new exception should *not* match any of the exceptions
> -	 *   (!deny_all, !match)
> +	 *   (behavior == DEVCG_DEFAULT_ALLOW, !match)
>  	 * - the dev cgroup has its default policy to deny + exception list:
>  	 *   the new exception *should* match the exceptions
> -	 *   (deny_all, match)
> +	 *   (behavior == DEVCG_DEFAULT_DENY, match)
>  	 */
> -	if (dev_cgroup->deny_all == match)
> +	if ((dev_cgroup->behavior == DEVCG_DEFAULT_DENY) == match)
>  		return 1;
>  	return 0;
>  }
> @@ -375,11 +378,11 @@ 	memset(&ex, 0, sizeof(ex));
>  			if (!parent_has_perm(devcgroup, &ex))
>  				return -EPERM;
>  			dev_exception_clean(devcgroup);
> -			devcgroup->deny_all = false;
> +			devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
>  			break;
>  		case DEVCG_DENY:
>  			dev_exception_clean(devcgroup);
> -			devcgroup->deny_all = true;
> +			devcgroup->behavior = DEVCG_DEFAULT_DENY;
>  			break;
>  		default:
>  			return -EINVAL;
> @@ -452,7 +455,7 @@ 		case '\0':
>  		 * an matching exception instead. And be silent about it: we
>  		 * don't want to break compatibility
>  		 */
> -		if (devcgroup->deny_all == false) {
> +		if (devcgroup->behavior == DEVCG_DEFAULT_ALLOW) {
>  			dev_exception_rm(devcgroup, &ex);
>  			return 0;
>  		}
> @@ -463,7 +466,7 @@ 			return 0;
>  		 * an matching exception instead. And be silent about it: we
>  		 * don't want to break compatibility
>  		 */
> -		if (devcgroup->deny_all == true) {
> +		if (devcgroup->behavior == DEVCG_DEFAULT_DENY) {
>  			dev_exception_rm(devcgroup, &ex);
>  			return 0;
>  		}
> 

  reply	other threads:[~2012-10-22 16:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-22 13:45 [PATCH 0/4] Rebase device_cgroup v2 patchset Aristeu Rozanski
2012-10-22 13:45 ` [PATCH 1/4] cgroup: fix invalid rcu dereference Aristeu Rozanski
     [not found]   ` <20121022134536.543579196-cd6kKtb6gxi3M6m420IelR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2012-10-22 16:11     ` Serge Hallyn
2012-10-23 12:50     ` Jiri Slaby
     [not found]       ` <508692A8.6090706-AlSwsSmVLrQ@public.gmane.org>
2012-10-23 13:17         ` Aristeu Rozanski
     [not found]           ` <20121023131746.GB14085-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-10-23 13:53             ` Jiri Slaby
2012-10-22 13:45 ` [PATCH 2/4] device_cgroup: rename deny_all to behavior Aristeu Rozanski
2012-10-22 16:12   ` Serge Hallyn [this message]
2012-10-22 13:45 ` [PATCH 3/4] device_cgroup: stop using simple_strtoul() Aristeu Rozanski
     [not found]   ` <20121022134537.125748392-cd6kKtb6gxi3M6m420IelR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2012-10-22 16:14     ` Serge Hallyn
2012-10-22 13:45 ` [PATCH 4/4] device_cgroup: add proper checking when changing default behavior Aristeu Rozanski
     [not found]   ` <20121022134537.447117744-cd6kKtb6gxi3M6m420IelR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2012-10-22 16:16     ` Serge Hallyn
     [not found] ` <20121022134536.172969567-cd6kKtb6gxi3M6m420IelR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2012-10-22 19:58   ` [PATCH 0/4] Rebase device_cgroup v2 patchset Andrew Morton
     [not found]     ` <20121022125838.20cdc240.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2012-10-22 20:14       ` Aristeu Rozanski
2013-05-14 15:05 ` Serge Hallyn
2013-05-14 15:51   ` Aristeu Rozanski
     [not found]     ` <20130514155111.GJ680-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-05-14 16:22       ` Serge Hallyn
2013-05-14 21:02         ` Eric W. Biederman
     [not found]           ` <87y5bhwa0h.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2013-05-16  1:14             ` Serge E. Hallyn
     [not found]               ` <20130516011401.GA17462-anj0Drq5vpzx6HRWoRZK3AC/G2K4zDHf@public.gmane.org>
2013-05-16  1:23                 ` Serge E. Hallyn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121022161257.GB23199@sergelap \
    --to=serge.hallyn@canonical.com \
    --cc=akpm@linux-foundation.org \
    --cc=aris@redhat.com \
    --cc=cgroups@vger.kernel.org \
    --cc=davej@redhat.com \
    --cc=jmorris@namei.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=tj@kernel.org \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox