Re: [PATCH v2 1/3] tracing: uprobes: Re-enable $comm support for uprobe events

From: Steven Rostedt
Date: Wed Feb 06 2019 - 15:52:48 EST


On Fri, 18 Jan 2019 13:44:25 +0900
Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:

> @@ -180,7 +183,12 @@ fetch_store_strlen(unsigned long addr)
> int len;
> void __user *vaddr = (void __force __user *) addr;
>
> - len = strnlen_user(vaddr, MAX_STRING_SIZE);
> + if (addr == (unsigned long)current->comm) {
> + len = strlen(current->comm);
> + if (len)
> + len++;

Why only add 1 if len is non zero? Why not always do it.

One thing, len should always be greater than 0, and the other is that
this makes it inconsistent with the NULL case of reading the address in
userspace.

-- Steve


> + } else
> + len = strnlen_user(vaddr, MAX_STRING_SIZE);
>
> return (len > MAX_STRING_SIZE) ? 0 : len;