Re: [PATCH v2 1/6] perf: Introduce extended syscall error reporting

Alexander Shishkin
2015-09-01T06:38:24Z

Andy Shevchenko <andy.shevchenko@gmail.com> writes:

> On Mon, Aug 24, 2015 at 5:32 PM, Alexander Shishkin
> <alexander.shishkin@linux.intel.com> wrote:
>> + /* trim the buffer to the supplied boundary */
>> + len = strlen(buffer);
>> + if (len >= attr->perf_err_size) {
>> + len = attr->perf_err_size - 1;
>> + buffer[len] = 0;
>> + }
>
> len = strnlen(buffer, attr->perf_err_size);
> buffer[len] = 0;
>
> And perhaps perf_err_size has to be length (perf_err_len) ?
>
>> +
>> + if (copy_to_user((void __user *)attr->perf_err, buffer, len + 1)) {
>> + /* if we failed to copy once, don't bother later */
>> + attr->perf_err_size = 0;
>
> Kaboom next time on buffer[-1] = 0; since len >= 0?

Of course, we never get here if attr::perf_err_size is 0, there's an
explicit check for that, but nice try.

Regards,
--
Alex