[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200519134449.1466624-21-hch@lst.de>
Date: Tue, 19 May 2020 15:44:49 +0200
From: Christoph Hellwig <hch@....de>
To: x86@...nel.org, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Masami Hiramatsu <mhiramat@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-parisc@...r.kernel.org, linux-um@...ts.infradead.org,
netdev@...r.kernel.org, bpf@...r.kernel.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 20/20] maccess: return -ERANGE when copy_from_kernel_nofault_allowed fails
Allow the callers to distinguish a real unmapped address vs a range
that can't be probed.
Suggested-by: Masami Hiramatsu <mhiramat@...nel.org>
Signed-off-by: Christoph Hellwig <hch@....de>
---
mm/maccess.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/maccess.c b/mm/maccess.c
index 1e7d77656c596..4010d64189d21 100644
--- a/mm/maccess.c
+++ b/mm/maccess.c
@@ -25,7 +25,7 @@ bool __weak copy_from_kernel_nofault_allowed(void *dst, const void *unsafe_src,
long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
{
if (!copy_from_kernel_nofault_allowed(dst, src, size))
- return -EFAULT;
+ return -ERANGE;
pagefault_disable();
copy_from_kernel_nofault_loop(dst, src, size, u64, Efault);
@@ -69,7 +69,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
if (unlikely(count <= 0))
return 0;
if (!copy_from_kernel_nofault_allowed(dst, unsafe_addr, count))
- return -EFAULT;
+ return -ERANGE;
pagefault_disable();
do {
@@ -107,7 +107,7 @@ long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
mm_segment_t old_fs = get_fs();
if (!copy_from_kernel_nofault_allowed(dst, src, size))
- return -EFAULT;
+ return -ERANGE;
set_fs(KERNEL_DS);
pagefault_disable();
@@ -174,7 +174,7 @@ long strncpy_from_kernel_nofault(char *dst, const void *unsafe_addr, long count)
if (unlikely(count <= 0))
return 0;
if (!copy_from_kernel_nofault_allowed(dst, unsafe_addr, count))
- return -EFAULT;
+ return -ERANGE;
set_fs(KERNEL_DS);
pagefault_disable();
--
2.26.2
Powered by blists - more mailing lists