Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285037
b: refs/heads/master
c: f1c84da
h: refs/heads/master
i:
  285035: d0eac58
v: v3
  • Loading branch information
Eric Paris committed Jan 5, 2012
1 parent 37f5838 commit aeb8612
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d2a7009f0bb03fa22ad08dd25472efa0568126b9
refs/heads/master: f1c84dae0ecc51aa35c81f19a0ebcd6c0921ddcb
1 change: 0 additions & 1 deletion trunk/include/linux/capability.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,6 @@ extern bool has_ns_capability_noaudit(struct task_struct *t,
struct user_namespace *ns, int cap);
extern bool capable(int cap);
extern bool ns_capable(struct user_namespace *ns, int cap);
extern bool task_ns_capable(struct task_struct *t, int cap);
extern bool nsown_capable(int cap);

/* audit system wants to get cap info from files as well */
Expand Down
6 changes: 4 additions & 2 deletions trunk/include/linux/cred.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,12 @@ static inline void put_cred(const struct cred *_cred)
#define current_security() (current_cred_xxx(security))

#ifdef CONFIG_USER_NS
#define current_user_ns() (current_cred_xxx(user_ns))
#define current_user_ns() (current_cred_xxx(user_ns))
#define task_user_ns(task) (task_cred_xxx((task), user_ns))
#else
extern struct user_namespace init_user_ns;
#define current_user_ns() (&init_user_ns)
#define current_user_ns() (&init_user_ns)
#define task_user_ns(task) (&init_user_ns)
#endif


Expand Down
14 changes: 0 additions & 14 deletions trunk/kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,6 @@ bool capable(int cap)
}
EXPORT_SYMBOL(capable);

/**
* task_ns_capable - Determine whether current task has a superior
* capability targeted at a specific task's user namespace.
* @t: The task whose user namespace is targeted.
* @cap: The capability in question.
*
* Return true if it does, false otherwise.
*/
bool task_ns_capable(struct task_struct *t, int cap)
{
return ns_capable(task_cred_xxx(t, user)->user_ns, cap);
}
EXPORT_SYMBOL(task_ns_capable);

/**
* nsown_capable - Check superior capability to one's own user_ns
* @cap: The capability in question
Expand Down
4 changes: 2 additions & 2 deletions trunk/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ int __ptrace_may_access(struct task_struct *task, unsigned int mode)
smp_rmb();
if (task->mm)
dumpable = get_dumpable(task->mm);
if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
if (!dumpable && !ns_capable(task_user_ns(task), CAP_SYS_PTRACE))
return -EPERM;

return security_ptrace_access_check(task, mode);
Expand Down Expand Up @@ -266,7 +266,7 @@ static int ptrace_attach(struct task_struct *task, long request,
task->ptrace = PT_PTRACED;
if (seize)
task->ptrace |= PT_SEIZED;
if (task_ns_capable(task, CAP_SYS_PTRACE))
if (ns_capable(task_user_ns(task), CAP_SYS_PTRACE))
task->ptrace |= PT_PTRACE_CAP;

__ptrace_link(task, current);
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -5409,7 +5409,7 @@ long sched_setaffinity(pid_t pid, const struct cpumask *in_mask)
goto out_free_cpus_allowed;
}
retval = -EPERM;
if (!check_same_owner(p) && !task_ns_capable(p, CAP_SYS_NICE))
if (!check_same_owner(p) && !ns_capable(task_user_ns(p), CAP_SYS_NICE))
goto out_unlock;

retval = security_task_setscheduler(p);
Expand Down

0 comments on commit aeb8612

Please sign in to comment.