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,8 +93,10 @@
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>
99102 #include "internal.h"
....@@ -141,9 +144,13 @@
141144 #define REG(NAME, MODE, fops) \
142145 NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})
143146 #define ONE(NAME, MODE, show) \
144
- NOD(NAME, (S_IFREG|(MODE)), \
147
+ NOD(NAME, (S_IFREG|(MODE)), \
145148 NULL, &proc_single_file_operations, \
146149 { .proc_show = show } )
150
+#define ATTR(LSM, NAME, MODE) \
151
+ NOD(NAME, (S_IFREG|(MODE)), \
152
+ NULL, &proc_pid_attr_operations, \
153
+ { .lsm = LSM })
147154
148155 /*
149156 * Count the number of hardlinks for the pid_entry table, excluding the .
....@@ -400,11 +407,11 @@
400407
401408 static int lock_trace(struct task_struct *task)
402409 {
403
- int err = mutex_lock_killable(&task->signal->cred_guard_mutex);
410
+ int err = down_read_killable(&task->signal->exec_update_lock);
404411 if (err)
405412 return err;
406413 if (!ptrace_may_access(task, PTRACE_MODE_ATTACH_FSCREDS)) {
407
- mutex_unlock(&task->signal->cred_guard_mutex);
414
+ up_read(&task->signal->exec_update_lock);
408415 return -EPERM;
409416 }
410417 return 0;
....@@ -412,7 +419,7 @@
412419
413420 static void unlock_trace(struct task_struct *task)
414421 {
415
- mutex_unlock(&task->signal->cred_guard_mutex);
422
+ up_read(&task->signal->exec_update_lock);
416423 }
417424
418425 #ifdef CONFIG_STACKTRACE
....@@ -422,7 +429,6 @@
422429 static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
423430 struct pid *pid, struct task_struct *task)
424431 {
425
- struct stack_trace trace;
426432 unsigned long *entries;
427433 int err;
428434
....@@ -445,20 +451,17 @@
445451 if (!entries)
446452 return -ENOMEM;
447453
448
- trace.nr_entries = 0;
449
- trace.max_entries = MAX_STACK_TRACE_DEPTH;
450
- trace.entries = entries;
451
- trace.skip = 0;
452
-
453454 err = lock_trace(task);
454455 if (!err) {
455
- unsigned int i;
456
+ unsigned int i, nr_entries;
456457
457
- save_stack_trace_tsk(task, &trace);
458
+ nr_entries = stack_trace_save_tsk(task, entries,
459
+ MAX_STACK_TRACE_DEPTH, 0);
458460
459
- for (i = 0; i < trace.nr_entries; i++) {
461
+ for (i = 0; i < nr_entries; i++) {
460462 seq_printf(m, "[<0>] %pB\n", (void *)entries[i]);
461463 }
464
+
462465 unlock_trace(task);
463466 }
464467 kfree(entries);
....@@ -475,7 +478,7 @@
475478 struct pid *pid, struct task_struct *task)
476479 {
477480 if (unlikely(!sched_info_on()))
478
- seq_printf(m, "0 0 0\n");
481
+ seq_puts(m, "0 0 0\n");
479482 else
480483 seq_printf(m, "%llu %llu %lu\n",
481484 (unsigned long long)task->se.sum_exec_runtime,
....@@ -504,9 +507,8 @@
504507 lr->count, lr->time, lr->max);
505508 for (q = 0; q < LT_BACKTRACEDEPTH; q++) {
506509 unsigned long bt = lr->backtrace[q];
510
+
507511 if (!bt)
508
- break;
509
- if (bt == ULONG_MAX)
510512 break;
511513 seq_printf(m, " %ps", (void *)bt);
512514 }
....@@ -530,7 +532,7 @@
530532
531533 if (!task)
532534 return -ESRCH;
533
- clear_all_latency_tracing(task);
535
+ clear_tsk_latency_tracing(task);
534536 put_task_struct(task);
535537
536538 return count;
....@@ -549,11 +551,19 @@
549551 static int proc_oom_score(struct seq_file *m, struct pid_namespace *ns,
550552 struct pid *pid, struct task_struct *task)
551553 {
552
- unsigned long totalpages = totalram_pages + total_swap_pages;
554
+ unsigned long totalpages = totalram_pages() + total_swap_pages;
553555 unsigned long points = 0;
556
+ long badness;
554557
555
- points = oom_badness(task, NULL, NULL, totalpages) *
556
- 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
+
557567 seq_printf(m, "%lu\n", points);
558568
559569 return 0;
....@@ -600,8 +610,10 @@
600610 /*
601611 * print the file header
602612 */
603
- seq_printf(m, "%-25s %-20s %-20s %-10s\n",
604
- "Limit", "Soft Limit", "Hard Limit", "Units");
613
+ seq_puts(m, "Limit "
614
+ "Soft Limit "
615
+ "Hard Limit "
616
+ "Units \n");
605617
606618 for (i = 0; i < RLIM_NLIMITS; i++) {
607619 if (rlim[i].rlim_cur == RLIM_INFINITY)
....@@ -629,24 +641,25 @@
629641 static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
630642 struct pid *pid, struct task_struct *task)
631643 {
632
- long nr;
633
- unsigned long args[6], sp, pc;
644
+ struct syscall_info info;
645
+ u64 *args = &info.data.args[0];
634646 int res;
635647
636648 res = lock_trace(task);
637649 if (res)
638650 return res;
639651
640
- if (task_current_syscall(task, &nr, args, 6, &sp, &pc))
652
+ if (task_current_syscall(task, &info))
641653 seq_puts(m, "running\n");
642
- else if (nr < 0)
643
- 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);
644657 else
645658 seq_printf(m,
646
- "%ld 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
647
- nr,
659
+ "%d 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx 0x%llx\n",
660
+ info.data.nr,
648661 args[0], args[1], args[2], args[3], args[4], args[5],
649
- sp, pc);
662
+ info.sp, info.data.instruction_pointer);
650663 unlock_trace(task);
651664
652665 return 0;
....@@ -695,13 +708,21 @@
695708 * May current process learn task's sched/cmdline info (for hide_pid_min=1)
696709 * or euid/egid (for hide_pid_min=2)?
697710 */
698
-static bool has_pid_permissions(struct pid_namespace *pid,
711
+static bool has_pid_permissions(struct proc_fs_info *fs_info,
699712 struct task_struct *task,
700
- int hide_pid_min)
713
+ enum proc_hidepid hide_pid_min)
701714 {
702
- 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)
703724 return true;
704
- if (in_group_p(pid->pid_gid))
725
+ if (in_group_p(fs_info->pid_gid))
705726 return true;
706727 return ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS);
707728 }
....@@ -709,18 +730,18 @@
709730
710731 static int proc_pid_permission(struct inode *inode, int mask)
711732 {
712
- struct pid_namespace *pid = proc_pid_ns(inode);
733
+ struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
713734 struct task_struct *task;
714735 bool has_perms;
715736
716737 task = get_proc_task(inode);
717738 if (!task)
718739 return -ESRCH;
719
- has_perms = has_pid_permissions(pid, task, HIDEPID_NO_ACCESS);
740
+ has_perms = has_pid_permissions(fs_info, task, HIDEPID_NO_ACCESS);
720741 put_task_struct(task);
721742
722743 if (!has_perms) {
723
- if (pid->hide_pid == HIDEPID_INVISIBLE) {
744
+ if (fs_info->hide_pid == HIDEPID_INVISIBLE) {
724745 /*
725746 * Let's make getdents(), stat(), and open()
726747 * consistent with each other. If a process
....@@ -744,7 +765,7 @@
744765 static int proc_single_show(struct seq_file *m, void *v)
745766 {
746767 struct inode *inode = m->private;
747
- struct pid_namespace *ns = proc_pid_ns(inode);
768
+ struct pid_namespace *ns = proc_pid_ns(inode->i_sb);
748769 struct pid *pid = proc_pid(inode);
749770 struct task_struct *task;
750771 int ret;
....@@ -1030,6 +1051,8 @@
10301051 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
10311052 OOM_SCORE_ADJ_MAX;
10321053 put_task_struct(task);
1054
+ if (oom_adj > OOM_ADJUST_MAX)
1055
+ oom_adj = OOM_ADJUST_MAX;
10331056 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
10341057 return simple_read_from_buffer(buf, count, ppos, buffer, len);
10351058 }
....@@ -1222,7 +1245,7 @@
12221245 .llseek = default_llseek,
12231246 };
12241247
1225
-#ifdef CONFIG_AUDITSYSCALL
1248
+#ifdef CONFIG_AUDIT
12261249 #define TMPBUFLEN 11
12271250 static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
12281251 size_t count, loff_t *ppos)
....@@ -1248,6 +1271,10 @@
12481271 uid_t loginuid;
12491272 kuid_t kloginuid;
12501273 int rv;
1274
+
1275
+ /* Don't let kthreads write their own loginuid */
1276
+ if (current->flags & PF_KTHREAD)
1277
+ return -EPERM;
12511278
12521279 rcu_read_lock();
12531280 if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
....@@ -1412,7 +1439,7 @@
14121439 static int sched_show(struct seq_file *m, void *v)
14131440 {
14141441 struct inode *inode = m->private;
1415
- struct pid_namespace *ns = proc_pid_ns(inode);
1442
+ struct pid_namespace *ns = proc_pid_ns(inode->i_sb);
14161443 struct task_struct *p;
14171444
14181445 p = get_proc_task(inode);
....@@ -1532,6 +1559,108 @@
15321559
15331560 #endif /* CONFIG_SCHED_AUTOGROUP */
15341561
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
+
15351664 static ssize_t comm_write(struct file *file, const char __user *buf,
15361665 size_t count, loff_t *offset)
15371666 {
....@@ -1625,8 +1754,7 @@
16251754 if (error)
16261755 goto out;
16271756
1628
- nd_jump_link(&path);
1629
- return NULL;
1757
+ error = nd_jump_link(&path);
16301758 out:
16311759 return ERR_PTR(error);
16321760 }
....@@ -1742,11 +1870,25 @@
17421870 *rgid = gid;
17431871 }
17441872
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
+
17451886 struct inode *proc_pid_make_inode(struct super_block * sb,
17461887 struct task_struct *task, umode_t mode)
17471888 {
17481889 struct inode * inode;
17491890 struct proc_inode *ei;
1891
+ struct pid *pid;
17501892
17511893 /* We need a new inode */
17521894
....@@ -1764,9 +1906,17 @@
17641906 /*
17651907 * grab the reference to task.
17661908 */
1767
- ei->pid = get_task_pid(task, PIDTYPE_PID);
1768
- if (!ei->pid)
1909
+ pid = get_task_pid(task, PIDTYPE_PID);
1910
+ if (!pid)
17691911 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
+ }
17701920
17711921 task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid);
17721922 security_task_to_inode(task, inode);
....@@ -1783,7 +1933,7 @@
17831933 u32 request_mask, unsigned int query_flags)
17841934 {
17851935 struct inode *inode = d_inode(path->dentry);
1786
- struct pid_namespace *pid = proc_pid_ns(inode);
1936
+ struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
17871937 struct task_struct *task;
17881938
17891939 generic_fillattr(inode, stat);
....@@ -1793,7 +1943,7 @@
17931943 rcu_read_lock();
17941944 task = pid_task(proc_pid(inode), PIDTYPE_PID);
17951945 if (task) {
1796
- if (!has_pid_permissions(pid, task, HIDEPID_INVISIBLE)) {
1946
+ if (!has_pid_permissions(fs_info, task, HIDEPID_INVISIBLE)) {
17971947 rcu_read_unlock();
17981948 /*
17991949 * This doesn't prevent learning whether PID exists,
....@@ -1890,7 +2040,7 @@
18902040
18912041 child = d_hash_and_lookup(dir, &qname);
18922042 if (!child) {
1893
- DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
2043
+ DECLARE_SWAIT_QUEUE_HEAD_ONSTACK(wq);
18942044 child = d_alloc_parallel(dir, &qname, &wq);
18952045 if (IS_ERR(child))
18962046 goto end_instantiate;
....@@ -1978,11 +2128,11 @@
19782128 goto out;
19792129
19802130 if (!dname_to_vma_addr(dentry, &vm_start, &vm_end)) {
1981
- status = down_read_killable(&mm->mmap_sem);
2131
+ status = mmap_read_lock_killable(mm);
19822132 if (!status) {
19832133 exact_vma_exists = !!find_exact_vma(mm, vm_start,
19842134 vm_end);
1985
- up_read(&mm->mmap_sem);
2135
+ mmap_read_unlock(mm);
19862136 }
19872137 }
19882138
....@@ -2029,7 +2179,7 @@
20292179 if (rc)
20302180 goto out_mmput;
20312181
2032
- rc = down_read_killable(&mm->mmap_sem);
2182
+ rc = mmap_read_lock_killable(mm);
20332183 if (rc)
20342184 goto out_mmput;
20352185
....@@ -2040,7 +2190,7 @@
20402190 path_get(path);
20412191 rc = 0;
20422192 }
2043
- up_read(&mm->mmap_sem);
2193
+ mmap_read_unlock(mm);
20442194
20452195 out_mmput:
20462196 mmput(mm);
....@@ -2055,16 +2205,16 @@
20552205 };
20562206
20572207 /*
2058
- * Only allow CAP_SYS_ADMIN to follow the links, due to concerns about how the
2059
- * symlinks may be used to bypass permissions on ancestor directories in the
2060
- * 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.
20612211 */
20622212 static const char *
20632213 proc_map_files_get_link(struct dentry *dentry,
20642214 struct inode *inode,
20652215 struct delayed_call *done)
20662216 {
2067
- if (!capable(CAP_SYS_ADMIN))
2217
+ if (!checkpoint_restore_ns_capable(&init_user_ns))
20682218 return ERR_PTR(-EPERM);
20692219
20702220 return proc_pid_get_link(dentry, inode, done);
....@@ -2130,7 +2280,7 @@
21302280 goto out_put_task;
21312281
21322282 result = ERR_PTR(-EINTR);
2133
- if (down_read_killable(&mm->mmap_sem))
2283
+ if (mmap_read_lock_killable(mm))
21342284 goto out_put_mm;
21352285
21362286 result = ERR_PTR(-ENOENT);
....@@ -2143,7 +2293,7 @@
21432293 (void *)(unsigned long)vma->vm_file->f_mode);
21442294
21452295 out_no_vma:
2146
- up_read(&mm->mmap_sem);
2296
+ mmap_read_unlock(mm);
21472297 out_put_mm:
21482298 mmput(mm);
21492299 out_put_task:
....@@ -2165,10 +2315,11 @@
21652315 struct task_struct *task;
21662316 struct mm_struct *mm;
21672317 unsigned long nr_files, pos, i;
2168
- struct flex_array *fa = NULL;
2169
- struct map_files_info info;
2318
+ GENRADIX(struct map_files_info) fa;
21702319 struct map_files_info *p;
21712320 int ret;
2321
+
2322
+ genradix_init(&fa);
21722323
21732324 ret = -ENOENT;
21742325 task = get_proc_task(file_inode(file));
....@@ -2187,7 +2338,7 @@
21872338 if (!mm)
21882339 goto out_put_task;
21892340
2190
- ret = down_read_killable(&mm->mmap_sem);
2341
+ ret = mmap_read_lock_killable(mm);
21912342 if (ret) {
21922343 mmput(mm);
21932344 goto out_put_task;
....@@ -2198,52 +2349,39 @@
21982349 /*
21992350 * We need two passes here:
22002351 *
2201
- * 1) Collect vmas of mapped files with mmap_sem taken
2202
- * 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
22032354 *
22042355 * otherwise we get lockdep complained, since filldir()
2205
- * routine might require mmap_sem taken in might_fault().
2356
+ * routine might require mmap_lock taken in might_fault().
22062357 */
22072358
22082359 for (vma = mm->mmap, pos = 2; vma; vma = vma->vm_next) {
2209
- if (vma->vm_file && ++pos > ctx->pos)
2210
- nr_files++;
2211
- }
2360
+ if (!vma->vm_file)
2361
+ continue;
2362
+ if (++pos <= ctx->pos)
2363
+ continue;
22122364
2213
- if (nr_files) {
2214
- fa = flex_array_alloc(sizeof(info), nr_files,
2215
- GFP_KERNEL);
2216
- if (!fa || flex_array_prealloc(fa, 0, nr_files,
2217
- GFP_KERNEL)) {
2365
+ p = genradix_ptr_alloc(&fa, nr_files++, GFP_KERNEL);
2366
+ if (!p) {
22182367 ret = -ENOMEM;
2219
- if (fa)
2220
- flex_array_free(fa);
2221
- up_read(&mm->mmap_sem);
2368
+ mmap_read_unlock(mm);
22222369 mmput(mm);
22232370 goto out_put_task;
22242371 }
2225
- for (i = 0, vma = mm->mmap, pos = 2; vma;
2226
- vma = vma->vm_next) {
2227
- if (!vma->vm_file)
2228
- continue;
2229
- if (++pos <= ctx->pos)
2230
- continue;
22312372
2232
- info.start = vma->vm_start;
2233
- info.end = vma->vm_end;
2234
- info.mode = vma->vm_file->f_mode;
2235
- if (flex_array_put(fa, i++, &info, GFP_KERNEL))
2236
- BUG();
2237
- }
2373
+ p->start = vma->vm_start;
2374
+ p->end = vma->vm_end;
2375
+ p->mode = vma->vm_file->f_mode;
22382376 }
2239
- up_read(&mm->mmap_sem);
2377
+ mmap_read_unlock(mm);
22402378 mmput(mm);
22412379
22422380 for (i = 0; i < nr_files; i++) {
22432381 char buf[4 * sizeof(long) + 2]; /* max: %lx-%lx\0 */
22442382 unsigned int len;
22452383
2246
- p = flex_array_get(fa, i);
2384
+ p = genradix_ptr(&fa, i);
22472385 len = snprintf(buf, sizeof(buf), "%lx-%lx", p->start, p->end);
22482386 if (!proc_fill_cache(file, ctx,
22492387 buf, len,
....@@ -2253,12 +2391,11 @@
22532391 break;
22542392 ctx->pos++;
22552393 }
2256
- if (fa)
2257
- flex_array_free(fa);
22582394
22592395 out_put_task:
22602396 put_task_struct(task);
22612397 out:
2398
+ genradix_free(&fa);
22622399 return ret;
22632400 }
22642401
....@@ -2357,7 +2494,7 @@
23572494 return -ENOMEM;
23582495
23592496 tp->pid = proc_pid(inode);
2360
- tp->ns = proc_pid_ns(inode);
2497
+ tp->ns = proc_pid_ns(inode->i_sb);
23612498 return 0;
23622499 }
23632500
....@@ -2386,10 +2523,13 @@
23862523 return -ESRCH;
23872524
23882525 if (p != current) {
2389
- 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();
23902529 count = -EPERM;
23912530 goto out;
23922531 }
2532
+ rcu_read_unlock();
23932533
23942534 err = security_task_setscheduler(p);
23952535 if (err) {
....@@ -2422,11 +2562,14 @@
24222562 return -ESRCH;
24232563
24242564 if (p != current) {
2425
-
2426
- 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();
24272568 err = -EPERM;
24282569 goto out;
24292570 }
2571
+ rcu_read_unlock();
2572
+
24302573 err = security_task_getscheduler(p);
24312574 if (err)
24322575 goto out;
....@@ -2481,11 +2624,10 @@
24812624
24822625 static struct dentry *proc_pident_lookup(struct inode *dir,
24832626 struct dentry *dentry,
2484
- const struct pid_entry *ents,
2485
- unsigned int nents)
2627
+ const struct pid_entry *p,
2628
+ const struct pid_entry *end)
24862629 {
24872630 struct task_struct *task = get_proc_task(dir);
2488
- const struct pid_entry *p, *last;
24892631 struct dentry *res = ERR_PTR(-ENOENT);
24902632
24912633 if (!task)
....@@ -2495,8 +2637,7 @@
24952637 * Yes, it does not scale. And it should not. Don't add
24962638 * new entries into /proc/<tgid>/ without very good reasons.
24972639 */
2498
- last = &ents[nents];
2499
- for (p = ents; p < last; p++) {
2640
+ for (; p < end; p++) {
25002641 if (p->len != dentry->d_name.len)
25012642 continue;
25022643 if (!memcmp(dentry->d_name.name, p->name, p->len)) {
....@@ -2554,7 +2695,7 @@
25542695 if (!task)
25552696 return -ESRCH;
25562697
2557
- length = security_getprocattr(task,
2698
+ length = security_getprocattr(task, PROC_I(inode)->op.lsm,
25582699 (char*)file->f_path.dentry->d_name.name,
25592700 &p);
25602701 put_task_struct(task);
....@@ -2612,7 +2753,9 @@
26122753 if (rv < 0)
26132754 goto out_free;
26142755
2615
- 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);
26162759 mutex_unlock(&current->signal->cred_guard_mutex);
26172760 out_free:
26182761 kfree(page);
....@@ -2628,13 +2771,66 @@
26282771 .release = mem_release,
26292772 };
26302773
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
+
26312819 static const struct pid_entry attr_dir_stuff[] = {
2632
- REG("current", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2633
- REG("prev", S_IRUGO, proc_pid_attr_operations),
2634
- REG("exec", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2635
- REG("fscreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2636
- REG("keycreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
2637
- 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
26382834 };
26392835
26402836 static int proc_attr_dir_readdir(struct file *file, struct dir_context *ctx)
....@@ -2653,7 +2849,8 @@
26532849 struct dentry *dentry, unsigned int flags)
26542850 {
26552851 return proc_pident_lookup(dir, dentry,
2656
- attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff));
2852
+ attr_dir_stuff,
2853
+ attr_dir_stuff + ARRAY_SIZE(attr_dir_stuff));
26572854 }
26582855
26592856 static const struct inode_operations proc_attr_dir_inode_operations = {
....@@ -2748,7 +2945,7 @@
27482945 unsigned long flags;
27492946 int result;
27502947
2751
- result = mutex_lock_killable(&task->signal->cred_guard_mutex);
2948
+ result = down_read_killable(&task->signal->exec_update_lock);
27522949 if (result)
27532950 return result;
27542951
....@@ -2784,7 +2981,7 @@
27842981 result = 0;
27852982
27862983 out_unlock:
2787
- mutex_unlock(&task->signal->cred_guard_mutex);
2984
+ up_read(&task->signal->exec_update_lock);
27882985 return result;
27892986 }
27902987
....@@ -2953,6 +3150,21 @@
29533150 }
29543151 #endif /* CONFIG_LIVEPATCH */
29553152
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
+
29563168 /*
29573169 * Thread groups
29583170 */
....@@ -2963,7 +3175,7 @@
29633175 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
29643176 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
29653177 DIR("map_files", S_IRUSR|S_IXUSR, proc_map_files_inode_operations, proc_map_files_operations),
2966
- 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),
29673179 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
29683180 #ifdef CONFIG_NET
29693181 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
....@@ -2978,6 +3190,9 @@
29783190 #endif
29793191 #ifdef CONFIG_SCHED_AUTOGROUP
29803192 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),
29813196 #endif
29823197 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
29833198 #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
....@@ -3024,10 +3239,13 @@
30243239 #ifdef CONFIG_CGROUPS
30253240 ONE("cgroup", S_IRUGO, proc_cgroup_show),
30263241 #endif
3242
+#ifdef CONFIG_PROC_CPU_RESCTRL
3243
+ ONE("cpu_resctrl_groups", S_IRUGO, proc_resctrl_show),
3244
+#endif
30273245 ONE("oom_score", S_IRUGO, proc_oom_score),
30283246 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
30293247 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
3030
-#ifdef CONFIG_AUDITSYSCALL
3248
+#ifdef CONFIG_AUDIT
30313249 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
30323250 REG("sessionid", S_IRUGO, proc_sessionid_operations),
30333251 #endif
....@@ -3057,6 +3275,12 @@
30573275 #ifdef CONFIG_CPU_FREQ_TIMES
30583276 ONE("time_in_state", 0444, proc_time_in_state_show),
30593277 #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
30603284 };
30613285
30623286 static int proc_tgid_base_readdir(struct file *file, struct dir_context *ctx)
....@@ -3073,8 +3297,7 @@
30733297
30743298 struct pid *tgid_pidfd_to_pid(const struct file *file)
30753299 {
3076
- if (!d_is_dir(file->f_path.dentry) ||
3077
- (file->f_op != &proc_tgid_base_operations))
3300
+ if (file->f_op != &proc_tgid_base_operations)
30783301 return ERR_PTR(-EBADF);
30793302
30803303 return proc_pid(file_inode(file));
....@@ -3083,7 +3306,8 @@
30833306 static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
30843307 {
30853308 return proc_pident_lookup(dir, dentry,
3086
- tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
3309
+ tgid_base_stuff,
3310
+ tgid_base_stuff + ARRAY_SIZE(tgid_base_stuff));
30873311 }
30883312
30893313 static const struct inode_operations proc_tgid_base_inode_operations = {
....@@ -3093,90 +3317,28 @@
30933317 .permission = proc_pid_permission,
30943318 };
30953319
3096
-static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
3097
-{
3098
- struct dentry *dentry, *leader, *dir;
3099
- char buf[10 + 1];
3100
- struct qstr name;
3101
-
3102
- name.name = buf;
3103
- name.len = snprintf(buf, sizeof(buf), "%u", pid);
3104
- /* no ->d_hash() rejects on procfs */
3105
- dentry = d_hash_and_lookup(mnt->mnt_root, &name);
3106
- if (dentry) {
3107
- d_invalidate(dentry);
3108
- dput(dentry);
3109
- }
3110
-
3111
- if (pid == tgid)
3112
- return;
3113
-
3114
- name.name = buf;
3115
- name.len = snprintf(buf, sizeof(buf), "%u", tgid);
3116
- leader = d_hash_and_lookup(mnt->mnt_root, &name);
3117
- if (!leader)
3118
- goto out;
3119
-
3120
- name.name = "task";
3121
- name.len = strlen(name.name);
3122
- dir = d_hash_and_lookup(leader, &name);
3123
- if (!dir)
3124
- goto out_put_leader;
3125
-
3126
- name.name = buf;
3127
- name.len = snprintf(buf, sizeof(buf), "%u", pid);
3128
- dentry = d_hash_and_lookup(dir, &name);
3129
- if (dentry) {
3130
- d_invalidate(dentry);
3131
- dput(dentry);
3132
- }
3133
-
3134
- dput(dir);
3135
-out_put_leader:
3136
- dput(leader);
3137
-out:
3138
- return;
3139
-}
3140
-
31413320 /**
3142
- * proc_flush_task - Remove dcache entries for @task from the /proc dcache.
3143
- * @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.
31443323 *
3145
- * When flushing dentries from proc, one needs to flush them from global
3146
- * proc (proc_mnt) and from all the namespaces' procs this task was seen
3147
- * in. This call is supposed to do all of this job.
3148
- *
3149
- * Looks in the dcache for
3150
- * /proc/@pid
3151
- * /proc/@tgid/task/@pid
3152
- * if either directory is present flushes it and all of it'ts children
3153
- * 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.
31543327 *
31553328 * It is safe and reasonable to cache /proc entries for a task until
31563329 * that task exits. After that they just clog up the dcache with
31573330 * useless entries, possibly causing useful dcache entries to be
3158
- * flushed instead. This routine is proved to flush those useless
3159
- * 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.
31603333 *
31613334 * NOTE: This routine is just an optimization so it does not guarantee
3162
- * that no dcache entries will exist at process exit time it
3163
- * 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.
31643337 */
31653338
3166
-void proc_flush_task(struct task_struct *task)
3339
+void proc_flush_pid(struct pid *pid)
31673340 {
3168
- int i;
3169
- struct pid *pid, *tgid;
3170
- struct upid *upid;
3171
-
3172
- pid = task_pid(task);
3173
- tgid = task_tgid(task);
3174
-
3175
- for (i = 0; i <= pid->level; i++) {
3176
- upid = &pid->numbers[i];
3177
- proc_flush_task_mnt(upid->ns->proc_mnt, upid->nr,
3178
- tgid->numbers[i].nr);
3179
- }
3341
+ proc_invalidate_siblings_dcache(&pid->inodes, &pid->lock);
31803342 }
31813343
31823344 static struct dentry *proc_pid_instantiate(struct dentry * dentry,
....@@ -3199,10 +3361,11 @@
31993361 return d_splice_alias(inode, dentry);
32003362 }
32013363
3202
-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)
32033365 {
32043366 struct task_struct *task;
32053367 unsigned tgid;
3368
+ struct proc_fs_info *fs_info;
32063369 struct pid_namespace *ns;
32073370 struct dentry *result = ERR_PTR(-ENOENT);
32083371
....@@ -3210,7 +3373,8 @@
32103373 if (tgid == ~0U)
32113374 goto out;
32123375
3213
- ns = dentry->d_sb->s_fs_info;
3376
+ fs_info = proc_sb_info(dentry->d_sb);
3377
+ ns = fs_info->pid_ns;
32143378 rcu_read_lock();
32153379 task = find_task_by_pid_ns(tgid, ns);
32163380 if (task)
....@@ -3219,7 +3383,14 @@
32193383 if (!task)
32203384 goto out;
32213385
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
+
32223392 result = proc_pid_instantiate(dentry, task, NULL);
3393
+out_put_task:
32233394 put_task_struct(task);
32243395 out:
32253396 return result;
....@@ -3245,20 +3416,8 @@
32453416 pid = find_ge_pid(iter.tgid, ns);
32463417 if (pid) {
32473418 iter.tgid = pid_nr_ns(pid, ns);
3248
- iter.task = pid_task(pid, PIDTYPE_PID);
3249
- /* What we to know is if the pid we have find is the
3250
- * pid of a thread_group_leader. Testing for task
3251
- * being a thread_group_leader is the obvious thing
3252
- * todo but there is a window when it fails, due to
3253
- * the pid transfer logic in de_thread.
3254
- *
3255
- * So we perform the straight forward test of seeing
3256
- * if the pid we have found is the pid of a thread
3257
- * group leader, and don't worry if the task we have
3258
- * found doesn't happen to be a thread group leader.
3259
- * As we don't care in the case of readdir.
3260
- */
3261
- if (!iter.task || !has_group_leader_pid(iter.task)) {
3419
+ iter.task = pid_task(pid, PIDTYPE_TGID);
3420
+ if (!iter.task) {
32623421 iter.tgid += 1;
32633422 goto retry;
32643423 }
....@@ -3274,20 +3433,21 @@
32743433 int proc_pid_readdir(struct file *file, struct dir_context *ctx)
32753434 {
32763435 struct tgid_iter iter;
3277
- 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);
32783438 loff_t pos = ctx->pos;
32793439
32803440 if (pos >= PID_MAX_LIMIT + TGID_OFFSET)
32813441 return 0;
32823442
32833443 if (pos == TGID_OFFSET - 2) {
3284
- struct inode *inode = d_inode(ns->proc_self);
3444
+ struct inode *inode = d_inode(fs_info->proc_self);
32853445 if (!dir_emit(ctx, "self", 4, inode->i_ino, DT_LNK))
32863446 return 0;
32873447 ctx->pos = pos = pos + 1;
32883448 }
32893449 if (pos == TGID_OFFSET - 1) {
3290
- struct inode *inode = d_inode(ns->proc_thread_self);
3450
+ struct inode *inode = d_inode(fs_info->proc_thread_self);
32913451 if (!dir_emit(ctx, "thread-self", 11, inode->i_ino, DT_LNK))
32923452 return 0;
32933453 ctx->pos = pos = pos + 1;
....@@ -3301,7 +3461,7 @@
33013461 unsigned int len;
33023462
33033463 cond_resched();
3304
- if (!has_pid_permissions(ns, iter.task, HIDEPID_INVISIBLE))
3464
+ if (!has_pid_permissions(fs_info, iter.task, HIDEPID_INVISIBLE))
33053465 continue;
33063466
33073467 len = snprintf(name, sizeof(name), "%u", iter.tgid);
....@@ -3359,7 +3519,7 @@
33593519 */
33603520 static const struct pid_entry tid_base_stuff[] = {
33613521 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
3362
- 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),
33633523 DIR("ns", S_IRUSR|S_IXUGO, proc_ns_dir_inode_operations, proc_ns_dir_operations),
33643524 #ifdef CONFIG_NET
33653525 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
....@@ -3421,10 +3581,13 @@
34213581 #ifdef CONFIG_CGROUPS
34223582 ONE("cgroup", S_IRUGO, proc_cgroup_show),
34233583 #endif
3584
+#ifdef CONFIG_PROC_CPU_RESCTRL
3585
+ ONE("cpu_resctrl_groups", S_IRUGO, proc_resctrl_show),
3586
+#endif
34243587 ONE("oom_score", S_IRUGO, proc_oom_score),
34253588 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
34263589 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
3427
-#ifdef CONFIG_AUDITSYSCALL
3590
+#ifdef CONFIG_AUDIT
34283591 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
34293592 REG("sessionid", S_IRUGO, proc_sessionid_operations),
34303593 #endif
....@@ -3444,6 +3607,9 @@
34443607 #ifdef CONFIG_LIVEPATCH
34453608 ONE("patch_state", S_IRUSR, proc_pid_patch_state),
34463609 #endif
3610
+#ifdef CONFIG_PROC_PID_ARCH_STATUS
3611
+ ONE("arch_status", S_IRUGO, proc_pid_arch_status),
3612
+#endif
34473613 #ifdef CONFIG_CPU_FREQ_TIMES
34483614 ONE("time_in_state", 0444, proc_time_in_state_show),
34493615 #endif
....@@ -3458,7 +3624,8 @@
34583624 static struct dentry *proc_tid_base_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
34593625 {
34603626 return proc_pident_lookup(dir, dentry,
3461
- tid_base_stuff, ARRAY_SIZE(tid_base_stuff));
3627
+ tid_base_stuff,
3628
+ tid_base_stuff + ARRAY_SIZE(tid_base_stuff));
34623629 }
34633630
34643631 static const struct file_operations proc_tid_base_operations = {
....@@ -3497,6 +3664,7 @@
34973664 struct task_struct *task;
34983665 struct task_struct *leader = get_proc_task(dir);
34993666 unsigned tid;
3667
+ struct proc_fs_info *fs_info;
35003668 struct pid_namespace *ns;
35013669 struct dentry *result = ERR_PTR(-ENOENT);
35023670
....@@ -3507,7 +3675,8 @@
35073675 if (tid == ~0U)
35083676 goto out;
35093677
3510
- ns = dentry->d_sb->s_fs_info;
3678
+ fs_info = proc_sb_info(dentry->d_sb);
3679
+ ns = fs_info->pid_ns;
35113680 rcu_read_lock();
35123681 task = find_task_by_pid_ns(tid, ns);
35133682 if (task)
....@@ -3621,7 +3790,7 @@
36213790 /* f_version caches the tgid value that the last readdir call couldn't
36223791 * return. lseek aka telldir automagically resets f_version to 0.
36233792 */
3624
- ns = proc_pid_ns(inode);
3793
+ ns = proc_pid_ns(inode->i_sb);
36253794 tid = (int)file->f_version;
36263795 file->f_version = 0;
36273796 for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns);