forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/fs/proc/base.c
....@@ -59,6 +59,7 @@
5959 #include <linux/capability.h>
6060 #include <linux/file.h>
6161 #include <linux/fdtable.h>
62
+#include <linux/generic-radix-tree.h>
6263 #include <linux/string.h>
6364 #include <linux/seq_file.h>
6465 #include <linux/namei.h>
....@@ -92,11 +93,12 @@
9293 #include <linux/sched/coredump.h>
9394 #include <linux/sched/debug.h>
9495 #include <linux/sched/stat.h>
95
-#include <linux/flex_array.h>
9696 #include <linux/posix-timers.h>
97
+#include <linux/time_namespace.h>
98
+#include <linux/resctrl.h>
99
+#include <linux/swait.h>
97100 #include <linux/cpufreq_times.h>
98101 #include <trace/events/oom.h>
99
-#include <linux/swait.h>
100102 #include "internal.h"
101103 #include "fd.h"
102104
....@@ -142,9 +144,13 @@
142144 #define REG(NAME, MODE, fops) \
143145 NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})
144146 #define ONE(NAME, MODE, show) \
145
- NOD(NAME, (S_IFREG|(MODE)), \
147
+ NOD(NAME, (S_IFREG|(MODE)), \
146148 NULL, &proc_single_file_operations, \
147149 { .proc_show = show } )
150
+#define ATTR(LSM, NAME, MODE) \
151
+ NOD(NAME, (S_IFREG|(MODE)), \
152
+ NULL, &proc_pid_attr_operations, \
153
+ { .lsm = LSM })
148154
149155 /*
150156 * Count the number of hardlinks for the pid_entry table, excluding the .
....@@ -401,11 +407,11 @@
401407
402408 static int lock_trace(struct task_struct *task)
403409 {
404
- int err = mutex_lock_killable(&task->signal->cred_guard_mutex);
410
+ int err = down_read_killable(&task->signal->exec_update_lock);
405411 if (err)
406412 return err;
407413 if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) {
408
- mutex_unlock(&task->signal->cred_guard_mutex);
414
+ up_read(&task->signal->exec_update_lock);
409415 return -EPERM;
410416 }
411417 return 0;
....@@ -413,7 +419,7 @@
413419
414420 static void unlock_trace(struct task_struct *task)
415421 {
416
- mutex_unlock(&task->signal->cred_guard_mutex);
422
+ up_read(&task->signal->exec_update_lock);
417423 }
418424
419425 #ifdef CONFIG_STACKTRACE
....@@ -423,7 +429,6 @@
423429 static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
424430 struct pid *pid, struct task_struct *task)
425431 {
426
- struct stack_trace trace;
427432 unsigned long *entries;
428433 int err;
429434
....@@ -446,20 +451,17 @@
446451 if (!entries)
447452 return -ENOMEM;
448453
449
- trace.nr_entries = 0;
450
- trace.max_entries = MAX_STACK_TRACE_DEPTH;
451
- trace.entries = entries;
452
- trace.skip = 0;
453
-
454454 err = lock_trace(task);
455455 if (!err) {
456
- unsigned int i;
456
+ unsigned int i, nr_entries;
457457
458
- save_stack_trace_tsk(task, &trace);
458
+ nr_entries = stack_trace_save_tsk(task, entries,
459
+ MAX_STACK_TRACE_DEPTH, 0);
459460
460
- for (i = 0; i < trace.nr_entries; i++) {
461
+ for (i = 0; i < nr_entries; i++) {
461462 seq_printf(m, "[<0>] %pB\n", (void *)entries[i]);
462463 }
464
+
463465 unlock_trace(task);
464466 }
465467 kfree(entries);
....@@ -476,7 +478,7 @@
476478 struct pid *pid, struct task_struct *task)
477479 {
478480 if (unlikely(!sched_info_on()))
479
- seq_printf(m, "0 0 0\n");
481
+ seq_puts(m, "0 0 0\n");
480482 else
481483 seq_printf(m, "%llu %llu %lu\n",
482484 (unsigned long long)task->se.sum_exec_runtime,
....@@ -505,9 +507,8 @@
505507 lr->count, lr->time, lr->max);
506508 for (q = 0; q < LT_BACKTRACEDEPTH; q++) {
507509 unsigned long bt = lr->backtrace[q];
510
+
508511 if (!bt)
509
- break;
510
- if (bt == ULONG_MAX)
511512 break;
512513 seq_printf(m, " %ps", (void *)bt);
513514 }
....@@ -531,7 +532,7 @@
531532
532533 if (!task)
533534 return -ESRCH;
534
- clear_all_latency_tracing(task);
535
+ clear_tsk_latency_tracing(task);
535536 put_task_struct(task);
536537
537538 return count;
....@@ -550,11 +551,19 @@
550551 static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
551552 struct pid *pid, struct task_struct *task)
552553 {
553
- unsigned long totalpages = totalram_pages + total_swap_pages;
554
+ unsigned long totalpages = totalram_pages() + total_swap_pages;
554555 unsigned long points = 0;
556
+ long badness;
555557
556
- points = oom_badness(task, NULL, NULL, totalpages) *
557
- 1000 / totalpages;
558
+ badness = oom_badness(task, totalpages);
559
+ /*
560
+ * Special case OOM_SCORE_ADJ_MIN for all others scale the
561
+ * badness value into [0, 2000] range which we have been
562
+ * exporting for a long time so userspace might depend on it.
563
+ */
564
+ if (badness != LONG_MIN)
565
+ points = (1000 + badness * 1000 / (long)totalpages) * 2 / 3;
566
+
558567 seq_printf(m, "%lu\n", points);
559568
560569 return 0;
....@@ -601,8 +610,10 @@
601610 /*
602611 * print the file header
603612 */
604
- seq_printf(m, "%-25s %-20s %-20s %-10s\n",
605
- "Limit", "Soft Limit", "Hard Limit", "Units");
613
+ seq_puts(m, "Limit "
614
+ "Soft Limit "
615
+ "Hard Limit "
616
+ "Units \n");
606617
607618 for (i = 0; i < RLIM_NLIMITS; i++) {
608619 if (rlim[i].rlim_cur == RLIM_INFINITY)
....@@ -630,24 +641,25 @@
630641 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
631642 struct pid *pid, struct task_struct *task)
632643 {
633
- long nr;
634
- unsigned long args[6], sp, pc;
644
+ struct syscall_info info;
645
+ u64 *args = &info.data.args[0];
635646 int res;
636647
637648 res = lock_trace(task);
638649 if (res)
639650 return res;
640651
641
- if (task_current_syscall(task, &nr, args, 6, &sp, &pc))
652
+ if (task_current_syscall(task, &info))
642653 seq_puts(m, "running\n");
643
- else if (nr < 0)
644
- seq_printf(m, "%ld 0x%lx 0x%lx\n", nr, sp, pc);
654
+ else if (info.data.nr < 0)
655
+ seq_printf(m, "%d 0x%llx 0x%llx\n",
656
+ info.data.nr, info.sp, info.data.instruction_pointer);
645657 else
646658 seq_printf(m,
647
- "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
648
- nr,
659
+ "%d 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx\n",
660
+ info.data.nr,
649661 args[0], args[1], args[2], args[3], args[4], args[5],
650
- sp, pc);
662
+ info.sp, info.data.instruction_pointer);
651663 unlock_trace(task);
652664
653665 return 0;
....@@ -696,13 +708,21 @@
696708 * May current process learn task's sched/cmdline info (for hide_pid_min=1)
697709 * or euid/egid (for hide_pid_min=2)?
698710 */
699
-static bool has_pid_permissions(struct pid_namespace *pid,
711
+static bool has_pid_permissions(struct proc_fs_info *fs_info,
700712 struct task_struct *task,
701
- int hide_pid_min)
713
+ enum proc_hidepid hide_pid_min)
702714 {
703
- if (pid->hide_pid < hide_pid_min)
715
+ /*
716
+ * If 'hidpid' mount option is set force a ptrace check,
717
+ * we indicate that we are using a filesystem syscall
718
+ * by passing PTRACE_MODE_READ_FSCREDS
719
+ */
720
+ if (fs_info->hide_pid == HIDEPID_NOT_PTRACEABLE)
721
+ return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS);
722
+
723
+ if (fs_info->hide_pid < hide_pid_min)
704724 return true;
705
- if (in_group_p(pid->pid_gid))
725
+ if (in_group_p(fs_info->pid_gid))
706726 return true;
707727 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS);
708728 }
....@@ -710,18 +730,18 @@
710730
711731 static int proc_pid_permission(struct inode *inode, int mask)
712732 {
713
- struct pid_namespace *pid = proc_pid_ns(inode);
733
+ struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
714734 struct task_struct *task;
715735 bool has_perms;
716736
717737 task = get_proc_task(inode);
718738 if (!task)
719739 return -ESRCH;
720
- has_perms = has_pid_permissions(pid, task, HIDEPID_NO_ACCESS);
740
+ has_perms = has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS);
721741 put_task_struct(task);
722742
723743 if (!has_perms) {
724
- if (pid->hide_pid == HIDEPID_INVISIBLE) {
744
+ if (fs_info->hide_pid == HIDEPID_INVISIBLE) {
725745 /*
726746 * Let's make getdents(), stat(), and open()
727747 * consistent with each other. If a process
....@@ -745,7 +765,7 @@
745765 static int proc_single_show(struct seq_file *m, void *v)
746766 {
747767 struct inode *inode = m->private;
748
- struct pid_namespace *ns = proc_pid_ns(inode);
768
+ struct pid_namespace *ns = proc_pid_ns(inode->i_sb);
749769 struct pid *pid = proc_pid(inode);
750770 struct task_struct *task;
751771 int ret;
....@@ -1031,6 +1051,8 @@
10311051 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
10321052 OOM_SCORE_ADJ_MAX;
10331053 put_task_struct(task);
1054
+ if (oom_adj > OOM_ADJUST_MAX)
1055
+ oom_adj = OOM_ADJUST_MAX;
10341056 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
10351057 return simple_read_from_buffer(buf, count, ppos, buffer, len);
10361058 }
....@@ -1223,7 +1245,7 @@
12231245 .llseek = default_llseek,
12241246 };
12251247
1226
-#ifdef CONFIG_AUDITSYSCALL
1248
+#ifdef CONFIG_AUDIT
12271249 #define TMPBUFLEN 11
12281250 static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
12291251 size_t count, loff_t *ppos)
....@@ -1249,6 +1271,10 @@
12491271 uid_t loginuid;
12501272 kuid_t kloginuid;
12511273 int rv;
1274
+
1275
+ /* Don't let kthreads write their own loginuid */
1276
+ if (current->flags & PF_KTHREAD)
1277
+ return -EPERM;
12521278
12531279 rcu_read_lock();
12541280 if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
....@@ -1413,7 +1439,7 @@
14131439 static int sched_show(struct seq_file *m, void *v)
14141440 {
14151441 struct inode *inode = m->private;
1416
- struct pid_namespace *ns = proc_pid_ns(inode);
1442
+ struct pid_namespace *ns = proc_pid_ns(inode->i_sb);
14171443 struct task_struct *p;
14181444
14191445 p = get_proc_task(inode);
....@@ -1533,6 +1559,108 @@
15331559
15341560 #endif /* CONFIG_SCHED_AUTOGROUP */
15351561
1562
+#ifdef CONFIG_TIME_NS
1563
+static int timens_offsets_show(struct seq_file *m, void *v)
1564
+{
1565
+ struct task_struct *p;
1566
+
1567
+ p = get_proc_task(file_inode(m->file));
1568
+ if (!p)
1569
+ return -ESRCH;
1570
+ proc_timens_show_offsets(p, m);
1571
+
1572
+ put_task_struct(p);
1573
+
1574
+ return 0;
1575
+}
1576
+
1577
+static ssize_t timens_offsets_write(struct file *file, const char __user *buf,
1578
+ size_t count, loff_t *ppos)
1579
+{
1580
+ struct inode *inode = file_inode(file);
1581
+ struct proc_timens_offset offsets[2];
1582
+ char *kbuf = NULL, *pos, *next_line;
1583
+ struct task_struct *p;
1584
+ int ret, noffsets;
1585
+
1586
+ /* Only allow < page size writes at the beginning of the file */
1587
+ if ((*ppos != 0) || (count >= PAGE_SIZE))
1588
+ return -EINVAL;
1589
+
1590
+ /* Slurp in the user data */
1591
+ kbuf = memdup_user_nul(buf, count);
1592
+ if (IS_ERR(kbuf))
1593
+ return PTR_ERR(kbuf);
1594
+
1595
+ /* Parse the user data */
1596
+ ret = -EINVAL;
1597
+ noffsets = 0;
1598
+ for (pos = kbuf; pos; pos = next_line) {
1599
+ struct proc_timens_offset *off = &offsets[noffsets];
1600
+ char clock[10];
1601
+ int err;
1602
+
1603
+ /* Find the end of line and ensure we don't look past it */
1604
+ next_line = strchr(pos, '\n');
1605
+ if (next_line) {
1606
+ *next_line = '\0';
1607
+ next_line++;
1608
+ if (*next_line == '\0')
1609
+ next_line = NULL;
1610
+ }
1611
+
1612
+ err = sscanf(pos, "%9s %lld %lu", clock,
1613
+ &off->val.tv_sec, &off->val.tv_nsec);
1614
+ if (err != 3 || off->val.tv_nsec >= NSEC_PER_SEC)
1615
+ goto out;
1616
+
1617
+ clock[sizeof(clock) - 1] = 0;
1618
+ if (strcmp(clock, "monotonic") == 0 ||
1619
+ strcmp(clock, __stringify(CLOCK_MONOTONIC)) == 0)
1620
+ off->clockid = CLOCK_MONOTONIC;
1621
+ else if (strcmp(clock, "boottime") == 0 ||
1622
+ strcmp(clock, __stringify(CLOCK_BOOTTIME)) == 0)
1623
+ off->clockid = CLOCK_BOOTTIME;
1624
+ else
1625
+ goto out;
1626
+
1627
+ noffsets++;
1628
+ if (noffsets == ARRAY_SIZE(offsets)) {
1629
+ if (next_line)
1630
+ count = next_line - kbuf;
1631
+ break;
1632
+ }
1633
+ }
1634
+
1635
+ ret = -ESRCH;
1636
+ p = get_proc_task(inode);
1637
+ if (!p)
1638
+ goto out;
1639
+ ret = proc_timens_set_offset(file, p, offsets, noffsets);
1640
+ put_task_struct(p);
1641
+ if (ret)
1642
+ goto out;
1643
+
1644
+ ret = count;
1645
+out:
1646
+ kfree(kbuf);
1647
+ return ret;
1648
+}
1649
+
1650
+static int timens_offsets_open(struct inode *inode, struct file *filp)
1651
+{
1652
+ return single_open(filp, timens_offsets_show, inode);
1653
+}
1654
+
1655
+static const struct file_operations proc_timens_offsets_operations = {
1656
+ .open = timens_offsets_open,
1657
+ .read = seq_read,
1658
+ .write = timens_offsets_write,
1659
+ .llseek = seq_lseek,
1660
+ .release = single_release,
1661
+};
1662
+#endif /* CONFIG_TIME_NS */
1663
+
15361664 static ssize_t comm_write(struct file *file, const char __user *buf,
15371665 size_t count, loff_t *offset)
15381666 {
....@@ -1626,8 +1754,7 @@
16261754 if (error)
16271755 goto out;
16281756
1629
- nd_jump_link(&path);
1630
- return NULL;
1757
+ error = nd_jump_link(&path);
16311758 out:
16321759 return ERR_PTR(error);
16331760 }
....@@ -1743,11 +1870,25 @@
17431870 *rgid = gid;
17441871 }
17451872
1873
+void proc_pid_evict_inode(struct proc_inode *ei)
1874
+{
1875
+ struct pid *pid = ei->pid;
1876
+
1877
+ if (S_ISDIR(ei->vfs_inode.i_mode)) {
1878
+ spin_lock(&pid->lock);
1879
+ hlist_del_init_rcu(&ei->sibling_inodes);
1880
+ spin_unlock(&pid->lock);
1881
+ }
1882
+
1883
+ put_pid(pid);
1884
+}
1885
+
17461886 struct inode *proc_pid_make_inode(struct super_block * sb,
17471887 struct task_struct *task, umode_t mode)
17481888 {
17491889 struct inode * inode;
17501890 struct proc_inode *ei;
1891
+ struct pid *pid;
17511892
17521893 /* We need a new inode */
17531894
....@@ -1765,9 +1906,17 @@
17651906 /*
17661907 * grab the reference to task.
17671908 */
1768
- ei->pid = get_task_pid(task, PIDTYPE_PID);
1769
- if (!ei->pid)
1909
+ pid = get_task_pid(task, PIDTYPE_PID);
1910
+ if (!pid)
17701911 goto out_unlock;
1912
+
1913
+ /* Let the pid remember us for quick removal */
1914
+ ei->pid = pid;
1915
+ if (S_ISDIR(mode)) {
1916
+ spin_lock(&pid->lock);
1917
+ hlist_add_head_rcu(&ei->sibling_inodes, &pid->inodes);
1918
+ spin_unlock(&pid->lock);
1919
+ }
17711920
17721921 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid);
17731922 security_task_to_inode(task, inode);
....@@ -1784,7 +1933,7 @@
17841933 u32 request_mask, unsigned int query_flags)
17851934 {
17861935 struct inode *inode = d_inode(path->dentry);
1787
- struct pid_namespace *pid = proc_pid_ns(inode);
1936
+ struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
17881937 struct task_struct *task;
17891938
17901939 generic_fillattr(inode, stat);
....@@ -1794,7 +1943,7 @@
17941943 rcu_read_lock();
17951944 task = pid_task(proc_pid(inode), PIDTYPE_PID);
17961945 if (task) {
1797
- if (!has_pid_permissions(pid, task, HIDEPID_INVISIBLE)) {
1946
+ if (!has_pid_permissions(fs_info, task, HIDEPID_INVISIBLE)) {
17981947 rcu_read_unlock();
17991948 /*
18001949 * This doesn't prevent learning whether PID exists,
....@@ -1979,11 +2128,11 @@
19792128 goto out;
19802129
19812130 if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) {
1982
- status = down_read_killable(&mm->mmap_sem);
2131
+ status = mmap_read_lock_killable(mm);
19832132 if (!status) {
19842133 exact_vma_exists = !!find_exact_vma(mm, vm_start,
19852134 vm_end);
1986
- up_read(&mm->mmap_sem);
2135
+ mmap_read_unlock(mm);
19872136 }
19882137 }
19892138
....@@ -2030,7 +2179,7 @@
20302179 if (rc)
20312180 goto out_mmput;
20322181
2033
- rc = down_read_killable(&mm->mmap_sem);
2182
+ rc = mmap_read_lock_killable(mm);
20342183 if (rc)
20352184 goto out_mmput;
20362185
....@@ -2041,7 +2190,7 @@
20412190 path_get(path);
20422191 rc = 0;
20432192 }
2044
- up_read(&mm->mmap_sem);
2193
+ mmap_read_unlock(mm);
20452194
20462195 out_mmput:
20472196 mmput(mm);
....@@ -2056,16 +2205,16 @@
20562205 };
20572206
20582207 /*
2059
- * Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the
2060
- * symlinks may be used to bypass permissions on ancestor directories in the
2061
- * path to the file in question.
2208
+ * Only allow CAP_SYS_ADMIN and CAP_CHECKPOINT_RESTORE to follow the links, due
2209
+ * to concerns about how the symlinks may be used to bypass permissions on
2210
+ * ancestor directories in the path to the file in question.
20622211 */
20632212 static const char *
20642213 proc_map_files_get_link(struct dentry *dentry,
20652214 struct inode *inode,
20662215 struct delayed_call *done)
20672216 {
2068
- if (!capable(CAP_SYS_ADMIN))
2217
+ if (!checkpoint_restore_ns_capable(&init_user_ns))
20692218 return ERR_PTR(-EPERM);
20702219
20712220 return proc_pid_get_link(dentry, inode, done);
....@@ -2131,7 +2280,7 @@
21312280 goto out_put_task;
21322281
21332282 result = ERR_PTR(-EINTR);
2134
- if (down_read_killable(&mm->mmap_sem))
2283
+ if (mmap_read_lock_killable(mm))
21352284 goto out_put_mm;
21362285
21372286 result = ERR_PTR(-ENOENT);
....@@ -2144,7 +2293,7 @@
21442293 (void *)(unsigned long)vma->vm_file->f_mode);
21452294
21462295 out_no_vma:
2147
- up_read(&mm->mmap_sem);
2296
+ mmap_read_unlock(mm);
21482297 out_put_mm:
21492298 mmput(mm);
21502299 out_put_task:
....@@ -2166,10 +2315,11 @@
21662315 struct task_struct *task;
21672316 struct mm_struct *mm;
21682317 unsigned long nr_files, pos, i;
2169
- struct flex_array *fa = NULL;
2170
- struct map_files_info info;
2318
+ GENRADIX(struct map_files_info) fa;
21712319 struct map_files_info *p;
21722320 int ret;
2321
+
2322
+ genradix_init(&fa);
21732323
21742324 ret = -ENOENT;
21752325 task = get_proc_task(file_inode(file));
....@@ -2188,7 +2338,7 @@
21882338 if (!mm)
21892339 goto out_put_task;
21902340
2191
- ret = down_read_killable(&mm->mmap_sem);
2341
+ ret = mmap_read_lock_killable(mm);
21922342 if (ret) {
21932343 mmput(mm);
21942344 goto out_put_task;
....@@ -2199,52 +2349,39 @@
21992349 /*
22002350 * We need two passes here:
22012351 *
2202
- * 1) Collect vmas of mapped files with mmap_sem taken
2203
- * 2) Release mmap_sem and instantiate entries
2352
+ * 1) Collect vmas of mapped files with mmap_lock taken
2353
+ * 2) Release mmap_lock and instantiate entries
22042354 *
22052355 * otherwise we get lockdep complained, since filldir()
2206
- * routine might require mmap_sem taken in might_fault().
2356
+ * routine might require mmap_lock taken in might_fault().
22072357 */
22082358
22092359 for (vma = mm->mmap, pos = 2; vma; vma = vma->vm_next) {
2210
- if (vma->vm_file && ++pos > ctx->pos)
2211
- nr_files++;
2212
- }
2360
+ if (!vma->vm_file)
2361
+ continue;
2362
+ if (++pos <= ctx->pos)
2363
+ continue;
22132364
2214
- if (nr_files) {
2215
- fa = flex_array_alloc(sizeof(info), nr_files,
2216
- GFP_KERNEL);
2217
- if (!fa || flex_array_prealloc(fa, 0, nr_files,
2218
- GFP_KERNEL)) {
2365
+ p = genradix_ptr_alloc(&fa, nr_files++, GFP_KERNEL);
2366
+ if (!p) {
22192367 ret = -ENOMEM;
2220
- if (fa)
2221
- flex_array_free(fa);
2222
- up_read(&mm->mmap_sem);
2368
+ mmap_read_unlock(mm);
22232369 mmput(mm);
22242370 goto out_put_task;
22252371 }
2226
- for (i = 0, vma = mm->mmap, pos = 2; vma;
2227
- vma = vma->vm_next) {
2228
- if (!vma->vm_file)
2229
- continue;
2230
- if (++pos <= ctx->pos)
2231
- continue;
22322372
2233
- info.start = vma->vm_start;
2234
- info.end = vma->vm_end;
2235
- info.mode = vma->vm_file->f_mode;
2236
- if (flex_array_put(fa, i++, &info, GFP_KERNEL))
2237
- BUG();
2238
- }
2373
+ p->start = vma->vm_start;
2374
+ p->end = vma->vm_end;
2375
+ p->mode = vma->vm_file->f_mode;
22392376 }
2240
- up_read(&mm->mmap_sem);
2377
+ mmap_read_unlock(mm);
22412378 mmput(mm);
22422379
22432380 for (i = 0; i < nr_files; i++) {
22442381 char buf[4 * sizeof(long) + 2]; /* max: %lx-%lx\0 */
22452382 unsigned int len;
22462383
2247
- p = flex_array_get(fa, i);
2384
+ p = genradix_ptr(&fa, i);
22482385 len = snprintf(buf, sizeof(buf), "%lx-%lx", p->start, p->end);
22492386 if (!proc_fill_cache(file, ctx,
22502387 buf, len,
....@@ -2254,12 +2391,11 @@
22542391 break;
22552392 ctx->pos++;
22562393 }
2257
- if (fa)
2258
- flex_array_free(fa);
22592394
22602395 out_put_task:
22612396 put_task_struct(task);
22622397 out:
2398
+ genradix_free(&fa);
22632399 return ret;
22642400 }
22652401
....@@ -2358,7 +2494,7 @@
23582494 return -ENOMEM;
23592495
23602496 tp->pid = proc_pid(inode);
2361
- tp->ns = proc_pid_ns(inode);
2497
+ tp->ns = proc_pid_ns(inode->i_sb);
23622498 return 0;
23632499 }
23642500
....@@ -2387,10 +2523,13 @@
23872523 return -ESRCH;
23882524
23892525 if (p != current) {
2390
- if (!capable(CAP_SYS_NICE)) {
2526
+ rcu_read_lock();
2527
+ if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
2528
+ rcu_read_unlock();
23912529 count = -EPERM;
23922530 goto out;
23932531 }
2532
+ rcu_read_unlock();
23942533
23952534 err = security_task_setscheduler(p);
23962535 if (err) {
....@@ -2423,11 +2562,14 @@
24232562 return -ESRCH;
24242563
24252564 if (p != current) {
2426
-
2427
- if (!capable(CAP_SYS_NICE)) {
2565
+ rcu_read_lock();
2566
+ if (!ns_capable(__task_cred(p)->user_ns, CAP_SYS_NICE)) {
2567
+ rcu_read_unlock();
24282568 err = -EPERM;
24292569 goto out;
24302570 }
2571
+ rcu_read_unlock();
2572
+
24312573 err = security_task_getscheduler(p);
24322574 if (err)
24332575 goto out;
....@@ -2482,11 +2624,10 @@
24822624
24832625 static struct dentry *proc_pident_lookup(struct inode *dir,
24842626 struct dentry *dentry,
2485
- const struct pid_entry *ents,
2486
- unsigned int nents)
2627
+ const struct pid_entry *p,
2628
+ const struct pid_entry *end)
24872629 {
24882630 struct task_struct *task = get_proc_task(dir);
2489
- const struct pid_entry *p, *last;
24902631 struct dentry *res = ERR_PTR(-ENOENT);
24912632
24922633 if (!task)
....@@ -2496,8 +2637,7 @@
24962637 * Yes, it does not scale. And it should not. Don't add
24972638 * new entries into /proc/<tgid>/ without very good reasons.
24982639 */
2499
- last = &ents[nents];
2500
- for (p = ents; p < last; p++) {
2640
+ for (; p < end; p++) {
25012641 if (p->len != dentry->d_name.len)
25022642 continue;
25032643 if (!memcmp(dentry->d_name.name, p->name, p->len)) {
....@@ -2555,7 +2695,7 @@
25552695 if (!task)
25562696 return -ESRCH;
25572697
2558
- length = security_getprocattr(task,
2698
+ length = security_getprocattr(task, PROC_I(inode)->op.lsm,
25592699 (char*)file->f_path.dentry->d_name.name,
25602700 &p);
25612701 put_task_struct(task);
....@@ -2613,7 +2753,9 @@
26132753 if (rv < 0)
26142754 goto out_free;
26152755
2616
- rv = security_setprocattr(file->f_path.dentry->d_name.name, page, count);
2756
+ rv = security_setprocattr(PROC_I(inode)->op.lsm,
2757
+ file->f_path.dentry->d_name.name, page,
2758
+ count);
26172759 mutex_unlock(&current->signal->cred_guard_mutex);
26182760 out_free:
26192761 kfree(page);
....@@ -2629,13 +2771,66 @@
26292771 .release = mem_release,
26302772 };
26312773
2774
+#define LSM_DIR_OPS(LSM) \
2775
+static int proc_##LSM##_attr_dir_iterate(struct file *filp, \
2776
+ struct dir_context *ctx) \
2777
+{ \
2778
+ return proc_pident_readdir(filp, ctx, \
2779
+ LSM##_attr_dir_stuff, \
2780
+ ARRAY_SIZE(LSM##_attr_dir_stuff)); \
2781
+} \
2782
+\
2783
+static const struct file_operations proc_##LSM##_attr_dir_ops = { \
2784
+ .read = generic_read_dir, \
2785
+ .iterate = proc_##LSM##_attr_dir_iterate, \
2786
+ .llseek = default_llseek, \
2787
+}; \
2788
+\
2789
+static struct dentry *proc_##LSM##_attr_dir_lookup(struct inode *dir, \
2790
+ struct dentry *dentry, unsigned int flags) \
2791
+{ \
2792
+ return proc_pident_lookup(dir, dentry, \
2793
+ LSM##_attr_dir_stuff, \
2794
+ LSM##_attr_dir_stuff + ARRAY_SIZE(LSM##_attr_dir_stuff)); \
2795
+} \
2796
+\
2797
+static const struct inode_operations proc_##LSM##_attr_dir_inode_ops = { \
2798
+ .lookup = proc_##LSM##_attr_dir_lookup, \
2799
+ .getattr = pid_getattr, \
2800
+ .setattr = proc_setattr, \
2801
+}
2802
+
2803
+#ifdef CONFIG_SECURITY_SMACK
2804
+static const struct pid_entry smack_attr_dir_stuff[] = {
2805
+ ATTR("smack", "current", 0666),
2806
+};
2807
+LSM_DIR_OPS(smack);
2808
+#endif
2809
+
2810
+#ifdef CONFIG_SECURITY_APPARMOR
2811
+static const struct pid_entry apparmor_attr_dir_stuff[] = {
2812
+ ATTR("apparmor", "current", 0666),
2813
+ ATTR("apparmor", "prev", 0444),
2814
+ ATTR("apparmor", "exec", 0666),
2815
+};
2816
+LSM_DIR_OPS(apparmor);
2817
+#endif
2818
+
26322819 static const struct pid_entry attr_dir_stuff[] = {
2633
- REG("current", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2634
- REG("prev", S_IRUGO, proc_pid_attr_operations),
2635
- REG("exec", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2636
- REG("fscreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2637
- REG("keycreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2638
- REG("sockcreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2820
+ ATTR(NULL, "current", 0666),
2821
+ ATTR(NULL, "prev", 0444),
2822
+ ATTR(NULL, "exec", 0666),
2823
+ ATTR(NULL, "fscreate", 0666),
2824
+ ATTR(NULL, "keycreate", 0666),
2825
+ ATTR(NULL, "sockcreate", 0666),
2826
+#ifdef CONFIG_SECURITY_SMACK
2827
+ DIR("smack", 0555,
2828
+ proc_smack_attr_dir_inode_ops, proc_smack_attr_dir_ops),
2829
+#endif
2830
+#ifdef CONFIG_SECURITY_APPARMOR
2831
+ DIR("apparmor", 0555,
2832
+ proc_apparmor_attr_dir_inode_ops, proc_apparmor_attr_dir_ops),
2833
+#endif
26392834 };
26402835
26412836 static int proc_attr_dir_readdir(struct file *file, struct dir_context *ctx)
....@@ -2654,7 +2849,8 @@
26542849 struct dentry *dentry, unsigned int flags)
26552850 {
26562851 return proc_pident_lookup(dir, dentry,
2657
- attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff));
2852
+ attr_dir_stuff,
2853
+ attr_dir_stuff + ARRAY_SIZE(attr_dir_stuff));
26582854 }
26592855
26602856 static const struct inode_operations proc_attr_dir_inode_operations = {
....@@ -2749,7 +2945,7 @@
27492945 unsigned long flags;
27502946 int result;
27512947
2752
- result = mutex_lock_killable(&task->signal->cred_guard_mutex);
2948
+ result = down_read_killable(&task->signal->exec_update_lock);
27532949 if (result)
27542950 return result;
27552951
....@@ -2785,7 +2981,7 @@
27852981 result = 0;
27862982
27872983 out_unlock:
2788
- mutex_unlock(&task->signal->cred_guard_mutex);
2984
+ up_read(&task->signal->exec_update_lock);
27892985 return result;
27902986 }
27912987
....@@ -2954,6 +3150,21 @@
29543150 }
29553151 #endif /* CONFIG_LIVEPATCH */
29563152
3153
+#ifdef CONFIG_STACKLEAK_METRICS
3154
+static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns,
3155
+ struct pid *pid, struct task_struct *task)
3156
+{
3157
+ unsigned long prev_depth = THREAD_SIZE -
3158
+ (task->prev_lowest_stack & (THREAD_SIZE - 1));
3159
+ unsigned long depth = THREAD_SIZE -
3160
+ (task->lowest_stack & (THREAD_SIZE - 1));
3161
+
3162
+ seq_printf(m, "previous stack depth: %lu\nstack depth: %lu\n",
3163
+ prev_depth, depth);
3164
+ return 0;
3165
+}
3166
+#endif /* CONFIG_STACKLEAK_METRICS */
3167
+
29573168 /*
29583169 * Thread groups
29593170 */
....@@ -2964,7 +3175,7 @@
29643175 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
29653176 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
29663177 DIR("map_files", S_IRUSR|S_IXUSR, proc_map_files_inode_operations, proc_map_files_operations),
2967
- DIR("fdinfo", S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations),
3178
+ DIR("fdinfo", S_IRUGO|S_IXUGO, proc_fdinfo_inode_operations, proc_fdinfo_operations),
29683179 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
29693180 #ifdef CONFIG_NET
29703181 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
....@@ -2979,6 +3190,9 @@
29793190 #endif
29803191 #ifdef CONFIG_SCHED_AUTOGROUP
29813192 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
3193
+#endif
3194
+#ifdef CONFIG_TIME_NS
3195
+ REG("timens_offsets", S_IRUGO|S_IWUSR, proc_timens_offsets_operations),
29823196 #endif
29833197 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
29843198 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
....@@ -3025,10 +3239,13 @@
30253239 #ifdef CONFIG_CGROUPS
30263240 ONE("cgroup", S_IRUGO, proc_cgroup_show),
30273241 #endif
3242
+#ifdef CONFIG_PROC_CPU_RESCTRL
3243
+ ONE("cpu_resctrl_groups", S_IRUGO, proc_resctrl_show),
3244
+#endif
30283245 ONE("oom_score", S_IRUGO, proc_oom_score),
30293246 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
30303247 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
3031
-#ifdef CONFIG_AUDITSYSCALL
3248
+#ifdef CONFIG_AUDIT
30323249 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
30333250 REG("sessionid", S_IRUGO, proc_sessionid_operations),
30343251 #endif
....@@ -3058,6 +3275,12 @@
30583275 #ifdef CONFIG_CPU_FREQ_TIMES
30593276 ONE("time_in_state", 0444, proc_time_in_state_show),
30603277 #endif
3278
+#ifdef CONFIG_STACKLEAK_METRICS
3279
+ ONE("stack_depth", S_IRUGO, proc_stack_depth),
3280
+#endif
3281
+#ifdef CONFIG_PROC_PID_ARCH_STATUS
3282
+ ONE("arch_status", S_IRUGO, proc_pid_arch_status),
3283
+#endif
30613284 };
30623285
30633286 static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
....@@ -3074,8 +3297,7 @@
30743297
30753298 struct pid *tgid_pidfd_to_pid(const struct file *file)
30763299 {
3077
- if (!d_is_dir(file->f_path.dentry) ||
3078
- (file->f_op != &proc_tgid_base_operations))
3300
+ if (file->f_op != &proc_tgid_base_operations)
30793301 return ERR_PTR(-EBADF);
30803302
30813303 return proc_pid(file_inode(file));
....@@ -3084,7 +3306,8 @@
30843306 static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
30853307 {
30863308 return proc_pident_lookup(dir, dentry,
3087
- tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
3309
+ tgid_base_stuff,
3310
+ tgid_base_stuff + ARRAY_SIZE(tgid_base_stuff));
30883311 }
30893312
30903313 static const struct inode_operations proc_tgid_base_inode_operations = {
....@@ -3094,90 +3317,28 @@
30943317 .permission = proc_pid_permission,
30953318 };
30963319
3097
-static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
3098
-{
3099
- struct dentry *dentry, *leader, *dir;
3100
- char buf[10 + 1];
3101
- struct qstr name;
3102
-
3103
- name.name = buf;
3104
- name.len = snprintf(buf, sizeof(buf), "%u", pid);
3105
- /* no ->d_hash() rejects on procfs */
3106
- dentry = d_hash_and_lookup(mnt->mnt_root, &name);
3107
- if (dentry) {
3108
- d_invalidate(dentry);
3109
- dput(dentry);
3110
- }
3111
-
3112
- if (pid == tgid)
3113
- return;
3114
-
3115
- name.name = buf;
3116
- name.len = snprintf(buf, sizeof(buf), "%u", tgid);
3117
- leader = d_hash_and_lookup(mnt->mnt_root, &name);
3118
- if (!leader)
3119
- goto out;
3120
-
3121
- name.name = "task";
3122
- name.len = strlen(name.name);
3123
- dir = d_hash_and_lookup(leader, &name);
3124
- if (!dir)
3125
- goto out_put_leader;
3126
-
3127
- name.name = buf;
3128
- name.len = snprintf(buf, sizeof(buf), "%u", pid);
3129
- dentry = d_hash_and_lookup(dir, &name);
3130
- if (dentry) {
3131
- d_invalidate(dentry);
3132
- dput(dentry);
3133
- }
3134
-
3135
- dput(dir);
3136
-out_put_leader:
3137
- dput(leader);
3138
-out:
3139
- return;
3140
-}
3141
-
31423320 /**
3143
- * proc_flush_task - Remove dcache entries for @task from the /proc dcache.
3144
- * @task: task that should be flushed.
3321
+ * proc_flush_pid - Remove dcache entries for @pid from the /proc dcache.
3322
+ * @pid: pid that should be flushed.
31453323 *
3146
- * When flushing dentries from proc, one needs to flush them from global
3147
- * proc (proc_mnt) and from all the namespaces' procs this task was seen
3148
- * in. This call is supposed to do all of this job.
3149
- *
3150
- * Looks in the dcache for
3151
- * /proc/@pid
3152
- * /proc/@tgid/task/@pid
3153
- * if either directory is present flushes it and all of it'ts children
3154
- * from the dcache.
3324
+ * This function walks a list of inodes (that belong to any proc
3325
+ * filesystem) that are attached to the pid and flushes them from
3326
+ * the dentry cache.
31553327 *
31563328 * It is safe and reasonable to cache /proc entries for a task until
31573329 * that task exits. After that they just clog up the dcache with
31583330 * useless entries, possibly causing useful dcache entries to be
3159
- * flushed instead. This routine is proved to flush those useless
3160
- * dcache entries at process exit time.
3331
+ * flushed instead. This routine is provided to flush those useless
3332
+ * dcache entries when a process is reaped.
31613333 *
31623334 * NOTE: This routine is just an optimization so it does not guarantee
3163
- * that no dcache entries will exist at process exit time it
3164
- * just makes it very unlikely that any will persist.
3335
+ * that no dcache entries will exist after a process is reaped
3336
+ * it just makes it very unlikely that any will persist.
31653337 */
31663338
3167
-void proc_flush_task(struct task_struct *task)
3339
+void proc_flush_pid(struct pid *pid)
31683340 {
3169
- int i;
3170
- struct pid *pid, *tgid;
3171
- struct upid *upid;
3172
-
3173
- pid = task_pid(task);
3174
- tgid = task_tgid(task);
3175
-
3176
- for (i = 0; i <= pid->level; i++) {
3177
- upid = &pid->numbers[i];
3178
- proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr,
3179
- tgid->numbers[i].nr);
3180
- }
3341
+ proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock);
31813342 }
31823343
31833344 static struct dentry *proc_pid_instantiate(struct dentry * dentry,
....@@ -3200,10 +3361,11 @@
32003361 return d_splice_alias(inode, dentry);
32013362 }
32023363
3203
-struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
3364
+struct dentry *proc_pid_lookup(struct dentry *dentry, unsigned int flags)
32043365 {
32053366 struct task_struct *task;
32063367 unsigned tgid;
3368
+ struct proc_fs_info *fs_info;
32073369 struct pid_namespace *ns;
32083370 struct dentry *result = ERR_PTR(-ENOENT);
32093371
....@@ -3211,7 +3373,8 @@
32113373 if (tgid == ~0U)
32123374 goto out;
32133375
3214
- ns = dentry->d_sb->s_fs_info;
3376
+ fs_info = proc_sb_info(dentry->d_sb);
3377
+ ns = fs_info->pid_ns;
32153378 rcu_read_lock();
32163379 task = find_task_by_pid_ns(tgid, ns);
32173380 if (task)
....@@ -3220,7 +3383,14 @@
32203383 if (!task)
32213384 goto out;
32223385
3386
+ /* Limit procfs to only ptraceable tasks */
3387
+ if (fs_info->hide_pid == HIDEPID_NOT_PTRACEABLE) {
3388
+ if (!has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS))
3389
+ goto out_put_task;
3390
+ }
3391
+
32233392 result = proc_pid_instantiate(dentry, task, NULL);
3393
+out_put_task:
32243394 put_task_struct(task);
32253395 out:
32263396 return result;
....@@ -3246,20 +3416,8 @@
32463416 pid = find_ge_pid(iter.tgid, ns);
32473417 if (pid) {
32483418 iter.tgid = pid_nr_ns(pid, ns);
3249
- iter.task = pid_task(pid, PIDTYPE_PID);
3250
- /* What we to know is if the pid we have find is the
3251
- * pid of a thread_group_leader. Testing for task
3252
- * being a thread_group_leader is the obvious thing
3253
- * todo but there is a window when it fails, due to
3254
- * the pid transfer logic in de_thread.
3255
- *
3256
- * So we perform the straight forward test of seeing
3257
- * if the pid we have found is the pid of a thread
3258
- * group leader, and don't worry if the task we have
3259
- * found doesn't happen to be a thread group leader.
3260
- * As we don't care in the case of readdir.
3261
- */
3262
- if (!iter.task || !has_group_leader_pid(iter.task)) {
3419
+ iter.task = pid_task(pid, PIDTYPE_TGID);
3420
+ if (!iter.task) {
32633421 iter.tgid += 1;
32643422 goto retry;
32653423 }
....@@ -3275,20 +3433,21 @@
32753433 int proc_pid_readdir(struct file *file, struct dir_context *ctx)
32763434 {
32773435 struct tgid_iter iter;
3278
- struct pid_namespace *ns = proc_pid_ns(file_inode(file));
3436
+ struct proc_fs_info *fs_info = proc_sb_info(file_inode(file)->i_sb);
3437
+ struct pid_namespace *ns = proc_pid_ns(file_inode(file)->i_sb);
32793438 loff_t pos = ctx->pos;
32803439
32813440 if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
32823441 return 0;
32833442
32843443 if (pos == TGID_OFFSET - 2) {
3285
- struct inode *inode = d_inode(ns->proc_self);
3444
+ struct inode *inode = d_inode(fs_info->proc_self);
32863445 if (!dir_emit(ctx, "self", 4, inode->i_ino, DT_LNK))
32873446 return 0;
32883447 ctx->pos = pos = pos + 1;
32893448 }
32903449 if (pos == TGID_OFFSET - 1) {
3291
- struct inode *inode = d_inode(ns->proc_thread_self);
3450
+ struct inode *inode = d_inode(fs_info->proc_thread_self);
32923451 if (!dir_emit(ctx, "thread-self", 11, inode->i_ino, DT_LNK))
32933452 return 0;
32943453 ctx->pos = pos = pos + 1;
....@@ -3302,7 +3461,7 @@
33023461 unsigned int len;
33033462
33043463 cond_resched();
3305
- if (!has_pid_permissions(ns, iter.task, HIDEPID_INVISIBLE))
3464
+ if (!has_pid_permissions(fs_info, iter.task, HIDEPID_INVISIBLE))
33063465 continue;
33073466
33083467 len = snprintf(name, sizeof(name), "%u", iter.tgid);
....@@ -3360,7 +3519,7 @@
33603519 */
33613520 static const struct pid_entry tid_base_stuff[] = {
33623521 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
3363
- DIR("fdinfo", S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations),
3522
+ DIR("fdinfo", S_IRUGO|S_IXUGO, proc_fdinfo_inode_operations, proc_fdinfo_operations),
33643523 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
33653524 #ifdef CONFIG_NET
33663525 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
....@@ -3422,10 +3581,13 @@
34223581 #ifdef CONFIG_CGROUPS
34233582 ONE("cgroup", S_IRUGO, proc_cgroup_show),
34243583 #endif
3584
+#ifdef CONFIG_PROC_CPU_RESCTRL
3585
+ ONE("cpu_resctrl_groups", S_IRUGO, proc_resctrl_show),
3586
+#endif
34253587 ONE("oom_score", S_IRUGO, proc_oom_score),
34263588 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
34273589 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
3428
-#ifdef CONFIG_AUDITSYSCALL
3590
+#ifdef CONFIG_AUDIT
34293591 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
34303592 REG("sessionid", S_IRUGO, proc_sessionid_operations),
34313593 #endif
....@@ -3445,6 +3607,9 @@
34453607 #ifdef CONFIG_LIVEPATCH
34463608 ONE("patch_state", S_IRUSR, proc_pid_patch_state),
34473609 #endif
3610
+#ifdef CONFIG_PROC_PID_ARCH_STATUS
3611
+ ONE("arch_status", S_IRUGO, proc_pid_arch_status),
3612
+#endif
34483613 #ifdef CONFIG_CPU_FREQ_TIMES
34493614 ONE("time_in_state", 0444, proc_time_in_state_show),
34503615 #endif
....@@ -3459,7 +3624,8 @@
34593624 static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
34603625 {
34613626 return proc_pident_lookup(dir, dentry,
3462
- tid_base_stuff, ARRAY_SIZE(tid_base_stuff));
3627
+ tid_base_stuff,
3628
+ tid_base_stuff + ARRAY_SIZE(tid_base_stuff));
34633629 }
34643630
34653631 static const struct file_operations proc_tid_base_operations = {
....@@ -3498,6 +3664,7 @@
34983664 struct task_struct *task;
34993665 struct task_struct *leader = get_proc_task(dir);
35003666 unsigned tid;
3667
+ struct proc_fs_info *fs_info;
35013668 struct pid_namespace *ns;
35023669 struct dentry *result = ERR_PTR(-ENOENT);
35033670
....@@ -3508,7 +3675,8 @@
35083675 if (tid == ~0U)
35093676 goto out;
35103677
3511
- ns = dentry->d_sb->s_fs_info;
3678
+ fs_info = proc_sb_info(dentry->d_sb);
3679
+ ns = fs_info->pid_ns;
35123680 rcu_read_lock();
35133681 task = find_task_by_pid_ns(tid, ns);
35143682 if (task)
....@@ -3622,7 +3790,7 @@
36223790 /* f_version caches the tgid value that the last readdir call couldn't
36233791 * return. lseek aka telldir automagically resets f_version to 0.
36243792 */
3625
- ns = proc_pid_ns(inode);
3793
+ ns = proc_pid_ns(inode->i_sb);
36263794 tid = (int)file->f_version;
36273795 file->f_version = 0;
36283796 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);