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
@ -127,7 +127,8 @@ static int get_from_target(struct task_struct *target, unsigned long uaddr,
|
||||
if (copy_from_user(kbuf, (void __user *) uaddr, len))
|
||||
return -EFAULT;
|
||||
} else {
|
||||
int len2 = access_process_vm(target, uaddr, kbuf, len, 0);
|
||||
int len2 = access_process_vm(target, uaddr, kbuf, len,
|
||||
FOLL_FORCE);
|
||||
if (len2 != len)
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -141,7 +142,8 @@ static int set_to_target(struct task_struct *target, unsigned long uaddr,
|
||||
if (copy_to_user((void __user *) uaddr, kbuf, len))
|
||||
return -EFAULT;
|
||||
} else {
|
||||
int len2 = access_process_vm(target, uaddr, kbuf, len, 1);
|
||||
int len2 = access_process_vm(target, uaddr, kbuf, len,
|
||||
FOLL_FORCE | FOLL_WRITE);
|
||||
if (len2 != len)
|
||||
return -EFAULT;
|
||||
}
|
||||
@ -505,7 +507,8 @@ static int genregs32_get(struct task_struct *target,
|
||||
if (access_process_vm(target,
|
||||
(unsigned long)
|
||||
®_window[pos],
|
||||
k, sizeof(*k), 0)
|
||||
k, sizeof(*k),
|
||||
FOLL_FORCE)
|
||||
!= sizeof(*k))
|
||||
return -EFAULT;
|
||||
k++;
|
||||
@ -531,12 +534,14 @@ static int genregs32_get(struct task_struct *target,
|
||||
if (access_process_vm(target,
|
||||
(unsigned long)
|
||||
®_window[pos],
|
||||
®, sizeof(reg), 0)
|
||||
®, sizeof(reg),
|
||||
FOLL_FORCE)
|
||||
!= sizeof(reg))
|
||||
return -EFAULT;
|
||||
if (access_process_vm(target,
|
||||
(unsigned long) u,
|
||||
®, sizeof(reg), 1)
|
||||
®, sizeof(reg),
|
||||
FOLL_FORCE | FOLL_WRITE)
|
||||
!= sizeof(reg))
|
||||
return -EFAULT;
|
||||
pos++;
|
||||
@ -615,7 +620,8 @@ static int genregs32_set(struct task_struct *target,
|
||||
(unsigned long)
|
||||
®_window[pos],
|
||||
(void *) k,
|
||||
sizeof(*k), 1)
|
||||
sizeof(*k),
|
||||
FOLL_FORCE | FOLL_WRITE)
|
||||
!= sizeof(*k))
|
||||
return -EFAULT;
|
||||
k++;
|
||||
@ -642,13 +648,15 @@ static int genregs32_set(struct task_struct *target,
|
||||
if (access_process_vm(target,
|
||||
(unsigned long)
|
||||
u,
|
||||
®, sizeof(reg), 0)
|
||||
®, sizeof(reg),
|
||||
FOLL_FORCE)
|
||||
!= sizeof(reg))
|
||||
return -EFAULT;
|
||||
if (access_process_vm(target,
|
||||
(unsigned long)
|
||||
®_window[pos],
|
||||
®, sizeof(reg), 1)
|
||||
®, sizeof(reg),
|
||||
FOLL_FORCE | FOLL_WRITE)
|
||||
!= sizeof(reg))
|
||||
return -EFAULT;
|
||||
pos++;
|
||||
|
Reference in New Issue
Block a user