lkml.org 
[lkml]   [2019]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [GIT PULL] perf fixes
On Fri, Nov 1, 2019 at 1:30 PM Ingo Molnar <mingo@kernel.org> wrote:
>
> Firstly, non-existent fields are initialized to zero by default in the
> perf ABI: *even if user-space was built well before that new field was
> introduced in the kernel*.
>
> This is done in perf_copy_attr():
>
> /* Zero the full structure, so that a short copy will be nice. */
> memset(attr, 0, sizeof(*attr));
>
> The user-space structure that is passed in ('uattr' within that function)
> might indeed be short and not contain the new field - but we handle this
> via uattr->size, which is set by user-space - for example 'perf' sets it
> in event_attr_init() in tools/perf/util/util.c:
>
> /* to capture ABI version */
> attr->size = sizeof(*attr);
>
> Second, the kernel syscall then checks this size against the kernel's
> size of attr:
>
> - if uattr->size < kattr_size: then old ABI user-space binary is
> running on new kernel, and we zero out residual fields.

Very good. These were the two pieces I was missing - just readfing the
commit messages it wasn't clear that this was safe at all.

Thanks for following up on my worry,

Linus

\
 
 \ /
  Last update: 2019-11-01 23:16    [W:0.232 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site