mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-04 21:31:51 +00:00
CRED: Use RCU to access another task's creds and to release a task's own creds
Use RCU to access another task's creds and to release a task's own creds. This means that it will be possible for the credentials of a task to be replaced without another task (a) requiring a full lock to read them, and (b) seeing deallocated memory. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
86a264abe5
commit
c69e8d9c01
28 changed files with 353 additions and 202 deletions
|
@ -159,6 +159,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
|||
struct group_info *group_info;
|
||||
int g;
|
||||
struct fdtable *fdt = NULL;
|
||||
const struct cred *cred;
|
||||
pid_t ppid, tpid;
|
||||
|
||||
rcu_read_lock();
|
||||
|
@ -170,6 +171,7 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
|||
if (tracer)
|
||||
tpid = task_pid_nr_ns(tracer, ns);
|
||||
}
|
||||
cred = get_cred((struct cred *) __task_cred(p));
|
||||
seq_printf(m,
|
||||
"State:\t%s\n"
|
||||
"Tgid:\t%d\n"
|
||||
|
@ -182,8 +184,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
|||
task_tgid_nr_ns(p, ns),
|
||||
pid_nr_ns(pid, ns),
|
||||
ppid, tpid,
|
||||
p->cred->uid, p->cred->euid, p->cred->suid, p->cred->fsuid,
|
||||
p->cred->gid, p->cred->egid, p->cred->sgid, p->cred->fsgid);
|
||||
cred->uid, cred->euid, cred->suid, cred->fsuid,
|
||||
cred->gid, cred->egid, cred->sgid, cred->fsgid);
|
||||
|
||||
task_lock(p);
|
||||
if (p->files)
|
||||
|
@ -194,13 +196,12 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
|
|||
fdt ? fdt->max_fds : 0);
|
||||
rcu_read_unlock();
|
||||
|
||||
group_info = p->cred->group_info;
|
||||
get_group_info(group_info);
|
||||
group_info = cred->group_info;
|
||||
task_unlock(p);
|
||||
|
||||
for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++)
|
||||
seq_printf(m, "%d ", GROUP_AT(group_info, g));
|
||||
put_group_info(group_info);
|
||||
put_cred(cred);
|
||||
|
||||
seq_printf(m, "\n");
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ static inline void task_sig(struct seq_file *m, struct task_struct *p)
|
|||
blocked = p->blocked;
|
||||
collect_sigign_sigcatch(p, &ignored, &caught);
|
||||
num_threads = atomic_read(&p->signal->count);
|
||||
qsize = atomic_read(&p->cred->user->sigpending);
|
||||
qsize = atomic_read(&__task_cred(p)->user->sigpending);
|
||||
qlim = p->signal->rlim[RLIMIT_SIGPENDING].rlim_cur;
|
||||
unlock_task_sighand(p, &flags);
|
||||
}
|
||||
|
@ -293,12 +294,21 @@ static void render_cap_t(struct seq_file *m, const char *header,
|
|||
|
||||
static inline void task_cap(struct seq_file *m, struct task_struct *p)
|
||||
{
|
||||
struct cred *cred = p->cred;
|
||||
const struct cred *cred;
|
||||
kernel_cap_t cap_inheritable, cap_permitted, cap_effective, cap_bset;
|
||||
|
||||
render_cap_t(m, "CapInh:\t", &cred->cap_inheritable);
|
||||
render_cap_t(m, "CapPrm:\t", &cred->cap_permitted);
|
||||
render_cap_t(m, "CapEff:\t", &cred->cap_effective);
|
||||
render_cap_t(m, "CapBnd:\t", &cred->cap_bset);
|
||||
rcu_read_lock();
|
||||
cred = __task_cred(p);
|
||||
cap_inheritable = cred->cap_inheritable;
|
||||
cap_permitted = cred->cap_permitted;
|
||||
cap_effective = cred->cap_effective;
|
||||
cap_bset = cred->cap_bset;
|
||||
rcu_read_unlock();
|
||||
|
||||
render_cap_t(m, "CapInh:\t", &cap_inheritable);
|
||||
render_cap_t(m, "CapPrm:\t", &cap_permitted);
|
||||
render_cap_t(m, "CapEff:\t", &cap_effective);
|
||||
render_cap_t(m, "CapBnd:\t", &cap_bset);
|
||||
}
|
||||
|
||||
static inline void task_context_switch_counts(struct seq_file *m,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue