diff options
| author | Lorenzo Stoakes <lstoakes@gmail.com> | 2016-10-12 20:20:19 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-19 11:12:14 -0400 |
| commit | 6347e8d5bcce33fc36e651901efefbe2c93a43ef (patch) | |
| tree | 8b738e79772acf156b4bbeca09127afb7dae9554 /fs/proc | |
| parent | 442486ec1096781c50227b73f721a63974b0fdda (diff) | |
mm: replace access_remote_vm() write parameter with gup_flags
This removes the 'write' argument from access_remote_vm() and replaces
it with 'gup_flags' as use of this function previously silently implied
FOLL_FORCE, whereas after this patch callers explicitly pass this flag.
We make this explicit as use of FOLL_FORCE can result in surprising
behaviour (and hence bugs) within the mm subsystem.
Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc')
| -rw-r--r-- | fs/proc/base.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index c2964d890c9a..8e654468ab67 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, 0); | 255 | rv = access_remote_vm(mm, arg_end - 1, &c, 1, FOLL_FORCE); |
| 256 | if (rv <= 0) | 256 | if (rv <= 0) |
| 257 | goto out_free_page; | 257 | goto out_free_page; |
| 258 | 258 | ||
| @@ -270,7 +270,8 @@ 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, 0); | 273 | nr_read = access_remote_vm(mm, p, page, _count, |
| 274 | FOLL_FORCE); | ||
| 274 | if (nr_read < 0) | 275 | if (nr_read < 0) |
| 275 | rv = nr_read; | 276 | rv = nr_read; |
| 276 | if (nr_read <= 0) | 277 | if (nr_read <= 0) |
| @@ -305,7 +306,8 @@ static ssize_t proc_pid_cmdline_read(struct file *file, char __user *buf, | |||
| 305 | bool final; | 306 | bool final; |
| 306 | 307 | ||
| 307 | _count = min3(count, len, PAGE_SIZE); | 308 | _count = min3(count, len, PAGE_SIZE); |
| 308 | nr_read = access_remote_vm(mm, p, page, _count, 0); | 309 | nr_read = access_remote_vm(mm, p, page, _count, |
| 310 | FOLL_FORCE); | ||
| 309 | if (nr_read < 0) | 311 | if (nr_read < 0) |
| 310 | rv = nr_read; | 312 | rv = nr_read; |
| 311 | if (nr_read <= 0) | 313 | if (nr_read <= 0) |
| @@ -354,7 +356,8 @@ skip_argv: | |||
| 354 | bool final; | 356 | bool final; |
| 355 | 357 | ||
| 356 | _count = min3(count, len, PAGE_SIZE); | 358 | _count = min3(count, len, PAGE_SIZE); |
| 357 | nr_read = access_remote_vm(mm, p, page, _count, 0); | 359 | nr_read = access_remote_vm(mm, p, page, _count, |
| 360 | FOLL_FORCE); | ||
| 358 | if (nr_read < 0) | 361 | if (nr_read < 0) |
| 359 | rv = nr_read; | 362 | rv = nr_read; |
| 360 | if (nr_read <= 0) | 363 | if (nr_read <= 0) |
| @@ -832,6 +835,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf, | |||
| 832 | unsigned long addr = *ppos; | 835 | unsigned long addr = *ppos; |
| 833 | ssize_t copied; | 836 | ssize_t copied; |
| 834 | char *page; | 837 | char *page; |
| 838 | unsigned int flags = FOLL_FORCE; | ||
| 835 | 839 | ||
| 836 | if (!mm) | 840 | if (!mm) |
| 837 | return 0; | 841 | return 0; |
| @@ -844,6 +848,9 @@ static ssize_t mem_rw(struct file *file, char __user *buf, | |||
| 844 | if (!atomic_inc_not_zero(&mm->mm_users)) | 848 | if (!atomic_inc_not_zero(&mm->mm_users)) |
| 845 | goto free; | 849 | goto free; |
| 846 | 850 | ||
| 851 | if (write) | ||
| 852 | flags |= FOLL_WRITE; | ||
| 853 | |||
| 847 | while (count > 0) { | 854 | while (count > 0) { |
| 848 | int this_len = min_t(int, count, PAGE_SIZE); | 855 | int this_len = min_t(int, count, PAGE_SIZE); |
| 849 | 856 | ||
| @@ -852,7 +859,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf, | |||
| 852 | break; | 859 | break; |
| 853 | } | 860 | } |
| 854 | 861 | ||
| 855 | this_len = access_remote_vm(mm, addr, page, this_len, write); | 862 | this_len = access_remote_vm(mm, addr, page, this_len, flags); |
| 856 | if (!this_len) { | 863 | if (!this_len) { |
| 857 | if (!copied) | 864 | if (!copied) |
| 858 | copied = -EIO; | 865 | copied = -EIO; |
| @@ -965,7 +972,7 @@ static ssize_t environ_read(struct file *file, char __user *buf, | |||
| 965 | this_len = min(max_len, this_len); | 972 | this_len = min(max_len, this_len); |
| 966 | 973 | ||
| 967 | retval = access_remote_vm(mm, (env_start + src), | 974 | retval = access_remote_vm(mm, (env_start + src), |
| 968 | page, this_len, 0); | 975 | page, this_len, FOLL_FORCE); |
| 969 | 976 | ||
| 970 | if (retval <= 0) { | 977 | if (retval <= 0) { |
| 971 | ret = retval; | 978 | ret = retval; |
