]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: don't assume build-id length is always 20 bytes
authorStanislav Fomichev <sdf@google.com>
Wed, 16 Jan 2019 22:03:15 +0000 (14:03 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Feb 2019 09:08:56 +0000 (10:08 +0100)
commitc4555b9f280743e6961f707ef2100ff36d5c3c2f
tree89e6b43819d55266528a0d25451e8c7860f4e676
parent5d6af6f9dd2f99381b147431e30a72fbd625fe70
bpf: don't assume build-id length is always 20 bytes

[ Upstream commit 0b698005a9d11c0e91141ec11a2c4918a129f703 ]

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")
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/stackmap.c