0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <stdio.h>
0023
0024
0025 bpf_map(__augmented_syscalls__, PERF_EVENT_ARRAY, int, u32, __NR_CPUS__);
0026
0027 struct augmented_filename {
0028 int size;
0029 int reserved;
0030 char value[64];
0031 };
0032
0033 #define augmented_filename_syscall_enter(syscall) \
0034 struct augmented_enter_##syscall##_args { \
0035 struct syscall_enter_##syscall##_args args; \
0036 struct augmented_filename filename; \
0037 }; \
0038 int syscall_enter(syscall)(struct syscall_enter_##syscall##_args *args) \
0039 { \
0040 char etc[6] = "/etc/"; \
0041 struct augmented_enter_##syscall##_args augmented_args = { .filename.reserved = 0, }; \
0042 probe_read(&augmented_args.args, sizeof(augmented_args.args), args); \
0043 augmented_args.filename.size = probe_read_str(&augmented_args.filename.value, \
0044 sizeof(augmented_args.filename.value), \
0045 args->filename_ptr); \
0046 if (__builtin_memcmp(augmented_args.filename.value, etc, 4) != 0) \
0047 return 0; \
0048 \
0049 return perf_event_output(args, &__augmented_syscalls__, BPF_F_CURRENT_CPU, \
0050 &augmented_args, \
0051 (sizeof(augmented_args) - sizeof(augmented_args.filename.value) + \
0052 augmented_args.filename.size)); \
0053 }
0054
0055 struct syscall_enter_openat_args {
0056 unsigned long long common_tp_fields;
0057 long syscall_nr;
0058 long dfd;
0059 char *filename_ptr;
0060 long flags;
0061 long mode;
0062 };
0063
0064 augmented_filename_syscall_enter(openat);
0065
0066 struct syscall_enter_open_args {
0067 unsigned long long common_tp_fields;
0068 long syscall_nr;
0069 char *filename_ptr;
0070 long flags;
0071 long mode;
0072 };
0073
0074 augmented_filename_syscall_enter(open);
0075
0076 license(GPL);