userns: Convert taskstats to handle the user and pid namespaces.
- Explicitly limit exit task stat broadcast to the initial user and pid namespaces, as it is already limited to the initial network namespace. - For broadcast task stats explicitly generate all of the idenitiers in terms of the initial user namespace and the initial pid namespace. - For request stats report them in terms of the current user namespace and the current pid namespace. Netlink messages are delivered syncrhonously to the kernel allowing us to get the user namespace and the pid namespace from the current task. - Pass the namespaces for representing pids and uids and gids into bacct_add_task. Cc: Balbir Singh <bsingharora@gmail.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
This commit is contained in:
parent
cca080d9b6
commit
4bd6e32ace
4 changed files with 30 additions and 14 deletions
|
@ -26,7 +26,9 @@
|
|||
/*
|
||||
* fill in basic accounting fields
|
||||
*/
|
||||
void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
|
||||
void bacct_add_tsk(struct user_namespace *user_ns,
|
||||
struct pid_namespace *pid_ns,
|
||||
struct taskstats *stats, struct task_struct *tsk)
|
||||
{
|
||||
const struct cred *tcred;
|
||||
struct timespec uptime, ts;
|
||||
|
@ -55,13 +57,13 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
|
|||
stats->ac_flag |= AXSIG;
|
||||
stats->ac_nice = task_nice(tsk);
|
||||
stats->ac_sched = tsk->policy;
|
||||
stats->ac_pid = tsk->pid;
|
||||
stats->ac_pid = task_pid_nr_ns(tsk, pid_ns);
|
||||
rcu_read_lock();
|
||||
tcred = __task_cred(tsk);
|
||||
stats->ac_uid = tcred->uid;
|
||||
stats->ac_gid = tcred->gid;
|
||||
stats->ac_uid = from_kuid_munged(user_ns, tcred->uid);
|
||||
stats->ac_gid = from_kgid_munged(user_ns, tcred->gid);
|
||||
stats->ac_ppid = pid_alive(tsk) ?
|
||||
rcu_dereference(tsk->real_parent)->tgid : 0;
|
||||
task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0;
|
||||
rcu_read_unlock();
|
||||
stats->ac_utime = cputime_to_usecs(tsk->utime);
|
||||
stats->ac_stime = cputime_to_usecs(tsk->stime);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue