1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Google */
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
8 extern const int bpf_prog_active __ksym;
10 SEC("fentry/security_inode_getattr")
11 int BPF_PROG(d_path_check_rdonly_mem, struct path *path, struct kstat *stat,
12 __u32 request_mask, unsigned int query_flags)
17 cpu = bpf_get_smp_processor_id();
18 active = (void *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);
20 /* FAIL here! 'active' points to readonly memory. bpf helpers
21 * that update its arguments can not write into it.
23 bpf_d_path(path, active, sizeof(int));
28 char _license[] SEC("license") = "GPL";