1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
3 
4 #include <vmlinux.h>
5 #include <bpf/bpf_tracing.h>
6 #include <bpf/bpf_helpers.h>
7 #include "bpf_misc.h"
8 
9 #include "nested_trust_common.h"
10 
11 char _license[] SEC("license") = "GPL";
12 
13 /* Prototype for all of the program trace events below:
14  *
15  * TRACE_EVENT(task_newtask,
16  *         TP_PROTO(struct task_struct *p, u64 clone_flags)
17  */
18 
19 SEC("tp_btf/task_newtask")
20 __failure __msg("R2 must be")
21 int BPF_PROG(test_invalid_nested_user_cpus, struct task_struct *task, u64 clone_flags)
22 {
23 	bpf_cpumask_test_cpu(0, task->user_cpus_ptr);
24 	return 0;
25 }
26 
27 SEC("tp_btf/task_newtask")
28 __failure __msg("R1 must have zero offset when passed to release func or trusted arg to kfunc")
29 int BPF_PROG(test_invalid_nested_offset, struct task_struct *task, u64 clone_flags)
30 {
31 	bpf_cpumask_first_zero(&task->cpus_mask);
32 	return 0;
33 }
34