diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 39fd336cfdb9..e31903aadd96 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -820,7 +820,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf, | |||
820 | goto out_free_page; | 820 | goto out_free_page; |
821 | 821 | ||
822 | } | 822 | } |
823 | length = audit_set_loginuid(task->audit_context, loginuid); | 823 | length = audit_set_loginuid(task, loginuid); |
824 | if (likely(length == 0)) | 824 | if (likely(length == 0)) |
825 | length = count; | 825 | length = count; |
826 | 826 | ||
@@ -1419,6 +1419,8 @@ static struct file_operations proc_tgid_attr_operations; | |||
1419 | static struct inode_operations proc_tgid_attr_inode_operations; | 1419 | static struct inode_operations proc_tgid_attr_inode_operations; |
1420 | #endif | 1420 | #endif |
1421 | 1421 | ||
1422 | static int get_tid_list(int index, unsigned int *tids, struct inode *dir); | ||
1423 | |||
1422 | /* SMP-safe */ | 1424 | /* SMP-safe */ |
1423 | static struct dentry *proc_pident_lookup(struct inode *dir, | 1425 | static struct dentry *proc_pident_lookup(struct inode *dir, |
1424 | struct dentry *dentry, | 1426 | struct dentry *dentry, |
@@ -1458,7 +1460,7 @@ static struct dentry *proc_pident_lookup(struct inode *dir, | |||
1458 | */ | 1460 | */ |
1459 | switch(p->type) { | 1461 | switch(p->type) { |
1460 | case PROC_TGID_TASK: | 1462 | case PROC_TGID_TASK: |
1461 | inode->i_nlink = 3; | 1463 | inode->i_nlink = 2 + get_tid_list(2, NULL, dir); |
1462 | inode->i_op = &proc_task_inode_operations; | 1464 | inode->i_op = &proc_task_inode_operations; |
1463 | inode->i_fop = &proc_task_operations; | 1465 | inode->i_fop = &proc_task_operations; |
1464 | break; | 1466 | break; |
@@ -1701,13 +1703,13 @@ static struct inode_operations proc_self_inode_operations = { | |||
1701 | }; | 1703 | }; |
1702 | 1704 | ||
1703 | /** | 1705 | /** |
1704 | * proc_pid_unhash - Unhash /proc/<pid> entry from the dcache. | 1706 | * proc_pid_unhash - Unhash /proc/@pid entry from the dcache. |
1705 | * @p: task that should be flushed. | 1707 | * @p: task that should be flushed. |
1706 | * | 1708 | * |
1707 | * Drops the /proc/<pid> dcache entry from the hash chains. | 1709 | * Drops the /proc/@pid dcache entry from the hash chains. |
1708 | * | 1710 | * |
1709 | * Dropping /proc/<pid> entries and detach_pid must be synchroneous, | 1711 | * Dropping /proc/@pid entries and detach_pid must be synchroneous, |
1710 | * otherwise e.g. /proc/<pid>/exe might point to the wrong executable, | 1712 | * otherwise e.g. /proc/@pid/exe might point to the wrong executable, |
1711 | * if the pid value is immediately reused. This is enforced by | 1713 | * if the pid value is immediately reused. This is enforced by |
1712 | * - caller must acquire spin_lock(p->proc_lock) | 1714 | * - caller must acquire spin_lock(p->proc_lock) |
1713 | * - must be called before detach_pid() | 1715 | * - must be called before detach_pid() |
@@ -1739,8 +1741,8 @@ struct dentry *proc_pid_unhash(struct task_struct *p) | |||
1739 | } | 1741 | } |
1740 | 1742 | ||
1741 | /** | 1743 | /** |
1742 | * proc_pid_flush - recover memory used by stale /proc/<pid>/x entries | 1744 | * proc_pid_flush - recover memory used by stale /proc/@pid/x entries |
1743 | * @proc_entry: directoy to prune. | 1745 | * @proc_dentry: directoy to prune. |
1744 | * | 1746 | * |
1745 | * Shrink the /proc directory that was used by the just killed thread. | 1747 | * Shrink the /proc directory that was used by the just killed thread. |
1746 | */ | 1748 | */ |
@@ -1800,8 +1802,12 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct | |||
1800 | inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; | 1802 | inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; |
1801 | inode->i_op = &proc_tgid_base_inode_operations; | 1803 | inode->i_op = &proc_tgid_base_inode_operations; |
1802 | inode->i_fop = &proc_tgid_base_operations; | 1804 | inode->i_fop = &proc_tgid_base_operations; |
1803 | inode->i_nlink = 3; | ||
1804 | inode->i_flags|=S_IMMUTABLE; | 1805 | inode->i_flags|=S_IMMUTABLE; |
1806 | #ifdef CONFIG_SECURITY | ||
1807 | inode->i_nlink = 5; | ||
1808 | #else | ||
1809 | inode->i_nlink = 4; | ||
1810 | #endif | ||
1805 | 1811 | ||
1806 | dentry->d_op = &pid_base_dentry_operations; | 1812 | dentry->d_op = &pid_base_dentry_operations; |
1807 | 1813 | ||
@@ -1855,8 +1861,12 @@ static struct dentry *proc_task_lookup(struct inode *dir, struct dentry * dentry | |||
1855 | inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; | 1861 | inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO; |
1856 | inode->i_op = &proc_tid_base_inode_operations; | 1862 | inode->i_op = &proc_tid_base_inode_operations; |
1857 | inode->i_fop = &proc_tid_base_operations; | 1863 | inode->i_fop = &proc_tid_base_operations; |
1858 | inode->i_nlink = 3; | ||
1859 | inode->i_flags|=S_IMMUTABLE; | 1864 | inode->i_flags|=S_IMMUTABLE; |
1865 | #ifdef CONFIG_SECURITY | ||
1866 | inode->i_nlink = 4; | ||
1867 | #else | ||
1868 | inode->i_nlink = 3; | ||
1869 | #endif | ||
1860 | 1870 | ||
1861 | dentry->d_op = &pid_base_dentry_operations; | 1871 | dentry->d_op = &pid_base_dentry_operations; |
1862 | 1872 | ||
@@ -1935,7 +1945,8 @@ static int get_tid_list(int index, unsigned int *tids, struct inode *dir) | |||
1935 | 1945 | ||
1936 | if (--index >= 0) | 1946 | if (--index >= 0) |
1937 | continue; | 1947 | continue; |
1938 | tids[nr_tids] = tid; | 1948 | if (tids != NULL) |
1949 | tids[nr_tids] = tid; | ||
1939 | nr_tids++; | 1950 | nr_tids++; |
1940 | if (nr_tids >= PROC_MAXPIDS) | 1951 | if (nr_tids >= PROC_MAXPIDS) |
1941 | break; | 1952 | break; |
@@ -2035,6 +2046,7 @@ static int proc_task_readdir(struct file * filp, void * dirent, filldir_t filldi | |||
2035 | } | 2046 | } |
2036 | 2047 | ||
2037 | nr_tids = get_tid_list(pos, tid_array, inode); | 2048 | nr_tids = get_tid_list(pos, tid_array, inode); |
2049 | inode->i_nlink = pos + nr_tids; | ||
2038 | 2050 | ||
2039 | for (i = 0; i < nr_tids; i++) { | 2051 | for (i = 0; i < nr_tids; i++) { |
2040 | unsigned long j = PROC_NUMBUF; | 2052 | unsigned long j = PROC_NUMBUF; |