1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2021 Facebook */
3#include "vmlinux.h"
4#include <bpf/bpf_helpers.h>
5
6char _license[] SEC("license") = "GPL";
7
8struct callback_ctx {
9 int dummy;
10};
11
12static long write_task(struct task_struct *task, struct vm_area_struct *vma,
13 struct callback_ctx *data)
14{
15 /* writing to task, which is illegal */
16 task->mm = NULL;
17
18 return 0;
19}
20
21SEC("raw_tp/sys_enter")
22int handle_getpid(void)
23{
24 struct task_struct *task = bpf_get_current_task_btf();
25 struct callback_ctx data = {};
26
27 bpf_find_vma(task, 0, write_task, &data, 0);
28 return 0;
29}
30

source code of linux/tools/testing/selftests/bpf/progs/find_vma_fail2.c