mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
selftests/bpf: Add test for non-NULLable PTR_TO_BTF_IDs
In a recent patch, we taught the verifier that trusted PTR_TO_BTF_ID can never be NULL. This prevents the verifier from incorrectly failing to load certain programs where it gets confused and thinks a reference isn't dropped because it incorrectly assumes that a branch exists in which a NULL PTR_TO_BTF_ID pointer is never released. This patch adds a testcase that verifies this cannot happen. Signed-off-by: David Vernet <void@manifault.com> Acked-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/20230602150112.1494194-2-void@manifault.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
51302c951c
commit
f904c67876
2 changed files with 25 additions and 0 deletions
|
@ -70,5 +70,6 @@ void test_cpumask(void)
|
||||||
verify_success(cpumask_success_testcases[i]);
|
verify_success(cpumask_success_testcases[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RUN_TESTS(cpumask_success);
|
||||||
RUN_TESTS(cpumask_failure);
|
RUN_TESTS(cpumask_failure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <bpf/bpf_tracing.h>
|
#include <bpf/bpf_tracing.h>
|
||||||
#include <bpf/bpf_helpers.h>
|
#include <bpf/bpf_helpers.h>
|
||||||
|
|
||||||
|
#include "bpf_misc.h"
|
||||||
#include "cpumask_common.h"
|
#include "cpumask_common.h"
|
||||||
|
|
||||||
char _license[] SEC("license") = "GPL";
|
char _license[] SEC("license") = "GPL";
|
||||||
|
@ -426,3 +427,26 @@ int BPF_PROG(test_global_mask_rcu, struct task_struct *task, u64 clone_flags)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SEC("tp_btf/task_newtask")
|
||||||
|
__success
|
||||||
|
int BPF_PROG(test_refcount_null_tracking, struct task_struct *task, u64 clone_flags)
|
||||||
|
{
|
||||||
|
struct bpf_cpumask *mask1, *mask2;
|
||||||
|
|
||||||
|
mask1 = bpf_cpumask_create();
|
||||||
|
mask2 = bpf_cpumask_create();
|
||||||
|
|
||||||
|
if (!mask1 || !mask2)
|
||||||
|
goto free_masks_return;
|
||||||
|
|
||||||
|
bpf_cpumask_test_cpu(0, (const struct cpumask *)mask1);
|
||||||
|
bpf_cpumask_test_cpu(0, (const struct cpumask *)mask2);
|
||||||
|
|
||||||
|
free_masks_return:
|
||||||
|
if (mask1)
|
||||||
|
bpf_cpumask_release(mask1);
|
||||||
|
if (mask2)
|
||||||
|
bpf_cpumask_release(mask2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue