aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/Makefile3
-rw-r--r--fs/proc/array.c4
-rw-r--r--fs/proc/base.c48
-rw-r--r--fs/proc/generic.c58
-rw-r--r--fs/proc/inode.c44
-rw-r--r--fs/proc/internal.h3
-rw-r--r--fs/proc/kcore.c3
-rw-r--r--fs/proc/meminfo.c6
-rw-r--r--fs/proc/namespaces.c12
-rw-r--r--fs/proc/nommu.c2
-rw-r--r--fs/proc/proc_devtree.c13
-rw-r--r--fs/proc/proc_net.c16
-rw-r--r--fs/proc/proc_sysctl.c23
-rw-r--r--fs/proc/task_mmu.c6
-rw-r--r--fs/proc/task_nommu.c2
-rw-r--r--fs/proc/vmcore.c35
16 files changed, 126 insertions, 152 deletions
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 981b05601931..712f24db9600 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -8,7 +8,8 @@ proc-y := nommu.o task_nommu.o
8proc-$(CONFIG_MMU) := mmu.o task_mmu.o 8proc-$(CONFIG_MMU) := mmu.o task_mmu.o
9 9
10proc-y += inode.o root.o base.o generic.o array.o \ 10proc-y += inode.o root.o base.o generic.o array.o \
11 proc_tty.o fd.o 11 fd.o
12proc-$(CONFIG_TTY) += proc_tty.o
12proc-y += cmdline.o 13proc-y += cmdline.o
13proc-y += consoles.o 14proc-y += consoles.o
14proc-y += cpuinfo.o 15proc-y += cpuinfo.o
diff --git a/fs/proc/array.c b/fs/proc/array.c
index 6a91e6ffbcbd..f7ed9ee46eb9 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -449,7 +449,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
449 do { 449 do {
450 min_flt += t->min_flt; 450 min_flt += t->min_flt;
451 maj_flt += t->maj_flt; 451 maj_flt += t->maj_flt;
452 gtime += t->gtime; 452 gtime += task_gtime(t);
453 t = next_thread(t); 453 t = next_thread(t);
454 } while (t != task); 454 } while (t != task);
455 455
@@ -472,7 +472,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
472 min_flt = task->min_flt; 472 min_flt = task->min_flt;
473 maj_flt = task->maj_flt; 473 maj_flt = task->maj_flt;
474 task_cputime_adjusted(task, &utime, &stime); 474 task_cputime_adjusted(task, &utime, &stime);
475 gtime = task->gtime; 475 gtime = task_gtime(task);
476 } 476 }
477 477
478 /* scale priority and nice values from timeslices to -20..20 */ 478 /* scale priority and nice values from timeslices to -20..20 */
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 9b43ff77a51e..69078c7cef1f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -73,6 +73,7 @@
73#include <linux/security.h> 73#include <linux/security.h>
74#include <linux/ptrace.h> 74#include <linux/ptrace.h>
75#include <linux/tracehook.h> 75#include <linux/tracehook.h>
76#include <linux/printk.h>
76#include <linux/cgroup.h> 77#include <linux/cgroup.h>
77#include <linux/cpuset.h> 78#include <linux/cpuset.h>
78#include <linux/audit.h> 79#include <linux/audit.h>
@@ -383,7 +384,7 @@ static int lstats_open(struct inode *inode, struct file *file)
383static ssize_t lstats_write(struct file *file, const char __user *buf, 384static ssize_t lstats_write(struct file *file, const char __user *buf,
384 size_t count, loff_t *offs) 385 size_t count, loff_t *offs)
385{ 386{
386 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 387 struct task_struct *task = get_proc_task(file_inode(file));
387 388
388 if (!task) 389 if (!task)
389 return -ESRCH; 390 return -ESRCH;
@@ -602,7 +603,7 @@ static const struct inode_operations proc_def_inode_operations = {
602static ssize_t proc_info_read(struct file * file, char __user * buf, 603static ssize_t proc_info_read(struct file * file, char __user * buf,
603 size_t count, loff_t *ppos) 604 size_t count, loff_t *ppos)
604{ 605{
605 struct inode * inode = file->f_path.dentry->d_inode; 606 struct inode * inode = file_inode(file);
606 unsigned long page; 607 unsigned long page;
607 ssize_t length; 608 ssize_t length;
608 struct task_struct *task = get_proc_task(inode); 609 struct task_struct *task = get_proc_task(inode);
@@ -668,7 +669,7 @@ static const struct file_operations proc_single_file_operations = {
668 669
669static int __mem_open(struct inode *inode, struct file *file, unsigned int mode) 670static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
670{ 671{
671 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 672 struct task_struct *task = get_proc_task(file_inode(file));
672 struct mm_struct *mm; 673 struct mm_struct *mm;
673 674
674 if (!task) 675 if (!task)
@@ -869,7 +870,7 @@ static const struct file_operations proc_environ_operations = {
869static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, 870static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
870 loff_t *ppos) 871 loff_t *ppos)
871{ 872{
872 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 873 struct task_struct *task = get_proc_task(file_inode(file));
873 char buffer[PROC_NUMBUF]; 874 char buffer[PROC_NUMBUF];
874 int oom_adj = OOM_ADJUST_MIN; 875 int oom_adj = OOM_ADJUST_MIN;
875 size_t len; 876 size_t len;
@@ -916,7 +917,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
916 goto out; 917 goto out;
917 } 918 }
918 919
919 task = get_proc_task(file->f_path.dentry->d_inode); 920 task = get_proc_task(file_inode(file));
920 if (!task) { 921 if (!task) {
921 err = -ESRCH; 922 err = -ESRCH;
922 goto out; 923 goto out;
@@ -952,7 +953,7 @@ static ssize_t oom_adj_write(struct file *file, const char __user *buf,
952 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use 953 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
953 * /proc/pid/oom_score_adj instead. 954 * /proc/pid/oom_score_adj instead.
954 */ 955 */
955 printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n", 956 pr_warn_once("%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
956 current->comm, task_pid_nr(current), task_pid_nr(task), 957 current->comm, task_pid_nr(current), task_pid_nr(task),
957 task_pid_nr(task)); 958 task_pid_nr(task));
958 959
@@ -976,7 +977,7 @@ static const struct file_operations proc_oom_adj_operations = {
976static ssize_t oom_score_adj_read(struct file *file, char __user *buf, 977static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
977 size_t count, loff_t *ppos) 978 size_t count, loff_t *ppos)
978{ 979{
979 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 980 struct task_struct *task = get_proc_task(file_inode(file));
980 char buffer[PROC_NUMBUF]; 981 char buffer[PROC_NUMBUF];
981 short oom_score_adj = OOM_SCORE_ADJ_MIN; 982 short oom_score_adj = OOM_SCORE_ADJ_MIN;
982 unsigned long flags; 983 unsigned long flags;
@@ -1019,7 +1020,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf,
1019 goto out; 1020 goto out;
1020 } 1021 }
1021 1022
1022 task = get_proc_task(file->f_path.dentry->d_inode); 1023 task = get_proc_task(file_inode(file));
1023 if (!task) { 1024 if (!task) {
1024 err = -ESRCH; 1025 err = -ESRCH;
1025 goto out; 1026 goto out;
@@ -1067,7 +1068,7 @@ static const struct file_operations proc_oom_score_adj_operations = {
1067static ssize_t proc_loginuid_read(struct file * file, char __user * buf, 1068static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
1068 size_t count, loff_t *ppos) 1069 size_t count, loff_t *ppos)
1069{ 1070{
1070 struct inode * inode = file->f_path.dentry->d_inode; 1071 struct inode * inode = file_inode(file);
1071 struct task_struct *task = get_proc_task(inode); 1072 struct task_struct *task = get_proc_task(inode);
1072 ssize_t length; 1073 ssize_t length;
1073 char tmpbuf[TMPBUFLEN]; 1074 char tmpbuf[TMPBUFLEN];
@@ -1084,7 +1085,7 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
1084static ssize_t proc_loginuid_write(struct file * file, const char __user * buf, 1085static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
1085 size_t count, loff_t *ppos) 1086 size_t count, loff_t *ppos)
1086{ 1087{
1087 struct inode * inode = file->f_path.dentry->d_inode; 1088 struct inode * inode = file_inode(file);
1088 char *page, *tmp; 1089 char *page, *tmp;
1089 ssize_t length; 1090 ssize_t length;
1090 uid_t loginuid; 1091 uid_t loginuid;
@@ -1142,7 +1143,7 @@ static const struct file_operations proc_loginuid_operations = {
1142static ssize_t proc_sessionid_read(struct file * file, char __user * buf, 1143static ssize_t proc_sessionid_read(struct file * file, char __user * buf,
1143 size_t count, loff_t *ppos) 1144 size_t count, loff_t *ppos)
1144{ 1145{
1145 struct inode * inode = file->f_path.dentry->d_inode; 1146 struct inode * inode = file_inode(file);
1146 struct task_struct *task = get_proc_task(inode); 1147 struct task_struct *task = get_proc_task(inode);
1147 ssize_t length; 1148 ssize_t length;
1148 char tmpbuf[TMPBUFLEN]; 1149 char tmpbuf[TMPBUFLEN];
@@ -1165,7 +1166,7 @@ static const struct file_operations proc_sessionid_operations = {
1165static ssize_t proc_fault_inject_read(struct file * file, char __user * buf, 1166static ssize_t proc_fault_inject_read(struct file * file, char __user * buf,
1166 size_t count, loff_t *ppos) 1167 size_t count, loff_t *ppos)
1167{ 1168{
1168 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 1169 struct task_struct *task = get_proc_task(file_inode(file));
1169 char buffer[PROC_NUMBUF]; 1170 char buffer[PROC_NUMBUF];
1170 size_t len; 1171 size_t len;
1171 int make_it_fail; 1172 int make_it_fail;
@@ -1197,7 +1198,7 @@ static ssize_t proc_fault_inject_write(struct file * file,
1197 make_it_fail = simple_strtol(strstrip(buffer), &end, 0); 1198 make_it_fail = simple_strtol(strstrip(buffer), &end, 0);
1198 if (*end) 1199 if (*end)
1199 return -EINVAL; 1200 return -EINVAL;
1200 task = get_proc_task(file->f_dentry->d_inode); 1201 task = get_proc_task(file_inode(file));
1201 if (!task) 1202 if (!task)
1202 return -ESRCH; 1203 return -ESRCH;
1203 task->make_it_fail = make_it_fail; 1204 task->make_it_fail = make_it_fail;
@@ -1237,7 +1238,7 @@ static ssize_t
1237sched_write(struct file *file, const char __user *buf, 1238sched_write(struct file *file, const char __user *buf,
1238 size_t count, loff_t *offset) 1239 size_t count, loff_t *offset)
1239{ 1240{
1240 struct inode *inode = file->f_path.dentry->d_inode; 1241 struct inode *inode = file_inode(file);
1241 struct task_struct *p; 1242 struct task_struct *p;
1242 1243
1243 p = get_proc_task(inode); 1244 p = get_proc_task(inode);
@@ -1288,7 +1289,7 @@ static ssize_t
1288sched_autogroup_write(struct file *file, const char __user *buf, 1289sched_autogroup_write(struct file *file, const char __user *buf,
1289 size_t count, loff_t *offset) 1290 size_t count, loff_t *offset)
1290{ 1291{
1291 struct inode *inode = file->f_path.dentry->d_inode; 1292 struct inode *inode = file_inode(file);
1292 struct task_struct *p; 1293 struct task_struct *p;
1293 char buffer[PROC_NUMBUF]; 1294 char buffer[PROC_NUMBUF];
1294 int nice; 1295 int nice;
@@ -1343,7 +1344,7 @@ static const struct file_operations proc_pid_sched_autogroup_operations = {
1343static ssize_t comm_write(struct file *file, const char __user *buf, 1344static ssize_t comm_write(struct file *file, const char __user *buf,
1344 size_t count, loff_t *offset) 1345 size_t count, loff_t *offset)
1345{ 1346{
1346 struct inode *inode = file->f_path.dentry->d_inode; 1347 struct inode *inode = file_inode(file);
1347 struct task_struct *p; 1348 struct task_struct *p;
1348 char buffer[TASK_COMM_LEN]; 1349 char buffer[TASK_COMM_LEN];
1349 1350
@@ -1711,7 +1712,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)
1711 return -ECHILD; 1712 return -ECHILD;
1712 1713
1713 if (!capable(CAP_SYS_ADMIN)) { 1714 if (!capable(CAP_SYS_ADMIN)) {
1714 status = -EACCES; 1715 status = -EPERM;
1715 goto out_notask; 1716 goto out_notask;
1716 } 1717 }
1717 1718
@@ -1844,7 +1845,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,
1844 struct dentry *result; 1845 struct dentry *result;
1845 struct mm_struct *mm; 1846 struct mm_struct *mm;
1846 1847
1847 result = ERR_PTR(-EACCES); 1848 result = ERR_PTR(-EPERM);
1848 if (!capable(CAP_SYS_ADMIN)) 1849 if (!capable(CAP_SYS_ADMIN))
1849 goto out; 1850 goto out;
1850 1851
@@ -1900,7 +1901,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)
1900 ino_t ino; 1901 ino_t ino;
1901 int ret; 1902 int ret;
1902 1903
1903 ret = -EACCES; 1904 ret = -EPERM;
1904 if (!capable(CAP_SYS_ADMIN)) 1905 if (!capable(CAP_SYS_ADMIN))
1905 goto out; 1906 goto out;
1906 1907
@@ -2146,7 +2147,7 @@ out_no_task:
2146static ssize_t proc_pid_attr_read(struct file * file, char __user * buf, 2147static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
2147 size_t count, loff_t *ppos) 2148 size_t count, loff_t *ppos)
2148{ 2149{
2149 struct inode * inode = file->f_path.dentry->d_inode; 2150 struct inode * inode = file_inode(file);
2150 char *p = NULL; 2151 char *p = NULL;
2151 ssize_t length; 2152 ssize_t length;
2152 struct task_struct *task = get_proc_task(inode); 2153 struct task_struct *task = get_proc_task(inode);
@@ -2167,7 +2168,7 @@ static ssize_t proc_pid_attr_read(struct file * file, char __user * buf,
2167static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, 2168static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
2168 size_t count, loff_t *ppos) 2169 size_t count, loff_t *ppos)
2169{ 2170{
2170 struct inode * inode = file->f_path.dentry->d_inode; 2171 struct inode * inode = file_inode(file);
2171 char *page; 2172 char *page;
2172 ssize_t length; 2173 ssize_t length;
2173 struct task_struct *task = get_proc_task(inode); 2174 struct task_struct *task = get_proc_task(inode);
@@ -2256,7 +2257,7 @@ static const struct inode_operations proc_attr_dir_inode_operations = {
2256static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf, 2257static ssize_t proc_coredump_filter_read(struct file *file, char __user *buf,
2257 size_t count, loff_t *ppos) 2258 size_t count, loff_t *ppos)
2258{ 2259{
2259 struct task_struct *task = get_proc_task(file->f_dentry->d_inode); 2260 struct task_struct *task = get_proc_task(file_inode(file));
2260 struct mm_struct *mm; 2261 struct mm_struct *mm;
2261 char buffer[PROC_NUMBUF]; 2262 char buffer[PROC_NUMBUF];
2262 size_t len; 2263 size_t len;
@@ -2308,7 +2309,7 @@ static ssize_t proc_coredump_filter_write(struct file *file,
2308 goto out_no_task; 2309 goto out_no_task;
2309 2310
2310 ret = -ESRCH; 2311 ret = -ESRCH;
2311 task = get_proc_task(file->f_dentry->d_inode); 2312 task = get_proc_task(file_inode(file));
2312 if (!task) 2313 if (!task)
2313 goto out_no_task; 2314 goto out_no_task;
2314 2315
@@ -2618,6 +2619,7 @@ static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
2618 2619
2619 name.name = buf; 2620 name.name = buf;
2620 name.len = snprintf(buf, sizeof(buf), "%d", pid); 2621 name.len = snprintf(buf, sizeof(buf), "%d", pid);
2622 /* no ->d_hash() rejects on procfs */
2621 dentry = d_hash_and_lookup(mnt->mnt_root, &name); 2623 dentry = d_hash_and_lookup(mnt->mnt_root, &name);
2622 if (dentry) { 2624 if (dentry) {
2623 shrink_dcache_parent(dentry); 2625 shrink_dcache_parent(dentry);
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 76ddae83daa5..4b3b3ffb52f1 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -15,6 +15,7 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/printk.h>
18#include <linux/mount.h> 19#include <linux/mount.h>
19#include <linux/init.h> 20#include <linux/init.h>
20#include <linux/idr.h> 21#include <linux/idr.h>
@@ -42,7 +43,7 @@ static ssize_t
42__proc_file_read(struct file *file, char __user *buf, size_t nbytes, 43__proc_file_read(struct file *file, char __user *buf, size_t nbytes,
43 loff_t *ppos) 44 loff_t *ppos)
44{ 45{
45 struct inode * inode = file->f_path.dentry->d_inode; 46 struct inode * inode = file_inode(file);
46 char *page; 47 char *page;
47 ssize_t retval=0; 48 ssize_t retval=0;
48 int eof=0; 49 int eof=0;
@@ -132,11 +133,8 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,
132 } 133 }
133 134
134 if (start == NULL) { 135 if (start == NULL) {
135 if (n > PAGE_SIZE) { 136 if (n > PAGE_SIZE) /* Apparent buffer overflow */
136 printk(KERN_ERR
137 "proc_file_read: Apparent buffer overflow!\n");
138 n = PAGE_SIZE; 137 n = PAGE_SIZE;
139 }
140 n -= *ppos; 138 n -= *ppos;
141 if (n <= 0) 139 if (n <= 0)
142 break; 140 break;
@@ -144,26 +142,19 @@ __proc_file_read(struct file *file, char __user *buf, size_t nbytes,
144 n = count; 142 n = count;
145 start = page + *ppos; 143 start = page + *ppos;
146 } else if (start < page) { 144 } else if (start < page) {
147 if (n > PAGE_SIZE) { 145 if (n > PAGE_SIZE) /* Apparent buffer overflow */
148 printk(KERN_ERR
149 "proc_file_read: Apparent buffer overflow!\n");
150 n = PAGE_SIZE; 146 n = PAGE_SIZE;
151 }
152 if (n > count) { 147 if (n > count) {
153 /* 148 /*
154 * Don't reduce n because doing so might 149 * Don't reduce n because doing so might
155 * cut off part of a data block. 150 * cut off part of a data block.
156 */ 151 */
157 printk(KERN_WARNING 152 pr_warn("proc_file_read: count exceeded\n");
158 "proc_file_read: Read count exceeded\n");
159 } 153 }
160 } else /* start >= page */ { 154 } else /* start >= page */ {
161 unsigned long startoff = (unsigned long)(start - page); 155 unsigned long startoff = (unsigned long)(start - page);
162 if (n > (PAGE_SIZE - startoff)) { 156 if (n > (PAGE_SIZE - startoff)) /* buffer overflow? */
163 printk(KERN_ERR
164 "proc_file_read: Apparent buffer overflow!\n");
165 n = PAGE_SIZE - startoff; 157 n = PAGE_SIZE - startoff;
166 }
167 if (n > count) 158 if (n > count)
168 n = count; 159 n = count;
169 } 160 }
@@ -188,7 +179,7 @@ static ssize_t
188proc_file_read(struct file *file, char __user *buf, size_t nbytes, 179proc_file_read(struct file *file, char __user *buf, size_t nbytes,
189 loff_t *ppos) 180 loff_t *ppos)
190{ 181{
191 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 182 struct proc_dir_entry *pde = PDE(file_inode(file));
192 ssize_t rv = -EIO; 183 ssize_t rv = -EIO;
193 184
194 spin_lock(&pde->pde_unload_lock); 185 spin_lock(&pde->pde_unload_lock);
@@ -209,7 +200,7 @@ static ssize_t
209proc_file_write(struct file *file, const char __user *buffer, 200proc_file_write(struct file *file, const char __user *buffer,
210 size_t count, loff_t *ppos) 201 size_t count, loff_t *ppos)
211{ 202{
212 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 203 struct proc_dir_entry *pde = PDE(file_inode(file));
213 ssize_t rv = -EIO; 204 ssize_t rv = -EIO;
214 205
215 if (pde->write_proc) { 206 if (pde->write_proc) {
@@ -412,8 +403,7 @@ static const struct dentry_operations proc_dentry_operations =
412struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, 403struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
413 struct dentry *dentry) 404 struct dentry *dentry)
414{ 405{
415 struct inode *inode = NULL; 406 struct inode *inode;
416 int error = -ENOENT;
417 407
418 spin_lock(&proc_subdir_lock); 408 spin_lock(&proc_subdir_lock);
419 for (de = de->subdir; de ; de = de->next) { 409 for (de = de->subdir; de ; de = de->next) {
@@ -422,22 +412,16 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
422 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { 412 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
423 pde_get(de); 413 pde_get(de);
424 spin_unlock(&proc_subdir_lock); 414 spin_unlock(&proc_subdir_lock);
425 error = -ENOMEM;
426 inode = proc_get_inode(dir->i_sb, de); 415 inode = proc_get_inode(dir->i_sb, de);
427 goto out_unlock; 416 if (!inode)
417 return ERR_PTR(-ENOMEM);
418 d_set_d_op(dentry, &proc_dentry_operations);
419 d_add(dentry, inode);
420 return NULL;
428 } 421 }
429 } 422 }
430 spin_unlock(&proc_subdir_lock); 423 spin_unlock(&proc_subdir_lock);
431out_unlock: 424 return ERR_PTR(-ENOENT);
432
433 if (inode) {
434 d_set_d_op(dentry, &proc_dentry_operations);
435 d_add(dentry, inode);
436 return NULL;
437 }
438 if (de)
439 pde_put(de);
440 return ERR_PTR(error);
441} 425}
442 426
443struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry, 427struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
@@ -460,7 +444,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
460{ 444{
461 unsigned int ino; 445 unsigned int ino;
462 int i; 446 int i;
463 struct inode *inode = filp->f_path.dentry->d_inode; 447 struct inode *inode = file_inode(filp);
464 int ret = 0; 448 int ret = 0;
465 449
466 ino = inode->i_ino; 450 ino = inode->i_ino;
@@ -522,7 +506,7 @@ out:
522 506
523int proc_readdir(struct file *filp, void *dirent, filldir_t filldir) 507int proc_readdir(struct file *filp, void *dirent, filldir_t filldir)
524{ 508{
525 struct inode *inode = filp->f_path.dentry->d_inode; 509 struct inode *inode = file_inode(filp);
526 510
527 return proc_readdir_de(PDE(inode), filp, dirent, filldir); 511 return proc_readdir_de(PDE(inode), filp, dirent, filldir);
528} 512}
@@ -576,7 +560,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
576 560
577 for (tmp = dir->subdir; tmp; tmp = tmp->next) 561 for (tmp = dir->subdir; tmp; tmp = tmp->next)
578 if (strcmp(tmp->name, dp->name) == 0) { 562 if (strcmp(tmp->name, dp->name) == 0) {
579 WARN(1, KERN_WARNING "proc_dir_entry '%s/%s' already registered\n", 563 WARN(1, "proc_dir_entry '%s/%s' already registered\n",
580 dir->name, dp->name); 564 dir->name, dp->name);
581 break; 565 break;
582 } 566 }
@@ -837,9 +821,9 @@ void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
837 if (S_ISDIR(de->mode)) 821 if (S_ISDIR(de->mode))
838 parent->nlink--; 822 parent->nlink--;
839 de->nlink = 0; 823 de->nlink = 0;
840 WARN(de->subdir, KERN_WARNING "%s: removing non-empty directory " 824 WARN(de->subdir, "%s: removing non-empty directory "
841 "'%s/%s', leaking at least '%s'\n", __func__, 825 "'%s/%s', leaking at least '%s'\n", __func__,
842 de->parent->name, de->name, de->subdir->name); 826 de->parent->name, de->name, de->subdir->name);
843 pde_put(de); 827 pde_put(de);
844} 828}
845EXPORT_SYMBOL(remove_proc_entry); 829EXPORT_SYMBOL(remove_proc_entry);
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 439ae6886507..a86aebc9ba7c 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -13,6 +13,7 @@
13#include <linux/stat.h> 13#include <linux/stat.h>
14#include <linux/completion.h> 14#include <linux/completion.h>
15#include <linux/poll.h> 15#include <linux/poll.h>
16#include <linux/printk.h>
16#include <linux/file.h> 17#include <linux/file.h>
17#include <linux/limits.h> 18#include <linux/limits.h>
18#include <linux/init.h> 19#include <linux/init.h>
@@ -144,7 +145,7 @@ void pde_users_dec(struct proc_dir_entry *pde)
144 145
145static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence) 146static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
146{ 147{
147 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 148 struct proc_dir_entry *pde = PDE(file_inode(file));
148 loff_t rv = -EINVAL; 149 loff_t rv = -EINVAL;
149 loff_t (*llseek)(struct file *, loff_t, int); 150 loff_t (*llseek)(struct file *, loff_t, int);
150 151
@@ -179,7 +180,7 @@ static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
179 180
180static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 181static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
181{ 182{
182 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 183 struct proc_dir_entry *pde = PDE(file_inode(file));
183 ssize_t rv = -EIO; 184 ssize_t rv = -EIO;
184 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *); 185 ssize_t (*read)(struct file *, char __user *, size_t, loff_t *);
185 186
@@ -201,7 +202,7 @@ static ssize_t proc_reg_read(struct file *file, char __user *buf, size_t count,
201 202
202static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 203static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
203{ 204{
204 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 205 struct proc_dir_entry *pde = PDE(file_inode(file));
205 ssize_t rv = -EIO; 206 ssize_t rv = -EIO;
206 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 207 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
207 208
@@ -223,7 +224,7 @@ static ssize_t proc_reg_write(struct file *file, const char __user *buf, size_t
223 224
224static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts) 225static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *pts)
225{ 226{
226 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 227 struct proc_dir_entry *pde = PDE(file_inode(file));
227 unsigned int rv = DEFAULT_POLLMASK; 228 unsigned int rv = DEFAULT_POLLMASK;
228 unsigned int (*poll)(struct file *, struct poll_table_struct *); 229 unsigned int (*poll)(struct file *, struct poll_table_struct *);
229 230
@@ -245,7 +246,7 @@ static unsigned int proc_reg_poll(struct file *file, struct poll_table_struct *p
245 246
246static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 247static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
247{ 248{
248 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 249 struct proc_dir_entry *pde = PDE(file_inode(file));
249 long rv = -ENOTTY; 250 long rv = -ENOTTY;
250 long (*ioctl)(struct file *, unsigned int, unsigned long); 251 long (*ioctl)(struct file *, unsigned int, unsigned long);
251 252
@@ -268,7 +269,7 @@ static long proc_reg_unlocked_ioctl(struct file *file, unsigned int cmd, unsigne
268#ifdef CONFIG_COMPAT 269#ifdef CONFIG_COMPAT
269static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 270static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
270{ 271{
271 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 272 struct proc_dir_entry *pde = PDE(file_inode(file));
272 long rv = -ENOTTY; 273 long rv = -ENOTTY;
273 long (*compat_ioctl)(struct file *, unsigned int, unsigned long); 274 long (*compat_ioctl)(struct file *, unsigned int, unsigned long);
274 275
@@ -291,7 +292,7 @@ static long proc_reg_compat_ioctl(struct file *file, unsigned int cmd, unsigned
291 292
292static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) 293static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma)
293{ 294{
294 struct proc_dir_entry *pde = PDE(file->f_path.dentry->d_inode); 295 struct proc_dir_entry *pde = PDE(file_inode(file));
295 int rv = -EIO; 296 int rv = -EIO;
296 int (*mmap)(struct file *, struct vm_area_struct *); 297 int (*mmap)(struct file *, struct vm_area_struct *);
297 298
@@ -445,12 +446,9 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
445 446
446struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de) 447struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
447{ 448{
448 struct inode * inode; 449 struct inode *inode = iget_locked(sb, de->low_ino);
449 450
450 inode = iget_locked(sb, de->low_ino); 451 if (inode && (inode->i_state & I_NEW)) {
451 if (!inode)
452 return NULL;
453 if (inode->i_state & I_NEW) {
454 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 452 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
455 PROC_I(inode)->pde = de; 453 PROC_I(inode)->pde = de;
456 454
@@ -482,10 +480,12 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
482 } else 480 } else
483 pde_put(de); 481 pde_put(de);
484 return inode; 482 return inode;
485} 483}
486 484
487int proc_fill_super(struct super_block *s) 485int proc_fill_super(struct super_block *s)
488{ 486{
487 struct inode *root_inode;
488
489 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC; 489 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC;
490 s->s_blocksize = 1024; 490 s->s_blocksize = 1024;
491 s->s_blocksize_bits = 10; 491 s->s_blocksize_bits = 10;
@@ -494,11 +494,17 @@ int proc_fill_super(struct super_block *s)
494 s->s_time_gran = 1; 494 s->s_time_gran = 1;
495 495
496 pde_get(&proc_root); 496 pde_get(&proc_root);
497 s->s_root = d_make_root(proc_get_inode(s, &proc_root)); 497 root_inode = proc_get_inode(s, &proc_root);
498 if (s->s_root) 498 if (!root_inode) {
499 return 0; 499 pr_err("proc_fill_super: get root inode failed\n");
500 return -ENOMEM;
501 }
500 502
501 printk("proc_read_super: get root inode failed\n"); 503 s->s_root = d_make_root(root_inode);
502 pde_put(&proc_root); 504 if (!s->s_root) {
503 return -ENOMEM; 505 pr_err("proc_fill_super: allocate dentry failed\n");
506 return -ENOMEM;
507 }
508
509 return 0;
504} 510}
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 252544c05207..85ff3a4598b3 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14#include <linux/binfmts.h>
14struct ctl_table_header; 15struct ctl_table_header;
15struct mempolicy; 16struct mempolicy;
16 17
@@ -108,7 +109,7 @@ static inline int task_dumpable(struct task_struct *task)
108 if (mm) 109 if (mm)
109 dumpable = get_dumpable(mm); 110 dumpable = get_dumpable(mm);
110 task_unlock(task); 111 task_unlock(task);
111 if (dumpable == SUID_DUMPABLE_ENABLED) 112 if (dumpable == SUID_DUMP_USER)
112 return 1; 113 return 1;
113 return 0; 114 return 0;
114} 115}
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index e96d4f18ca3a..eda6f017f272 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -17,6 +17,7 @@
17#include <linux/elfcore.h> 17#include <linux/elfcore.h>
18#include <linux/vmalloc.h> 18#include <linux/vmalloc.h>
19#include <linux/highmem.h> 19#include <linux/highmem.h>
20#include <linux/printk.h>
20#include <linux/bootmem.h> 21#include <linux/bootmem.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
@@ -619,7 +620,7 @@ static int __init proc_kcore_init(void)
619 proc_root_kcore = proc_create("kcore", S_IRUSR, NULL, 620 proc_root_kcore = proc_create("kcore", S_IRUSR, NULL,
620 &proc_kcore_operations); 621 &proc_kcore_operations);
621 if (!proc_root_kcore) { 622 if (!proc_root_kcore) {
622 printk(KERN_ERR "couldn't create /proc/kcore\n"); 623 pr_err("couldn't create /proc/kcore\n");
623 return 0; /* Always returns 0. */ 624 return 0; /* Always returns 0. */
624 } 625 }
625 /* Store text area if it's special */ 626 /* Store text area if it's special */
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index 80e4645f7990..1efaaa19c4f3 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -40,7 +40,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
40 * sysctl_overcommit_ratio / 100) + total_swap_pages; 40 * sysctl_overcommit_ratio / 100) + total_swap_pages;
41 41
42 cached = global_page_state(NR_FILE_PAGES) - 42 cached = global_page_state(NR_FILE_PAGES) -
43 total_swapcache_pages - i.bufferram; 43 total_swapcache_pages() - i.bufferram;
44 if (cached < 0) 44 if (cached < 0)
45 cached = 0; 45 cached = 0;
46 46
@@ -109,7 +109,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
109 K(i.freeram), 109 K(i.freeram),
110 K(i.bufferram), 110 K(i.bufferram),
111 K(cached), 111 K(cached),
112 K(total_swapcache_pages), 112 K(total_swapcache_pages()),
113 K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]), 113 K(pages[LRU_ACTIVE_ANON] + pages[LRU_ACTIVE_FILE]),
114 K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]), 114 K(pages[LRU_INACTIVE_ANON] + pages[LRU_INACTIVE_FILE]),
115 K(pages[LRU_ACTIVE_ANON]), 115 K(pages[LRU_ACTIVE_ANON]),
@@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
158 vmi.used >> 10, 158 vmi.used >> 10,
159 vmi.largest_chunk >> 10 159 vmi.largest_chunk >> 10
160#ifdef CONFIG_MEMORY_FAILURE 160#ifdef CONFIG_MEMORY_FAILURE
161 ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10) 161 ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
162#endif 162#endif
163#ifdef CONFIG_TRANSPARENT_HUGEPAGE 163#ifdef CONFIG_TRANSPARENT_HUGEPAGE
164 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) * 164 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index b7a47196c8c3..66b51c0383da 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -118,7 +118,7 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
118 struct super_block *sb = inode->i_sb; 118 struct super_block *sb = inode->i_sb;
119 struct proc_inode *ei = PROC_I(inode); 119 struct proc_inode *ei = PROC_I(inode);
120 struct task_struct *task; 120 struct task_struct *task;
121 struct dentry *ns_dentry; 121 struct path ns_path;
122 void *error = ERR_PTR(-EACCES); 122 void *error = ERR_PTR(-EACCES);
123 123
124 task = get_proc_task(inode); 124 task = get_proc_task(inode);
@@ -128,14 +128,14 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
128 if (!ptrace_may_access(task, PTRACE_MODE_READ)) 128 if (!ptrace_may_access(task, PTRACE_MODE_READ))
129 goto out_put_task; 129 goto out_put_task;
130 130
131 ns_dentry = proc_ns_get_dentry(sb, task, ei->ns_ops); 131 ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns_ops);
132 if (IS_ERR(ns_dentry)) { 132 if (IS_ERR(ns_path.dentry)) {
133 error = ERR_CAST(ns_dentry); 133 error = ERR_CAST(ns_path.dentry);
134 goto out_put_task; 134 goto out_put_task;
135 } 135 }
136 136
137 dput(nd->path.dentry); 137 ns_path.mnt = mntget(nd->path.mnt);
138 nd->path.dentry = ns_dentry; 138 nd_jump_link(nd, &ns_path);
139 error = NULL; 139 error = NULL;
140 140
141out_put_task: 141out_put_task:
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dde55c2..ccfd99bd1c5a 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -45,7 +45,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
45 file = region->vm_file; 45 file = region->vm_file;
46 46
47 if (file) { 47 if (file) {
48 struct inode *inode = region->vm_file->f_path.dentry->d_inode; 48 struct inode *inode = file_inode(region->vm_file);
49 dev = inode->i_sb->s_dev; 49 dev = inode->i_sb->s_dev;
50 ino = inode->i_ino; 50 ino = inode->i_ino;
51 } 51 }
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index de20ec480fa0..30b590f5bd35 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -8,6 +8,7 @@
8#include <linux/time.h> 8#include <linux/time.h>
9#include <linux/proc_fs.h> 9#include <linux/proc_fs.h>
10#include <linux/seq_file.h> 10#include <linux/seq_file.h>
11#include <linux/printk.h>
11#include <linux/stat.h> 12#include <linux/stat.h>
12#include <linux/string.h> 13#include <linux/string.h>
13#include <linux/of.h> 14#include <linux/of.h>
@@ -110,8 +111,8 @@ void proc_device_tree_update_prop(struct proc_dir_entry *pde,
110 if (ent->data == oldprop) 111 if (ent->data == oldprop)
111 break; 112 break;
112 if (ent == NULL) { 113 if (ent == NULL) {
113 printk(KERN_WARNING "device-tree: property \"%s\" " 114 pr_warn("device-tree: property \"%s\" does not exist\n",
114 " does not exist\n", oldprop->name); 115 oldprop->name);
115 } else { 116 } else {
116 ent->data = newprop; 117 ent->data = newprop;
117 ent->size = newprop->length; 118 ent->size = newprop->length;
@@ -153,8 +154,8 @@ static const char *fixup_name(struct device_node *np, struct proc_dir_entry *de,
153realloc: 154realloc:
154 fixed_name = kmalloc(fixup_len, GFP_KERNEL); 155 fixed_name = kmalloc(fixup_len, GFP_KERNEL);
155 if (fixed_name == NULL) { 156 if (fixed_name == NULL) {
156 printk(KERN_ERR "device-tree: Out of memory trying to fixup " 157 pr_err("device-tree: Out of memory trying to fixup "
157 "name \"%s\"\n", name); 158 "name \"%s\"\n", name);
158 return name; 159 return name;
159 } 160 }
160 161
@@ -175,8 +176,8 @@ retry:
175 goto retry; 176 goto retry;
176 } 177 }
177 178
178 printk(KERN_WARNING "device-tree: Duplicate name in %s, " 179 pr_warn("device-tree: Duplicate name in %s, renamed to \"%s\"\n",
179 "renamed to \"%s\"\n", np->full_name, fixed_name); 180 np->full_name, fixed_name);
180 181
181 return fixed_name; 182 return fixed_name;
182} 183}
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index fe72cd073dea..b4ac6572474f 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -163,7 +163,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent,
163 struct net *net; 163 struct net *net;
164 164
165 ret = -EINVAL; 165 ret = -EINVAL;
166 net = get_proc_task_net(filp->f_path.dentry->d_inode); 166 net = get_proc_task_net(file_inode(filp));
167 if (net != NULL) { 167 if (net != NULL) {
168 ret = proc_readdir_de(net->proc_net, filp, dirent, filldir); 168 ret = proc_readdir_de(net->proc_net, filp, dirent, filldir);
169 put_net(net); 169 put_net(net);
@@ -177,20 +177,6 @@ const struct file_operations proc_net_operations = {
177 .readdir = proc_tgid_net_readdir, 177 .readdir = proc_tgid_net_readdir,
178}; 178};
179 179
180
181struct proc_dir_entry *proc_net_fops_create(struct net *net,
182 const char *name, umode_t mode, const struct file_operations *fops)
183{
184 return proc_create(name, mode, net->proc_net, fops);
185}
186EXPORT_SYMBOL_GPL(proc_net_fops_create);
187
188void proc_net_remove(struct net *net, const char *name)
189{
190 remove_proc_entry(name, net->proc_net);
191}
192EXPORT_SYMBOL_GPL(proc_net_remove);
193
194static __net_init int proc_net_ns_init(struct net *net) 180static __net_init int proc_net_ns_init(struct net *net)
195{ 181{
196 struct proc_dir_entry *netd, *net_statd; 182 struct proc_dir_entry *netd, *net_statd;
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 1827d88ad58b..ac05f33a0dde 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -5,6 +5,7 @@
5#include <linux/sysctl.h> 5#include <linux/sysctl.h>
6#include <linux/poll.h> 6#include <linux/poll.h>
7#include <linux/proc_fs.h> 7#include <linux/proc_fs.h>
8#include <linux/printk.h>
8#include <linux/security.h> 9#include <linux/security.h>
9#include <linux/sched.h> 10#include <linux/sched.h>
10#include <linux/namei.h> 11#include <linux/namei.h>
@@ -57,7 +58,7 @@ static void sysctl_print_dir(struct ctl_dir *dir)
57{ 58{
58 if (dir->header.parent) 59 if (dir->header.parent)
59 sysctl_print_dir(dir->header.parent); 60 sysctl_print_dir(dir->header.parent);
60 printk(KERN_CONT "%s/", dir->header.ctl_table[0].procname); 61 pr_cont("%s/", dir->header.ctl_table[0].procname);
61} 62}
62 63
63static int namecmp(const char *name1, int len1, const char *name2, int len2) 64static int namecmp(const char *name1, int len1, const char *name2, int len2)
@@ -134,9 +135,9 @@ static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry)
134 else if (cmp > 0) 135 else if (cmp > 0)
135 p = &(*p)->rb_right; 136 p = &(*p)->rb_right;
136 else { 137 else {
137 printk(KERN_ERR "sysctl duplicate entry: "); 138 pr_err("sysctl duplicate entry: ");
138 sysctl_print_dir(head->parent); 139 sysctl_print_dir(head->parent);
139 printk(KERN_CONT "/%s\n", entry->procname); 140 pr_cont("/%s\n", entry->procname);
140 return -EEXIST; 141 return -EEXIST;
141 } 142 }
142 } 143 }
@@ -478,7 +479,7 @@ out:
478static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf, 479static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
479 size_t count, loff_t *ppos, int write) 480 size_t count, loff_t *ppos, int write)
480{ 481{
481 struct inode *inode = filp->f_path.dentry->d_inode; 482 struct inode *inode = file_inode(filp);
482 struct ctl_table_header *head = grab_header(inode); 483 struct ctl_table_header *head = grab_header(inode);
483 struct ctl_table *table = PROC_I(inode)->sysctl_entry; 484 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
484 ssize_t error; 485 ssize_t error;
@@ -542,7 +543,7 @@ static int proc_sys_open(struct inode *inode, struct file *filp)
542 543
543static unsigned int proc_sys_poll(struct file *filp, poll_table *wait) 544static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
544{ 545{
545 struct inode *inode = filp->f_path.dentry->d_inode; 546 struct inode *inode = file_inode(filp);
546 struct ctl_table_header *head = grab_header(inode); 547 struct ctl_table_header *head = grab_header(inode);
547 struct ctl_table *table = PROC_I(inode)->sysctl_entry; 548 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
548 unsigned int ret = DEFAULT_POLLMASK; 549 unsigned int ret = DEFAULT_POLLMASK;
@@ -927,9 +928,9 @@ found:
927 subdir->header.nreg++; 928 subdir->header.nreg++;
928failed: 929failed:
929 if (unlikely(IS_ERR(subdir))) { 930 if (unlikely(IS_ERR(subdir))) {
930 printk(KERN_ERR "sysctl could not get directory: "); 931 pr_err("sysctl could not get directory: ");
931 sysctl_print_dir(dir); 932 sysctl_print_dir(dir);
932 printk(KERN_CONT "/%*.*s %ld\n", 933 pr_cont("/%*.*s %ld\n",
933 namelen, namelen, name, PTR_ERR(subdir)); 934 namelen, namelen, name, PTR_ERR(subdir));
934 } 935 }
935 drop_sysctl_table(&dir->header); 936 drop_sysctl_table(&dir->header);
@@ -995,8 +996,8 @@ static int sysctl_err(const char *path, struct ctl_table *table, char *fmt, ...)
995 vaf.fmt = fmt; 996 vaf.fmt = fmt;
996 vaf.va = &args; 997 vaf.va = &args;
997 998
998 printk(KERN_ERR "sysctl table check failed: %s/%s %pV\n", 999 pr_err("sysctl table check failed: %s/%s %pV\n",
999 path, table->procname, &vaf); 1000 path, table->procname, &vaf);
1000 1001
1001 va_end(args); 1002 va_end(args);
1002 return -EINVAL; 1003 return -EINVAL;
@@ -1510,9 +1511,9 @@ static void put_links(struct ctl_table_header *header)
1510 drop_sysctl_table(link_head); 1511 drop_sysctl_table(link_head);
1511 } 1512 }
1512 else { 1513 else {
1513 printk(KERN_ERR "sysctl link missing during unregister: "); 1514 pr_err("sysctl link missing during unregister: ");
1514 sysctl_print_dir(parent); 1515 sysctl_print_dir(parent);
1515 printk(KERN_CONT "/%s\n", name); 1516 pr_cont("/%s\n", name);
1516 } 1517 }
1517 } 1518 }
1518} 1519}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index ca5ce7f9f800..3e636d864d56 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -271,7 +271,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
271 const char *name = NULL; 271 const char *name = NULL;
272 272
273 if (file) { 273 if (file) {
274 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 274 struct inode *inode = file_inode(vma->vm_file);
275 dev = inode->i_sb->s_dev; 275 dev = inode->i_sb->s_dev;
276 ino = inode->i_ino; 276 ino = inode->i_ino;
277 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; 277 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
@@ -743,7 +743,7 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf,
743 return rv; 743 return rv;
744 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED) 744 if (type < CLEAR_REFS_ALL || type > CLEAR_REFS_MAPPED)
745 return -EINVAL; 745 return -EINVAL;
746 task = get_proc_task(file->f_path.dentry->d_inode); 746 task = get_proc_task(file_inode(file));
747 if (!task) 747 if (!task)
748 return -ESRCH; 748 return -ESRCH;
749 mm = get_task_mm(task); 749 mm = get_task_mm(task);
@@ -1015,7 +1015,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask,
1015static ssize_t pagemap_read(struct file *file, char __user *buf, 1015static ssize_t pagemap_read(struct file *file, char __user *buf,
1016 size_t count, loff_t *ppos) 1016 size_t count, loff_t *ppos)
1017{ 1017{
1018 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); 1018 struct task_struct *task = get_proc_task(file_inode(file));
1019 struct mm_struct *mm; 1019 struct mm_struct *mm;
1020 struct pagemapread pm; 1020 struct pagemapread pm;
1021 int ret = -ESRCH; 1021 int ret = -ESRCH;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 1ccfa537f5f5..56123a6f462e 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -149,7 +149,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
149 file = vma->vm_file; 149 file = vma->vm_file;
150 150
151 if (file) { 151 if (file) {
152 struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 152 struct inode *inode = file_inode(vma->vm_file);
153 dev = inode->i_sb->s_dev; 153 dev = inode->i_sb->s_dev;
154 ino = inode->i_ino; 154 ino = inode->i_ino;
155 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; 155 pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT;
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 0d5071d29985..b870f740ab5a 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -15,6 +15,7 @@
15#include <linux/export.h> 15#include <linux/export.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/printk.h>
18#include <linux/bootmem.h> 19#include <linux/bootmem.h>
19#include <linux/init.h> 20#include <linux/init.h>
20#include <linux/crash_dump.h> 21#include <linux/crash_dump.h>
@@ -175,15 +176,15 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
175 start = map_offset_to_paddr(*fpos, &vmcore_list, &curr_m); 176 start = map_offset_to_paddr(*fpos, &vmcore_list, &curr_m);
176 if (!curr_m) 177 if (!curr_m)
177 return -EINVAL; 178 return -EINVAL;
178 if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
179 tsz = buflen;
180
181 /* Calculate left bytes in current memory segment. */
182 nr_bytes = (curr_m->size - (start - curr_m->paddr));
183 if (tsz > nr_bytes)
184 tsz = nr_bytes;
185 179
186 while (buflen) { 180 while (buflen) {
181 tsz = min_t(size_t, buflen, PAGE_SIZE - (start & ~PAGE_MASK));
182
183 /* Calculate left bytes in current memory segment. */
184 nr_bytes = (curr_m->size - (start - curr_m->paddr));
185 if (tsz > nr_bytes)
186 tsz = nr_bytes;
187
187 tmp = read_from_oldmem(buffer, tsz, &start, 1); 188 tmp = read_from_oldmem(buffer, tsz, &start, 1);
188 if (tmp < 0) 189 if (tmp < 0)
189 return tmp; 190 return tmp;
@@ -198,12 +199,6 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
198 struct vmcore, list); 199 struct vmcore, list);
199 start = curr_m->paddr; 200 start = curr_m->paddr;
200 } 201 }
201 if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
202 tsz = buflen;
203 /* Calculate left bytes in current memory segment. */
204 nr_bytes = (curr_m->size - (start - curr_m->paddr));
205 if (tsz > nr_bytes)
206 tsz = nr_bytes;
207 } 202 }
208 return acc; 203 return acc;
209} 204}
@@ -553,8 +548,7 @@ static int __init parse_crash_elf64_headers(void)
553 ehdr.e_ehsize != sizeof(Elf64_Ehdr) || 548 ehdr.e_ehsize != sizeof(Elf64_Ehdr) ||
554 ehdr.e_phentsize != sizeof(Elf64_Phdr) || 549 ehdr.e_phentsize != sizeof(Elf64_Phdr) ||
555 ehdr.e_phnum == 0) { 550 ehdr.e_phnum == 0) {
556 printk(KERN_WARNING "Warning: Core image elf header is not" 551 pr_warn("Warning: Core image elf header is not sane\n");
557 "sane\n");
558 return -EINVAL; 552 return -EINVAL;
559 } 553 }
560 554
@@ -609,8 +603,7 @@ static int __init parse_crash_elf32_headers(void)
609 ehdr.e_ehsize != sizeof(Elf32_Ehdr) || 603 ehdr.e_ehsize != sizeof(Elf32_Ehdr) ||
610 ehdr.e_phentsize != sizeof(Elf32_Phdr) || 604 ehdr.e_phentsize != sizeof(Elf32_Phdr) ||
611 ehdr.e_phnum == 0) { 605 ehdr.e_phnum == 0) {
612 printk(KERN_WARNING "Warning: Core image elf header is not" 606 pr_warn("Warning: Core image elf header is not sane\n");
613 "sane\n");
614 return -EINVAL; 607 return -EINVAL;
615 } 608 }
616 609
@@ -653,8 +646,7 @@ static int __init parse_crash_elf_headers(void)
653 if (rc < 0) 646 if (rc < 0)
654 return rc; 647 return rc;
655 if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) { 648 if (memcmp(e_ident, ELFMAG, SELFMAG) != 0) {
656 printk(KERN_WARNING "Warning: Core image elf header" 649 pr_warn("Warning: Core image elf header not found\n");
657 " not found\n");
658 return -EINVAL; 650 return -EINVAL;
659 } 651 }
660 652
@@ -673,8 +665,7 @@ static int __init parse_crash_elf_headers(void)
673 /* Determine vmcore size. */ 665 /* Determine vmcore size. */
674 vmcore_size = get_vmcore_size_elf32(elfcorebuf); 666 vmcore_size = get_vmcore_size_elf32(elfcorebuf);
675 } else { 667 } else {
676 printk(KERN_WARNING "Warning: Core image elf header is not" 668 pr_warn("Warning: Core image elf header is not sane\n");
677 " sane\n");
678 return -EINVAL; 669 return -EINVAL;
679 } 670 }
680 return 0; 671 return 0;
@@ -690,7 +681,7 @@ static int __init vmcore_init(void)
690 return rc; 681 return rc;
691 rc = parse_crash_elf_headers(); 682 rc = parse_crash_elf_headers();
692 if (rc) { 683 if (rc) {
693 printk(KERN_WARNING "Kdump: vmcore not initialized\n"); 684 pr_warn("Kdump: vmcore not initialized\n");
694 return rc; 685 return rc;
695 } 686 }
696 687