| .. | .. |
|---|
| 96 | 96 | #include <linux/posix-timers.h> |
|---|
| 97 | 97 | #include <linux/time_namespace.h> |
|---|
| 98 | 98 | #include <linux/resctrl.h> |
|---|
| 99 | | -#include <linux/swait.h> |
|---|
| 100 | 99 | #include <linux/cpufreq_times.h> |
|---|
| 101 | 100 | #include <trace/events/oom.h> |
|---|
| 102 | 101 | #include "internal.h" |
|---|
| .. | .. |
|---|
| 1883 | 1882 | put_pid(pid); |
|---|
| 1884 | 1883 | } |
|---|
| 1885 | 1884 | |
|---|
| 1886 | | -struct inode *proc_pid_make_inode(struct super_block * sb, |
|---|
| 1885 | +struct inode *proc_pid_make_inode(struct super_block *sb, |
|---|
| 1887 | 1886 | struct task_struct *task, umode_t mode) |
|---|
| 1888 | 1887 | { |
|---|
| 1889 | 1888 | struct inode * inode; |
|---|
| .. | .. |
|---|
| 1912 | 1911 | |
|---|
| 1913 | 1912 | /* Let the pid remember us for quick removal */ |
|---|
| 1914 | 1913 | 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 | | - } |
|---|
| 1920 | 1914 | |
|---|
| 1921 | 1915 | task_dump_owner(task, 0, &inode->i_uid, &inode->i_gid); |
|---|
| 1922 | 1916 | security_task_to_inode(task, inode); |
|---|
| .. | .. |
|---|
| 1927 | 1921 | out_unlock: |
|---|
| 1928 | 1922 | iput(inode); |
|---|
| 1929 | 1923 | return NULL; |
|---|
| 1924 | +} |
|---|
| 1925 | + |
|---|
| 1926 | +/* |
|---|
| 1927 | + * Generating an inode and adding it into @pid->inodes, so that task will |
|---|
| 1928 | + * invalidate inode's dentry before being released. |
|---|
| 1929 | + * |
|---|
| 1930 | + * This helper is used for creating dir-type entries under '/proc' and |
|---|
| 1931 | + * '/proc/<tgid>/task'. Other entries(eg. fd, stat) under '/proc/<tgid>' |
|---|
| 1932 | + * can be released by invalidating '/proc/<tgid>' dentry. |
|---|
| 1933 | + * In theory, dentries under '/proc/<tgid>/task' can also be released by |
|---|
| 1934 | + * invalidating '/proc/<tgid>' dentry, we reserve it to handle single |
|---|
| 1935 | + * thread exiting situation: Any one of threads should invalidate its |
|---|
| 1936 | + * '/proc/<tgid>/task/<pid>' dentry before released. |
|---|
| 1937 | + */ |
|---|
| 1938 | +static struct inode *proc_pid_make_base_inode(struct super_block *sb, |
|---|
| 1939 | + struct task_struct *task, umode_t mode) |
|---|
| 1940 | +{ |
|---|
| 1941 | + struct inode *inode; |
|---|
| 1942 | + struct proc_inode *ei; |
|---|
| 1943 | + struct pid *pid; |
|---|
| 1944 | + |
|---|
| 1945 | + inode = proc_pid_make_inode(sb, task, mode); |
|---|
| 1946 | + if (!inode) |
|---|
| 1947 | + return NULL; |
|---|
| 1948 | + |
|---|
| 1949 | + /* Let proc_flush_pid find this directory inode */ |
|---|
| 1950 | + ei = PROC_I(inode); |
|---|
| 1951 | + pid = ei->pid; |
|---|
| 1952 | + spin_lock(&pid->lock); |
|---|
| 1953 | + hlist_add_head_rcu(&ei->sibling_inodes, &pid->inodes); |
|---|
| 1954 | + spin_unlock(&pid->lock); |
|---|
| 1955 | + |
|---|
| 1956 | + return inode; |
|---|
| 1930 | 1957 | } |
|---|
| 1931 | 1958 | |
|---|
| 1932 | 1959 | int pid_getattr(const struct path *path, struct kstat *stat, |
|---|
| .. | .. |
|---|
| 2040 | 2067 | |
|---|
| 2041 | 2068 | child = d_hash_and_lookup(dir, &qname); |
|---|
| 2042 | 2069 | if (!child) { |
|---|
| 2043 | | - DECLARE_SWAIT_QUEUE_HEAD_ONSTACK(wq); |
|---|
| 2070 | + DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); |
|---|
| 2044 | 2071 | child = d_alloc_parallel(dir, &qname, &wq); |
|---|
| 2045 | 2072 | if (IS_ERR(child)) |
|---|
| 2046 | 2073 | goto end_instantiate; |
|---|
| .. | .. |
|---|
| 3346 | 3373 | { |
|---|
| 3347 | 3374 | struct inode *inode; |
|---|
| 3348 | 3375 | |
|---|
| 3349 | | - inode = proc_pid_make_inode(dentry->d_sb, task, S_IFDIR | S_IRUGO | S_IXUGO); |
|---|
| 3376 | + inode = proc_pid_make_base_inode(dentry->d_sb, task, |
|---|
| 3377 | + S_IFDIR | S_IRUGO | S_IXUGO); |
|---|
| 3350 | 3378 | if (!inode) |
|---|
| 3351 | 3379 | return ERR_PTR(-ENOENT); |
|---|
| 3352 | 3380 | |
|---|
| .. | .. |
|---|
| 3511 | 3539 | } |
|---|
| 3512 | 3540 | |
|---|
| 3513 | 3541 | static const struct inode_operations proc_tid_comm_inode_operations = { |
|---|
| 3514 | | - .permission = proc_tid_comm_permission, |
|---|
| 3542 | + .setattr = proc_setattr, |
|---|
| 3543 | + .permission = proc_tid_comm_permission, |
|---|
| 3515 | 3544 | }; |
|---|
| 3516 | 3545 | |
|---|
| 3517 | 3546 | /* |
|---|
| .. | .. |
|---|
| 3644 | 3673 | struct task_struct *task, const void *ptr) |
|---|
| 3645 | 3674 | { |
|---|
| 3646 | 3675 | struct inode *inode; |
|---|
| 3647 | | - inode = proc_pid_make_inode(dentry->d_sb, task, S_IFDIR | S_IRUGO | S_IXUGO); |
|---|
| 3676 | + inode = proc_pid_make_base_inode(dentry->d_sb, task, |
|---|
| 3677 | + S_IFDIR | S_IRUGO | S_IXUGO); |
|---|
| 3648 | 3678 | if (!inode) |
|---|
| 3649 | 3679 | return ERR_PTR(-ENOENT); |
|---|
| 3650 | 3680 | |
|---|