[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHk-=wg0tH4tf-YiviztA=8TpHsg-K_ERJW3t143uNnpkvCfWg@mail.gmail.com>
Date: Fri, 1 Nov 2019 15:15:34 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...radead.org>,
Jiri Olsa <jolsa@...hat.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Mark Rutland <mark.rutland@....com>,
Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [GIT PULL] perf fixes
On Fri, Nov 1, 2019 at 1:30 PM Ingo Molnar <mingo@...nel.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
Powered by blists - more mailing lists