summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/progs/find_vma_fail2.c
blob: 9bcf3203e26b5eb3a1d2d66390cd6108e96dcd59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2021 Facebook */
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>

char _license[] SEC("license") = "GPL";

struct callback_ctx {
	int dummy;
};

static long write_task(struct task_struct *task, struct vm_area_struct *vma,
		       struct callback_ctx *data)
{
	/* writing to task, which is illegal */
	task->mm = NULL;

	return 0;
}

SEC("raw_tp/sys_enter")
int handle_getpid(void)
{
	struct task_struct *task = bpf_get_current_task_btf();
	struct callback_ctx data = {};

	bpf_find_vma(task, 0, write_task, &data, 0);
	return 0;
}