Messages in this thread | | | From | Linus Torvalds <> | Date | Fri, 1 Nov 2019 15:15:34 -0700 | Subject | Re: [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
| |