selftests/bpf: validate eliminated global subprog is not freplaceable
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 11 Dec 2023 17:41:31 +0000 (09:41 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 12 Dec 2023 03:16:32 +0000 (19:16 -0800)
commite72c1ccfd449598f7eda10d3bb7441d501ddcfc3
tree7a2c8fc5c837b5a8a74a5360c5129adf9a1a9b0f
parent2ebe81c814355d000fe49d9c4213983844dcb32b
selftests/bpf: validate eliminated global subprog is not freplaceable

Add selftest that establishes dead code-eliminated valid global subprog
(global_dead) and makes sure that it's not possible to freplace it, as
it's effectively not there. This test will fail with unexpected success
before 2afae08c9dcb ("bpf: Validate global subprogs lazily").

v2->v3:
  - add missing err assignment (Alan);
  - undo unnecessary signature changes in verifier_global_subprogs.c (Eduard);
v1->v2:
  - don't rely on assembly output in verifier log, which changes between
    compiler versions (CI).

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/20231211174131.2324306-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/global_func_dead_code.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/freplace_dead_global_func.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/verifier_global_subprogs.c