Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2021 Facebook */
0003 #include "vmlinux.h"
0004 #include <bpf/bpf_helpers.h>
0005 
0006 char _license[] SEC("license") = "GPL";
0007 
0008 struct callback_ctx {
0009     int dummy;
0010 };
0011 
0012 static long write_vma(struct task_struct *task, struct vm_area_struct *vma,
0013               struct callback_ctx *data)
0014 {
0015     /* writing to vma, which is illegal */
0016     vma->vm_flags |= 0x55;
0017 
0018     return 0;
0019 }
0020 
0021 SEC("raw_tp/sys_enter")
0022 int handle_getpid(void)
0023 {
0024     struct task_struct *task = bpf_get_current_task_btf();
0025     struct callback_ctx data = {};
0026 
0027     bpf_find_vma(task, 0, write_vma, &data, 0);
0028     return 0;
0029 }