Re: [patch] trace: Add user-space event tracing/injection

From: Peter Zijlstra
Date: Wed Nov 17 2010 - 07:37:35 EST


On Wed, 2010-11-17 at 13:29 +0100, Peter Zijlstra wrote:
> > + case PR_TASK_PERF_USER_TRACE:
> > + {
> > + void __user *uevent_ptr = (void *)arg2;
> > + char kstring[MAX_USER_TRACE_SIZE+1];
> > + unsigned long uevent_len = arg3;
> > +
> > + if (uevent_len > MAX_USER_TRACE_SIZE)
> > + return -EINVAL;
> > + if (copy_from_user(kstring, uevent_ptr, uevent_len))
> > + return -EFAULT;
> > + kstring[uevent_len] = 0;
> > +
> > + trace_user(kstring);
> > + return 0;
> > + }

That implementation can be improved upon, no need to actually do the
copy_from_user() when the tracepoint isn't enabled.

Also, do we really need a max size here? I know ftrace (and the perf
tracepoint interface) are currently limited to 1 page of trace data but
that can be fixed (although not trivially).

Also, -EINVAL isn't really a helpful error code in that case, -EMSGSIZE
seems like a good candidate.

And the uevent name is already taken for something else, re-using it
here might cause confusion.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/