hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/fs/proc/array.c
....@@ -92,7 +92,6 @@
9292 #include <linux/user_namespace.h>
9393 #include <linux/fs_struct.h>
9494
95
-#include <asm/pgtable.h>
9695 #include <asm/processor.h>
9796 #include "internal.h"
9897
....@@ -248,8 +247,8 @@
248247 seq_putc(m, '\n');
249248 }
250249
251
-static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign,
252
- sigset_t *catch)
250
+static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *sigign,
251
+ sigset_t *sigcatch)
253252 {
254253 struct k_sigaction *k;
255254 int i;
....@@ -257,9 +256,9 @@
257256 k = p->sighand->action;
258257 for (i = 1; i <= _NSIG; ++i, ++k) {
259258 if (k->sa.sa_handler == SIG_IGN)
260
- sigaddset(ign, i);
259
+ sigaddset(sigign, i);
261260 else if (k->sa.sa_handler != SIG_DFL)
262
- sigaddset(catch, i);
261
+ sigaddset(sigcatch, i);
263262 }
264263 }
265264
....@@ -342,29 +341,33 @@
342341 seq_put_decimal_ull(m, "NoNewPrivs:\t", task_no_new_privs(p));
343342 #ifdef CONFIG_SECCOMP
344343 seq_put_decimal_ull(m, "\nSeccomp:\t", p->seccomp.mode);
344
+#ifdef CONFIG_SECCOMP_FILTER
345
+ seq_put_decimal_ull(m, "\nSeccomp_filters:\t",
346
+ atomic_read(&p->seccomp.filter_count));
345347 #endif
346
- seq_printf(m, "\nSpeculation_Store_Bypass:\t");
348
+#endif
349
+ seq_puts(m, "\nSpeculation_Store_Bypass:\t");
347350 switch (arch_prctl_spec_ctrl_get(p, PR_SPEC_STORE_BYPASS)) {
348351 case -EINVAL:
349
- seq_printf(m, "unknown");
352
+ seq_puts(m, "unknown");
350353 break;
351354 case PR_SPEC_NOT_AFFECTED:
352
- seq_printf(m, "not vulnerable");
355
+ seq_puts(m, "not vulnerable");
353356 break;
354357 case PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE:
355
- seq_printf(m, "thread force mitigated");
358
+ seq_puts(m, "thread force mitigated");
356359 break;
357360 case PR_SPEC_PRCTL | PR_SPEC_DISABLE:
358
- seq_printf(m, "thread mitigated");
361
+ seq_puts(m, "thread mitigated");
359362 break;
360363 case PR_SPEC_PRCTL | PR_SPEC_ENABLE:
361
- seq_printf(m, "thread vulnerable");
364
+ seq_puts(m, "thread vulnerable");
362365 break;
363366 case PR_SPEC_DISABLE:
364
- seq_printf(m, "globally mitigated");
367
+ seq_puts(m, "globally mitigated");
365368 break;
366369 default:
367
- seq_printf(m, "vulnerable");
370
+ seq_puts(m, "vulnerable");
368371 break;
369372 }
370373 seq_putc(m, '\n');
....@@ -392,6 +395,15 @@
392395 seq_putc(m, '\n');
393396 }
394397
398
+static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm)
399
+{
400
+ bool thp_enabled = IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE);
401
+
402
+ if (thp_enabled)
403
+ thp_enabled = !test_bit(MMF_DISABLE_THP, &mm->flags);
404
+ seq_printf(m, "THP_enabled:\t%d\n", thp_enabled);
405
+}
406
+
395407 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
396408 struct pid *pid, struct task_struct *task)
397409 {
....@@ -406,6 +418,7 @@
406418 if (mm) {
407419 task_mem(m, mm);
408420 task_core_dumping(m, mm);
421
+ task_thp_status(m, mm);
409422 mmput(mm);
410423 }
411424 task_sig(m, task);
....@@ -523,7 +536,7 @@
523536 nice = task_nice(task);
524537
525538 /* convert nsec -> ticks */
526
- start_time = nsec_to_clock_t(task->real_start_time);
539
+ start_time = nsec_to_clock_t(task->start_boottime);
527540
528541 seq_put_decimal_ull(m, "", pid_nr_ns(pid, ns));
529542 seq_puts(m, " (");
....@@ -625,28 +638,35 @@
625638 int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
626639 struct pid *pid, struct task_struct *task)
627640 {
628
- unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
629641 struct mm_struct *mm = get_task_mm(task);
630642
631643 if (mm) {
644
+ unsigned long size;
645
+ unsigned long resident = 0;
646
+ unsigned long shared = 0;
647
+ unsigned long text = 0;
648
+ unsigned long data = 0;
649
+
632650 size = task_statm(mm, &shared, &text, &data, &resident);
633651 mmput(mm);
634
- }
635
- /*
636
- * For quick read, open code by putting numbers directly
637
- * expected format is
638
- * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
639
- * size, resident, shared, text, data);
640
- */
641
- seq_put_decimal_ull(m, "", size);
642
- seq_put_decimal_ull(m, " ", resident);
643
- seq_put_decimal_ull(m, " ", shared);
644
- seq_put_decimal_ull(m, " ", text);
645
- seq_put_decimal_ull(m, " ", 0);
646
- seq_put_decimal_ull(m, " ", data);
647
- seq_put_decimal_ull(m, " ", 0);
648
- seq_putc(m, '\n');
649652
653
+ /*
654
+ * For quick read, open code by putting numbers directly
655
+ * expected format is
656
+ * seq_printf(m, "%lu %lu %lu %lu 0 %lu 0\n",
657
+ * size, resident, shared, text, data);
658
+ */
659
+ seq_put_decimal_ull(m, "", size);
660
+ seq_put_decimal_ull(m, " ", resident);
661
+ seq_put_decimal_ull(m, " ", shared);
662
+ seq_put_decimal_ull(m, " ", text);
663
+ seq_put_decimal_ull(m, " ", 0);
664
+ seq_put_decimal_ull(m, " ", data);
665
+ seq_put_decimal_ull(m, " ", 0);
666
+ seq_putc(m, '\n');
667
+ } else {
668
+ seq_write(m, "0 0 0 0 0 0 0\n", 14);
669
+ }
650670 return 0;
651671 }
652672
....@@ -711,7 +731,7 @@
711731 {
712732 struct inode *inode = file_inode(seq->file);
713733
714
- seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(inode)));
734
+ seq_printf(seq, "%d ", pid_nr_ns(v, proc_pid_ns(inode->i_sb)));
715735 return 0;
716736 }
717737