Re: [PATCH 3/6] uprobes/tracing: Ensure inode != NULL in create_trace_uprobe()

Srikar Dronamraju
2013-02-04T10:51:00Z

* Oleg Nesterov <oleg@redhat.com> [2013-01-31 20:18:22]:

> probe_event_enable/disable() check tu->inode != NULL at the start.
> This is ugly, if igrab() can fail create_trace_uprobe() should not
> succeed and "postpone" the failure.
>
> Note: alloc_uprobe() should probably check igrab() != NULL as well.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>

Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

> ---
> kernel/trace/trace_uprobe.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
> index 7b75949..f02bbec 100644
> --- a/kernel/trace/trace_uprobe.c
> +++ b/kernel/trace/trace_uprobe.c
> @@ -255,6 +255,8 @@ static int create_trace_uprobe(int argc, char **argv)
>
> inode = igrab(path.dentry->d_inode);
> path_put(&path);
> + if (!inode)
> + goto fail_address_parse;
>
> ret = kstrtoul(arg, 0, &offset);
> if (ret)
> @@ -539,7 +541,7 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)
> struct uprobe_trace_consumer *utc;
> int ret = 0;
>
> - if (!tu->inode || tu->consumer)
> + if (tu->consumer)
> return -EINTR;
>
> utc = kzalloc(sizeof(struct uprobe_trace_consumer), GFP_KERNEL);
> @@ -563,7 +565,7 @@ static int probe_event_enable(struct trace_uprobe *tu, int flag)
>
> static void probe_event_disable(struct trace_uprobe *tu, int flag)
> {
> - if (!tu->inode || !tu->consumer)
> + if (!tu->consumer)
> return;
>
> uprobe_unregister(tu->inode, tu->offset, &tu->consumer->cons);
> --
> 1.5.5.1
>

--
Thanks and Regards
Srikar Dronamraju