linux/tools/testing/selftests/bpf/progs/find_vma_fail1.c
<<
>>
Prefs
   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_vma(struct task_struct *task, struct vm_area_struct *vma,
  13                      struct callback_ctx *data)
  14{
  15        /* writing to vma, which is illegal */
  16        vma->vm_flags |= 0x55;
  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_vma, &data, 0);
  28        return 0;
  29}
  30