Re: [PATCH 20/20] maccess: return -ERANGE when copy_from_kernel_nofault_allowed fails

From: Masami Hiramatsu
Date: Wed May 20 2020 - 07:03:04 EST


On Tue, 19 May 2020 15:44:49 +0200
Christoph Hellwig <hch@xxxxxx> wrote:

> Allow the callers to distinguish a real unmapped address vs a range
> that can't be probed.
>
> Suggested-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Hi Christoph,

Can you also update the kerneldoc comment too?
Other than that, this looks good to me.

Reviewed-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>

Thank you!

> ---
> 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
>


--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>