提交 bd88bb5d 编写于 作者: C Christoph Hellwig 提交者: Linus Torvalds

maccess: rename strncpy_from_unsafe_user to strncpy_from_user_nofault

This matches the naming of strncpy_from_user, and also makes it more
clear what the function is supposed to do.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20200521152301.2587579-7-hch@lst.deSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 3f0acb1e
...@@ -313,8 +313,8 @@ extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); ...@@ -313,8 +313,8 @@ extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count);
extern long strncpy_from_unsafe_strict(char *dst, const void *unsafe_addr, extern long strncpy_from_unsafe_strict(char *dst, const void *unsafe_addr,
long count); long count);
extern long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); extern long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count);
extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, long strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr,
long count); long count);
extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count); extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count);
/** /**
......
...@@ -159,7 +159,7 @@ const struct bpf_func_proto bpf_probe_read_user_proto = { ...@@ -159,7 +159,7 @@ const struct bpf_func_proto bpf_probe_read_user_proto = {
BPF_CALL_3(bpf_probe_read_user_str, void *, dst, u32, size, BPF_CALL_3(bpf_probe_read_user_str, void *, dst, u32, size,
const void __user *, unsafe_ptr) const void __user *, unsafe_ptr)
{ {
int ret = strncpy_from_unsafe_user(dst, unsafe_ptr, size); int ret = strncpy_from_user_nofault(dst, unsafe_ptr, size);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
memset(dst, 0, size); memset(dst, 0, size);
...@@ -419,7 +419,7 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1, ...@@ -419,7 +419,7 @@ BPF_CALL_5(bpf_trace_printk, char *, fmt, u32, fmt_size, u64, arg1,
sizeof(buf)); sizeof(buf));
break; break;
case 'u': case 'u':
strncpy_from_unsafe_user(buf, strncpy_from_user_nofault(buf,
(__force void __user *)unsafe_ptr, (__force void __user *)unsafe_ptr,
sizeof(buf)); sizeof(buf));
break; break;
......
...@@ -1268,7 +1268,7 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base) ...@@ -1268,7 +1268,7 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base)
__dest = get_loc_data(dest, base); __dest = get_loc_data(dest, base);
ret = strncpy_from_unsafe_user(__dest, uaddr, maxlen); ret = strncpy_from_user_nofault(__dest, uaddr, maxlen);
if (ret >= 0) if (ret >= 0)
*(u32 *)dest = make_data_loc(ret, __dest - base); *(u32 *)dest = make_data_loc(ret, __dest - base);
......
...@@ -217,7 +217,7 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count) ...@@ -217,7 +217,7 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
} }
/** /**
* strncpy_from_unsafe_user: - Copy a NUL terminated string from unsafe user * strncpy_from_user_nofault: - Copy a NUL terminated string from unsafe user
* address. * address.
* @dst: Destination address, in kernel space. This buffer must be at * @dst: Destination address, in kernel space. This buffer must be at
* least @count bytes long. * least @count bytes long.
...@@ -234,7 +234,7 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count) ...@@ -234,7 +234,7 @@ long __strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
* If @count is smaller than the length of the string, copies @count-1 bytes, * If @count is smaller than the length of the string, copies @count-1 bytes,
* sets the last byte of @dst buffer to NUL and returns @count. * sets the last byte of @dst buffer to NUL and returns @count.
*/ */
long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, long strncpy_from_user_nofault(char *dst, const void __user *unsafe_addr,
long count) long count)
{ {
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册