]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: btf: Fix arg verification in btf_ctx_access()
authorKP Singh <kpsingh@google.com>
Mon, 30 Mar 2020 14:42:46 +0000 (16:42 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 30 Mar 2020 20:28:02 +0000 (13:28 -0700)
commit074d206f8657139d4af635e8a1e79a270ca6a987
tree20d9df623fc83ec508db1cfe8586cf961061a262
parentbe2ad077b7f3c51539d4aabe6dcd4dfb4e45ea18
bpf: btf: Fix arg verification in btf_ctx_access()

The bounds checking for the arguments accessed in the BPF program breaks
when the expected_attach_type is not BPF_TRACE_FEXIT, BPF_LSM_MAC or
BPF_MODIFY_RETURN resulting in no check being done for the default case
(the programs which do not receive the return value of the attached
function in its arguments) when the index of the argument being accessed
is equal to the number of arguments (nr_args).

This was a result of a misplaced "else if" block  introduced by the
Commit d8e49679b261 ("bpf: Attachment verification for
BPF_MODIFY_RETURN")

Fixes: d8e49679b261 ("bpf: Attachment verification for BPF_MODIFY_RETURN")
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200330144246.338-1-kpsingh@chromium.org
kernel/bpf/btf.c