aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/array.c')
-rw-r--r--fs/proc/array.c134
1 files changed, 76 insertions, 58 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index c602b8d20f06..dc4c5a7b9ece 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -81,6 +81,7 @@
81#include <linux/pid_namespace.h> 81#include <linux/pid_namespace.h>
82#include <linux/ptrace.h> 82#include <linux/ptrace.h>
83#include <linux/tracehook.h> 83#include <linux/tracehook.h>
84#include <linux/user_namespace.h>
84 85
85#include <asm/pgtable.h> 86#include <asm/pgtable.h>
86#include <asm/processor.h> 87#include <asm/processor.h>
@@ -161,6 +162,7 @@ static inline const char *get_task_state(struct task_struct *tsk)
161static inline void task_state(struct seq_file *m, struct pid_namespace *ns, 162static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
162 struct pid *pid, struct task_struct *p) 163 struct pid *pid, struct task_struct *p)
163{ 164{
165 struct user_namespace *user_ns = current_user_ns();
164 struct group_info *group_info; 166 struct group_info *group_info;
165 int g; 167 int g;
166 struct fdtable *fdt = NULL; 168 struct fdtable *fdt = NULL;
@@ -189,8 +191,14 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
189 task_tgid_nr_ns(p, ns), 191 task_tgid_nr_ns(p, ns),
190 pid_nr_ns(pid, ns), 192 pid_nr_ns(pid, ns),
191 ppid, tpid, 193 ppid, tpid,
192 cred->uid, cred->euid, cred->suid, cred->fsuid, 194 from_kuid_munged(user_ns, cred->uid),
193 cred->gid, cred->egid, cred->sgid, cred->fsgid); 195 from_kuid_munged(user_ns, cred->euid),
196 from_kuid_munged(user_ns, cred->suid),
197 from_kuid_munged(user_ns, cred->fsuid),
198 from_kgid_munged(user_ns, cred->gid),
199 from_kgid_munged(user_ns, cred->egid),
200 from_kgid_munged(user_ns, cred->sgid),
201 from_kgid_munged(user_ns, cred->fsgid));
194 202
195 task_lock(p); 203 task_lock(p);
196 if (p->files) 204 if (p->files)
@@ -205,7 +213,8 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
205 task_unlock(p); 213 task_unlock(p);
206 214
207 for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) 215 for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++)
208 seq_printf(m, "%d ", GROUP_AT(group_info, g)); 216 seq_printf(m, "%d ",
217 from_kgid_munged(user_ns, GROUP_AT(group_info, g)));
209 put_cred(cred); 218 put_cred(cred);
210 219
211 seq_putc(m, '\n'); 220 seq_putc(m, '\n');
@@ -462,59 +471,56 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
462 /* convert nsec -> ticks */ 471 /* convert nsec -> ticks */
463 start_time = nsec_to_clock_t(start_time); 472 start_time = nsec_to_clock_t(start_time);
464 473
465 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \ 474 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
466%lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \ 475 seq_put_decimal_ll(m, ' ', ppid);
467%lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld %lu %lu %lu\n", 476 seq_put_decimal_ll(m, ' ', pgid);
468 pid_nr_ns(pid, ns), 477 seq_put_decimal_ll(m, ' ', sid);
469 tcomm, 478 seq_put_decimal_ll(m, ' ', tty_nr);
470 state, 479 seq_put_decimal_ll(m, ' ', tty_pgrp);
471 ppid, 480 seq_put_decimal_ull(m, ' ', task->flags);
472 pgid, 481 seq_put_decimal_ull(m, ' ', min_flt);
473 sid, 482 seq_put_decimal_ull(m, ' ', cmin_flt);
474 tty_nr, 483 seq_put_decimal_ull(m, ' ', maj_flt);
475 tty_pgrp, 484 seq_put_decimal_ull(m, ' ', cmaj_flt);
476 task->flags, 485 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(utime));
477 min_flt, 486 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(stime));
478 cmin_flt, 487 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cutime));
479 maj_flt, 488 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cstime));
480 cmaj_flt, 489 seq_put_decimal_ll(m, ' ', priority);
481 cputime_to_clock_t(utime), 490 seq_put_decimal_ll(m, ' ', nice);
482 cputime_to_clock_t(stime), 491 seq_put_decimal_ll(m, ' ', num_threads);
483 cputime_to_clock_t(cutime), 492 seq_put_decimal_ull(m, ' ', 0);
484 cputime_to_clock_t(cstime), 493 seq_put_decimal_ull(m, ' ', start_time);
485 priority, 494 seq_put_decimal_ull(m, ' ', vsize);
486 nice, 495 seq_put_decimal_ll(m, ' ', mm ? get_mm_rss(mm) : 0);
487 num_threads, 496 seq_put_decimal_ull(m, ' ', rsslim);
488 start_time, 497 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
489 vsize, 498 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
490 mm ? get_mm_rss(mm) : 0, 499 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
491 rsslim, 500 seq_put_decimal_ull(m, ' ', esp);
492 mm ? (permitted ? mm->start_code : 1) : 0, 501 seq_put_decimal_ull(m, ' ', eip);
493 mm ? (permitted ? mm->end_code : 1) : 0, 502 /* The signal information here is obsolete.
494 (permitted && mm) ? mm->start_stack : 0, 503 * It must be decimal for Linux 2.0 compatibility.
495 esp, 504 * Use /proc/#/status for real-time signals.
496 eip, 505 */
497 /* The signal information here is obsolete. 506 seq_put_decimal_ull(m, ' ', task->pending.signal.sig[0] & 0x7fffffffUL);
498 * It must be decimal for Linux 2.0 compatibility. 507 seq_put_decimal_ull(m, ' ', task->blocked.sig[0] & 0x7fffffffUL);
499 * Use /proc/#/status for real-time signals. 508 seq_put_decimal_ull(m, ' ', sigign.sig[0] & 0x7fffffffUL);
500 */ 509 seq_put_decimal_ull(m, ' ', sigcatch.sig[0] & 0x7fffffffUL);
501 task->pending.signal.sig[0] & 0x7fffffffUL, 510 seq_put_decimal_ull(m, ' ', wchan);
502 task->blocked.sig[0] & 0x7fffffffUL, 511 seq_put_decimal_ull(m, ' ', 0);
503 sigign .sig[0] & 0x7fffffffUL, 512 seq_put_decimal_ull(m, ' ', 0);
504 sigcatch .sig[0] & 0x7fffffffUL, 513 seq_put_decimal_ll(m, ' ', task->exit_signal);
505 wchan, 514 seq_put_decimal_ll(m, ' ', task_cpu(task));
506 0UL, 515 seq_put_decimal_ull(m, ' ', task->rt_priority);
507 0UL, 516 seq_put_decimal_ull(m, ' ', task->policy);
508 task->exit_signal, 517 seq_put_decimal_ull(m, ' ', delayacct_blkio_ticks(task));
509 task_cpu(task), 518 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
510 task->rt_priority, 519 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
511 task->policy, 520 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_data : 0);
512 (unsigned long long)delayacct_blkio_ticks(task), 521 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->end_data : 0);
513 cputime_to_clock_t(gtime), 522 seq_put_decimal_ull(m, ' ', (mm && permitted) ? mm->start_brk : 0);
514 cputime_to_clock_t(cgtime), 523 seq_putc(m, '\n');
515 (mm && permitted) ? mm->start_data : 0,
516 (mm && permitted) ? mm->end_data : 0,
517 (mm && permitted) ? mm->start_brk : 0);
518 if (mm) 524 if (mm)
519 mmput(mm); 525 mmput(mm);
520 return 0; 526 return 0;
@@ -542,8 +548,20 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
542 size = task_statm(mm, &shared, &text, &data, &resident); 548 size = task_statm(mm, &shared, &text, &data, &resident);
543 mmput(mm); 549 mmput(mm);
544 } 550 }
545 seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n", 551 /*
546 size, resident, shared, text, data); 552 * For quick read, open code by putting numbers directly
553 * expected format is
554 * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
555 * size, resident, shared, text, data);
556 */
557 seq_put_decimal_ull(m, 0, size);
558 seq_put_decimal_ull(m, ' ', resident);
559 seq_put_decimal_ull(m, ' ', shared);
560 seq_put_decimal_ull(m, ' ', text);
561 seq_put_decimal_ull(m, ' ', 0);
562 seq_put_decimal_ull(m, ' ', data);
563 seq_put_decimal_ull(m, ' ', 0);
564 seq_putc(m, '\n');
547 565
548 return 0; 566 return 0;
549} 567}