diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2011-11-17 02:15:31 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-04-07 19:55:51 -0400 |
commit | c4a4d603796c727b9555867571f89483be9c565e (patch) | |
tree | ae3b47a7b8b35c866df53cb4b4a051d49a28904a /kernel/sys.c | |
parent | 7e6bd8fadd1216f50468f965d0308f45e5109ced (diff) |
userns: Use cred->user_ns instead of cred->user->user_ns
Optimize performance and prepare for the removal of the user_ns reference
from user_struct. Remove the slow long walk through cred->user->user_ns and
instead go straight to cred->user_ns.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index f7a43514ac65..82d8714bbede 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -133,11 +133,11 @@ static bool set_one_prio_perm(struct task_struct *p) | |||
133 | { | 133 | { |
134 | const struct cred *cred = current_cred(), *pcred = __task_cred(p); | 134 | const struct cred *cred = current_cred(), *pcred = __task_cred(p); |
135 | 135 | ||
136 | if (pcred->user->user_ns == cred->user->user_ns && | 136 | if (pcred->user_ns == cred->user_ns && |
137 | (pcred->uid == cred->euid || | 137 | (pcred->uid == cred->euid || |
138 | pcred->euid == cred->euid)) | 138 | pcred->euid == cred->euid)) |
139 | return true; | 139 | return true; |
140 | if (ns_capable(pcred->user->user_ns, CAP_SYS_NICE)) | 140 | if (ns_capable(pcred->user_ns, CAP_SYS_NICE)) |
141 | return true; | 141 | return true; |
142 | return false; | 142 | return false; |
143 | } | 143 | } |
@@ -1498,7 +1498,7 @@ static int check_prlimit_permission(struct task_struct *task) | |||
1498 | return 0; | 1498 | return 0; |
1499 | 1499 | ||
1500 | tcred = __task_cred(task); | 1500 | tcred = __task_cred(task); |
1501 | if (cred->user->user_ns == tcred->user->user_ns && | 1501 | if (cred->user_ns == tcred->user_ns && |
1502 | (cred->uid == tcred->euid && | 1502 | (cred->uid == tcred->euid && |
1503 | cred->uid == tcred->suid && | 1503 | cred->uid == tcred->suid && |
1504 | cred->uid == tcred->uid && | 1504 | cred->uid == tcred->uid && |
@@ -1506,7 +1506,7 @@ static int check_prlimit_permission(struct task_struct *task) | |||
1506 | cred->gid == tcred->sgid && | 1506 | cred->gid == tcred->sgid && |
1507 | cred->gid == tcred->gid)) | 1507 | cred->gid == tcred->gid)) |
1508 | return 0; | 1508 | return 0; |
1509 | if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE)) | 1509 | if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE)) |
1510 | return 0; | 1510 | return 0; |
1511 | 1511 | ||
1512 | return -EPERM; | 1512 | return -EPERM; |