lkml.org 
[lkml]   [2015]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH RFC v1 1/4] perf: Introduce extended syscall error reporting
On Fri, Jul 24, 2015 at 02:45:56PM +0300, Alexander Shishkin wrote:
> +static void perf_error_report_site(struct perf_event_attr *attr,
> + const struct perf_err_site *site)
> +{
> + void *buffer;
> +
> + if (!site || !extended_reporting_enabled(attr))
> + return;
> +
> + /* in case of nested perf_err()s, which you shouldn't really do */
> + while (site->code <= -PERF_ERRNO)
> + site = perf_errno_to_site(site->code);
> +
> + buffer = kasprintf(GFP_KERNEL,
> + "{\n"
> + "\t\"code\": %d,\n"
> + "\t\"module\": \"%s\",\n"
> + "\t\"message\": \"%s\"\n"
> + "}\n",
> + site->code, site->owner, site->message
> + );
> + if (!buffer)
> + return;
> +
> + if (copy_to_user((void __user *)attr->perf_err, buffer,
> + attr->perf_err_size)) {

Should that not be min(attr->perf_err_size, strlen(buffer)) ?

Also, should we not '\0' the last char in attr->perf_err in case buffer
is longer.

> + /* if we failed to copy once, don't bother later */
> + attr->perf_err_size = 0;
> + }

So we want update the user's perf_err_size with the actual size we
copied in?

> +
> + kfree(buffer);
> +}


\
 
 \ /
  Last update: 2015-08-05 18:01    [W:0.141 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site