diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index 33537487f5ab..c59852b38787 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -88,10 +88,6 @@ | |||
88 | * in /proc for a task before it execs a suid executable. | 88 | * in /proc for a task before it execs a suid executable. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | |||
92 | /* Worst case buffer size needed for holding an integer. */ | ||
93 | #define PROC_NUMBUF 13 | ||
94 | |||
95 | struct pid_entry { | 91 | struct pid_entry { |
96 | char *name; | 92 | char *name; |
97 | int len; | 93 | int len; |
@@ -787,7 +783,7 @@ out_no_task: | |||
787 | } | 783 | } |
788 | #endif | 784 | #endif |
789 | 785 | ||
790 | static loff_t mem_lseek(struct file * file, loff_t offset, int orig) | 786 | loff_t mem_lseek(struct file *file, loff_t offset, int orig) |
791 | { | 787 | { |
792 | switch (orig) { | 788 | switch (orig) { |
793 | case 0: | 789 | case 0: |
@@ -935,42 +931,6 @@ static const struct file_operations proc_oom_adjust_operations = { | |||
935 | .write = oom_adjust_write, | 931 | .write = oom_adjust_write, |
936 | }; | 932 | }; |
937 | 933 | ||
938 | #ifdef CONFIG_MMU | ||
939 | static ssize_t clear_refs_write(struct file *file, const char __user *buf, | ||
940 | size_t count, loff_t *ppos) | ||
941 | { | ||
942 | struct task_struct *task; | ||
943 | char buffer[PROC_NUMBUF], *end; | ||
944 | struct mm_struct *mm; | ||
945 | |||
946 | memset(buffer, 0, sizeof(buffer)); | ||
947 | if (count > sizeof(buffer) - 1) | ||
948 | count = sizeof(buffer) - 1; | ||
949 | if (copy_from_user(buffer, buf, count)) | ||
950 | return -EFAULT; | ||
951 | if (!simple_strtol(buffer, &end, 0)) | ||
952 | return -EINVAL; | ||
953 | if (*end == '\n') | ||
954 | end++; | ||
955 | task = get_proc_task(file->f_path.dentry->d_inode); | ||
956 | if (!task) | ||
957 | return -ESRCH; | ||
958 | mm = get_task_mm(task); | ||
959 | if (mm) { | ||
960 | clear_refs_smap(mm); | ||
961 | mmput(mm); | ||
962 | } | ||
963 | put_task_struct(task); | ||
964 | if (end - buffer == 0) | ||
965 | return -EIO; | ||
966 | return end - buffer; | ||
967 | } | ||
968 | |||
969 | static struct file_operations proc_clear_refs_operations = { | ||
970 | .write = clear_refs_write, | ||
971 | }; | ||
972 | #endif | ||
973 | |||
974 | #ifdef CONFIG_AUDITSYSCALL | 934 | #ifdef CONFIG_AUDITSYSCALL |
975 | #define TMPBUFLEN 21 | 935 | #define TMPBUFLEN 21 |
976 | static ssize_t proc_loginuid_read(struct file * file, char __user * buf, | 936 | static ssize_t proc_loginuid_read(struct file * file, char __user * buf, |
@@ -2289,9 +2249,10 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2289 | LNK("exe", exe), | 2249 | LNK("exe", exe), |
2290 | REG("mounts", S_IRUGO, mounts), | 2250 | REG("mounts", S_IRUGO, mounts), |
2291 | REG("mountstats", S_IRUSR, mountstats), | 2251 | REG("mountstats", S_IRUSR, mountstats), |
2292 | #ifdef CONFIG_MMU | 2252 | #ifdef CONFIG_PROC_PAGE_MONITOR |
2293 | REG("clear_refs", S_IWUSR, clear_refs), | 2253 | REG("clear_refs", S_IWUSR, clear_refs), |
2294 | REG("smaps", S_IRUGO, smaps), | 2254 | REG("smaps", S_IRUGO, smaps), |
2255 | REG("pagemap", S_IRUSR, pagemap), | ||
2295 | #endif | 2256 | #endif |
2296 | #ifdef CONFIG_SECURITY | 2257 | #ifdef CONFIG_SECURITY |
2297 | DIR("attr", S_IRUGO|S_IXUGO, attr_dir), | 2258 | DIR("attr", S_IRUGO|S_IXUGO, attr_dir), |
@@ -2360,7 +2321,8 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid) | |||
2360 | name.len = snprintf(buf, sizeof(buf), "%d", pid); | 2321 | name.len = snprintf(buf, sizeof(buf), "%d", pid); |
2361 | dentry = d_hash_and_lookup(mnt->mnt_root, &name); | 2322 | dentry = d_hash_and_lookup(mnt->mnt_root, &name); |
2362 | if (dentry) { | 2323 | if (dentry) { |
2363 | shrink_dcache_parent(dentry); | 2324 | if (!(current->flags & PF_EXITING)) |
2325 | shrink_dcache_parent(dentry); | ||
2364 | d_drop(dentry); | 2326 | d_drop(dentry); |
2365 | dput(dentry); | 2327 | dput(dentry); |
2366 | } | 2328 | } |
@@ -2617,9 +2579,10 @@ static const struct pid_entry tid_base_stuff[] = { | |||
2617 | LNK("root", root), | 2579 | LNK("root", root), |
2618 | LNK("exe", exe), | 2580 | LNK("exe", exe), |
2619 | REG("mounts", S_IRUGO, mounts), | 2581 | REG("mounts", S_IRUGO, mounts), |
2620 | #ifdef CONFIG_MMU | 2582 | #ifdef CONFIG_PROC_PAGE_MONITOR |
2621 | REG("clear_refs", S_IWUSR, clear_refs), | 2583 | REG("clear_refs", S_IWUSR, clear_refs), |
2622 | REG("smaps", S_IRUGO, smaps), | 2584 | REG("smaps", S_IRUGO, smaps), |
2585 | REG("pagemap", S_IRUSR, pagemap), | ||
2623 | #endif | 2586 | #endif |
2624 | #ifdef CONFIG_SECURITY | 2587 | #ifdef CONFIG_SECURITY |
2625 | DIR("attr", S_IRUGO|S_IXUGO, attr_dir), | 2588 | DIR("attr", S_IRUGO|S_IXUGO, attr_dir), |