[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8E0EA410-7FF2-4E89-8BF2-AFA04D0FD2B4@fb.com>
Date: Wed, 16 Jan 2019 18:20:47 +0000
From: Song Liu <songliubraving@...com>
To: Stanislav Fomichev <sdf@...gle.com>
CC: Netdev <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>
Subject: Re: [PATCH bpf v2 1/3] bpf: don't assume build-id length is always 20
bytes
> On Jan 16, 2019, at 10:11 AM, Stanislav Fomichev <sdf@...gle.com> wrote:
>
> Build-id length is not fixed to 20, it can be (`man ld` /--build-id):
> * 128-bit (uuid)
> * 160-bit (sha1)
> * any length specified in ld --build-id=0xhexstring
>
> To fix the issue of missing BPF_STACK_BUILD_ID_VALID for shorter build-ids,
> assume that build-id is somewhere in the range of 1 .. 20.
> Set the remaining bytes to zero.
>
> v2:
> * don't introduce new "len = min(BPF_BUILD_ID_SIZE, nhdr->n_descsz)",
> we already know that nhdr->n_descsz <= BPF_BUILD_ID_SIZE if we enter
> this 'if' condition
>
> Fixes: 615755a77b24 ("bpf: extend stackmap to save binary_build_id+offset instead of address")
> Signed-off-by: Stanislav Fomichev <sdf@...gle.com>
Acked-by: Song Liu <songliubraving@...com>
> ---
> kernel/bpf/stackmap.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index d9e2483669d0..f9df545e92f6 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -180,11 +180,14 @@ static inline int stack_map_parse_build_id(void *page_addr,
>
> if (nhdr->n_type == BPF_BUILD_ID &&
> nhdr->n_namesz == sizeof("GNU") &&
> - nhdr->n_descsz == BPF_BUILD_ID_SIZE) {
> + nhdr->n_descsz > 0 &&
> + nhdr->n_descsz <= BPF_BUILD_ID_SIZE) {
> memcpy(build_id,
> note_start + note_offs +
> ALIGN(sizeof("GNU"), 4) + sizeof(Elf32_Nhdr),
> - BPF_BUILD_ID_SIZE);
> + nhdr->n_descsz);
> + memset(build_id + nhdr->n_descsz, 0,
> + BPF_BUILD_ID_SIZE - nhdr->n_descsz);
> return 0;
> }
> new_offs = note_offs + sizeof(Elf32_Nhdr) +
> --
> 2.20.1.97.g81188d93c3-goog
>
Powered by blists - more mailing lists