aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/base.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-24 22:00:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-24 22:00:44 -0400
commit272ddc8b37354c3fe111ab26d25e792629148eee (patch)
tree78d4280320fbee5b4b37a839023b6a9ba34865ef /fs/proc/base.c
parent07d9a380680d1c0eb51ef87ff2eab5c994949e69 (diff)
proc: don't use FOLL_FORCE for reading cmdline and environment
Now that Lorenzo cleaned things up and made the FOLL_FORCE users explicit, it becomes obvious how some of them don't really need FOLL_FORCE at all. So remove FOLL_FORCE from the proc code that reads the command line and arguments from user space. The mem_rw() function actually does want FOLL_FORCE, because gdd (and possibly many other debuggers) use it as a much more convenient version of PTRACE_PEEKDATA, but we should consider making the FOLL_FORCE part conditional on actually being a ptracer. This does not actually do that, just moves adds a comment to that effect and moves the gup_flags settings next to each other. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8e654468ab67..adfc5b4986f5 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -252,7 +252,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
252 * Inherently racy -- command line shares address space 252 * Inherently racy -- command line shares address space
253 * with code and data. 253 * with code and data.
254 */ 254 */
255 rv = access_remote_vm(mm, arg_end - 1, &c, 1, FOLL_FORCE); 255 rv = access_remote_vm(mm, arg_end - 1, &c, 1, 0);
256 if (rv <= 0) 256 if (rv <= 0)
257 goto out_free_page; 257 goto out_free_page;
258 258
@@ -270,8 +270,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
270 int nr_read; 270 int nr_read;
271 271
272 _count = min3(count, len, PAGE_SIZE); 272 _count = min3(count, len, PAGE_SIZE);
273 nr_read = access_remote_vm(mm, p, page, _count, 273 nr_read = access_remote_vm(mm, p, page, _count, 0);
274 FOLL_FORCE);
275 if (nr_read < 0) 274 if (nr_read < 0)
276 rv = nr_read; 275 rv = nr_read;
277 if (nr_read <= 0) 276 if (nr_read <= 0)
@@ -306,8 +305,7 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf,
306 bool final; 305 bool final;
307 306
308 _count = min3(count, len, PAGE_SIZE); 307 _count = min3(count, len, PAGE_SIZE);
309 nr_read = access_remote_vm(mm, p, page, _count, 308 nr_read = access_remote_vm(mm, p, page, _count, 0);
310 FOLL_FORCE);
311 if (nr_read < 0) 309 if (nr_read < 0)
312 rv = nr_read; 310 rv = nr_read;
313 if (nr_read <= 0) 311 if (nr_read <= 0)
@@ -356,8 +354,7 @@ skip_argv:
356 bool final; 354 bool final;
357 355
358 _count = min3(count, len, PAGE_SIZE); 356 _count = min3(count, len, PAGE_SIZE);
359 nr_read = access_remote_vm(mm, p, page, _count, 357 nr_read = access_remote_vm(mm, p, page, _count, 0);
360 FOLL_FORCE);
361 if (nr_read < 0) 358 if (nr_read < 0)
362 rv = nr_read; 359 rv = nr_read;
363 if (nr_read <= 0) 360 if (nr_read <= 0)
@@ -835,7 +832,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
835 unsigned long addr = *ppos; 832 unsigned long addr = *ppos;
836 ssize_t copied; 833 ssize_t copied;
837 char *page; 834 char *page;
838 unsigned int flags = FOLL_FORCE; 835 unsigned int flags;
839 836
840 if (!mm) 837 if (!mm)
841 return 0; 838 return 0;
@@ -848,6 +845,8 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
848 if (!atomic_inc_not_zero(&mm->mm_users)) 845 if (!atomic_inc_not_zero(&mm->mm_users))
849 goto free; 846 goto free;
850 847
848 /* Maybe we should limit FOLL_FORCE to actual ptrace users? */
849 flags = FOLL_FORCE;
851 if (write) 850 if (write)
852 flags |= FOLL_WRITE; 851 flags |= FOLL_WRITE;
853 852
@@ -971,8 +970,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
971 max_len = min_t(size_t, PAGE_SIZE, count); 970 max_len = min_t(size_t, PAGE_SIZE, count);
972 this_len = min(max_len, this_len); 971 this_len = min(max_len, this_len);
973 972
974 retval = access_remote_vm(mm, (env_start + src), 973 retval = access_remote_vm(mm, (env_start + src), page, this_len, 0);
975 page, this_len, FOLL_FORCE);
976 974
977 if (retval <= 0) { 975 if (retval <= 0) {
978 ret = retval; 976 ret = retval;