mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
bpf: don't assume build-id length is always 20 bytes
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: 615755a77b
("bpf: extend stackmap to save binary_build_id+offset instead of address")
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
6e8ccb4f62
commit
0b698005a9
1 changed files with 5 additions and 2 deletions
|
@ -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) +
|
||||
|
|
Loading…
Reference in a new issue