From: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] devcgroup: skip superfluous checks when found the DEV_ALL elem
Date: Thu, 9 Apr 2009 17:06:10 -0700 [thread overview]
Message-ID: <20090409170610.9ee6e8e4.akpm@linux-foundation.org> (raw)
In-Reply-To: <49DAE8E4.2030106-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
On Tue, 07 Apr 2009 13:47:16 +0800
Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:
> While walking through the whitelist, if the DEV_ALL item is found,
> no more check is needed.
>
It's unobvious whether this is a behavioural change, a bugfix or just a
speedup?
>
> diff --git a/security/device_cgroup.c b/security/device_cgroup.c
> index 5fda7df..b8186ba 100644
> --- a/security/device_cgroup.c
> +++ b/security/device_cgroup.c
> @@ -490,7 +490,7 @@ int devcgroup_inode_permission(struct inode *inode, int mask)
>
> list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) {
> if (wh->type & DEV_ALL)
> - goto acc_check;
> + goto found;
> if ((wh->type & DEV_BLOCK) && !S_ISBLK(inode->i_mode))
> continue;
> if ((wh->type & DEV_CHAR) && !S_ISCHR(inode->i_mode))
> @@ -499,11 +499,12 @@ int devcgroup_inode_permission(struct inode *inode, int mask)
> continue;
> if (wh->minor != ~0 && wh->minor != iminor(inode))
> continue;
> -acc_check:
> +
> if ((mask & MAY_WRITE) && !(wh->access & ACC_WRITE))
> continue;
> if ((mask & MAY_READ) && !(wh->access & ACC_READ))
> continue;
> +found:
> rcu_read_unlock();
> return 0;
> }
> @@ -527,7 +528,7 @@ int devcgroup_inode_mknod(int mode, dev_t dev)
>
> list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) {
> if (wh->type & DEV_ALL)
> - goto acc_check;
> + goto found;
> if ((wh->type & DEV_BLOCK) && !S_ISBLK(mode))
> continue;
> if ((wh->type & DEV_CHAR) && !S_ISCHR(mode))
> @@ -536,9 +537,10 @@ int devcgroup_inode_mknod(int mode, dev_t dev)
> continue;
> if (wh->minor != ~0 && wh->minor != MINOR(dev))
> continue;
> -acc_check:
> +
> if (!(wh->access & ACC_MKNOD))
> continue;
> +found:
> rcu_read_unlock();
> return 0;
> }
next prev parent reply other threads:[~2009-04-10 0:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <49DAE8E4.2030106@cn.fujitsu.com>
[not found] ` <49DAE8E4.2030106-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2009-04-08 2:55 ` [PATCH] devcgroup: skip superfluous checks when found the DEV_ALL elem Serge E. Hallyn
2009-04-10 0:06 ` Andrew Morton [this message]
[not found] ` <20090409170610.9ee6e8e4.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2009-04-10 0:20 ` Li Zefan
2009-04-07 5:47 Li Zefan
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=20090409170610.9ee6e8e4.akpm@linux-foundation.org \
--to=akpm-de/tnxtf+jlsfhdxvbkv3wd2fqjk+8+b@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.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