mm: replace access_process_vm() write parameter with gup_flags
This removes the 'write' argument from access_process_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: Jesper Nilsson <jesper.nilsson@axis.com> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:

committed by
Linus Torvalds

parent
6347e8d5bc
commit
f307ab6dce
@@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
|
||||
int this_len, retval;
|
||||
|
||||
this_len = (len > sizeof(buf)) ? sizeof(buf) : len;
|
||||
retval = access_process_vm(tsk, src, buf, this_len, 0);
|
||||
retval = access_process_vm(tsk, src, buf, this_len, FOLL_FORCE);
|
||||
if (!retval) {
|
||||
if (copied)
|
||||
break;
|
||||
@@ -564,7 +564,8 @@ int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long ds
|
||||
this_len = (len > sizeof(buf)) ? sizeof(buf) : len;
|
||||
if (copy_from_user(buf, src, this_len))
|
||||
return -EFAULT;
|
||||
retval = access_process_vm(tsk, dst, buf, this_len, 1);
|
||||
retval = access_process_vm(tsk, dst, buf, this_len,
|
||||
FOLL_FORCE | FOLL_WRITE);
|
||||
if (!retval) {
|
||||
if (copied)
|
||||
break;
|
||||
@@ -1127,7 +1128,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
|
||||
unsigned long tmp;
|
||||
int copied;
|
||||
|
||||
copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
|
||||
copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), FOLL_FORCE);
|
||||
if (copied != sizeof(tmp))
|
||||
return -EIO;
|
||||
return put_user(tmp, (unsigned long __user *)data);
|
||||
@@ -1138,7 +1139,8 @@ int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
|
||||
{
|
||||
int copied;
|
||||
|
||||
copied = access_process_vm(tsk, addr, &data, sizeof(data), 1);
|
||||
copied = access_process_vm(tsk, addr, &data, sizeof(data),
|
||||
FOLL_FORCE | FOLL_WRITE);
|
||||
return (copied == sizeof(data)) ? 0 : -EIO;
|
||||
}
|
||||
|
||||
@@ -1155,7 +1157,8 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
|
||||
switch (request) {
|
||||
case PTRACE_PEEKTEXT:
|
||||
case PTRACE_PEEKDATA:
|
||||
ret = access_process_vm(child, addr, &word, sizeof(word), 0);
|
||||
ret = access_process_vm(child, addr, &word, sizeof(word),
|
||||
FOLL_FORCE);
|
||||
if (ret != sizeof(word))
|
||||
ret = -EIO;
|
||||
else
|
||||
@@ -1164,7 +1167,8 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
|
||||
|
||||
case PTRACE_POKETEXT:
|
||||
case PTRACE_POKEDATA:
|
||||
ret = access_process_vm(child, addr, &data, sizeof(data), 1);
|
||||
ret = access_process_vm(child, addr, &data, sizeof(data),
|
||||
FOLL_FORCE | FOLL_WRITE);
|
||||
ret = (ret != sizeof(data) ? -EIO : 0);
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user