diff options
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/exec.c | 9 | ||||
| -rw-r--r-- | fs/proc/base.c | 19 |
2 files changed, 20 insertions, 8 deletions
| @@ -191,6 +191,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, | |||
| 191 | { | 191 | { |
| 192 | struct page *page; | 192 | struct page *page; |
| 193 | int ret; | 193 | int ret; |
| 194 | unsigned int gup_flags = FOLL_FORCE; | ||
| 194 | 195 | ||
| 195 | #ifdef CONFIG_STACK_GROWSUP | 196 | #ifdef CONFIG_STACK_GROWSUP |
| 196 | if (write) { | 197 | if (write) { |
| @@ -199,12 +200,16 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, | |||
| 199 | return NULL; | 200 | return NULL; |
| 200 | } | 201 | } |
| 201 | #endif | 202 | #endif |
| 203 | |||
| 204 | if (write) | ||
| 205 | gup_flags |= FOLL_WRITE; | ||
| 206 | |||
| 202 | /* | 207 | /* |
| 203 | * We are doing an exec(). 'current' is the process | 208 | * We are doing an exec(). 'current' is the process |
| 204 | * doing the exec and bprm->mm is the new process's mm. | 209 | * doing the exec and bprm->mm is the new process's mm. |
| 205 | */ | 210 | */ |
| 206 | ret = get_user_pages_remote(current, bprm->mm, pos, 1, write, | 211 | ret = get_user_pages_remote(current, bprm->mm, pos, 1, gup_flags, |
| 207 | 1, &page, NULL); | 212 | &page, NULL); |
| 208 | if (ret <= 0) | 213 | if (ret <= 0) |
| 209 | return NULL; | 214 | return NULL; |
| 210 | 215 | ||
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; |
