Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Steve,

On Fri, 22 Feb 2019 00:58:12 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:

> On Thu, 21 Feb 2019 09:36:25 -0500
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> 
> > On Thu, 21 Feb 2019 16:52:52 +0900
> > Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
> > 
> > > Basically OK to me.
> > > Could you use probe_kernel_read() in this context, since probe_mem_read() is a
> > > wrapper function for template code.
> > > 
> > > With that change,
> > > 
> > > Acked-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> > 
> > This already hit Linus's tree. I was able to reproduce the crash, so I
> > streamlined it. I should have still pushed more for your ack first.
> > Sorry about that.
> 
> Oh, never mind. That seems urgent issue for kprobe event.
> Thank you very much for fixing it!
> 
> > For some reason, I thought the change was in the generic probe code,
> > and accepted the probe_mem_read(). Anyway, did you want to send a patch
> > to change it to probe_kernel_read(), for the merge window?
> 
> No problem.

Oops, I mean No, not yet. but it is a simple and cosmetic patch like below.
Feel free to merge it to ftrace/core.

---------
tracing/kprobes: Use probe_kernel_read instead of probe_mem_read

From: Masami Hiramatsu <mhiramat@xxxxxxxxxx>

Use probe_kernel_read() instead of probe_mem_read() because
probe_mem_read() is a kind of wrapper for switching memory
read function between uprobes and kprobes.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
---
 kernel/trace/trace_kprobe.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 9eaf07f99212..99592c27465e 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -865,7 +865,7 @@ fetch_store_strlen(unsigned long addr)
 	u8 c;
 
 	do {
-		ret = probe_mem_read(&c, (u8 *)addr + len, 1);
+		ret = probe_kernel_read(&c, (u8 *)addr + len, 1);
 		len++;
 	} while (c && ret == 0 && len < MAX_STRING_SIZE);
 

-- 
Masami Hiramatsu <mhiramat@xxxxxxxxxx>



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux