lkml.org 
[lkml]   [2019]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault
Hi,

On Thu, 21 Feb 2019 16:52:52 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> > ---
> > kernel/trace/trace_kprobe.c | 10 +---------
> > 1 file changed, 1 insertion(+), 9 deletions(-)
> >
> > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
> > index d5fb09ebba8b..9eaf07f99212 100644
> > --- a/kernel/trace/trace_kprobe.c
> > +++ b/kernel/trace/trace_kprobe.c
> > @@ -861,22 +861,14 @@ static const struct file_operations kprobe_profile_ops = {
> > static nokprobe_inline int
> > fetch_store_strlen(unsigned long addr)
> > {
> > - mm_segment_t old_fs;
> > int ret, len = 0;
> > u8 c;
> >
> > - old_fs = get_fs();
> > - set_fs(KERNEL_DS);
> > - pagefault_disable();
> > -

BTW, compared with probe_kernel_read() implementation, this function
lacks current->kernel_uaccess_faults_ok modification here.

I would like to know whether we can avoid this issue if we tweak this flag.

Thank you,

> > do {
> > - ret = __copy_from_user_inatomic(&c, (u8 *)addr + len, 1);
> > + ret = probe_mem_read(&c, (u8 *)addr + len, 1);
> > len++;
> > } while (c && ret == 0 && len < MAX_STRING_SIZE);
> >
> > - pagefault_enable();
> > - set_fs(old_fs);
> > -
> > return (ret < 0) ? ret : len;
> > }
> >
> > --
> > 2.20.1
> >
> >
>
>
> --
> Masami Hiramatsu <mhiramat@kernel.org>


--
Masami Hiramatsu <mhiramat@kernel.org>

\
 
 \ /
  Last update: 2019-02-23 20:31    [W:0.215 / U:0.840 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site