Re: [PATCH 10/18] maccess: unify the probe kernel arch hooks

From: Masami Hiramatsu
Date: Wed May 13 2020 - 21:13:26 EST


Hi Christoph,

On Wed, 13 May 2020 18:00:30 +0200
Christoph Hellwig <hch@xxxxxx> wrote:

> @@ -36,14 +50,20 @@ long __weak probe_kernel_read(void *dst, const void *src, size_t size)
> * probe_kernel_read() suitable for use within regions where the caller
> * already holds mmap_sem, or other locks which nest inside mmap_sem.
> */
> -long __weak probe_kernel_read_strict(void *dst, const void *src, size_t size)
> - __attribute__((alias("__probe_kernel_read")));
> +long probe_kernel_read_strict(void *dst, const void *src, size_t size)
> +{
> + return __probe_kernel_read(dst, src, size, true);
> +}
>
> -long __probe_kernel_read(void *dst, const void *src, size_t size)
> +static long __probe_kernel_read(void *dst, const void *src, size_t size,
> + bool strict)
> {
> long ret;
> mm_segment_t old_fs = get_fs();
>
> + if (!probe_kernel_read_allowed(dst, src, size, strict))
> + return -EFAULT;

Could you make this return -ERANGE instead of -EFAULT so that
the caller can notice that the address might be user space?

Thank you,

--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>