Merge branch 'gup_flag-cleanups'
Merge the gup_flags cleanups from Lorenzo Stoakes:
"This patch series adjusts functions in the get_user_pages* family such
that desired FOLL_* flags are passed as an argument rather than
implied by flags.
The purpose of this change is to make the use of FOLL_FORCE explicit
so it is easier to grep for and clearer to callers that this flag is
being used. The use of FOLL_FORCE is an issue as it overrides missing
VM_READ/VM_WRITE flags for the VMA whose pages we are reading
from/writing to, which can result in surprising behaviour.
The patch series came out of the discussion around commit 38e0885465
("mm: check VMA flags to avoid invalid PROT_NONE NUMA balancing"),
which addressed a BUG_ON() being triggered when a page was faulted in
with PROT_NONE set but having been overridden by FOLL_FORCE.
do_numa_page() was run on the assumption the page _must_ be one marked
for NUMA node migration as an actual PROT_NONE page would have been
dealt with prior to this code path, however FOLL_FORCE introduced a
situation where this assumption did not hold.
See
https://marc.info/?l=linux-mm&m=147585445805166
for the patch proposal"
Additionally, there's a fix for an ancient bug related to FOLL_FORCE and
FOLL_WRITE by me.
[ This branch was rebased recently to add a few more acked-by's and
reviewed-by's ]
* gup_flag-cleanups:
mm: replace access_process_vm() write parameter with gup_flags
mm: replace access_remote_vm() write parameter with gup_flags
mm: replace __access_remote_vm() write parameter with gup_flags
mm: replace get_user_pages_remote() write/force parameters with gup_flags
mm: replace get_user_pages() write/force parameters with gup_flags
mm: replace get_vaddr_frames() write/force parameters with gup_flags
mm: replace get_user_pages_locked() write/force parameters with gup_flags
mm: replace get_user_pages_unlocked() write/force parameters with gup_flags
mm: remove write/force parameters from __get_user_pages_unlocked()
mm: remove write/force parameters from __get_user_pages_locked()
mm: remove gup_flags FOLL_WRITE games from __get_user_pages()
This commit is contained in:
@@ -142,7 +142,7 @@ store_virtual_to_phys(struct device *dev, struct device_attribute *attr,
|
||||
u64 virt_addr=simple_strtoull(buf, NULL, 16);
|
||||
int ret;
|
||||
|
||||
ret = get_user_pages(virt_addr, 1, VM_READ, 0, NULL, NULL);
|
||||
ret = get_user_pages(virt_addr, 1, FOLL_WRITE, NULL, NULL);
|
||||
if (ret<=0) {
|
||||
#ifdef ERR_INJ_DEBUG
|
||||
printk("Virtual address %lx is not existing.\n",virt_addr);
|
||||
|
@@ -453,7 +453,7 @@ ia64_peek (struct task_struct *child, struct switch_stack *child_stack,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
copied = access_process_vm(child, addr, &ret, sizeof(ret), 0);
|
||||
copied = access_process_vm(child, addr, &ret, sizeof(ret), FOLL_FORCE);
|
||||
if (copied != sizeof(ret))
|
||||
return -EIO;
|
||||
*val = ret;
|
||||
@@ -489,7 +489,8 @@ ia64_poke (struct task_struct *child, struct switch_stack *child_stack,
|
||||
*ia64_rse_skip_regs(krbs, regnum) = val;
|
||||
}
|
||||
}
|
||||
} else if (access_process_vm(child, addr, &val, sizeof(val), 1)
|
||||
} else if (access_process_vm(child, addr, &val, sizeof(val),
|
||||
FOLL_FORCE | FOLL_WRITE)
|
||||
!= sizeof(val))
|
||||
return -EIO;
|
||||
return 0;
|
||||
@@ -543,7 +544,8 @@ ia64_sync_user_rbs (struct task_struct *child, struct switch_stack *sw,
|
||||
ret = ia64_peek(child, sw, user_rbs_end, addr, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (access_process_vm(child, addr, &val, sizeof(val), 1)
|
||||
if (access_process_vm(child, addr, &val, sizeof(val),
|
||||
FOLL_FORCE | FOLL_WRITE)
|
||||
!= sizeof(val))
|
||||
return -EIO;
|
||||
}
|
||||
@@ -559,7 +561,8 @@ ia64_sync_kernel_rbs (struct task_struct *child, struct switch_stack *sw,
|
||||
|
||||
/* now copy word for word from user rbs to kernel rbs: */
|
||||
for (addr = user_rbs_start; addr < user_rbs_end; addr += 8) {
|
||||
if (access_process_vm(child, addr, &val, sizeof(val), 0)
|
||||
if (access_process_vm(child, addr, &val, sizeof(val),
|
||||
FOLL_FORCE)
|
||||
!= sizeof(val))
|
||||
return -EIO;
|
||||
|
||||
@@ -1156,7 +1159,8 @@ arch_ptrace (struct task_struct *child, long request,
|
||||
case PTRACE_PEEKTEXT:
|
||||
case PTRACE_PEEKDATA:
|
||||
/* read word at location addr */
|
||||
if (access_process_vm(child, addr, &data, sizeof(data), 0)
|
||||
if (access_process_vm(child, addr, &data, sizeof(data),
|
||||
FOLL_FORCE)
|
||||
!= sizeof(data))
|
||||
return -EIO;
|
||||
/* ensure return value is not mistaken for error code */
|
||||
|
Reference in New Issue
Block a user