mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 19:56:18 +00:00
devcgroup: skip superfluous checks when found the DEV_ALL elem
While walking through the whitelist, if the DEV_ALL item is found, no more check is needed. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
f9ab5b5b0f
commit
cd5008196f
1 changed files with 6 additions and 4 deletions
|
@ -490,7 +490,7 @@ int devcgroup_inode_permission(struct inode *inode, int mask)
|
||||||
|
|
||||||
list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) {
|
list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) {
|
||||||
if (wh->type & DEV_ALL)
|
if (wh->type & DEV_ALL)
|
||||||
goto acc_check;
|
goto found;
|
||||||
if ((wh->type & DEV_BLOCK) && !S_ISBLK(inode->i_mode))
|
if ((wh->type & DEV_BLOCK) && !S_ISBLK(inode->i_mode))
|
||||||
continue;
|
continue;
|
||||||
if ((wh->type & DEV_CHAR) && !S_ISCHR(inode->i_mode))
|
if ((wh->type & DEV_CHAR) && !S_ISCHR(inode->i_mode))
|
||||||
|
@ -499,11 +499,12 @@ int devcgroup_inode_permission(struct inode *inode, int mask)
|
||||||
continue;
|
continue;
|
||||||
if (wh->minor != ~0 && wh->minor != iminor(inode))
|
if (wh->minor != ~0 && wh->minor != iminor(inode))
|
||||||
continue;
|
continue;
|
||||||
acc_check:
|
|
||||||
if ((mask & MAY_WRITE) && !(wh->access & ACC_WRITE))
|
if ((mask & MAY_WRITE) && !(wh->access & ACC_WRITE))
|
||||||
continue;
|
continue;
|
||||||
if ((mask & MAY_READ) && !(wh->access & ACC_READ))
|
if ((mask & MAY_READ) && !(wh->access & ACC_READ))
|
||||||
continue;
|
continue;
|
||||||
|
found:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return 0;
|
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) {
|
list_for_each_entry_rcu(wh, &dev_cgroup->whitelist, list) {
|
||||||
if (wh->type & DEV_ALL)
|
if (wh->type & DEV_ALL)
|
||||||
goto acc_check;
|
goto found;
|
||||||
if ((wh->type & DEV_BLOCK) && !S_ISBLK(mode))
|
if ((wh->type & DEV_BLOCK) && !S_ISBLK(mode))
|
||||||
continue;
|
continue;
|
||||||
if ((wh->type & DEV_CHAR) && !S_ISCHR(mode))
|
if ((wh->type & DEV_CHAR) && !S_ISCHR(mode))
|
||||||
|
@ -536,9 +537,10 @@ int devcgroup_inode_mknod(int mode, dev_t dev)
|
||||||
continue;
|
continue;
|
||||||
if (wh->minor != ~0 && wh->minor != MINOR(dev))
|
if (wh->minor != ~0 && wh->minor != MINOR(dev))
|
||||||
continue;
|
continue;
|
||||||
acc_check:
|
|
||||||
if (!(wh->access & ACC_MKNOD))
|
if (!(wh->access & ACC_MKNOD))
|
||||||
continue;
|
continue;
|
||||||
|
found:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue