Commit c0ee37e8 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

maccess: rename probe_user_{read,write} to copy_{from,to}_user_nofault

Better describe what these functions do.
Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe557319
...@@ -1305,7 +1305,8 @@ void show_user_instructions(struct pt_regs *regs) ...@@ -1305,7 +1305,8 @@ void show_user_instructions(struct pt_regs *regs)
for (i = 0; i < 8 && n; i++, n--, pc += sizeof(int)) { for (i = 0; i < 8 && n; i++, n--, pc += sizeof(int)) {
int instr; int instr;
if (probe_user_read(&instr, (void __user *)pc, sizeof(instr))) { if (copy_from_user_nofault(&instr, (void __user *)pc,
sizeof(instr))) {
seq_buf_printf(&s, "XXXXXXXX "); seq_buf_printf(&s, "XXXXXXXX ");
continue; continue;
} }
......
...@@ -64,9 +64,9 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid, ...@@ -64,9 +64,9 @@ unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
isync(); isync();
if (is_load) if (is_load)
ret = probe_user_read(to, (const void __user *)from, n); ret = copy_from_user_nofault(to, (const void __user *)from, n);
else else
ret = probe_user_write((void __user *)to, from, n); ret = copy_to_user_nofault((void __user *)to, from, n);
/* switch the pid first to avoid running host with unallocated pid */ /* switch the pid first to avoid running host with unallocated pid */
if (quadrant == 1 && pid != old_pid) if (quadrant == 1 && pid != old_pid)
......
...@@ -15,11 +15,11 @@ int probe_user_read_inst(struct ppc_inst *inst, ...@@ -15,11 +15,11 @@ int probe_user_read_inst(struct ppc_inst *inst,
unsigned int val, suffix; unsigned int val, suffix;
int err; int err;
err = probe_user_read(&val, nip, sizeof(val)); err = copy_from_user_nofault(&val, nip, sizeof(val));
if (err) if (err)
return err; return err;
if (get_op(val) == OP_PREFIX) { if (get_op(val) == OP_PREFIX) {
err = probe_user_read(&suffix, (void __user *)nip + 4, 4); err = copy_from_user_nofault(&suffix, (void __user *)nip + 4, 4);
*inst = ppc_inst_prefix(val, suffix); *inst = ppc_inst_prefix(val, suffix);
} else { } else {
*inst = ppc_inst(val); *inst = ppc_inst(val);
...@@ -51,7 +51,7 @@ int probe_user_read_inst(struct ppc_inst *inst, ...@@ -51,7 +51,7 @@ int probe_user_read_inst(struct ppc_inst *inst,
unsigned int val; unsigned int val;
int err; int err;
err = probe_user_read(&val, nip, sizeof(val)); err = copy_from_user_nofault(&val, nip, sizeof(val));
if (!err) if (!err)
*inst = ppc_inst(val); *inst = ppc_inst(val);
......
...@@ -33,7 +33,8 @@ static unsigned int user_getsp32(unsigned int sp, int is_first) ...@@ -33,7 +33,8 @@ static unsigned int user_getsp32(unsigned int sp, int is_first)
* which means that we've done all that we can do from * which means that we've done all that we can do from
* interrupt context. * interrupt context.
*/ */
if (probe_user_read(stack_frame, (void __user *)p, sizeof(stack_frame))) if (copy_from_user_nofault(stack_frame, (void __user *)p,
sizeof(stack_frame)))
return 0; return 0;
if (!is_first) if (!is_first)
...@@ -51,7 +52,8 @@ static unsigned long user_getsp64(unsigned long sp, int is_first) ...@@ -51,7 +52,8 @@ static unsigned long user_getsp64(unsigned long sp, int is_first)
{ {
unsigned long stack_frame[3]; unsigned long stack_frame[3];
if (probe_user_read(stack_frame, (void __user *)sp, sizeof(stack_frame))) if (copy_from_user_nofault(stack_frame, (void __user *)sp,
sizeof(stack_frame)))
return 0; return 0;
if (!is_first) if (!is_first)
......
...@@ -44,7 +44,7 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret) ...@@ -44,7 +44,7 @@ static int read_user_stack_32(unsigned int __user *ptr, unsigned int *ret)
((unsigned long)ptr & 3)) ((unsigned long)ptr & 3))
return -EFAULT; return -EFAULT;
rc = probe_user_read(ret, ptr, sizeof(*ret)); rc = copy_from_user_nofault(ret, ptr, sizeof(*ret));
if (IS_ENABLED(CONFIG_PPC64) && rc) if (IS_ENABLED(CONFIG_PPC64) && rc)
return read_user_stack_slow(ptr, ret, 4); return read_user_stack_slow(ptr, ret, 4);
......
...@@ -50,7 +50,7 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret) ...@@ -50,7 +50,7 @@ static int read_user_stack_64(unsigned long __user *ptr, unsigned long *ret)
((unsigned long)ptr & 7)) ((unsigned long)ptr & 7))
return -EFAULT; return -EFAULT;
if (!probe_user_read(ret, ptr, sizeof(*ret))) if (!copy_from_user_nofault(ret, ptr, sizeof(*ret)))
return 0; return 0;
return read_user_stack_slow(ptr, ret, 8); return read_user_stack_slow(ptr, ret, 8);
......
...@@ -426,7 +426,8 @@ static __u64 power_pmu_bhrb_to(u64 addr) ...@@ -426,7 +426,8 @@ static __u64 power_pmu_bhrb_to(u64 addr)
} }
/* Userspace: need copy instruction here then translate it */ /* Userspace: need copy instruction here then translate it */
if (probe_user_read(&instr, (unsigned int __user *)addr, sizeof(instr))) if (copy_from_user_nofault(&instr, (unsigned int __user *)addr,
sizeof(instr)))
return 0; return 0;
target = branch_target((struct ppc_inst *)&instr); target = branch_target((struct ppc_inst *)&instr);
......
...@@ -1066,8 +1066,8 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs) ...@@ -1066,8 +1066,8 @@ int fsl_pci_mcheck_exception(struct pt_regs *regs)
if (is_in_pci_mem_space(addr)) { if (is_in_pci_mem_space(addr)) {
if (user_mode(regs)) if (user_mode(regs))
ret = probe_user_read(&inst, (void __user *)regs->nip, ret = copy_from_user_nofault(&inst,
sizeof(inst)); (void __user *)regs->nip, sizeof(inst));
else else
ret = probe_kernel_address((void *)regs->nip, inst); ret = probe_kernel_address((void *)regs->nip, inst);
......
...@@ -306,8 +306,8 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size); ...@@ -306,8 +306,8 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size);
long copy_from_kernel_nofault(void *dst, const void *src, size_t size); long copy_from_kernel_nofault(void *dst, const void *src, size_t size);
long notrace copy_to_kernel_nofault(void *dst, const void *src, size_t size); long notrace copy_to_kernel_nofault(void *dst, const void *src, size_t size);
extern long probe_user_read(void *dst, const void __user *src, size_t size); long copy_from_user_nofault(void *dst, const void __user *src, size_t size);
extern long notrace probe_user_write(void __user *dst, const void *src, long notrace copy_to_user_nofault(void __user *dst, const void *src,
size_t size); size_t size);
long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr,
......
...@@ -141,7 +141,7 @@ bpf_probe_read_user_common(void *dst, u32 size, const void __user *unsafe_ptr) ...@@ -141,7 +141,7 @@ bpf_probe_read_user_common(void *dst, u32 size, const void __user *unsafe_ptr)
{ {
int ret; int ret;
ret = probe_user_read(dst, unsafe_ptr, size); ret = copy_from_user_nofault(dst, unsafe_ptr, size);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
memset(dst, 0, size); memset(dst, 0, size);
return ret; return ret;
...@@ -326,7 +326,7 @@ BPF_CALL_3(bpf_probe_write_user, void __user *, unsafe_ptr, const void *, src, ...@@ -326,7 +326,7 @@ BPF_CALL_3(bpf_probe_write_user, void __user *, unsafe_ptr, const void *, src,
if (unlikely(!nmi_uaccess_okay())) if (unlikely(!nmi_uaccess_okay()))
return -EPERM; return -EPERM;
return probe_user_write(unsafe_ptr, src, size); return copy_to_user_nofault(unsafe_ptr, src, size);
} }
static const struct bpf_func_proto bpf_probe_write_user_proto = { static const struct bpf_func_proto bpf_probe_write_user_proto = {
......
...@@ -1290,7 +1290,7 @@ probe_mem_read_user(void *dest, void *src, size_t size) ...@@ -1290,7 +1290,7 @@ probe_mem_read_user(void *dest, void *src, size_t size)
{ {
const void __user *uaddr = (__force const void __user *)src; const void __user *uaddr = (__force const void __user *)src;
return probe_user_read(dest, uaddr, size); return copy_from_user_nofault(dest, uaddr, size);
} }
static nokprobe_inline int static nokprobe_inline int
......
...@@ -194,7 +194,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count) ...@@ -194,7 +194,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
#endif /* HAVE_GET_KERNEL_NOFAULT */ #endif /* HAVE_GET_KERNEL_NOFAULT */
/** /**
* probe_user_read(): safely attempt to read from a user-space location * copy_from_user_nofault(): safely attempt to read from a user-space location
* @dst: pointer to the buffer that shall take the data * @dst: pointer to the buffer that shall take the data
* @src: address to read from. This must be a user address. * @src: address to read from. This must be a user address.
* @size: size of the data chunk * @size: size of the data chunk
...@@ -202,7 +202,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count) ...@@ -202,7 +202,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
* Safely read from user address @src to the buffer at @dst. If a kernel fault * Safely read from user address @src to the buffer at @dst. If a kernel fault
* happens, handle that and return -EFAULT. * happens, handle that and return -EFAULT.
*/ */
long probe_user_read(void *dst, const void __user *src, size_t size) long copy_from_user_nofault(void *dst, const void __user *src, size_t size)
{ {
long ret = -EFAULT; long ret = -EFAULT;
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
...@@ -219,10 +219,10 @@ long probe_user_read(void *dst, const void __user *src, size_t size) ...@@ -219,10 +219,10 @@ long probe_user_read(void *dst, const void __user *src, size_t size)
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(probe_user_read); EXPORT_SYMBOL_GPL(copy_from_user_nofault);
/** /**
* probe_user_write(): safely attempt to write to a user-space location * copy_to_user_nofault(): safely attempt to write to a user-space location
* @dst: address to write to * @dst: address to write to
* @src: pointer to the data that shall be written * @src: pointer to the data that shall be written
* @size: size of the data chunk * @size: size of the data chunk
...@@ -230,7 +230,7 @@ EXPORT_SYMBOL_GPL(probe_user_read); ...@@ -230,7 +230,7 @@ EXPORT_SYMBOL_GPL(probe_user_read);
* Safely write to address @dst from the buffer at @src. If a kernel fault * Safely write to address @dst from the buffer at @src. If a kernel fault
* happens, handle that and return -EFAULT. * happens, handle that and return -EFAULT.
*/ */
long probe_user_write(void __user *dst, const void *src, size_t size) long copy_to_user_nofault(void __user *dst, const void *src, size_t size)
{ {
long ret = -EFAULT; long ret = -EFAULT;
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
...@@ -247,7 +247,7 @@ long probe_user_write(void __user *dst, const void *src, size_t size) ...@@ -247,7 +247,7 @@ long probe_user_write(void __user *dst, const void *src, size_t size)
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(probe_user_write); EXPORT_SYMBOL_GPL(copy_to_user_nofault);
/** /**
* strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment