From 25e75703410a84b80623da3653db6b70282e5c6a Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Tue, 3 Jan 2012 12:25:15 -0500 Subject: [PATCH] capabilities: call has_ns_capability from has_capability Declare the more specific has_ns_capability first in the code and then call it from has_capability. The declaration reversal isn't stricty necessary since they are both declared in header files, but it just makes sense to put more specific functions first in the code. Signed-off-by: Eric Paris Acked-by: Serge E. Hallyn --- kernel/capability.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/kernel/capability.c b/kernel/capability.c index ff50ab62cfca..fb815d1b9ea2 100644 --- a/kernel/capability.c +++ b/kernel/capability.c @@ -287,28 +287,7 @@ error: } /** - * has_capability - Does a task have a capability in init_user_ns - * @t: The task in question - * @cap: The capability to be tested for - * - * Return true if the specified task has the given superior capability - * currently in effect to the initial user namespace, false if not. - * - * Note that this does not set PF_SUPERPRIV on the task. - */ -bool has_capability(struct task_struct *t, int cap) -{ - int ret; - - rcu_read_lock(); - ret = security_capable(__task_cred(t), &init_user_ns, cap); - rcu_read_unlock(); - - return (ret == 0); -} - -/** - * has_capability - Does a task have a capability in a specific user ns + * has_ns_capability - Does a task have a capability in a specific user ns * @t: The task in question * @ns: target user namespace * @cap: The capability to be tested for @@ -330,6 +309,21 @@ bool has_ns_capability(struct task_struct *t, return (ret == 0); } +/** + * has_capability - Does a task have a capability in init_user_ns + * @t: The task in question + * @cap: The capability to be tested for + * + * Return true if the specified task has the given superior capability + * currently in effect to the initial user namespace, false if not. + * + * Note that this does not set PF_SUPERPRIV on the task. + */ +bool has_capability(struct task_struct *t, int cap) +{ + return has_ns_capability(t, &init_user_ns, cap); +} + /** * has_capability_noaudit - Does a task have a capability (unaudited) * @t: The task in question