Last active
November 4, 2025 13:50
-
-
Save naveensrinivasan/7165fada6ed9df1af987b473a413933c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "vmlinux.h" | |
| #include <bpf/bpf_helpers.h> | |
| #include <bpf/bpf_core_read.h> | |
| #define PATH_MAX 1024 | |
| struct path_key { | |
| char container_path[PATH_MAX]; // 1024 bytes | |
| char directory_path[PATH_MAX]; // 1024 bytes | |
| }; | |
| struct { | |
| __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); | |
| __uint(max_entries, 1); | |
| __type(key, u32); | |
| __type(value, struct path_key); | |
| } temp_map SEC(".maps"); | |
| SEC("kprobe/vfs_open_broken") | |
| int broken_no_barrier(struct pt_regs *ctx) | |
| { | |
| u32 idx = 0; | |
| struct path_key *out = bpf_map_lookup_elem(&temp_map, &idx); | |
| if (!out) | |
| return 0; | |
| __builtin_memset(out->container_path, 0, sizeof(out->container_path)); | |
| // asm volatile("" ::: "memory"); | |
| __builtin_memset(out->directory_path, 0, sizeof(out->directory_path)); | |
| const char *path = "/some/path"; | |
| bpf_probe_read_kernel_str(out->directory_path, | |
| sizeof(out->directory_path), path); | |
| return 0; | |
| } | |
| char LICENSE[] SEC("license") = "GPL"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment