summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-05-30 14:51:15 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2020-06-02 19:28:37 +1000
commit8e7bc08defad969a8ed9f51df5a0329c3a10960d (patch)
tree247a87314a92bffa7a4fed9f67ac2f0d198c38dd
parentac2118e4a587bbadafb7d3ac9eb692862da64732 (diff)
downloadlinux-8e7bc08defad969a8ed9f51df5a0329c3a10960d.tar.gz
maccess: remove strncpy_from_unsafe
All users are gone now. Link: http://lkml.kernel.org/r/20200521152301.2587579-16-hch@lst.de Signed-off-by: Christoph Hellwig <hch@lst.de> 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-rw-r--r--include/linux/uaccess.h1
-rw-r--r--mm/maccess.c39
2 files changed, 1 insertions, 39 deletions
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 69bd552b07f5..a3ee0b3b5c1a 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -311,7 +311,6 @@ extern long probe_user_read(void *dst, const void __user *src, size_t size);
extern long notrace probe_kernel_write(void *dst, const void *src, size_t size);
extern long notrace probe_user_write(void __user *dst, const void *src, size_t size);
-extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count);
long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr,
long count);
diff --git a/mm/maccess.c b/mm/maccess.c
index 73d1a8993a68..c2ad1de78f0d 100644
--- a/mm/maccess.c
+++ b/mm/maccess.c
@@ -8,8 +8,6 @@
static long __probe_kernel_read(void *dst, const void *src, size_t size,
bool strict);
-static long __strncpy_from_unsafe(char *dst, const void *unsafe_addr,
- long count, bool strict);
bool __weak probe_kernel_read_allowed(const void *unsafe_src, size_t size,
bool strict)
@@ -157,35 +155,6 @@ long probe_user_write(void __user *dst, const void *src, size_t size)
}
/**
- * strncpy_from_unsafe: - Copy a NUL terminated string from unsafe address.
- * @dst: Destination address, in kernel space. This buffer must be at
- * least @count bytes long.
- * @unsafe_addr: Unsafe address.
- * @count: Maximum number of bytes to copy, including the trailing NUL.
- *
- * Copies a NUL-terminated string from unsafe address to kernel buffer.
- *
- * On success, returns the length of the string INCLUDING the trailing NUL.
- *
- * If access fails, returns -EFAULT (some data may have been copied
- * and the trailing NUL added).
- *
- * 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.
- *
- * Same as strncpy_from_kernel_nofault() except that for architectures with
- * not fully separated user and kernel address spaces this function also works
- * for user address tanges.
- *
- * DO NOT USE THIS FUNCTION - it is broken on architectures with entirely
- * separate kernel and user address spaces, and also a bad idea otherwise.
- */
-long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
-{
- return __strncpy_from_unsafe(dst, unsafe_addr, count, false);
-}
-
-/**
* strncpy_from_kernel_nofault: - Copy a NUL terminated string from unsafe
* address.
* @dst: Destination address, in kernel space. This buffer must be at
@@ -205,19 +174,13 @@ long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
*/
long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
{
- return __strncpy_from_unsafe(dst, unsafe_addr, count, true);
-}
-
-static long __strncpy_from_unsafe(char *dst, const void *unsafe_addr,
- long count, bool strict)
-{
mm_segment_t old_fs = get_fs();
const void *src = unsafe_addr;
long ret;
if (unlikely(count <= 0))
return 0;
- if (!probe_kernel_read_allowed(unsafe_addr, count, strict))
+ if (!probe_kernel_read_allowed(unsafe_addr, count, true))
return -EFAULT;
set_fs(KERNEL_DS);